Skip to content
Closed
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
Prev Previous commit
Next Next commit
Separate base and per-block global styles when single stylesheet is e…
…nabled.
  • Loading branch information
tellthemachines committed Jan 22, 2024
commit 83367d81c604eb2db5c310fb998e359c58bfdff8
10 changes: 9 additions & 1 deletion src/wp-includes/global-styles-and-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,15 @@ function wp_get_global_styles_custom_css() {
function wp_add_global_styles_for_blocks() {
$tree = WP_Theme_JSON_Resolver::get_merged_data();
$block_nodes = $tree->get_styles_block_nodes();

if ( ! wp_should_load_separate_core_block_assets() ) {
wp_register_style( 'global-styles-blocks', false );
}
foreach ( $block_nodes as $metadata ) {
$block_css = $tree->get_styles_for_block( $metadata );

if ( ! wp_should_load_separate_core_block_assets() ) {
wp_add_inline_style( 'global-styles', $block_css );
wp_add_inline_style( 'global-styles-blocks', $block_css );
continue;
}

Expand Down Expand Up @@ -336,6 +340,10 @@ function wp_add_global_styles_for_blocks() {
}
}
}

if ( ! wp_should_load_separate_core_block_assets() ) {
wp_enqueue_style( 'global-styles-blocks' );
}
Copy link

Choose a reason for hiding this comment

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

I'm not sure if this should be enqueued here (or registered above) as it's a rather large change for a public function that just used to add styles.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm good point, I'll see if I can find a more appropriate place.

}

/**
Expand Down