-
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
Site Editor: Implement a settings object filter #33737
Conversation
The post editor has the block_editor_settings_all and block_editor_settings filter that allows us to modify the settings object injected into the block editor. A similar filter, however, doesn't exist for the site editor. We apply the same filter here for the site editor.
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.
Left a comment about needing another param and Core's filter documentation convention. Otherwise, this is great, and good call on not needing to call gutenberg_experimental_global_styles_settings
directly, since it runs on the filter.
We need to add a second param to our call to apply filters because it is included in Core WordPress.
@@ -101,7 +101,10 @@ function gutenberg_edit_site_init( $hook ) { | |||
'__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(), | |||
) | |||
); | |||
$settings = gutenberg_experimental_global_styles_settings( $settings ); | |||
|
|||
$site_editor_context = new WP_Block_Editor_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.
I'm not quite sure why the edit site page doesn't integrate this filter like other screens. If we decide to change it, we should refactor the code to use gutenberg_get_block_editor_settings
to handle it all behind the scenes rather that duplicating a similar logic.
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.
Makes sense to me. I'll make the changes. 👍
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.
Updated in 72b175c
@@ -89,19 +89,17 @@ function gutenberg_edit_site_init( $hook ) { | |||
*/ | |||
$current_screen->is_block_editor( true ); | |||
|
|||
$settings = array_merge( | |||
gutenberg_get_default_block_editor_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.
gutenberg_get_default_block_editor_settings
will be merged in the gutenberg_get_block_editor_settings
function, which is why we remove it from here.
gutenberg/lib/compat/wordpress-5.8/block-editor.php
Lines 264 to 272 in c96feeb
function gutenberg_get_block_editor_settings( $custom_settings, $block_editor_context ) { | |
$editor_settings = array_merge( | |
gutenberg_get_default_block_editor_settings(), | |
array( | |
'allowedBlockTypes' => gutenberg_get_allowed_block_types( $block_editor_context ), | |
'blockCategories' => gutenberg_get_block_categories( $block_editor_context ), | |
), | |
$custom_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.
Code looks good and it aligns with configuration for other screens with the block editor.
Thanks @gziolo! Planning to let this PR sit a a few more days so that @mattwiebe and @youknowriad get a chance to take a look. |
If @gziolo is happy about multi editor settings, I'm happy too :) |
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.
Looks good to me!
Potentially solves #33736
Description
The post editor has the
block_editor_settings_all
andblock_editor_settings
filter that allows us to modify thesettings
object injected into the block editor. A similar filter, however, doesn't exist for the site editor.How has this been tested?
There should be no visible changes to the UI.
Screenshots
Types of changes
New feature
Checklist:
*.native.js
files for terms that need renaming or removal).