-
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
Add hooks to modify theme.json structure #27722
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
53f4ef1
Add filter
oandregal dbce6b4
Use core/group as example
oandregal d3bc935
Filter out props that are not declared in the schema
oandregal a76eb88
use different key for subtree
oandregal 0cfa9da
Allow schema to be filtered
oandregal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -174,5 +174,12 @@ | |
"customRadius": true | ||
} | ||
} | ||
}, | ||
"core/group": { | ||
"styles": { | ||
"box": { | ||
"boxShadow": "10px 5px 5px red" | ||
} | ||
} | ||
} | ||
} |
This file contains 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
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.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.