From 4ba0963a1f61d062d7345e429c823f3eb5ab5f78 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 21 Feb 2024 09:36:18 +0000 Subject: [PATCH] Editor: Allow symlinks in directories provided to `get_block_asset_url()`. This changeset allows using symbolic links for `editorScript` and `editorStyle` in `register_block_type()`. This adds `realpath` to template and stylesheet in `get_block_asset_url()` to ensure returning canonicalized absolute pathnames. Follow-up to [56683]. Props antonlukin, spacedmonkey, maxpertici. Fixes #59175. See #58525. git-svn-id: https://develop.svn.wordpress.org/trunk@57675 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index edd30478af..242429a424 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -106,7 +106,7 @@ function get_block_asset_url( $path ) { $template = get_template(); if ( ! isset( $template_paths_norm[ $template ] ) ) { - $template_paths_norm[ $template ] = wp_normalize_path( get_template_directory() ); + $template_paths_norm[ $template ] = wp_normalize_path( realpath( get_template_directory() ) ); } if ( str_starts_with( $path, trailingslashit( $template_paths_norm[ $template ] ) ) ) { @@ -116,7 +116,7 @@ function get_block_asset_url( $path ) { if ( is_child_theme() ) { $stylesheet = get_stylesheet(); if ( ! isset( $template_paths_norm[ $stylesheet ] ) ) { - $template_paths_norm[ $stylesheet ] = wp_normalize_path( get_stylesheet_directory() ); + $template_paths_norm[ $stylesheet ] = wp_normalize_path( realpath( get_stylesheet_directory() ) ); } if ( str_starts_with( $path, trailingslashit( $template_paths_norm[ $stylesheet ] ) ) ) {