[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

REST API: WP_REST_Entity_Actions_Controller class

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

Defines 1 class

WP_REST_Entity_Actions_Controller:: (8 methods):
  __construct()
  register_routes()
  is_route_of_entity_items()
  get_items_permissions_check()
  get_required_capability()
  get_items()
  get_item_schema()
  get_action_schema()


Class: WP_REST_Entity_Actions_Controller  - X-Ref

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

The actions are the ones registered on the server on the
`wp_entity_actions_api_init` action: the serializable part of each action, plus
the script modules that provide the JavaScript parts (callbacks, modals,
eligibility checks, icons), each with the ids of the actions it applies
to. The client merges both into the actions it shows.

__construct()   X-Ref
Constructor.


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


is_route_of_entity_items()   X-Ref
Checks whether a post type or taxonomy has its items on the route of
the controller, reporting it with _doing_it_wrong().

The route is then left to the post type or taxonomy: registering it
as well would not serve the actions, as the route of the items comes
first, and would replace the schema of that route.

return: bool Whether a post type or taxonomy has its items on the route.

get_items_permissions_check( $request )   X-Ref
Checks if a given request has access to read the actions 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 actions of an entity.

Mirrors the fields 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 actions 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 actions, or null if

get_items( $request )   X-Ref
Returns the actions 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_action_schema()   X-Ref
Returns the schema for an action definition.

Describes the serializable subset of the DataViews Action API, see
packages/dataviews/src/types/dataviews.ts. The properties that are
JavaScript callbacks, components, or elements (`callback`,
`RenderModal`, `isEligible`, `icon`, …) come from the script modules and
are not part of the definition. Additional properties are allowed, so a
plugin can register an action with properties of its own that its script
module understands.

return: array Schema for an action definition.



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