mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 09:07:59 +01:00
Editor: Avoid a JS console error on the Navigation block view.
Props mkaz, sabernhardt, costdev. Fixes #54456. Built from https://develop.svn.wordpress.org/trunk@52291 git-svn-id: http://core.svn.wordpress.org/trunk@51883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
68537a8eed
commit
25b3d172b7
@ -83,9 +83,11 @@ function register_block_script_handle( $metadata, $field_name ) {
|
||||
}
|
||||
|
||||
$script_handle = generate_block_asset_handle( $metadata['name'], $field_name );
|
||||
$script_asset_path = realpath(
|
||||
dirname( $metadata['file'] ) . '/' .
|
||||
substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
|
||||
$script_asset_path = wp_normalize_path(
|
||||
realpath(
|
||||
dirname( $metadata['file'] ) . '/' .
|
||||
substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
|
||||
)
|
||||
);
|
||||
if ( ! file_exists( $script_asset_path ) ) {
|
||||
_doing_it_wrong(
|
||||
@ -100,9 +102,13 @@ function register_block_script_handle( $metadata, $field_name ) {
|
||||
);
|
||||
return false;
|
||||
}
|
||||
$is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC );
|
||||
// Path needs to be normalized to work in Windows env.
|
||||
$wpinc_path_norm = wp_normalize_path( 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 );
|
||||
|
||||
$script_uri = $is_core_block ?
|
||||
includes_url( str_replace( ABSPATH . WPINC, '', realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ) ) :
|
||||
includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ) :
|
||||
plugins_url( $script_path, $metadata['file'] );
|
||||
$script_asset = require $script_asset_path;
|
||||
$script_dependencies = isset( $script_asset['dependencies'] ) ? $script_asset['dependencies'] : array();
|
||||
@ -139,7 +145,8 @@ function register_block_style_handle( $metadata, $field_name ) {
|
||||
if ( empty( $metadata[ $field_name ] ) ) {
|
||||
return false;
|
||||
}
|
||||
$is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC );
|
||||
$wpinc_path_norm = wp_normalize_path( 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;
|
||||
}
|
||||
@ -232,7 +239,7 @@ function register_block_type_from_metadata( $file_or_folder, $args = array() ) {
|
||||
if ( ! is_array( $metadata ) || empty( $metadata['name'] ) ) {
|
||||
return false;
|
||||
}
|
||||
$metadata['file'] = $metadata_file;
|
||||
$metadata['file'] = wp_normalize_path( $metadata_file );
|
||||
|
||||
/**
|
||||
* Filters the metadata provided for registering a block type.
|
||||
|
@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.9-alpha-52290';
|
||||
$wp_version = '5.9-alpha-52291';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user