diff --git a/lib/compat/wordpress-6.8/class-gutenberg-rest-post-types-controller-6-8.php b/lib/compat/wordpress-6.8/class-gutenberg-rest-post-types-controller-6-8.php index 1309472b80024..003bbe0ef9c48 100644 --- a/lib/compat/wordpress-6.8/class-gutenberg-rest-post-types-controller-6-8.php +++ b/lib/compat/wordpress-6.8/class-gutenberg-rest-post-types-controller-6-8.php @@ -13,29 +13,33 @@ * @return void */ function gutenberg_editor_rendering_mode_field() { - register_rest_field( 'type', 'default_rendering_mode', array( - 'get_callback' => static function( $object ) { - $post_type_object = get_post_type_object( $object['slug'] ); + register_rest_field( + 'type', + 'default_rendering_mode', + array( + 'get_callback' => static function ( $object ) { + $post_type_object = get_post_type_object( $object['slug'] ); - // Property will only exist if the post type supports the block editor. - if ( ! $post_type_object || ! isset( $post_type_object->default_rendering_mode ) ) { - return ''; - } + // Property will only exist if the post type supports the block editor. + if ( ! $post_type_object || ! isset( $post_type_object->default_rendering_mode ) ) { + return 'post-only'; + } - // Validate the filtered rendering mode. - if ( ! in_array( $post_type_object->default_rendering_mode, gutenberg_post_type_rendering_modes(), true ) ) { - return 'post-only'; - } + // Validate the filtered rendering mode. + if ( ! in_array( $post_type_object->default_rendering_mode, gutenberg_post_type_rendering_modes(), true ) ) { + return 'post-only'; + } - return $post_type_object->default_rendering_mode; - }, - 'schema' => array( - 'description' => __( 'The rendering mode for the editor.', 'gutenberg' ), - 'type' => 'string', - 'enum' => array( 'post-only', 'template-locked' ), - 'context' => array( 'edit' ), - 'readonly' => true, - ), - ) ); + return $post_type_object->default_rendering_mode; + }, + 'schema' => array( + 'description' => __( 'The rendering mode for the editor.', 'gutenberg' ), + 'type' => 'string', + 'enum' => array( 'post-only', 'template-locked' ), + 'context' => array( 'edit' ), + 'readonly' => true, + ), + ) + ); } add_action( 'rest_api_init', 'gutenberg_editor_rendering_mode_field' );