Editor: Abstract block editor configuration#1118
Closed
gziolo wants to merge 1 commit intoWordPress:masterfrom
gziolo:add/initialize-block-editor
Closed
Editor: Abstract block editor configuration#1118gziolo wants to merge 1 commit intoWordPress:masterfrom gziolo:add/initialize-block-editor
gziolo wants to merge 1 commit intoWordPress:masterfrom
gziolo:add/initialize-block-editor
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Trac ticket: https://core.trac.wordpress.org/ticket/52920
Related to WordPress/gutenberg#28701.
Required for WordPress/gutenberg#29969 - new REST API endpoint for the editor settings.
We are approaching the day where new screens with the block editor get included in WordPress core. It looks like there are several WordPress hooks defined on the server that depends on
$postobject that isn’t present on the edit site, edit widgets, or edit navigation screens. It feels like we should deprecate existing filters and create replacements that are going to be context-aware.It's a work in progress.
Changes included so far:
get_default_block_categorieswere introduced to make is possible to share default block categoriesget_allowed_block_typeswas introduced to handle filters depending on the editor typeget_default_block_editor_settingsmethodget_block_editor_settingsgot introduced to ensure that editor settings can be filtered depending on the editor typeblock_editor_rest_api_preloadmethodAll existing filters that depend on
$postobject get deprecated withapply_filters_deprecatedas suggested by @jeremyfelt:allowed_block_typesblock_categoriesblock_editor_preload_pathsblock_editor_settingsNew filters are introduced that are context-aware:
allowed_block_types_allallowed_block_types_{$editor_name}block_categories_allblock_editor_rest_api_preload_pathsblock_editor_preload_paths_{$editor_name}block_editor_settings_allblock_editor_settings_{$editor_name}In the case where there are two filters for a general use case that covers any editor type and a specific one, I followed https://core.trac.wordpress.org/ticket/46187 and the implementation forrender_block+render_block_{$block_name}. @johnbillion shared more examples in https://core.trac.wordpress.org/ticket/46187#comment:9:Detailed filters per editor type are on hold upon feedback received from @youknowriad, @chrisvanpatten, and @TimothyBJacobs . We want to make it more flexible and it might end up with a special object that holds context.
Details
> This is a fairly common pattern in core, see for example: `gettext/gettext_{$domain}`, `plugin_action_links/plugin_action_links_{$plugin_file}`, `manage_posts_columns/manage_{$post_type}_posts_columns`, etc. The dynamically named filter should come after the generic one.This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.