Add hooks to modify theme.json structure#27722
Conversation
|
Size Change: +11 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
| if ( isset( $context['styles'] ) ) { | ||
| $this->process_key( 'color', $context['styles'], self::SCHEMA['styles'] ); | ||
| $this->process_key( 'typography', $context['styles'], self::SCHEMA['styles'] ); | ||
| $this->process_key( 'color', $context['styles'], $schema['styles'] ); |
There was a problem hiding this comment.
Hi @nosolosw,
With this PR we will be able to change the schema but this PR does not allow us to make the new properties output/do anything. When we add a new property to the schema, or a new preset how are we going to output the new styles?
E.g: after we move lib/class-wp-theme-json.php to the core if we want to add more functionalities to theme.json what is the strategy we should follow?
I guess a possibility would be to in plugin keeep lib/class-wp-theme-json.php and ignore/unregister the one shipped in the core?
There was a problem hiding this comment.
Hey, while this is proof of concept it already works in the front-end and post editor. The remaining task would be to be able to make it work in the site editor, which seems a matter of being able to extend __EXPERIMENTAL_STYLE_PROPERTY client-side. What other blockers do you anticipate to make this work?
Also note that I don't think we should add hooks yet, as we're still consolidating the theme.json shape #27295 #28110
There was a problem hiding this comment.
I'm also happy to hear/discuss what use cases we anticipate to have to see if we may need a different approach. I've listed the ones I can think of at #27504
There was a problem hiding this comment.
At first sight, it seems if we also add a filter to presets we cover the extensibility needs of class-wp-theme-json.php.
But to allow the Gutenberg plugin to continue to evolve and not need to standardize on an API/fitlers right after including theme.json into the core, we also have the opportunity of on the plugin simply unregistering what core is doing and making core class-wp-theme-json.php unused and simply use class-wp-theme-json.php from the plugin. Then updating core would be a matter of updating class-wp-theme-json.php to match the plugin. Similarly to what happens on server-side render blocks.
|
We're changing theme.json format as per #29891 so this is going to need change. Closing it for now. |
Implements part of #27504
Now that we're looking into merging the "global styles" mechanism into WordPress core, we need a way to iterate on the theme.json structure from the Gutenberg plugin. The main use case is to add new style properties, although removing existing ones should also be considered.
TODO:
__EXPERIMENTAL_STYLE_PROPERTY, so it works in the site editor.fontSize) matches. Currently, it validates the section instead (typography). This can perhaps be a follow-up, as it something pre-existing.Test