WPDev.one
Core Class

WP_REST_Controller

class WP_REST_Controller // Constructor: function Object() { [native code] }

Core base controller for managing and interacting with REST API items.

Methods 27 methods

Method / Return Description
register_routes()
void

Registers the routes for the objects of the controller.

get_items_permissions_check()
(true

Checks if a given request has access to get items.

Parameters: $request: mixed
get_items()
(WP_REST_Response

Retrieves a collection of items.

Parameters: $request: mixed
get_item_permissions_check()
(true

Checks if a given request has access to get a specific item.

Parameters: $request: mixed
get_item()
(WP_REST_Response

Retrieves one item from the collection.

Parameters: $request: mixed
create_item_permissions_check()
(true

Checks if a given request has access to create items.

Parameters: $request: mixed
create_item()
(WP_REST_Response

Creates one item from the collection.

Parameters: $request: mixed
update_item_permissions_check()
(true

Checks if a given request has access to update a specific item.

Parameters: $request: mixed
update_item()
(WP_REST_Response

Updates one item from the collection.

Parameters: $request: mixed
delete_item_permissions_check()
(true

Checks if a given request has access to delete a specific item.

Parameters: $request: mixed
delete_item()
(WP_REST_Response

Deletes one item from the collection.

Parameters: $request: mixed
prepare_item_for_database()
(object

Prepares one item for create or update operation.

Parameters: $request: mixed
prepare_item_for_response()
(WP_REST_Response

Prepares the item for the REST response.

Parameters: $item: mixed, $request: mixed
prepare_response_for_collection()
(array

Prepares a response for insertion into a collection.

Parameters: $response: mixed
filter_response_by_context()
array

Filters a response based on the context defined in the schema.

Parameters: $response_data: mixed, $context: mixed
get_item_schema()
array

Retrieves the item's schema, conforming to JSON Schema.

get_public_item_schema()
array

Retrieves the item's schema for display / public consumption purposes.

get_collection_params()
array

Retrieves the query params for the collections.

get_context_param()
array

Retrieves the magical context param.

Parameters: $args: mixed
add_additional_fields_to_object()
array

Adds the values from additional fields to a data object.

Parameters: $response_data: mixed, $request: mixed
update_additional_fields_for_object()
(true

Updates the values of additional fields added to a data object.

Parameters: $data_object: mixed, $request: mixed
add_additional_fields_schema()
array

Adds the schema from additional fields to a schema array.

Parameters: $schema: mixed
get_additional_fields()
array

Retrieves all of the registered additional fields for a given object-type.

Parameters: $object_type: mixed
get_object_type()
string

Retrieves the object type this controller is responsible for managing.

get_fields_for_response()
string[]

Gets an array of fields to be included on the response.

Parameters: $request: mixed
get_endpoint_args_for_item_schema()
array

Retrieves an array of endpoint arguments from the item schema for the controller.

Parameters: $method: mixed
sanitize_slug()
string

Sanitizes the slug value.

Parameters: $slug: mixed

Properties

Property / Type Description
$namespace
mixed
public
No description available.
$rest_base
mixed
public
No description available.
$schema
mixed
public
No description available.

Class Information

Since Version
4.7.0
Source File
wp-includes/rest-api/endpoints/class-wp-rest-controller.php
Advertisement