Make WordPress Core

Changeset 52738


Ignore:
Timestamp:
02/16/2022 10:34:20 AM (3 years ago)
Author:
audrasjb
Message:

Script Loader: Load block themes styles in the head section.

Previously, some logic was added to load the global stylesheet in the bottom of <body> 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 <head>. 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 <body> for them. This changeset fixes this.

Props oandregal, aristath.
Fixes #55148.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r52695 r52738  
    23082308 */
    23092309function wp_enqueue_global_styles() {
    2310     $separate_assets = wp_should_load_separate_core_block_assets();
     2310    $separate_assets  = wp_should_load_separate_core_block_assets();
     2311    $is_block_theme   = wp_is_block_theme();
     2312    $is_classic_theme = ! $is_block_theme;
    23112313
    23122314    /*
     
    23162318     * See https://core.trac.wordpress.org/ticket/53494.
    23172319     */
    2318     if ( ( ! $separate_assets && doing_action( 'wp_footer' ) ) || ( $separate_assets && doing_action( 'wp_enqueue_scripts' ) ) ) {
     2320    if (
     2321        ( $is_block_theme && doing_action( 'wp_footer' ) ) ||
     2322        ( $is_classic_theme && doing_action( 'wp_footer' ) && ! $separate_assets ) ||
     2323        ( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $separate_assets )
     2324    ) {
    23192325        return;
    23202326    }
Note: See TracChangeset for help on using the changeset viewer.