CMB2 Documentation
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  • Hooks
  • Download Docs
  • Github

Packages

  • CMB2
  • Demo
    • CMB2
  • None
  • Tests
    • CMB2

Classes

  • CMB2_Integration_Box
  • WP_REST_Controller

Hooks

  • Hook Reference

Class WP_REST_Controller

Direct known subclasses

CMB2_REST_Controller

Indirect known subclasses

CMB2_REST_Controller_Boxes, CMB2_REST_Controller_Fields

Abstract
Located at includes/shim/WP_REST_Controller.php

Methods summary

public
# register_routes( )

Register the routes for the objects of the controller.

Register the routes for the objects of the controller.

public WP_Error|boolean
# get_items_permissions_check( WP_REST_Request $request )

Check if a given request has access to get items.

Check if a given request has access to get items.

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean
public WP_Error|WP_REST_Response
# get_items( WP_REST_Request $request )

Get a collection of items.

Get a collection of items.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response
public WP_Error|boolean
# get_item_permissions_check( WP_REST_Request $request )

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

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

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean
public WP_Error|WP_REST_Response
# get_item( WP_REST_Request $request )

Get one item from the collection.

Get one item from the collection.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response
public WP_Error|boolean
# create_item_permissions_check( WP_REST_Request $request )

Check if a given request has access to create items.

Check if a given request has access to create items.

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean
public WP_Error|WP_REST_Response
# create_item( WP_REST_Request $request )

Create one item from the collection.

Create one item from the collection.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response
public WP_Error|boolean
# update_item_permissions_check( WP_REST_Request $request )

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

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

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean
public WP_Error|WP_REST_Response
# update_item( WP_REST_Request $request )

Update one item from the collection.

Update one item from the collection.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response
public WP_Error|boolean
# delete_item_permissions_check( WP_REST_Request $request )

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

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

Parameters

$request
Full data about the request.

Returns

WP_Error|boolean
public WP_Error|WP_REST_Response
# delete_item( WP_REST_Request $request )

Delete one item from the collection.

Delete one item from the collection.

Parameters

$request
Full data about the request.

Returns

WP_Error|WP_REST_Response
protected WP_Error|object
# prepare_item_for_database( WP_REST_Request $request )

Prepare the item for create or update operation.

Prepare the item for create or update operation.

Parameters

$request
Request object.

Returns

WP_Error|object
$prepared_item
public WP_REST_Response
# prepare_item_for_response( mixed $item, WP_REST_Request $request )

Prepare the item for the REST response.

Prepare the item for the REST response.

Parameters

$item
WordPress representation of the item.
$request
Request object.

Returns

WP_REST_Response
$response
public array
# prepare_response_for_collection( WP_REST_Response $response )

Prepare a response for inserting into a collection.

Prepare a response for inserting into a collection.

Parameters

$response
Response object.

Returns

array
Response data, ready for insertion into collection data.
public array
# filter_response_by_context( array $data, string $context )

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

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

Parameters

$data
$context

Returns

array
public array
# get_item_schema( )

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

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

Returns

array
public array
# get_public_item_schema( )

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

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

Returns

array
public array
# get_collection_params( )

Get the query params for collections.

Get the query params for collections.

Returns

array
public array
# get_context_param( array $args = array() )

Get the magical context param.

Get the magical context param.

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

Parameters

$args

Returns

array
protected array
# add_additional_fields_to_object( array $object, WP_REST_Request $request )

Add the values from additional fields to a data object.

Add the values from additional fields to a data object.

Parameters

$object
$request

Returns

array
modified object with additional fields.
protected
# update_additional_fields_for_object( array $object, WP_REST_Request $request )

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

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

Parameters

$object
$request
protected
# add_additional_fields_schema( array $schema )

Add the schema from additional fields to an schema array.

Add the schema from additional fields to an schema array.

The type of object is inferred from the passed schema.

Parameters

$schema
Schema array.
protected array
# get_additional_fields( string $object_type = null )

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

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

Parameters

$object_type

Returns

array
protected string
# get_object_type( )

Get the object type this controller is responsible for managing.

Get the object type this controller is responsible for managing.

Returns

string
public array
# get_endpoint_args_for_item_schema( string $method = WP_REST_Server::CREATABLE )

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

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

Parameters

$method

HTTP method of the request. The arguments for CREATABLE requests are checked for required values and may fall-back to a given default, this is not done on EDITABLE requests. Default is WP_REST_Server::CREATABLE.

Returns

array
$endpoint_args
public WP_Post|null
# get_post( integer|WP_Post $post )

Retrieves post data given a post ID or post object.

Retrieves post data given a post ID or post object.

This is a subset of the functionality of the get_post() function, with the additional functionality of having the_post action done on the resultant post object. This is done so that plugins may manipulate the post that is used in the REST API.

Parameters

$post
Post ID or post object. Defaults to global $post.

Returns

WP_Post|null
A WP_Post object when successful.

See

WP_REST_Controller::get_post()

Properties summary

protected string $namespace

The namespace of this controller's route.

The namespace of this controller's route.

#
protected string $rest_base

The base of this controller's route.

The base of this controller's route.

#
CMB2 Documentation API documentation generated by ApiGen