Skip to content

Conversation

@westonruter
Copy link
Member

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.

@github-actions
Copy link

github-actions bot commented Oct 25, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props westonruter, peterwilsoncc.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@westonruter westonruter requested a review from dmsnell October 25, 2025 16:14
@westonruter westonruter force-pushed the trac-64150-fix-late-printed-styles-when-not-using-block-styles branch from 4312099 to 3702f9e Compare October 27, 2025 19:40
@peterwilsoncc
Copy link
Contributor

On this branch, I'm seeing the inline block styles loading when running the testing plugin included on the ticket.

Reproduction steps:

  1. Activate 2014
  2. Deactivate the test plugin
  3. Create a post with the gallery block or any other block that contains styles
  4. Activate the test plugin
  5. Check out the 6.8 branch (no need to npm install or rebuild assets)
  6. Load the post created earlier
  7. The gallery block will not be styled as there are are no block styles or inline CSS.
  8. Check out this branch
  9. Reload the post created earlier
  10. The gallery block will be styled as the inline block styles are included in the output

I'm figuring out a test for this, will follow up once I have one.

@westonruter
Copy link
Member Author

@peterwilsoncc as we've chatted about over Slack, the issue is there are two test plugins:

  1. Enqueue Stylesheet at WP Footer (as listed in the ticket description)
  2. Disable Block Styles (listed in comment)

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 wp-block-library is absent (and thus the normal placeholder in the inline style is not present, meaning a fallback to inserting the late-printed styles before </head> is needed.

@peterwilsoncc
Copy link
Contributor

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.

pento pushed a commit that referenced this pull request Oct 28, 2025
…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
@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61076
GitHub commit: d14ae9c

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@westonruter
Copy link
Member Author

Committed in r61076.

@github-actions github-actions bot closed this Oct 28, 2025
markjaquith pushed a commit to markjaquith/WordPress that referenced this pull request Oct 28, 2025
…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
github-actions bot pushed a commit to platformsh/wordpress-performance that referenced this pull request Oct 28, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants