Skip to content
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

Fix global styles loading logic #38745

Merged
merged 3 commits into from
Feb 11, 2022
Merged

Fix global styles loading logic #38745

merged 3 commits into from
Feb 11, 2022

Conversation

oandregal
Copy link
Member

@oandregal oandregal commented Feb 11, 2022

Part of #38434

The global styles stylesheet should be loaded using this logic, no matter the WordPress version:

  1. Block theme. Always load in the <head>.
  2. Classic theme that hasn't opted into loading core assets separately. Load in the <head>.
  3. Classic theme that has opted into loading core assets separately. Load in the <body>.

In trunk it's not working as expected and shows differences between WordPress 5.8 and WordPress 5.9.

Backport

The parts of this that need backporting to core are in this PR already WordPress/wordpress-develop#2303

How to test

Use TwentyTwenty, unmodified. Test both in WordPress 5.8 and WordPress 5.9.

  • Load the front end.
  • Verify the global-styles-inline-css embedded stylesheet is loaded in the head.

Use TwentyTwenty after opting into loading separate assets. Test both in WordPress 5.8 and WordPress 5.9.

  • Paste add_filter( 'should_load_separate_core_block_assets', '__return_true' ); in TwentyTwenty's functions.php.
  • Load the front end.
  • Verify the global-styles-inline-css embedded stylesheet is loaded in the body.

Use EmptyTheme. Test both in WordPress 5.8 and WordPress 5.9.

  • Load the front end.
  • Verify the global-styles-inline-css embedded stylesheet is loaded in the head.

@oandregal oandregal self-assigned this Feb 11, 2022
@oandregal oandregal added [Type] Bug An existing feature does not function as intended Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json labels Feb 11, 2022
@oandregal oandregal requested review from youknowriad, a team and tellthemachines and removed request for a team February 11, 2022 13:24
Copy link
Contributor

@draganescu draganescu left a comment

Choose a reason for hiding this comment

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

The code makes sense and the testing did as described.

@oandregal oandregal merged commit 88671f7 into trunk Feb 11, 2022
@oandregal oandregal deleted the fix/global-styles-to-head branch February 11, 2022 15:27
@github-actions github-actions bot added this to the Gutenberg 12.7 milestone Feb 11, 2022
@youknowriad
Copy link
Contributor

Thanks André and Andrei 👍

@youknowriad youknowriad added the Backport to WP Minor Release Pull request that needs to be backported to a WordPress minor release label Feb 11, 2022
@oandregal
Copy link
Member Author

For awareness: PR for backporting this to core at WordPress/wordpress-develop#2303 (related trac ticket).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Global Styles Anything related to the broader Global Styles efforts, including Styles Engine and theme.json [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants