From 85607279eb13aa150e3a90adb29613c6e3a7e1ec Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sun, 11 Jun 2023 00:22:22 +0900 Subject: [PATCH 1/3] Clarify error message if duotone color values is incorrect --- lib/class-wp-duotone-gutenberg.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index b18121086bae0e..597ebd93b57a48 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -530,10 +530,19 @@ private static function get_filter_svg( $filter_id, $colors ) { foreach ( $colors as $color_str ) { $color = self::colord_parse( $color_str ); - $duotone_values['r'][] = $color['r'] / 255; - $duotone_values['g'][] = $color['g'] / 255; - $duotone_values['b'][] = $color['b'] / 255; - $duotone_values['a'][] = $color['a']; + if ( null === $color ) { + $error_message = sprintf( + /* translators: %s: duotone colors */ + __( '"%s" is not a hex or rgb string in theme.json settings', 'gutenberg' ), + $color_str + ); + _doing_it_wrong( __METHOD__, $error_message, '6.3.0' ); + } else { + $duotone_values['r'][] = $color['r'] / 255; + $duotone_values['g'][] = $color['g'] / 255; + $duotone_values['b'][] = $color['b'] / 255; + $duotone_values['a'][] = $color['a']; + } } ob_start(); From 50b96c69682423e3865030e4bd2eaa033581b8fc Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Sun, 11 Jun 2023 00:46:44 +0900 Subject: [PATCH 2/3] Add period --- lib/class-wp-duotone-gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index 597ebd93b57a48..810643a389def7 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -533,7 +533,7 @@ private static function get_filter_svg( $filter_id, $colors ) { if ( null === $color ) { $error_message = sprintf( /* translators: %s: duotone colors */ - __( '"%s" is not a hex or rgb string in theme.json settings', 'gutenberg' ), + __( '"%s" is not a hex or rgb string in theme.json settings.', 'gutenberg' ), $color_str ); _doing_it_wrong( __METHOD__, $error_message, '6.3.0' ); From dae5201dbdfbed5e81413cf6258780b559a0c260 Mon Sep 17 00:00:00 2001 From: Tetsuaki Hamano Date: Mon, 12 Jun 2023 20:28:49 +0900 Subject: [PATCH 3/3] Update message --- lib/class-wp-duotone-gutenberg.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/class-wp-duotone-gutenberg.php b/lib/class-wp-duotone-gutenberg.php index 810643a389def7..816f7e414ad793 100644 --- a/lib/class-wp-duotone-gutenberg.php +++ b/lib/class-wp-duotone-gutenberg.php @@ -533,7 +533,7 @@ private static function get_filter_svg( $filter_id, $colors ) { if ( null === $color ) { $error_message = sprintf( /* translators: %s: duotone colors */ - __( '"%s" is not a hex or rgb string in theme.json settings.', 'gutenberg' ), + __( '"%s" in theme.json settings.color.duotone is not a hex or rgb string.', 'gutenberg' ), $color_str ); _doing_it_wrong( __METHOD__, $error_message, '6.3.0' );