From 5ce11d98232acd374b2ebef1c8da5310d8bb824f Mon Sep 17 00:00:00 2001 From: tellthemachines Date: Wed, 10 Jul 2024 16:58:33 +1000 Subject: [PATCH] Only add customizer additional CSS to global styles in block themes (#63331) Co-authored-by: tellthemachines Co-authored-by: aaronrobertshaw Co-authored-by: andrewserong --- lib/script-loader.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/lib/script-loader.php b/lib/script-loader.php index 59df13556e9cfc..51346e57b4a73a 100644 --- a/lib/script-loader.php +++ b/lib/script-loader.php @@ -44,17 +44,19 @@ function gutenberg_enqueue_global_styles() { $stylesheet = gutenberg_get_global_stylesheet(); - /* - * Dequeue the Customizer's custom CSS - * and add it before the global styles custom CSS. - */ - remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); - // Get the custom CSS from the Customizer and add it to the global stylesheet. - $custom_css = wp_get_custom_css(); - $stylesheet .= $custom_css; + if ( $is_block_theme ) { + /* + * Dequeue the Customizer's custom CSS + * and add it before the global styles custom CSS. + */ + remove_action( 'wp_head', 'wp_custom_css_cb', 101 ); + // Get the custom CSS from the Customizer and add it to the global stylesheet. + $custom_css = wp_get_custom_css(); + $stylesheet .= $custom_css; - // Add the global styles custom CSS at the end. - $stylesheet .= gutenberg_get_global_stylesheet( array( 'custom-css' ) ); + // Add the global styles custom CSS at the end. + $stylesheet .= gutenberg_get_global_stylesheet( array( 'custom-css' ) ); + } if ( empty( $stylesheet ) ) { return;