Editor: Ensure global styles are loaded in the footer when loading core assets individually.

This fixes the logic in `wp_enqueue_global_styles()` to ensure that global styles are loaded in the footer when a site opts-in to loading Core block assets individually.

This fixes a bug where styles defined in `themes.json` are not respected.

Props walbo, nosolosw, mcsf, aristath, desrosj.
Fixes #53494.

git-svn-id: https://develop.svn.wordpress.org/trunk@51309 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jonathan Desrosiers
2021-07-02 18:46:58 +00:00
parent 66d9364d39
commit 8477f505be
2 changed files with 16 additions and 1 deletions

View File

@@ -2267,6 +2267,18 @@ function wp_enqueue_global_styles() {
return;
}
$separate_assets = wp_should_load_separate_core_block_assets();
/*
* Global styles should be printed in the head when loading all styles combined.
* The footer should only be used to print global styles for classic themes with separate core assets enabled.
*
* See https://core.trac.wordpress.org/ticket/53494.
*/
if ( ( ! $separate_assets && doing_action( 'wp_footer' ) ) || ( $separate_assets && doing_action( 'wp_enqueue_scripts' ) ) ) {
return;
}
$can_use_cache = (
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&