From 55847136109b13502078c620ac6921f707157405 Mon Sep 17 00:00:00 2001 From: Alex Lende Date: Fri, 19 May 2023 15:02:59 -0500 Subject: [PATCH] Better error message when theme.json styles use a duotone preset not in settings (#50714) * Show a more specific error when theme.json styles use a preset not from settings * Remove the period in the error message * Add gutenberg domain to translation --- lib/class-wp-duotone-gutenberg.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index b461e4ba0a64fc..b18121086bae0e 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -712,6 +712,15 @@ private static function enqueue_custom_filter( $filter_id, $duotone_selector, $f * @param string $filter_value The filter CSS value. e.g. 'url(#wp-duotone-blue-orange)' or 'unset'. */ private static function enqueue_global_styles_preset( $filter_id, $duotone_selector, $filter_value ) { + if ( ! array_key_exists( $filter_id, self::$global_styles_presets ) ) { + $error_message = sprintf( + /* translators: %s: duotone filter ID */ + __( 'The duotone id "%s" is not registered in theme.json settings', 'gutenberg' ), + $filter_id + ); + _doing_it_wrong( __METHOD__, $error_message, '6.3.0' ); + return; + } self::$used_global_styles_presets[ $filter_id ] = self::$global_styles_presets[ $filter_id ]; self::enqueue_custom_filter( $filter_id, $duotone_selector, $filter_value, self::$global_styles_presets[ $filter_id ] ); }