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 requested review from youknowriad, and tellthemachines (assigned from WordPress/gutenberg-core) and removed request for Feb 11, 2022
Copy link
Contributor

@draganescu draganescu left a comment

The code makes sense and the testing did as described.

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

@youknowriad youknowriad commented Feb 11, 2022

Thanks André and Andrei 👍

@oandregal
Copy link
Member Author

@oandregal oandregal commented Feb 11, 2022

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
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants