-
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
Better error message when theme.json styles use a duotone preset not in settings #50714
Conversation
9e6c942
to
ee8d435
Compare
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
lib/class-wp-duotone-gutenberg.php
Outdated
__( 'The duotone id "%s" is not registered in theme.json settings', 'gutenberg' ), | ||
$filter_id | ||
); | ||
trigger_error( $error_message ); |
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.
Trigger error? Let's use _doing_it_wrong
instead.
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.
I was under the impression that _doing_it_wrong
was used for developers calling functions incorrectly. The function is being called correctly, but the theme.json it's reading from has bad data. Is it still the right choice in this case?
EDIT: For reference, this is what I was basing things off of which uses trigger_error
. https://github.com/WordPress/gutenberg/blob/trunk/lib/class-wp-theme-json-resolver-gutenberg.php#L501
I pushed up the change to use
|
Flaky tests detected in ef60cd5. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5027636815
|
What?
Provides a more helpful error message when you've misspelled a duotone variable name or tried to use a variable that we don't have the duotone information to generate an SVG.
Why?
More clear error messages are more helpful for theme developers. And it's better to show a clear error than silently not render the filter since this problem exists within a hand-coded theme.json that a developer would be creating. Using the global styles UI shouldn't create this error because only presets are able to be selected from in the interface.
How?
Triggers a custom error message when the CSS
var
being used instyles
isn't part of the presets defined insettings
.Testing Instructions
styles.blocks['core/image'].filter.duotone = var(--wp--preset--duotone--does-not-exist)
.Testing Instructions for Keyboard
Screenshots or screencast
Before
After
Previously, in this PR using
trigger_error
.