-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Move editor settings code to compat folder #39030
Conversation
from #36327
a725b3e
to
64ffed5
Compare
We need the editor settings to use the plugin code until the minimim WordPress version is 6.0.
* | ||
* @return array New block editor settings. | ||
*/ | ||
function gutenberg_get_block_editor_settings_mobile( $settings ) { |
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 has been extracted to the experimental folder because we don't know yet what's going to happen with the REST Endpoint this method complements. To land in core in the same release as the endpoint.
} | ||
|
||
// Copied from get_block_editor_settings() at wordpress-develop/block-editor.php. | ||
$settings['__experimentalFeatures'] = gutenberg_get_global_settings(); |
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.
We've done some modifications to the data available in theme.json that we expect to land in 6.0. While this doesn't have any changes with respect to what's in WordPress core, we still need to make sure this calls the gutenberg_*
methods so the said modifications are loaded in the editors.
$context = 'mobile'; | ||
} | ||
|
||
if ( 'mobile' === $context && WP_Theme_JSON_Resolver_Gutenberg::theme_has_support() ) { |
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 has been extracted to a separate file, see https://github.com/WordPress/gutenberg/pull/39030/files#r814083346
} | ||
if ( isset( $settings['__experimentalFeatures']['spacing']['units'] ) ) { | ||
$settings['enableCustomUnits'] = $settings['__experimentalFeatures']['spacing']['units']; | ||
unset( $settings['__experimentalFeatures']['spacing']['units'] ); |
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 PR brings back this unset
line.
This line had been accidentally removed in #32898 while backporting changes from this core patch https://core.trac.wordpress.org/changeset/51203 (note how the core patch still had the unset
but it was removed in the Gutenberg PR).
if ( isset( $settings['__experimentalFeatures']['typography']['fontSizes'] ) ) { | ||
$font_sizes_by_origin = $settings['__experimentalFeatures']['typography']['fontSizes']; | ||
$settings['fontSizes'] = isset( $font_sizes_by_origin['custom'] ) ? | ||
$font_sizes_by_origin['custom'] : ( |
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.
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 LGTM!
defined( 'REST_REQUEST' ) && | ||
REST_REQUEST && | ||
isset( $_GET['context'] ) && | ||
'mobile' === $_GET['context'] |
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 missed a check, see #39806
This PR continues with the work of moving PHP code to the corresponding
lib/compat
folder so it's easier to do the backports and we have a path to remove PHP code from the plugin.Specifically:
lib/compat/6.0
=> we've done some modifications to the underlying allowed theme.json to be landed in 6.0 and we need the editors to be aware of them (by using thegutenberg_*
functions), that's why this needs to be moved to the 6.0 folder.lib/compat/experimental
the changes we're still unclear about (gutenberg_get_block_editor_settings_mobile
) and that should land together with the settings REST endpoint.Follow-ups:
styles
and__experimentalFeatures
to any caller of this function, including the site editor (see). However, in the plugin, we do not passstyles
to the site editor or mobile because they don't use them. We need to figure out a way forward for this in a follow-up PR. In the meantime, this PR doesn't change this behavior.How to test
Verify that tests pass.