Global Styles: fix presets that use a callback to validate user data#35255
Merged
Conversation
This was referenced Sep 30, 2021
ajlende
reviewed
Oct 4, 2021
ajlende
approved these changes
Oct 6, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #34667
Related #35228 #35248
This PR makes the
remove_insecure_settingstake 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_attrfunction 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_keyof 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 intrunkif we usevalue_funcfor thecolor.palette.