From 06ab3dca5440e8101e00546ff214ad3dddc8b03f Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Wed, 12 Jul 2023 13:59:52 -0500 Subject: [PATCH 1/2] Fix duotone filters in classic themes --- src/wp-includes/class-wp-duotone.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/class-wp-duotone.php b/src/wp-includes/class-wp-duotone.php index 99da521f06619..7bd609821c6d8 100644 --- a/src/wp-includes/class-wp-duotone.php +++ b/src/wp-includes/class-wp-duotone.php @@ -1180,9 +1180,14 @@ public static function output_footer_assets() { echo self::get_svg_definitions( self::$used_svg_filter_data ); } - // This is for classic themes - in block themes, the CSS is added in the head via wp_add_inline_style in the wp_enqueue_scripts action. - if ( ! wp_is_block_theme() && ! empty( self::$used_global_styles_presets ) ) { - wp_add_inline_style( 'core-block-supports', self::get_global_styles_presets( self::$used_global_styles_presets ) ); + // In block themes, the CSS is added in the head via wp_add_inline_style in the wp_enqueue_scripts action. + if ( ! wp_is_block_theme() ) { + if ( ! empty( self::$used_global_styles_presets ) ) { + wp_add_inline_style( 'core-block-supports', self::get_global_styles_presets( self::$used_global_styles_presets ) ); + } + if ( ! empty( self::$block_css_declarations ) ) { + wp_add_inline_style( 'core-block-supports', wp_style_engine_get_stylesheet_from_css_rules( self::$block_css_declarations ) ); + } } } From 75e3bc09a5e7972ffb4bdef2ba53f5355c3b7725 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Wed, 12 Jul 2023 17:30:14 -0500 Subject: [PATCH 2/2] Register separate stylesheet for duotone --- src/wp-includes/class-wp-duotone.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-duotone.php b/src/wp-includes/class-wp-duotone.php index 7bd609821c6d8..b29f38acf5677 100644 --- a/src/wp-includes/class-wp-duotone.php +++ b/src/wp-includes/class-wp-duotone.php @@ -1182,12 +1182,15 @@ public static function output_footer_assets() { // In block themes, the CSS is added in the head via wp_add_inline_style in the wp_enqueue_scripts action. if ( ! wp_is_block_theme() ) { + $style_tag_id = 'core-block-supports-duotone'; + wp_register_style( $style_tag_id, false ); if ( ! empty( self::$used_global_styles_presets ) ) { - wp_add_inline_style( 'core-block-supports', self::get_global_styles_presets( self::$used_global_styles_presets ) ); + wp_add_inline_style( $style_tag_id, self::get_global_styles_presets( self::$used_global_styles_presets ) ); } if ( ! empty( self::$block_css_declarations ) ) { - wp_add_inline_style( 'core-block-supports', wp_style_engine_get_stylesheet_from_css_rules( self::$block_css_declarations ) ); + wp_add_inline_style( $style_tag_id, wp_style_engine_get_stylesheet_from_css_rules( self::$block_css_declarations ) ); } + wp_enqueue_style( $style_tag_id ); } }