[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

REST API: WP_REST_Controller class

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

Defines 27 functions

  register_routes()
  get_items_permissions_check()
  get_items()
  get_item_permissions_check()
  get_item()
  create_item_permissions_check()
  create_item()
  update_item_permissions_check()
  update_item()
  delete_item_permissions_check()
  delete_item()
  prepare_item_for_database()
  prepare_item_for_response()
  prepare_response_for_collection()
  filter_response_by_context()
  get_item_schema()
  get_public_item_schema()
  get_collection_params()
  get_context_param()
  add_additional_fields_to_object()
  update_additional_fields_for_object()
  add_additional_fields_schema()
  get_additional_fields()
  get_object_type()
  get_fields_for_response()
  get_endpoint_args_for_item_schema()
  sanitize_slug()

Functions
Functions that are not part of a class:

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

since: 4.7.0

get_items_permissions_check( $request )   X-Ref
Checks if a given request has access to get items.

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.
since: 4.7.0

get_items( $request )   X-Ref
Retrieves a collection of items.

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.
since: 4.7.0

get_item_permissions_check( $request )   X-Ref
Checks if a given request has access to get a specific item.

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

get_item( $request )   X-Ref
Retrieves one item from the collection.

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.
since: 4.7.0

create_item_permissions_check( $request )   X-Ref
Checks if a given request has access to create items.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True if the request has access to create items, WP_Error object otherwise.
since: 4.7.0

create_item( $request )   X-Ref
Creates one item from the collection.

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.
since: 4.7.0

update_item_permissions_check( $request )   X-Ref
Checks if a given request has access to update a specific item.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True if the request has access to update the item, WP_Error object otherwise.
since: 4.7.0

update_item( $request )   X-Ref
Updates one item from the collection.

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.
since: 4.7.0

delete_item_permissions_check( $request )   X-Ref
Checks if a given request has access to delete a specific item.

param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True if the request has access to delete the item, WP_Error object otherwise.
since: 4.7.0

delete_item( $request )   X-Ref
Deletes one item from the collection.

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.
since: 4.7.0

prepare_item_for_database( $request )   X-Ref
Prepares one item for create or update operation.

param: WP_REST_Request $request Request object.
return: object|WP_Error The prepared item, or WP_Error object on failure.
since: 4.7.0

prepare_item_for_response( $item, $request )   X-Ref
Prepares the item for the REST response.

param: mixed           $item    WordPress representation of the item.
param: WP_REST_Request $request Request object.
return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.
since: 4.7.0

prepare_response_for_collection( $response )   X-Ref
Prepares a response for insertion into a collection.

param: WP_REST_Response $response Response object.
return: array|mixed Response data, ready for insertion into collection data.
since: 4.7.0

filter_response_by_context( $data, $context )   X-Ref
Filters a response based on the context defined in the schema.

param: array  $data    Response data to filter.
param: string $context Context defined in the schema.
return: array Filtered response.
since: 4.7.0

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

return: array Item schema data.
since: 4.7.0

get_public_item_schema()   X-Ref
Retrieves the item's schema for display / public consumption purposes.

return: array Public item schema data.
since: 4.7.0

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

return: array Query parameters for the collection.
since: 4.7.0

get_context_param( $args = array()   X-Ref
Retrieves the magical context param.

Ensures consistent descriptions between endpoints, and populates enum from schema.

param: array $args Optional. Additional arguments for context parameter. Default empty array.
return: array Context parameter details.
since: 4.7.0

add_additional_fields_to_object( $prepared, $request )   X-Ref
Adds the values from additional fields to a data object.

param: array           $prepared Prepared response array.
param: WP_REST_Request $request  Full details about the request.
return: array Modified data object with additional fields.
since: 4.7.0

update_additional_fields_for_object( $object, $request )   X-Ref
Updates the values of additional fields added to a data object.

param: object          $object  Data model like WP_Term or WP_Post.
param: WP_REST_Request $request Full details about the request.
return: true|WP_Error True on success, WP_Error object if a field cannot be updated.
since: 4.7.0

add_additional_fields_schema( $schema )   X-Ref
Adds the schema from additional fields to a schema array.

The type of object is inferred from the passed schema.

param: array $schema Schema array.
return: array Modified Schema array.
since: 4.7.0

get_additional_fields( $object_type = null )   X-Ref
Retrieves all of the registered additional fields for a given object-type.

param: string $object_type Optional. The object type.
return: array Registered additional fields (if any), empty array if none or if the object type
since: 4.7.0

get_object_type()   X-Ref
Retrieves the object type this controller is responsible for managing.

return: string Object type for the controller.
since: 4.7.0

get_fields_for_response( $request )   X-Ref
Gets an array of fields to be included on the response.

Included fields are based on item schema and `_fields=` request argument.

param: WP_REST_Request $request Full details about the request.
return: string[] Fields to be included in the response.
since: 4.9.6

get_endpoint_args_for_item_schema( $method = WP_REST_Server::CREATABLE )   X-Ref
No description

sanitize_slug( $slug )   X-Ref
Sanitizes the slug value.

param: string $slug Slug value passed in request.
return: string Sanitized value for the slug.
since: 4.7.0



Generated: Sat Apr 20 01:00:03 2024 Cross-referenced by PHPXref 0.7.1