Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions lib/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,43 +273,22 @@ function gutenberg_register_core_block_assets( $block_name ) {
// and instead attach each block's theme-styles to their block styles stylesheet.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit: one line above this comment (Github wouldn't let me comment on it) the comment says "dequeue the full stylesheet". Looks like we can remove that part of the comment now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh well spotted! I'll update the comment.

if ( current_theme_supports( 'wp-block-styles' ) ) {

// Dequeue the full stylesheet.
// Make sure this only runs once, it doesn't need to run for every block.
static $stylesheet_removed;
if ( ! $stylesheet_removed ) {
add_action(
'wp_enqueue_scripts',
static function () {
wp_dequeue_style( 'wp-block-library-theme' );
}
);
$stylesheet_removed = true;
}

Comment on lines -276 to -288
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice clean up 👍

// Get the path to the block's stylesheet.
$theme_style_path = is_rtl()
? "build/block-library/blocks/$block_name/theme-rtl.css"
: "build/block-library/blocks/$block_name/theme.css";

// If the file exists, enqueue it.
if ( file_exists( gutenberg_dir_path() . $theme_style_path ) ) {

if ( file_exists( $stylesheet_path ) ) {
// If there is a main stylesheet for this block, 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}",
gutenberg_url( $theme_style_path ),
array(),
$default_version
);
wp_style_add_data( "wp-block-{$block_name}", 'path', gutenberg_dir_path() . $theme_style_path );
}
wp_deregister_style( "wp-block-{$block_name}-theme" );
wp_register_style(
"wp-block-{$block_name}-theme",
gutenberg_url( $theme_style_path ),
array(),
$default_version
);
wp_style_add_data( "wp-block-{$block_name}-theme", 'path', gutenberg_dir_path() . $theme_style_path );

}
}

Expand All @@ -328,6 +307,8 @@ static function () {
}
}

// add_filter( 'should_load_separate_core_block_assets', '__return_false', 11 );

/**
* Complements the implementation of block type `core/social-icon`, whether it
* be provided by core or the plugin, with derived block types for each
Expand Down