Skip to content

Commit

Permalink
Gutenberg Plugin: Correctly enqueue core block theme styles
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Dec 28, 2023
1 parent d7c222c commit 458f1b2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,18 @@ 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 )
);
} 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
Expand Down

0 comments on commit 458f1b2

Please sign in to comment.