From 905a1c776910ca933a9b70be106f0fbc4cb7a08d Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 23 Jun 2026 19:09:35 +0100 Subject: [PATCH 1/4] REST API: Add pattern summary form config --- src/wp-includes/view-config.php | 28 +++++++++++ .../rest-api/rest-view-config-controller.php | 46 +++++++++++++++++++ 2 files changed, 74 insertions(+) diff --git a/src/wp-includes/view-config.php b/src/wp-includes/view-config.php index 810fafb840384..fa30f9f3eade7 100644 --- a/src/wp-includes/view-config.php +++ b/src/wp-includes/view-config.php @@ -473,6 +473,34 @@ function _wp_get_entity_view_config_post_type_wp_block( $config ) { $config['view_list'] = $view_list; + $config['form'] = array( + 'layout' => array( 'type' => 'panel' ), + 'fields' => array( + array( + 'id' => 'excerpt', + 'layout' => array( + 'type' => 'panel', + 'labelPosition' => 'top', + ), + ), + array( + 'id' => 'post-content-info', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + array( + 'id' => 'sync-status', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'side', + ), + ), + 'revisions', + ), + ); + return $config; } diff --git a/tests/phpunit/tests/rest-api/rest-view-config-controller.php b/tests/phpunit/tests/rest-api/rest-view-config-controller.php index b487055ff14d8..fe3bfb1afa11b 100644 --- a/tests/phpunit/tests/rest-api/rest-view-config-controller.php +++ b/tests/phpunit/tests/rest-api/rest-view-config-controller.php @@ -301,6 +301,52 @@ public function test_get_items_matches_underlying_config() { $this->assertSame( $config['form'], $data['form'] ); } + /** + * The pattern form config exposes the fields shown in the pattern summary. + * + * @ticket 65516 + * + * @covers WP_REST_View_Config_Controller::get_items + */ + public function test_wp_block_config_includes_pattern_summary_form() { + wp_set_current_user( self::$editor_id ); + + $response = $this->dispatch_request( 'postType', 'wp_block' ); + $data = $response->get_data(); + + $this->assertSame( 200, $response->get_status() ); + $this->assertSame( + array( + 'layout' => array( 'type' => 'panel' ), + 'fields' => array( + array( + 'id' => 'excerpt', + 'layout' => array( + 'type' => 'panel', + 'labelPosition' => 'top', + ), + ), + array( + 'id' => 'post-content-info', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + array( + 'id' => 'sync-status', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'side', + ), + ), + 'revisions', + ), + ), + $data['form'] + ); + } + /** * Empty object-typed config values serialize as JSON objects ({}), not arrays ([]). * From 2e989c5b8f67e84d2eb314e9f119ce3b56359f37 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 29 Jun 2026 13:51:34 +0300 Subject: [PATCH 2/4] updates from GB --- src/wp-includes/view-config.php | 8 +--- .../rest-api/rest-view-config-controller.php | 46 ------------------- 2 files changed, 1 insertion(+), 53 deletions(-) diff --git a/src/wp-includes/view-config.php b/src/wp-includes/view-config.php index fa30f9f3eade7..2c29f3fd2ee21 100644 --- a/src/wp-includes/view-config.php +++ b/src/wp-includes/view-config.php @@ -490,13 +490,7 @@ function _wp_get_entity_view_config_post_type_wp_block( $config ) { 'labelPosition' => 'none', ), ), - array( - 'id' => 'sync-status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'side', - ), - ), + 'sync-status', 'revisions', ), ); diff --git a/tests/phpunit/tests/rest-api/rest-view-config-controller.php b/tests/phpunit/tests/rest-api/rest-view-config-controller.php index fe3bfb1afa11b..b487055ff14d8 100644 --- a/tests/phpunit/tests/rest-api/rest-view-config-controller.php +++ b/tests/phpunit/tests/rest-api/rest-view-config-controller.php @@ -301,52 +301,6 @@ public function test_get_items_matches_underlying_config() { $this->assertSame( $config['form'], $data['form'] ); } - /** - * The pattern form config exposes the fields shown in the pattern summary. - * - * @ticket 65516 - * - * @covers WP_REST_View_Config_Controller::get_items - */ - public function test_wp_block_config_includes_pattern_summary_form() { - wp_set_current_user( self::$editor_id ); - - $response = $this->dispatch_request( 'postType', 'wp_block' ); - $data = $response->get_data(); - - $this->assertSame( 200, $response->get_status() ); - $this->assertSame( - array( - 'layout' => array( 'type' => 'panel' ), - 'fields' => array( - array( - 'id' => 'excerpt', - 'layout' => array( - 'type' => 'panel', - 'labelPosition' => 'top', - ), - ), - array( - 'id' => 'post-content-info', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - array( - 'id' => 'sync-status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'side', - ), - ), - 'revisions', - ), - ), - $data['form'] - ); - } - /** * Empty object-typed config values serialize as JSON objects ({}), not arrays ([]). * From a46cbe847cfa0a4f9f9b1367a948c7654f360584 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Mon, 29 Jun 2026 13:59:43 +0300 Subject: [PATCH 3/4] backport 79625 --- src/wp-includes/default-filters.php | 2 +- src/wp-includes/view-config.php | 226 ++++++++++------------------ 2 files changed, 84 insertions(+), 144 deletions(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 3d00e5ae1ba22..4e0b74a8d22c2 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -819,7 +819,7 @@ add_filter( 'rest_pre_insert_wp_template_part', 'inject_ignored_hooked_blocks_metadata_attributes' ); // View Config API. -foreach ( array( 'page', 'post', 'wp_block', 'wp_template_part', 'wp_template' ) as $post_type ) { +foreach ( array( 'page', 'wp_block', 'wp_template_part', 'wp_template' ) as $post_type ) { add_filter( "get_entity_view_config_postType_{$post_type}", "_wp_get_entity_view_config_post_type_{$post_type}", diff --git a/src/wp-includes/view-config.php b/src/wp-includes/view-config.php index 2c29f3fd2ee21..f412c215fb998 100644 --- a/src/wp-includes/view-config.php +++ b/src/wp-includes/view-config.php @@ -10,6 +10,88 @@ * @since 7.1.0 */ +/** + * Builds the default `form` configuration shared by every post type entity. + * + * This is the single `form` consumed today; it is a sensible default for `post`, + * `page`, and custom post types alike rather than being tailored per type. + * + * It is intentionally NOT gated by `supports`. The registered fields are the + * single source of truth for what applies: each field is registered for a post + * type based on its `supports` (and related flags such as `theme_supports`), and + * the editor drops any form field whose definition is absent or whose `isVisible` + * returns `false`. + * + * @since 7.1.0 + * + * @return array The default form configuration. + */ +function _wp_get_default_post_type_form() { + return array( + 'layout' => array( 'type' => 'panel' ), + 'fields' => array( + array( + 'id' => 'featured_media', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + array( + 'id' => 'post-content-info', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + array( + 'id' => 'excerpt', + 'layout' => array( + 'type' => 'panel', + 'labelPosition' => 'top', + ), + ), + array( + 'id' => 'status', + 'label' => __( 'Status' ), + 'children' => array( + array( + 'id' => 'status', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + 'scheduled_date', + 'password', + 'sticky', + ), + ), + 'date', + 'slug', + 'author', + 'template', + array( + 'id' => 'discussion', + 'label' => __( 'Discussion' ), + 'children' => array( + array( + 'id' => 'comment_status', + 'layout' => array( + 'type' => 'regular', + 'labelPosition' => 'none', + ), + ), + 'ping_status', + ), + ), + 'parent', + 'format', + 'revisions', + ), + ); +} + /** * Returns the view configuration for the given entity. * @@ -65,7 +147,7 @@ function wp_get_entity_view_config( $kind, $name ) { 'default_view' => $default_view, 'default_layouts' => $default_layouts, 'view_list' => $view_list, - 'form' => array(), + 'form' => 'postType' === $kind ? _wp_get_default_post_type_form() : array(), ); /** @@ -241,148 +323,6 @@ function _wp_get_entity_view_config_post_type_page( $config ) { ), ); - $config['form'] = array( - 'layout' => array( 'type' => 'panel' ), - 'fields' => array( - array( - 'id' => 'featured_media', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - array( - 'id' => 'post-content-info', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - array( - 'id' => 'excerpt', - 'layout' => array( - 'type' => 'panel', - 'labelPosition' => 'top', - ), - ), - array( - 'id' => 'status', - 'label' => __( 'Status' ), - 'children' => array( - array( - 'id' => 'status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - 'scheduled_date', - 'password', - 'sticky', - ), - ), - 'date', - 'slug', - 'author', - 'template', - array( - 'id' => 'discussion', - 'label' => __( 'Discussion' ), - 'children' => array( - array( - 'id' => 'comment_status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - 'ping_status', - ), - ), - 'parent', - 'format', - 'revisions', - ), - ); - - return $config; -} - -/** - * Provides the view configuration for the `post` post type. - * - * @since 7.1.0 - * - * @param array $config { - * The view configuration for the entity. - * } - * @return array The filtered view configuration. - */ -function _wp_get_entity_view_config_post_type_post( $config ) { - $config['form'] = array( - 'layout' => array( 'type' => 'panel' ), - 'fields' => array( - array( - 'id' => 'featured_media', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - array( - 'id' => 'post-content-info', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - array( - 'id' => 'excerpt', - 'layout' => array( - 'type' => 'panel', - 'labelPosition' => 'top', - ), - ), - array( - 'id' => 'status', - 'label' => __( 'Status' ), - 'children' => array( - array( - 'id' => 'status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - 'scheduled_date', - 'password', - 'sticky', - ), - ), - 'date', - 'slug', - 'author', - 'template', - array( - 'id' => 'discussion', - 'label' => __( 'Discussion' ), - 'children' => array( - array( - 'id' => 'comment_status', - 'layout' => array( - 'type' => 'regular', - 'labelPosition' => 'none', - ), - ), - 'ping_status', - ), - ), - 'parent', - 'format', - 'revisions', - ), - ); - return $config; } From 2eae4cda77f0737f1ab72bd96567bf1216697a91 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 30 Jun 2026 08:19:41 +0300 Subject: [PATCH 4/4] update comments --- src/wp-includes/view-config.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/view-config.php b/src/wp-includes/view-config.php index f412c215fb998..8b7e019e48b84 100644 --- a/src/wp-includes/view-config.php +++ b/src/wp-includes/view-config.php @@ -11,10 +11,11 @@ */ /** - * Builds the default `form` configuration shared by every post type entity. + * Builds the default `form` configuration for post types that don't provide their own. * - * This is the single `form` consumed today; it is a sensible default for `post`, - * `page`, and custom post types alike rather than being tailored per type. + * It is a sensible default for `post`, `page`, and custom post types alike rather + * than being tailored per type. Post types that need a different shape can replace + * it entirely with a dedicated `form` through their own filter callback. * * It is intentionally NOT gated by `supports`. The registered fields are the * single source of truth for what applies: each field is registered for a post