[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/rest-api/endpoints/ -> class-wp-rest-abilities-v1-list-controller.php (summary)

REST API list controller for Abilities API.

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

Defines 1 class

WP_REST_Abilities_V1_List_Controller:: (10 methods):
  register_routes()
  get_items()
  get_item()
  get_items_permissions_check()
  get_item_permissions_check()
  is_associative_array()
  prepare_schema_for_response()
  prepare_item_for_response()
  get_item_schema()
  get_collection_params()


Class: WP_REST_Abilities_V1_List_Controller  - X-Ref

Core controller used to access abilities via the REST API.

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


get_items( $request )   X-Ref
Retrieves all abilities.

param: WP_REST_Request $request Full details about the request.
return: WP_REST_Response Response object on success.

get_item( $request )   X-Ref
Retrieves a specific ability.

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_items_permissions_check( $request )   X-Ref
Checks if a given request has access to read ability items.

param: WP_REST_Request $request Full details about the request.
return: bool True if the request has read access.

get_item_permissions_check( $request )   X-Ref
Checks if a given request has access to read an ability item.

param: WP_REST_Request $request Full details about the request.
return: bool True if the request has read access.

is_associative_array( $value )   X-Ref
Determines whether the value is an associative array.

param: mixed $value Value.
return: bool Whether it is associative array.

prepare_schema_for_response( array $schema )   X-Ref
Transforms an ability schema for REST response output.

The input and output schemas are a public contract: REST clients (such as
the `@wordpress/abilities` JS client) consume them as standard JSON Schema
and validate ability input and output against them. The response must
therefore use JSON Schema draft-04 forms that standard validators
understand, not the WordPress-internal conventions that
`rest_validate_value_from_schema()` also accepts on the server.

Ability schemas may include WordPress-internal properties or unsupported
schema keywords that should not be exposed in REST responses. This method
strips keys not recognized by the REST API schema handling. It also
converts empty array defaults to objects when the schema type is 'object'
to ensure proper JSON serialization as {} instead of [], and normalizes
the `required` keyword from the draft-03 per-property boolean form into
the draft-04 array of property names.

param: array<string, mixed> $schema The schema array.
return: array<string, mixed> The transformed schema.

prepare_item_for_response( $ability, $request )   X-Ref
Prepares an ability for response.

param: WP_Ability      $ability The ability object.
param: WP_REST_Request $request Request object.
return: WP_REST_Response Response object.

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

return: array<string, mixed> Item schema data.

get_collection_params()   X-Ref
Retrieves the query params for collections.

return: array<string, mixed> Collection parameters.



Generated : Mon Jun 15 08:20:09 2026 Cross-referenced by PHPXref