-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 __experimentalFeatures
data for the block editor
#1262
Conversation
@@ -4626,6 +4626,65 @@ function _wp_array_get( $array, $path, $default = null ) { | |||
return $array; | |||
} | |||
|
|||
/** |
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.
Extracted this to #1263 Added here for simplicity of review/test. That PR should land before this one and should be reviewed over there.
@@ -0,0 +1,368 @@ | |||
<?php |
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.
This file comes from https://github.com/WordPress/gutenberg/blob/trunk/lib/class-wp-theme-json-resolver.php but I've removed the bits that weren't necessary just yet (user data, etc).
@@ -0,0 +1,374 @@ | |||
<?php |
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.
This file comes from https://github.com/WordPress/gutenberg/blob/trunk/lib/class-wp-theme-json.php and I've removed the bits that weren't necessary just yet (processing styles, settings that are not stable yet so aren't mean to land in core, etc).
__experimentalFeatures
data for the block editor
Current status: the code has been adapted from Gutenberg's to only contain the parts that deal with the settings. All tests are passing. It's functional using themes with and without theme.json support. Gutenberg can be activated using this companion PR WordPress/gutenberg#32059 |
* | ||
* @param WP_Theme_JSON $incoming Data to merge. | ||
*/ | ||
public function merge( $incoming ) { |
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.
Note that this function hasn't been updated to include the changes to the merge algorithm introduced at WordPress/gutenberg#31669 It needs the 10.7 Gutenberg packages to work as expected. It should be updated later.
Because the data can be augmented (new settings, styles, etc) we need a mechanism to also set the values for this data.
* Class that abstracts the processing | ||
* of the different data sources. | ||
*/ | ||
class WP_Theme_JSON_Resolver { |
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.
Is there a way to mark all these introduced classes as "internal" to allow them to refactor/update the code in future versions?
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 don't know. I've seen some function names prepended as _function_name
when they're only expected to be used internally. Can we do the same for the classes or using something like _EXPERIMENTAL_
?
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.
Maybe we can just mark it @access private
or something like that. @desrosj would know maybe?
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.
Done that at 665801c
I think this is a very good first step. I'm just concerned about the number of new APIs this exposes in Core. I'd rather have just "theme.json" file (for themes) and |
Landed at ef3da33 |
As per the follow-ups on this PR:
|
Part of https://core.trac.wordpress.org/ticket/53175
This PR ports the first piece of landing the theme.json processing in WordPress core. It deals with merging the new settings (
__experimentalFeatures
) for all editors to access. The second piece would be to land the stylesheet engine.What this PR does
__experimentalFeatures
to the block editor settings. This data comes fromtheme.json
(core and theme). See for the whole rationale about thetheme.json
file.theme-i18n.json
file to WordPress core, to be used by core, the plugin, and wp-cli for translations.WP_Theme_JSON
andWP_Theme_JSON_Resolver
classes. These are used to pull settings fromtheme.json
(core and theme). If you compare these with the ones that come with Gutenberg you'll note that this PR only includes the necessary bits for settings to work. Subsequent PRs will deal with adding styles, etc.How this can be extended
There are a few ways:
theme.json
file, etc): because we're adding new data undersettings.__experimentalFeatures
this can be filtered by the existing block editor filters.theme_json_allowed_schema
: to modify the schema used in sanitize thetheme.json
data.theme_json_core_data
: to set defaults for core data, including new settings added via the previous filter.Related work
Dependant PRs:
_wp_array_set
function and extract it from this PR Add_wp_array_set
function #1263 (to land first)Follow-ups:
How to test
A theme without
theme.json
:theme.json
).__experimentalFeatures
available undersettings
in thecore/block-editor
store and that it contains the ALLOWED_SETTINGS (see)A theme with
theme.json
support (but doesn't provide specific color palette):__experimentalFeatures
available undersettings
in thecore/block-editor
store and that it contains the ALLOWED_SETTINGS (see)A theme with
theme.json
support (but does provide a color palette):__experimentalFeatures
available undersettings
in thecore/block-editor
store and that it contains the ALLOWED_SETTINGS (see)With the Gutenberg plugin active:
__experimentalFeatures
available undersettings
in thecore/block-editor
store and that it contains the allowed settings passed from the plugin (seegutenberg_global_styles_theme_json_allowed_settings
method).