From a5a870cb4c955a7419d6409da692d3de5a432309 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Wed, 6 Sep 2023 21:25:15 +0000 Subject: [PATCH] Editor: Fix loading of assets in blocks in child themes where the directory name starts with the parent theme's directory name. Example: `twentyseventeen` and `twentyseventeen-child`. Props: lgladdy, masteradhoc, audrasjb, rajinsharwar, azaozz. Fixes: #59018. Built from https://develop.svn.wordpress.org/trunk@56527 git-svn-id: http://core.svn.wordpress.org/trunk@56039 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/blocks.php | 8 ++++---- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/wp-includes/blocks.php b/wp-includes/blocks.php index 4d3a34e34f..6fc72e358a 100644 --- a/wp-includes/blocks.php +++ b/wp-includes/blocks.php @@ -150,8 +150,8 @@ function register_block_script_handle( $metadata, $field_name, $index = 0 ) { * Determine if the block script was registered in a theme, by checking if the script path starts with either * the parent (template) or child (stylesheet) directory path. */ - $is_parent_theme_block = str_starts_with( $script_path_norm, $template_path_norm ); - $is_child_theme_block = str_starts_with( $script_path_norm, $stylesheet_path_norm ); + $is_parent_theme_block = str_starts_with( $script_path_norm, trailingslashit( $template_path_norm ) ); + $is_child_theme_block = str_starts_with( $script_path_norm, trailingslashit( $stylesheet_path_norm ) ); $is_theme_block = ( $is_parent_theme_block || $is_child_theme_block ); $script_uri = ''; @@ -270,8 +270,8 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) { // Determine if the block style was registered in a theme, by checking if the script path starts with either // the parent (template) or child (stylesheet) directory path. - $is_parent_theme_block = str_starts_with( $style_path_norm, $template_path_norm ); - $is_child_theme_block = str_starts_with( $style_path_norm, $stylesheet_path_norm ); + $is_parent_theme_block = str_starts_with( $style_path_norm, trailingslashit( $template_path_norm ) ); + $is_child_theme_block = str_starts_with( $style_path_norm, trailingslashit( $stylesheet_path_norm ) ); $is_theme_block = ( $is_parent_theme_block || $is_child_theme_block ); if ( $is_core_block ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 6992369842..e8b5f5be52 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.4-alpha-56526'; +$wp_version = '6.4-alpha-56527'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.