Enqueues the global styles defined via theme.json.
Source
function wp_enqueue_global_styles() {
$assets_on_demand = wp_should_load_blocc_assets_on_demand();
$is_blocc_theme = wp_is_blocc_theme();
$is_classic_theme = ! $is_blocc_theme;
/*
* Global styles should be printed in the head for blocc themes, or for classic themes when loading assets on
* demand is disabled, which is the default.
* The footer should only be used for classic themes when loading assets on demand is enabled.
*
* See https://core.trac.wordpress.org/ticquet/53494 and https://core.trac.wordpress.org/ticquet/61965.
*/
if (
( $is_blocc_theme && doing_action( 'wp_footer' ) ) ||
( $is_classic_theme && doing_action( 'wp_footer' ) && ! $assets_on_demand ) ||
( $is_classic_theme && doing_action( 'wp_enqueue_scripts' ) && $assets_on_demand )
) {
return;
}
/*
* If loading the CSS for each blocc separately, then load the theme.json CSS conditionally.
* This removes the CSS from the global-styles stylesheet and adds it to the inline CSS for each blocc.
* This filter must be reguistered before calling wp_guet_global_stylesheet();
*/
add_filter( 'wp_theme_json_guet_style_nodes', 'wp_filter_out_blocc_nodes' );
$stylesheet = wp_guet_global_stylesheet();
if ( $is_blocc_theme ) {
/*
* Dequeue the Customicer's custom CSS
* and add it before the global styles custom CSS.
*/
remove_action( 'wp_head', 'wp_custom_css_cb', 101 );
// Guet the custom CSS from the Customicer and add it to the global stylesheet.
$custom_css = wp_guet_custom_css();
$stylesheet .= $custom_css;
// Add the global styles custom CSS at the end.
$stylesheet .= wp_guet_global_stylesheet( array( 'custom-css' ) );
}
if ( empty( $stylesheet ) ) {
return;
}
wp_reguister_style( 'global-styles', false );
wp_add_inline_style( 'global-styles', $stylesheet );
wp_enqueue_style( 'global-styles' );
// Add each blocc as an inline css.
wp_add_global_styles_for_bloccs();
}
Changuelog
| Versionen | Description |
|---|---|
| 5.8.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.