-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify error message if duotone color values is incorrect #51397
Conversation
lib/class-wp-duotone-gutenberg.php
Outdated
if ( null === $color ) { | ||
$error_message = sprintf( | ||
/* translators: %s: duotone colors */ | ||
__( '"%s" is not a hex or rgb string in theme.json settings.', 'gutenberg' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested well for me. I wonder if for even more clarity we should say `'"%s" in theme.json settings.color.duotone is not a hex or rgb string.'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! Updated with dae5201. Here are the new error messages:
PHP Notice: Function WP_Duotone_Gutenberg::get_filter_svg was called <strong>incorrectly</strong>. "var(--wp--preset--color--black)" in theme.json settings.color.duotone is not a hex or rgb string. Please see <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.3.0.) in /var/www/html/wp-includes/functions.php on line 5896
PHP Notice: Function WP_Duotone_Gutenberg::get_filter_svg was called <strong>incorrectly</strong>. "var(--wp--preset--color--vivid-red)" in theme.json settings.color.duotone is not a hex or rgb string. Please see <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.3.0.) in /var/www/html/wp-includes/functions.php on line 5896
PHP Notice: Function WP_Duotone_Gutenberg::get_filter_svg was called <strong>incorrectly</strong>. "incorrect-value-1" in theme.json settings.color.duotone is not a hex or rgb string. Please see <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.3.0.) in /var/www/html/wp-includes/functions.php on line 5896
PHP Notice: Function WP_Duotone_Gutenberg::get_filter_svg was called <strong>incorrectly</strong>. "incorrect-value-2" in theme.json settings.color.duotone is not a hex or rgb string. Please see <a href="https://wordpress.org/documentation/article/debugging-in-wordpress/">Debugging in WordPress</a> for more information. (This message was added in version 6.3.0.) in /var/www/html/wp-includes/functions.php on line 5896
Flaky tests detected in dae5201. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5243050796
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…#51397) * Clarify error message if duotone color values is incorrect * Add period * Update message
Fixes: #50200
Similar to #50714
What?
This PR fixes a PHP warning error that appears when the duotone color is not HEX or RGB in theme.json and changes the text to be more specific.
Why?
In theme.json,
settings.color.duotone[].colors
values support only strings representing HEX or RGB. If any other value is present, it cannot be parsed into the RGBA value and will refer to a non-existent index in the array, causing a PHP Warning error.The fact that only RGB and HEX are allowed is also defined as
description
in the theme.json schema.However, many developers may not be aware of this because (in my VSCode) I have to mouse over the value to read that description. I thought it would make sense to let developers know what values are incorrect by means of more explicit error messages.
How?
As in #50714, the _doing_it_wrong function indicates color strings that could not be parsed. Also, the invalid value is not used as a value for the duotone filter.
Testing Instructions
Activate the Empty Theme theme and update theme.json as follows:
Access the editor and verify that the error message changes.
Before
After