Make WordPress Core


Ignore:
Timestamp:
11/30/2021 08:00:09 PM (5 years ago)
Author:
audrasjb
Message:

Editor: Avoid a JS console error on the Navigation block view.

Props mkaz, sabernhardt, costdev.
Fixes #54456.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/blocks.php

    r52069 r52291  
    8484
    8585        $script_handle     = generate_block_asset_handle( $metadata['name'], $field_name );
    86         $script_asset_path = realpath(
    87                 dirname( $metadata['file'] ) . '/' .
    88                 substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
     86        $script_asset_path = wp_normalize_path(
     87                realpath(
     88                        dirname( $metadata['file'] ) . '/' .
     89                        substr_replace( $script_path, '.asset.php', - strlen( '.js' ) )
     90                )
    8991        );
    9092        if ( ! file_exists( $script_asset_path ) ) {
     
    101103                return false;
    102104        }
    103         $is_core_block       = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC );
     105        // Path needs to be normalized to work in Windows env.
     106        $wpinc_path_norm     = wp_normalize_path( ABSPATH . WPINC );
     107        $script_path_norm    = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) );
     108        $is_core_block       = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
     109
    104110        $script_uri          = $is_core_block ?
    105                 includes_url( str_replace( ABSPATH . WPINC, '', realpath( dirname( $metadata['file'] ) . '/' . $script_path ) ) ) :
     111                includes_url( str_replace( $wpinc_path_norm, '', $script_path_norm ) ) :
    106112                plugins_url( $script_path, $metadata['file'] );
    107113        $script_asset        = require $script_asset_path;
     
    140146                return false;
    141147        }
    142         $is_core_block = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], ABSPATH . WPINC );
     148        $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC );
     149        $is_core_block   = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
    143150        if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) {
    144151                return false;
     
    233240                return false;
    234241        }
    235         $metadata['file'] = $metadata_file;
     242        $metadata['file'] = wp_normalize_path( $metadata_file );
    236243
    237244        /**
Note: See TracChangeset for help on using the changeset viewer.