View Config: Make the panel summary of the default form groups explicit - #13308
View Config: Make the panel summary of the default form groups explicit#13308oandregal wants to merge 1 commit into
Conversation
The `status` and `discussion` groups of the default post type form used to be summarized by the field sharing their id (`status`, and the composite `discussion` field). A combined form field no longer resolves its own id against the field definitions, so the summary field is declared through `layout.summary` instead. Backports WordPress/gutenberg#82175. See #65981. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
There was a problem hiding this comment.
Pull request overview
This PR updates the default post type entity view config form so the status and discussion field groups explicitly declare their panel summary via layout.summary, aligning core’s server-provided configuration with the updated summary-resolution behavior for composite/group fields.
Changes:
- Add explicit
layout(type: panel,summary: <group-id>) for thestatusanddiscussiongroups in_wp_get_default_posttype_form(). - Add a PHPUnit test to assert that these groups exist, retain children, and declare an explicit summary for built-in and custom post types.
- Introduce a small test helper for retrieving a form field by id from a config.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/wp-includes/view-config.php |
Makes status and discussion groups declare layout.summary explicitly in the default post type form config. |
tests/phpunit/tests/view-config.php |
Adds coverage to ensure the default post type form groups explicitly declare their summary for core and custom post types. |
Suppressed comments (1)
tests/phpunit/tests/view-config.php:121
- The test indexes
$field['children']and$field['layout']directly. If either key is missing (which is exactly what this test is meant to detect), PHP notices can occur before assertions run, making the failure less clear. AddassertArrayHasKey()checks and assert only the relevantlayoutproperties so the test stays robust if additional optional layout keys are added later.
$this->assertNotNull( $field, "The `{$group}` group is present." );
$this->assertNotEmpty( $field['children'], "The `{$group}` group keeps its children." );
$this->assertSame(
array(
'type' => 'panel',
'summary' => $group,
),
$field['layout'],
"The `{$group}` group summary is explicit."
);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| private function get_form_field( $config, $id ) { | ||
| foreach ( $config['form']['fields'] as $field ) { | ||
| if ( is_array( $field ) && isset( $field['id'] ) && $id === $field['id'] ) { | ||
| return $field; | ||
| } | ||
| } | ||
| return null; | ||
| } |
The
statusanddiscussiongroups of the default post type form used to be summarized by the field sharing their id (status, and the compositediscussionfield from@wordpress/fields). A combined form field no longer resolves its own id against the field definitions, so the summary field is declared throughlayout.summaryinstead. Without it, the groups would be summarized by their first child (statusis unchanged, butdiscussionwould showcomment_statusalone).Gutenberg PR: WordPress/gutenberg#82175
Trac ticket: https://core.trac.wordpress.org/ticket/65981
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable
Used for: Porting the server-side change and its unit test from the Gutenberg PR. Reviewed and edited by me.