[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/rest-api/endpoints/ -> class-wp-rest-entity-fields-controller.php (summary)

REST API: WP_REST_Entity_Fields_Controller class

File Size: 402 lines (12 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_REST_Entity_Fields_Controller:: (7 methods):
  __construct()
  register_routes()
  get_items_permissions_check()
  get_required_capability()
  get_items()
  get_item_schema()
  get_field_schema()


Class: WP_REST_Entity_Fields_Controller  - X-Ref

Controller which provides a REST endpoint for retrieving the fields
registered for a given entity type.

The fields are the ones registered on the server on the
`wp_entity_fields_api_init` action: the serializable part of each field, plus
the script modules that provide the JavaScript parts (render callbacks,
components, value getters and setters), each with the ids of the fields
it applies to. The client merges both into the fields it derives itself.

__construct()   X-Ref
Constructor.


register_routes()   X-Ref
Registers the routes for the controller.


get_items_permissions_check( $request )   X-Ref
Checks if a given request has access to read the fields of an entity.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True if the request has read access, WP_Error object otherwise.

get_required_capability( $kind, $name )   X-Ref
Resolves the capability required to read the fields of an entity.

Mirrors the view config endpoint, which gates the same entities: post
types use their own `edit_posts` capability (which honors custom
`capability_type` registrations), taxonomies use `manage_terms`, and
root-level entities use `manage_options`. A post type or taxonomy that is
not registered, or not exposed to the REST API, resolves to `null` so the
request is treated as referencing an unknown entity.

Any other kind falls back to `edit_posts`, so fields registered for a
custom entity kind stay readable behind a baseline capability.

param: string $kind The entity kind (e.g. `postType`).
param: string $name The entity name (e.g. `page`).
return: string|null Capability required to read the fields, or null if

get_items( $request )   X-Ref
Returns the fields registered for the given entity type.

param: WP_REST_Request $request Full details about the request.
return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

get_item_schema()   X-Ref
Retrieves the item's schema, conforming to JSON Schema.

return: array Item schema data.

get_field_schema()   X-Ref
Returns the schema for a field definition.

Describes the serializable subset of the DataViews Field API, see
packages/dataviews/src/types/field-api.ts in Gutenberg. The properties
that are JavaScript callbacks or components (`render`, `sort`,
`getValue`, …) come from the script modules and are not part of the
definition.
Additional properties are allowed, so a plugin can register a field
with properties of its own that its script module understands.

return: array Schema for a field definition.



Generated : Tue Oct 20 08:20:34 2026 Cross-referenced by PHPXref