Skip to content

Commit

Permalink
Plugin: Fix eligibility check for post types' default rendering mode (#…
Browse files Browse the repository at this point in the history
…67879)

* Plugin: Fix eligibility check for post types' default rendering mode
* Add backport changelog entry

Unlinked contributors: CreativeDive.

Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
  • Loading branch information
3 people authored Dec 13, 2024
1 parent 7050a44 commit 7e85993
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions backport-changelog/6.8/7129.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
https://github.com/WordPress/wordpress-develop/pull/7129

* https://github.com/WordPress/gutenberg/pull/62304
* https://github.com/WordPress/gutenberg/pull/67879
9 changes: 6 additions & 3 deletions lib/compat/wordpress-6.8/post.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ function gutenberg_post_type_rendering_modes() {
* @return array Updated array of post type arguments.
*/
function gutenberg_post_type_default_rendering_mode( $args, $post_type ) {
$rendering_mode = 'page' === $post_type ? 'template-locked' : 'post-only';
$rendering_modes = gutenberg_post_type_rendering_modes();
if ( ! wp_is_block_theme() || ! current_theme_supports( 'block-templates' ) ) {
return $args;
}

// Make sure the post type supports the block editor.
if (
wp_is_block_theme() &&
( isset( $args['show_in_rest'] ) && $args['show_in_rest'] ) &&
( ! empty( $args['supports'] ) && in_array( 'editor', $args['supports'], true ) )
) {
$rendering_mode = 'page' === $post_type ? 'template-locked' : 'post-only';
$rendering_modes = gutenberg_post_type_rendering_modes();

// Validate the supplied rendering mode.
if (
isset( $args['default_rendering_mode'] ) &&
Expand Down

0 comments on commit 7e85993

Please sign in to comment.