From c7d34827c8963bd3e658c4f6d201c186a585a2df Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Fri, 29 Sep 2023 21:29:56 +0900 Subject: [PATCH] Gutenberg Plugin: Correctly enqueue core block theme styles --- lib/blocks.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/blocks.php b/lib/blocks.php index e1d4622a0f23da..059dc5ee929037 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -293,9 +293,10 @@ static function () { // If the file exists, enqueue it. if ( file_exists( gutenberg_dir_path() . $theme_style_path ) ) { - + wp_deregister_style( "wp-block-{$block_name}-theme" ); if ( file_exists( $stylesheet_path ) ) { - // If there is a main stylesheet for this block, append the theme styles to main styles. + // If there is a main stylesheet for this block, deregister the core theme + // styles and append the theme styles to main styles. wp_add_inline_style( "wp-block-{$block_name}", file_get_contents( gutenberg_dir_path() . $theme_style_path ) @@ -303,7 +304,7 @@ static function () { } else { // If there is no main stylesheet for this block, register theme style. wp_register_style( - "wp-block-{$block_name}", + "wp-block-{$block_name}-theme", gutenberg_url( $theme_style_path ), array(), $default_version