Make WordPress Core


Ignore:
Timestamp:
03/29/2022 03:41:42 PM (2 years ago)
Author:
audrasjb
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 gziolo, SergeyBiryukov, pgpagely, Mamaduka.
Merges [52939] to the 5.9 branch.
Fixes #55311.

Location:
branches/5.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.9

  • branches/5.9/src/wp-includes/blocks.php

    r52748 r53019  
    104104    }
    105105    // Path needs to be normalized to work in Windows env.
    106     $wpinc_path_norm  = wp_normalize_path( ABSPATH . WPINC );
     106    $wpinc_path_norm  = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    107107    $script_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $script_path ) );
    108108    $is_core_block    = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
     
    146146        return false;
    147147    }
    148     $wpinc_path_norm = wp_normalize_path( ABSPATH . WPINC );
     148    $wpinc_path_norm = wp_normalize_path( realpath( ABSPATH . WPINC ) );
    149149    $is_core_block   = isset( $metadata['file'] ) && 0 === strpos( $metadata['file'], $wpinc_path_norm );
    150150    if ( $is_core_block && ! wp_should_load_separate_core_block_assets() ) {
     
    240240        return false;
    241241    }
    242     $metadata['file'] = wp_normalize_path( $metadata_file );
     242    $metadata['file'] = wp_normalize_path( realpath( $metadata_file ) );
    243243
    244244    /**
Note: See TracChangeset for help on using the changeset viewer.