Editor: Fix block editor styles being registered with frontend stylesheets.

This changeset fixes a bug where WordPress core's own block editor styles (`wp-block-{$block_name}-editor`) were referencing the same CSS files as their frontend equivalents (`wp-block-{$block_name}`). This would result in incorrect frontend styles potentially being loaded in the block editor.

Tests for the related logic have been added.

Props flixos90, joemcgill, mukesh27, spacedmonkey.
Fixes #58605.

Built from https://develop.svn.wordpress.org/trunk@56005


git-svn-id: http://core.svn.wordpress.org/trunk@55517 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2023-06-23 19:01:24 +00:00
parent d1717e60b9
commit df12352e16
2 changed files with 4 additions and 3 deletions

View File

@ -219,7 +219,7 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) {
// Check whether styles should have a ".min" suffix or not.
$suffix = SCRIPT_DEBUG ? '' : '.min';
if ( $is_core_block ) {
$style_path = "style$suffix.css";
$style_path = ( 'editorStyle' === $field_name ) ? "editor{$suffix}.css" : "style{$suffix}.css";
}
$style_path_norm = wp_normalize_path( realpath( dirname( $metadata['file'] ) . '/' . $style_path ) );
@ -239,7 +239,8 @@ function register_block_style_handle( $metadata, $field_name, $index = 0 ) {
if ( $is_theme_block ) {
$style_uri = get_theme_file_uri( str_replace( $theme_path_norm, '', $style_path_norm ) );
} elseif ( $is_core_block ) {
$style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . "/style$suffix.css" );
// All possible $style_path variants for core blocks are hard-coded above.
$style_uri = includes_url( 'blocks/' . str_replace( 'core/', '', $metadata['name'] ) . '/' . $style_path );
}
} else {
$style_uri = false;

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.3-alpha-56004';
$wp_version = '6.3-alpha-56005';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.