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. Built from https://develop.svn.wordpress.org/trunk@51309 git-svn-id: http://core.svn.wordpress.org/trunk@50918 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
bc5908011b
commit
3e271ba7a7
|
@ -554,7 +554,6 @@ add_action( 'wp_default_scripts', 'wp_default_packages' );
|
||||||
|
|
||||||
add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
||||||
add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
add_action( 'wp_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
||||||
add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
|
|
||||||
add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 );
|
||||||
add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
add_action( 'admin_enqueue_scripts', 'wp_common_block_scripts_and_styles' );
|
||||||
add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
|
add_action( 'enqueue_block_assets', 'wp_enqueue_registered_block_scripts_and_styles' );
|
||||||
|
@ -568,6 +567,10 @@ add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' );
|
||||||
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
|
add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );
|
||||||
add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
|
add_filter( 'customize_controls_print_styles', 'wp_resource_hints', 1 );
|
||||||
|
|
||||||
|
// Global styles can be enqueued in both the header and the footer. See https://core.trac.wordpress.org/ticket/53494.
|
||||||
|
add_action( 'wp_enqueue_scripts', 'wp_enqueue_global_styles' );
|
||||||
|
add_action( 'wp_footer', 'wp_enqueue_global_styles', 1 );
|
||||||
|
|
||||||
add_action( 'wp_default_styles', 'wp_default_styles' );
|
add_action( 'wp_default_styles', 'wp_default_styles' );
|
||||||
add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
|
add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );
|
||||||
|
|
||||||
|
|
|
@ -2267,6 +2267,18 @@ function wp_enqueue_global_styles() {
|
||||||
return;
|
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 = (
|
$can_use_cache = (
|
||||||
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
|
( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) &&
|
||||||
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
|
( ! defined( 'SCRIPT_DEBUG' ) || ! SCRIPT_DEBUG ) &&
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.9-alpha-51307';
|
$wp_version = '5.9-alpha-51309';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue