From 6dc1e0ed3b51965c0f45ad9ee90848824b9c69d4 Mon Sep 17 00:00:00 2001 From: Jb Audras Date: Wed, 16 Feb 2022 10:34:20 +0000 Subject: [PATCH] Script Loader: Load block themes styles in the head section. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, some logic was added to load the global stylesheet in the bottom of `` for classic themes that opted-in into loading individual block styles instead of a single stylesheet for them all. At the time, block themes always loaded the global stylesheet in the ``. When block themes landed in core during WordPress 5.9 this logic wasn’t updated to consider them, hence the global stylesheet loaded in the `` for them. This changeset fixes this. Props oandregal, aristath. Fixes #55148. git-svn-id: https://develop.svn.wordpress.org/trunk@52738 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index d351a502d6..a18cc78e2c 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -2307,7 +2307,9 @@ function wp_common_block_scripts_and_styles() { * @since 5.8.0 */ function wp_enqueue_global_styles() { - $separate_assets = wp_should_load_separate_core_block_assets(); + $separate_assets = wp_should_load_separate_core_block_assets(); + $is_block_theme = wp_is_block_theme(); + $is_classic_theme = ! $is_block_theme; /* * Global styles should be printed in the head when loading all styles combined. @@ -2315,7 +2317,11 @@ function wp_enqueue_global_styles() { * * See https://core.trac.wordpress.org/ticket/53494. */ - if ( ( ! $separate_assets && doing_action( 'wp_footer' ) ) || ( $separate_assets && doing_action( 'wp_enqueue_scripts' ) ) ) { + if ( + ( $is_block_theme && doing_action( 'wp_footer' ) ) || + ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) || + ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets ) + ) { return; }