Global Styles: fix presets that use a callback to validate user data #35255
+7
−1
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Follow-up to #34667
Related #35228 #35248
This PR makes the
remove_insecure_settings
take the value from the callback registered by the preset viavalue_func
, if it exists.Note that for allowing the user to create their own duotones via the global styles sidebar, we'd need to also update or hook into the
safecss_filter_attr
function from WordPress core. I'm not doing this here because we don't need it so far.How to test
lib/class-wp-theme-json-gutenberg.php
(alternative create your own function in any file that's in scope):PRESETS_METADATA
, remove thevalue_key
of the first preset (color.palette
) and paste this instead:'value_func' => 'return_color_key_value_from_preset',
. This is telling the preset will look up for the value via the callback we created.Then, run
npm run test-php
: the expected result is that all the tests still pass. Also verify that the tests will fail intrunk
if we usevalue_func
for thecolor.palette
.The text was updated successfully, but these errors were encountered: