-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Fall back to hosting late-printed styles to end of HEAD if wp-block-library stylesheet is not enqueued
#10417
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ibrary is not enqueued
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
…-using-block-styles
…ort wp-block-styles
4312099 to
3702f9e
Compare
|
On this branch, I'm seeing the inline block styles loading when running the testing plugin included on the ticket. Reproduction steps:
I'm figuring out a test for this, will follow up once I have one. |
|
@peterwilsoncc as we've chatted about over Slack, the issue is there are two test plugins:
To test the issue with a theme not wanting to have any block styles at all, the second plugin needs to be used to test. The first plugin is just to test that late-enqueued styles successfully get printed even when the |
|
As discussed in Slack, I think I was using the wrong plugin when testing earlier. At the time of my earlier tests I was running the following, which produces different results on each branch. add_action(
'enqueue_block_assets',
function (): void {
wp_deregister_style( 'wp-block-library' );
}
);
add_action(
'wp_head',
static function () {
echo '<style>body { background-color: red; }</style>';
}
);
add_action(
'wp_footer',
static function () {
wp_register_style( 'lime-background', null );
wp_add_inline_style( 'lime-background', 'body { background-color: lime !important; }' );
wp_enqueue_style( 'lime-background' );
}
);Using the second plugin on the ticket I am seeing the same thing on both branches, IE running add_action(
'enqueue_block_assets',
function (): void {
wp_deregister_style( 'wp-block-library' );
wp_register_style( 'wp-block-library', '' );
}
);
add_action(
'after_setup_theme',
static function (): void {
remove_theme_support( 'wp-block-styles' );
},
PHP_INT_MAX
);So I think this is good to go. |
…EAD` if `wp-block-library` is not enqueued. When the `wp-block-library` stylesheet is not enqueued, there will be no associated inline style present. This inline style normally contains the placeholder CSS comment for the HTML Tag Processor to identify the token after which the late-printed styles should be inserted. However, when the `wp-block-library` stylesheet is not enqueued (such as in themes which do not use blocks), or else the inline style is not printed for whatever reason, this adds a fallback to insert the late-printed styles immediately before `</head>`. This ensures that late-printed styles will always get hoisted. Developed in #10417 Follow-up to [61008]. Props westonruter, peterwilsoncc, Soean. See #64099, #43258. Fixes #64150. git-svn-id: https://develop.svn.wordpress.org/trunk@61076 602fd350-edb4-49c9-b593-d223f7449a82
|
Committed in r61076. |
…EAD` if `wp-block-library` is not enqueued. When the `wp-block-library` stylesheet is not enqueued, there will be no associated inline style present. This inline style normally contains the placeholder CSS comment for the HTML Tag Processor to identify the token after which the late-printed styles should be inserted. However, when the `wp-block-library` stylesheet is not enqueued (such as in themes which do not use blocks), or else the inline style is not printed for whatever reason, this adds a fallback to insert the late-printed styles immediately before `</head>`. This ensures that late-printed styles will always get hoisted. Developed in WordPress/wordpress-develop#10417 Follow-up to [61008]. Props westonruter, peterwilsoncc, Soean. See #64099, #43258. Fixes #64150. Built from https://develop.svn.wordpress.org/trunk@61076 git-svn-id: http://core.svn.wordpress.org/trunk@60412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
…EAD` if `wp-block-library` is not enqueued. When the `wp-block-library` stylesheet is not enqueued, there will be no associated inline style present. This inline style normally contains the placeholder CSS comment for the HTML Tag Processor to identify the token after which the late-printed styles should be inserted. However, when the `wp-block-library` stylesheet is not enqueued (such as in themes which do not use blocks), or else the inline style is not printed for whatever reason, this adds a fallback to insert the late-printed styles immediately before `</head>`. This ensures that late-printed styles will always get hoisted. Developed in WordPress/wordpress-develop#10417 Follow-up to [61008]. Props westonruter, peterwilsoncc, Soean. See #64099, #43258. Fixes #64150. Built from https://develop.svn.wordpress.org/trunk@61076 git-svn-id: https://core.svn.wordpress.org/trunk@60412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Trac ticket: https://core.trac.wordpress.org/ticket/64150
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.