@@ -2535,20 +2535,6 @@ function wp_enqueue_global_styles() {
25352535
25362536 $ stylesheet = wp_get_global_stylesheet ();
25372537
2538- if ( $ is_block_theme ) {
2539- /*
2540- * Dequeue the Customizer's custom CSS
2541- * and add it before the global styles custom CSS.
2542- */
2543- remove_action ( 'wp_head ' , 'wp_custom_css_cb ' , 101 );
2544- // Get the custom CSS from the Customizer and add it to the global stylesheet.
2545- $ custom_css = wp_get_custom_css ();
2546- $ stylesheet .= $ custom_css ;
2547-
2548- // Add the global styles custom CSS at the end.
2549- $ stylesheet .= wp_get_global_stylesheet ( array ( 'custom-css ' ) );
2550- }
2551-
25522538 if ( empty ( $ stylesheet ) ) {
25532539 return ;
25542540 }
@@ -2557,6 +2543,24 @@ function wp_enqueue_global_styles() {
25572543 wp_add_inline_style ( 'global-styles ' , $ stylesheet );
25582544 wp_enqueue_style ( 'global-styles ' );
25592545
2546+ if ( $ is_block_theme ) {
2547+ /*
2548+ * Dequeue the Customizer's custom CSS
2549+ * and add it before the global styles custom CSS.
2550+ */
2551+ remove_action ( 'wp_head ' , 'wp_custom_css_cb ' , 101 );
2552+ $ customizer_custom_css = wp_get_custom_css ();
2553+ wp_register_style ( 'wp-custom-css ' , false );
2554+ wp_add_inline_style ( 'wp-custom-css ' , $ customizer_custom_css );
2555+ wp_enqueue_style ( 'wp-custom-css ' );
2556+
2557+ // Enqueue the global styles custom CSS.
2558+ $ global_styles_custom_css = wp_get_global_stylesheet ( array ( 'custom-css ' ) );
2559+ wp_register_style ( 'global-styles-custom-css ' , false );
2560+ wp_add_inline_style ( 'global-styles-custom-css ' , $ global_styles_custom_css );
2561+ wp_enqueue_style ( 'global-styles-custom-css ' );
2562+ }
2563+
25602564 // Add each block as an inline css.
25612565 wp_add_global_styles_for_blocks ();
25622566}
0 commit comments