From 573581f43f63f12cc37620172432cf93745f568c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=83=C2=B3=C3=85=E2=80=9Akowski?= Date: Wed, 16 Mar 2022 10:20:12 +0000 Subject: [PATCH] Editor: Fix broken asset URLs when using WP outside of the regular directory Both CSS and JS URLs were totally broken for some of the newer blocks (e.g. the navigation block in the 2022 theme) when WP core is outside of the current directory using a different prefix. Props pgpagely, Mamaduka. Fixes #55311. git-svn-id: https://develop.svn.wordpress.org/trunk@52939 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index e911de832a..7c3509daac 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -107,7 +107,7 @@ function register_block_script_handle( $metadata, $field_name ) { return false; } // Path needs to be normalized to work in Windows env. - $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC ); + $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ); $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); @@ -149,7 +149,7 @@ function register_block_style_handle( $metadata, $field_name ) { if ( empty( $metadata[ $field_name ] ) ) { return false; } - $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC ); + $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) ); $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm ); if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) { return false; @@ -243,7 +243,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) { if ( ! is_array( $metadata ) || empty( $metadata['name'] ) ) { return false; } - $metadata['file'] = wp_normalize_path( $metadata_file ); + $metadata['file'] = wp_normalize_path( realpath( $metadata_file ) ); /** * Filters the metadata provided for registering a block type.