Repository navigation
Theme Export: Restore appearanceTools when exporting a theme - #39840
Conversation
| if ( array_key_exists( 'appearanceTools', $theme_json['settings'] ) ) { // Is it safe to assume that 'settings' always exsits? | ||
| foreach ( static::TO_OPT_IN as $path ) { | ||
| // Remove the path. | ||
| if ( ! empty( $theme_json['settings'][ $path[ 0 ] ][ $path[ 1 ] ] ) ) { |
There was a problem hiding this comment.
This is really hard to read because of the $path[ 0 ] thing, but I'm not sure what would be a better approach...
There was a problem hiding this comment.
Maybe something like
foreach ( static::TO_OPT_IN as list( $group, $prop ) ) {
if ( ! empty( $theme_json['settings'][ $group ][ $prop ] ) ) {|
Why overload |
So that it can use the new class variable - the old one just has that array hardcoded into the function. |
1d5d27c to
ced68ae
Compare
There was a problem hiding this comment.
Can unset prop be, or ever become, a valid value? I know it's unlikely for, say, color – but still. How about an object? It should also have a unique identity.
There was a problem hiding this comment.
All existing opt-ins are booleans (or null).
9a5b652 to
790bbbc
Compare
|
I was looking into this and thought I'd push a couple of changes to:
|
|
Thanks @oandregal. I fixed a few linting issues... |
d289eba to
655b216
Compare
we don't want to pass this to the block-editor store.
655b216 to
ffb8f1a
Compare
What?
When you export a theme that declares support for
appearanceToolsin theme.json we should keep this declaration rather than converting it to the properties that this maps to. Fixes #39464.Why?
This will make it easier for theme developers to use the theme export tool, and also enable them to easy opt in to more settings in the future.
How?
By overloading the
do_opt_in_into_settingsmethod inWP_Theme_JSON_Gutenbergand creating a new one calleddo_opt_out_of_settingswhich does the reverse.Testing Instructions
appearanceToolsproperty in theme.json (e.g. TT2)Notes
There are also some other settings that are opted in to (e.g. settings.color.custom, settings.color.customGradient) but this has a different cause so we should look at it in a different PR...
cc @WordPress/block-themers