Add ability to set default rendering mode per post type#62302
Add ability to set default rendering mode per post type#62302TylerB24890 wants to merge 6 commits intoWordPress:trunkfrom
Conversation
…deringMode value into the Editor rendering function.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
What?
Related Issue & PR:
block_editor_settings_allhook in PHP to allow customizing it #61844This PR adds a filterable
rendering_modeproperty to theWP_Post_Typeobject allowing users to define the default rendering mode for the editor for that post type.The
rendering_modeproperty can be added to the arguments when registering the post type viaregister_post_type()and can be overwritten using the available filters:{$post_type}_default_rendering_mode: To target an individual specific post type.post_type_default_rendering_mode: To target all (or multiple) post types.Why?
Currently there is no way to set the default rendering mode of the block editor. You can select the mode while in the block editor, but upon refreshing that mode is reset back to the default
post-only. With this update developers have more control over the editing experience and provides a means of setting the default view for the block editor.How?
The linked PR has a discussion that mentions this setting should be applied at the post type level, allowing for a difference editing mode per post type. This PR applies the
rendering_modeproperty to theWP_Post_Typeobject itself and provides multiple ways of overriding or setting the default for a custom (or core) post type.Testing Instructions
postpost type and observe the default editor UI.functions.phpfile (or similar) use one of the available filters to set therendering_modeproperty totemplate-lock:posteditor and confirm you are now seeing the Template UI instead of the default Post UI.pagepost and confirm thepageeditor also loads with the Template UI.functions.phpto target only thepagepost type:pageeditor and confirm it still renders the Template UI.posteditor and confirm it now renders the default Post UI.functions.phpto set the rendering mode for thepostandpagepost types, but no others:register_post_typeand set therendering_modeparameter totemplate-lock:rendering_modeargument from your post type registration & confirm the editor now loads with the default Post UI.