From 1de97d4b2252c3404e7527cf85e47009f7dafa1d Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Tue, 13 Jun 2023 11:32:26 +0900 Subject: [PATCH] Clarify error message if duotone color values is incorrect (#51397) * Clarify error message if duotone color values is incorrect * Add period * Update message --- 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..816f7e414ad793 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" 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' ); + } 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();