Repository navigation
Conversation
Adds the missing `align` style to the author column of the `wp_block` table layout, which was left out when the "Site patterns" rename was synced in [64499]. Synced from WordPress/gutenberg#84680. See #65981. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the logic of `WP_REST_View_Config_Controller::cast_empty_objects()` into a new private `_rest_cast_empty_objects_from_schema()` function, so it can be shared with the upcoming Entity Fields controller (#66229). The protected method is kept as a wrapper for backward compatibility. Synced from WordPress/gutenberg#84078. See #65981. Co-Authored-By: Claude Opus 5.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. |
There was a problem hiding this comment.
🟢 Approval recommended
The extraction preserves normalization behavior, adds focused tests, and has no identified blocking issues.
No open issues 🎉
What changed in this PR
Extracts schema-based empty-object normalization into a shared REST helper for view configuration.
Changes:
- Moves normalization logic into a shared helper, retaining the controller wrapper.
- Adds tests for object, array, nested, and union schemas.
- Sets block author column alignment to
start.
| File | Description |
|---|---|
| tests/phpunit/tests/rest-api/restCastEmptyObjectsFromSchema.php | Tests the shared normalization helper. |
| src/wp-includes/view-config.php | Sets block author column alignment. |
| src/wp-includes/rest-api/endpoints/class-wp-rest-view-config-controller.php | Delegates normalization to the shared helper. |
| src/wp-includes/rest-api.php | Adds the extracted normalization helper. |
Review effort: Balanced
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. |
| * @param array $schema The schema node describing the value. | ||
| * @return mixed The normalized value, with empty object-typed arrays cast to objects. | ||
| */ | ||
| function _rest_cast_empty_objects_from_schema( $value, $schema ) { |
There was a problem hiding this comment.
This utility is now used by the view config endpoint and it's going to be used by the fields and actions endpoints as well (landing in the next hours). I thought I'd extract it first.
| 'styles' => array( | ||
| 'author' => array( | ||
| 'width' => '1%', | ||
| 'align' => 'start', |
There was a problem hiding this comment.
This was missing from https://core.trac.wordpress.org/ticket/66307
|
Committed at https://core.trac.wordpress.org/changeset/64503 |
Trac ticket https://core.trac.wordpress.org/ticket/65981
Backports view config changes for WordPress 7.2:
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Implementation. Reviewed and edited by me.