Editor: New default rendering mode for editor via post type supports#68549
Editor: New default rendering mode for editor via post type supports#68549
Conversation
|
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. |
|
Size Change: +35 B (0%) Total Size: 1.84 MB
ℹ️ View Unchanged
|
| ).hasFinishedResolution( 'getPostType', [ post.type ] ); | ||
| const _defaultMode = Array.isArray( postTypeSupports?.editor ) | ||
| ? postTypeSupports.editor.find( | ||
| ( features ) => 'default_mode' in features |
There was a problem hiding this comment.
What do you think about using default_mode as the key for this option, or should I revert it to rendering_mode?
| ( features ) => 'default_mode' in features | ||
| )?.default_mode | ||
| : undefined; | ||
| const hasDefaultMode = RENDERING_MODES.includes( _defaultMode ); |
There was a problem hiding this comment.
Had to go with the client-side validation since it's not possible to validate arguments passed via add_post_type_support.
|
I've restored the default rendering mode for Pages to Let's discuss separately whether this should remain the default mode for the "page" post type. See: #67867 (comment). |
63e4ed1 to
4517ec3
Compare
|
@fabiankaegy, @swissspidy, if you have time, I would appreciate your review and approval of this. |
fabiankaegy
left a comment
There was a problem hiding this comment.
Thank you for taking care of this :) It works as expected for me
|
Thank you, @fabiankaegy, @swissspidy for testing 🙇 |
4517ec3 to
6f75447
Compare
6f75447 to
c588236
Compare
|
Created a new issue to discuss the new default rendering mode for page post type - #68684. |
|
Nice update! Thanks for explaining the changes as well 🙂 |
|
Thanks again for contributing, @TylerB24890! |
| if ( false !== $editor_support_key ) { | ||
| unset( $args['supports'][ $editor_support_key ] ); | ||
| $args['supports']['editor'] = array( | ||
| 'default_mode' => 'template-locked', |
There was a problem hiding this comment.
I know I'm focusing on non-important issueshere, but what's the naming convention here? Should it be default-mode instead of default_mode?
I recently examined the add_theme_support method, which seems to use dashes instead of underscores.
There was a problem hiding this comment.
@Mamaduka I'd go with consistency while it's possible.
There was a problem hiding this comment.
Thanks, @peterwilsoncc!
I'll update the argument to use the dash separator.
…ordPress#68549) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: swissspidy <swissspidy@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
…ordPress#68549) Co-authored-by: Mamaduka <mamaduka@git.wordpress.org> Co-authored-by: swissspidy <swissspidy@git.wordpress.org> Co-authored-by: fabiankaegy <fabiankaegy@git.wordpress.org>
What?
Alternative to #67867.
This PR updates how the new default rendering mode can be set for a post type. It can now be specified by passing additional information about
editorsupport.Why?
This method doesn't require a REST endpoint or any API-related changes. Existing
add_post_type_supportcan be used to change or reset the default rendering mode.Code examples
Testing Instructions
Testing Instructions for Keyboard
Same.
Screenshots or screencast