Editor: Allow symlinks in directories provided to get_block_asset_url().

This changeset allows using symbolic links for `editorScript` and `editorStyle` in `register_block_type()`. This adds `realpath` to template and stylesheet in `get_block_asset_url()` to ensure returning canonicalized absolute pathnames.

Follow-up to [56683].

Props antonlukin, spacedmonkey, maxpertici.
Fixes #59175.
See #58525.





git-svn-id: https://develop.svn.wordpress.org/trunk@57675 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2024-02-21 09:36:18 +00:00
parent 75eb1a86e9
commit 4ba0963a1f

View File

@ -106,7 +106,7 @@ function get_block_asset_url( $path ) {
$template = get_template();
if ( ! isset( $template_paths_norm[ $template ] ) ) {
$template_paths_norm[ $template ] = wp_normalize_path( get_template_directory() );
$template_paths_norm[ $template ] = wp_normalize_path( realpath( get_template_directory() ) );
}
if ( str_starts_with( $path, trailingslashit( $template_paths_norm[ $template ] ) ) ) {
@ -116,7 +116,7 @@ function get_block_asset_url( $path ) {
if ( is_child_theme() ) {
$stylesheet = get_stylesheet();
if ( ! isset( $template_paths_norm[ $stylesheet ] ) ) {
$template_paths_norm[ $stylesheet ] = wp_normalize_path( get_stylesheet_directory() );
$template_paths_norm[ $stylesheet ] = wp_normalize_path( realpath( get_stylesheet_directory() ) );
}
if ( str_starts_with( $path, trailingslashit( $template_paths_norm[ $stylesheet ] ) ) ) {