Always load global styles in head for block themes #2303
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trac ticket https://core.trac.wordpress.org/ticket/55148
Backports WordPress/gutenberg#38745
In the linked trac ticket we added some logic to load the global stylesheet in the bottom of
<body>
for classic themes that opted-in into loading individual block styles instead of a single stylesheet for them all. At the time, block themes always loaded the global stylesheet in the<head>
.When block themes landed in core during the WordPress 5.9 this logic wasn't updated to consider them, hence the global stylesheet loaded in the
<body>
for them. This PR fixes this.How to test
global-styles-inline-css
embedded stylesheet is loaded in the<head>
.should_load_separate_core_block_assets
: load a site using TwentyTwenty and verify that theglobal-styles-inline-css
embedded stylesheet is loaded in the<head>
.should_load_separate_core_block_assets
:add_filter( 'should_load_separate_core_block_assets', '__return_true' );
to itsfunctions.php
.global-styles-inline-css
is loaded at the bottom of the<body>
.