Repository navigation
Conversation
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. |
e87a741 to
4db7bb1
Compare
|
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. |
4db7bb1 to
5dbb447
Compare
|
#14495 was merged and this rebased onto trunk. |
| } | ||
| // The id comes first, like in the fields registered directly. | ||
| $field = array_merge( array( 'id' => basename( dirname( $file ) ) ), $field ); | ||
| $fields[ $field['id'] ] = $field; |
There was a problem hiding this comment.
Should we validate that $field['id'] is a string? A field.php returning an array id causes a fatal error here.
There was a problem hiding this comment.
Ah, that's good thinking, thanks. Related to your comment, I found an edge case and pushed a fix (and tests) at 91fea0c
5dbb447 to
0a5dedd
Compare
jorgefilipecosta
left a comment
There was a problem hiding this comment.
Left some comments but they are not blockers.
Adds a registry of the fields of an entity, identified by its kind and name, along with `wp_register_entity_fields()`, `wp_update_entity_fields()`, `wp_unregister_entity_fields()`, and `wp_register_entity_field_collection()`, which only run on the new `wp_entity_fields_api_init` action, and the functions that read the registry. The registry is filled lazily: the action fires the first time the fields are read, once `init` has completed. A field definition is the serializable subset of the DataViews Field API. Its JavaScript parts ship in a script module registered along with the fields. The script modules of the fields are added as dynamic `module_dependencies` of the `wp-editor` script on `admin_footer`, so they reach the import map of the pages that load the editor. The `WP_REST_Entity_Fields_Controller` class is introduced too, as the registry validates the field types against its schema. Its route is registered separately. Synced from WordPress/gutenberg#84078. Synced from WordPress/gutenberg#84168. Synced from WordPress/gutenberg#84691. See #66229. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Registers the `/wp/v2/entity-fields` route, served by `WP_REST_Entity_Fields_Controller`. Given an entity kind and name, it returns the fields registered for the entity with the Entity Fields API, and the script modules providing their JavaScript parts, each with the ids of the fields it applies to. Access mirrors the `/wp/v2/view-config` route: post types require their own `edit_posts` capability, taxonomies their `manage_terms` capability, and root entities `manage_options`. Post types and taxonomies that are not registered or not exposed in the REST API are not found. Synced from WordPress/gutenberg#84078. Synced from WordPress/gutenberg#84691. See #66229. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ists. The Site Editor reads the fields of the post types it lists from the `/wp/v2/entity-fields` route before it can render them. The fields of the edited post type, if any, and of the post types of the screen the Site Editor opens on, from its `p` query arg, are now added to the preloaded paths. Synced from WordPress/gutenberg#84700. See #66229. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `field.php` that returned a non-string `id`, such as an array, caused a fatal error when the id was used as a key in get_collection_fields(). Other non-string ids were silently coerced, and a folder setting the id of an earlier one silently replaced it. Such fields are now reported with _doing_it_wrong() and skipped, along with a `field.php` that does not return an array. The rest of the collection is read, and register_collection() returns false when a field was skipped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pass hook names, file names, keys, and method names as placeholders, wrapped in `<code>`, instead of keeping them inside the strings to translate, as core does elsewhere. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
788e45c to
ff8698d
Compare
|
Committed at https://core.trac.wordpress.org/changeset/64528 |
Trac ticket: https://core.trac.wordpress.org/ticket/66229
See: WordPress/gutenberg#74865
What
This PR lands the PHP parts of the entity fields API.
Prerequisites to merge
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Opus 5.5
Used for: Implementation. Reviewed and edited by me.