PHP Class WP_REST_Terms_Controller, wordpress

Inheritance: extends WP_REST_Controller
显示文件 Open project: johnpbloch/wordpress Class Usage Examples

Protected Properties

Property Type Description
$meta WP_REST_Term_Meta_Fields Instance of a term meta fields object.
$sort_column string Column to have the terms be sorted by.
$taxonomy string Taxonomy key.
$total_terms integer Number of terms that were found.

Public Methods

Method Description
__construct ( string $taxonomy ) Constructor.
create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Creates a single term in a taxonomy.
create_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a request has access to create a term.
delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Deletes a single term from a taxonomy.
delete_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a request has access to delete the specified term.
get_collection_params ( ) : array Retrieves the query params for collections.
get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Gets a single term from a taxonomy.
get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a request has access to read the specified term.
get_item_schema ( ) : array Retrieves the term's schema, conforming to JSON Schema.
get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves terms associated with a taxonomy.
get_items_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a request has access to read terms in the specified taxonomy.
prepare_item_for_database ( WP_REST_Request $request ) : object Prepares a single term for create or update.
prepare_item_for_response ( obj $item, WP_REST_Request $request ) : WP_REST_Response Prepares a single term output for response.
register_routes ( ) Registers the routes for the objects of the controller.
update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Updates a single term from a taxonomy.
update_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a request has access to update the specified term.

Protected Methods

Method Description
check_is_taxonomy_allowed ( string $taxonomy ) : boolean Checks that the taxonomy is valid.
prepare_links ( object $term ) : array Prepares links for the request.

Method Details

__construct() public method

Constructor.
Since: 4.7.0
public __construct ( string $taxonomy )
$taxonomy string Taxonomy key.

check_is_taxonomy_allowed() protected method

Checks that the taxonomy is valid.
Since: 4.7.0
protected check_is_taxonomy_allowed ( string $taxonomy ) : boolean
$taxonomy string Taxonomy to check.
return boolean Whether the taxonomy is allowed for REST management.

create_item() public method

Creates a single term in a taxonomy.
Since: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

create_item_permissions_check() public method

Checks if a request has access to create a term.
Since: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
return boolean | WP_Error True if the request has access to create items, false or WP_Error object otherwise.

delete_item() public method

Deletes a single term from a taxonomy.
Since: 4.7.0
public delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

delete_item_permissions_check() public method

Checks if a request has access to delete the specified term.
Since: 4.7.0
public delete_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
return boolean | WP_Error True if the request has access to delete the item, otherwise false or WP_Error object.

get_collection_params() public method

Retrieves the query params for collections.
Since: 4.7.0
public get_collection_params ( ) : array
return array Collection parameters.

get_item() public method

Gets a single term from a taxonomy.
Since: 4.7.0
public get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_item_permissions_check() public method

Checks if a request has access to read the specified term.
Since: 4.7.0
public get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
return boolean | WP_Error True if the request has read access for the item, otherwise false or WP_Error object.

get_item_schema() public method

Retrieves the term's schema, conforming to JSON Schema.
Since: 4.7.0
public get_item_schema ( ) : array
return array Item schema data.

get_items() public method

Retrieves terms associated with a taxonomy.
Since: 4.7.0
public get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_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() public method

Checks if a request has access to read terms in the specified taxonomy.
Since: 4.7.0
public get_items_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
return boolean | WP_Error True if the request has read access, otherwise false or WP_Error object.

prepare_item_for_database() public method

Prepares a single term for create or update.
Since: 4.7.0
public prepare_item_for_database ( WP_REST_Request $request ) : object
$request WP_REST_Request Request object.
return object $prepared_term Term object.

prepare_item_for_response() public method

Prepares a single term output for response.
Since: 4.7.0
public prepare_item_for_response ( obj $item, WP_REST_Request $request ) : WP_REST_Response
$item obj Term object.
$request WP_REST_Request Request object.
return WP_REST_Response $response Response object.

register_routes() public method

Registers the routes for the objects of the controller.
See also: register_rest_route()
Since: 4.7.0
public register_routes ( )

update_item() public method

Updates a single term from a taxonomy.
Since: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
return WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

update_item_permissions_check() public method

Checks if a request has access to update the specified term.
Since: 4.7.0
public update_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
return boolean | WP_Error True if the request has access to update the item, false or WP_Error object otherwise.

Property Details

$meta protected_oe property

Instance of a term meta fields object.
Since: 4.7.0
protected WP_REST_Term_Meta_Fields $meta
return WP_REST_Term_Meta_Fields

$sort_column protected_oe property

Column to have the terms be sorted by.
Since: 4.7.0
protected string $sort_column
return string

$taxonomy protected_oe property

Taxonomy key.
Since: 4.7.0
protected string $taxonomy
return string

$total_terms protected_oe property

Number of terms that were found.
Since: 4.7.0
protected int $total_terms
return integer