Make WordPress Core

Changeset 52939


Ignore:
Timestamp:
03/16/2022 10:20:12 AM (3 years ago)
Author:
gziolo
Message:

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.

File:
1 edited

Legend:

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

    r52793 r52939  
    108108    }
    109109    // Path needs to be normalized to work in Windows env.
    110     $wpinc_path_norm  = wp_normalize_path( ABSPATH . WPINC );
     110    $wpinc_path_norm  = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    111111    $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) );
    112112    $is_core_block    = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
     
    150150        return false;
    151151    }
    152     $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC );
     152    $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    153153    $is_core_block   = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
    154154    if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) {
     
    244244        return false;
    245245    }
    246     $metadata['file'] = wp_normalize_path( $metadata_file );
     246    $metadata['file'] = wp_normalize_path( realpath( $metadata_file ) );
    247247
    248248    /**
Note: See TracChangeset for help on using the changeset viewer.