mirror of
git://develop.git.wordpress.org/
synced 2025-03-20 03:49:54 +01:00
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
This commit is contained in:
parent
c7e067c578
commit
573581f43f
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user