WPDev.one
Core Class

WP_REST_Posts_Controller

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

Core class to access posts via the REST API.

Methods 40 methods

Method / Return Description
__construct()
void

Constructor.

Parameters: $post_type: mixed
register_routes()
void

Registers the routes for posts.

get_items_permissions_check()
(true

Checks if a given request has access to read posts.

Parameters: $request: mixed
check_password_required()
bool

Overrides the result of the post password check for REST requested posts.

Parameters: $required: mixed, $post: mixed
get_items()
(WP_REST_Response

Retrieves a collection of posts.

Parameters: $request: mixed
get_post()
(WP_Post

Gets the post, if the ID is valid.

Parameters: $id: mixed
get_item_permissions_check()
(bool

Checks if a given request has access to read a post.

Parameters: $request: mixed
can_access_password_content()
bool

Checks if the user can access password-protected content.

Parameters: $post: mixed, $request: mixed
get_item()
(WP_REST_Response

Retrieves a single post.

Parameters: $request: mixed
create_item_permissions_check()
(true

Checks if a given request has access to create a post.

Parameters: $request: mixed
create_item()
(WP_REST_Response

Creates a single post.

Parameters: $request: mixed
update_item_permissions_check()
(true

Checks if a given request has access to update a post.

Parameters: $request: mixed
update_item()
(WP_REST_Response

Updates a single post.

Parameters: $request: mixed
delete_item_permissions_check()
(true

Checks if a given request has access to delete a post.

Parameters: $request: mixed
delete_item()
(WP_REST_Response

Deletes a single post.

Parameters: $request: mixed
prepare_items_query()
array

Determines the allowed query_vars for a get_items() response and prepares

Parameters: $prepared_args: mixed, $request: mixed
prepare_date_response()
(string

Checks the post_date_gmt or modified_gmt and prepare any post or

Parameters: $date_gmt: mixed, $date: mixed
prepare_item_for_database()
(stdClass

Prepares a single post for create or update.

Parameters: $request: mixed
check_status()
(true

Checks whether the status is valid for the given post.

Parameters: $status: mixed, $request: mixed, $param: mixed
handle_status_param()
(string

Determines validity and normalizes the given status parameter.

Parameters: $post_status: mixed, $post_type: mixed
handle_featured_media()
(bool

Determines the featured media based on a request param.

Parameters: $featured_media: mixed, $post_id: mixed
check_template()
(true

Checks whether the template is valid for the given post.

Parameters: $template: mixed, $request: mixed
handle_template()
void

Sets the template for a post.

Parameters: $template: mixed, $post_id: mixed, $validate: mixed
handle_terms()
(null

Updates the post's terms from a REST request.

Parameters: $post_id: mixed, $request: mixed
check_assign_terms_permission()
bool

Checks whether current user can assign all terms sent with the current request.

Parameters: $request: mixed
check_is_post_type_allowed()
bool

Checks if a given post type can be viewed or managed.

Parameters: $post_type: mixed
check_read_permission()
bool

Checks if a post can be read.

Parameters: $post: mixed
check_update_permission()
bool

Checks if a post can be edited.

Parameters: $post: mixed
check_create_permission()
bool

Checks if a post can be created.

Parameters: $post: mixed
check_delete_permission()
bool

Checks if a post can be deleted.

Parameters: $post: mixed
prepare_item_for_response()
WP_REST_Response

Prepares a single post output for response.

Parameters: $item: mixed, $request: mixed
protected_title_format()
string

Overwrites the default protected and private title format.

prepare_links()
array

Prepares links for the request.

Parameters: $post: mixed
get_available_actions()
array

Gets the link relations available for the post and current user.

Parameters: $post: mixed, $request: mixed
get_item_schema()
array

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

get_schema_links()
array

Retrieves Link Description Objects that should be added to the Schema for the posts collection.

get_collection_params()
array

Retrieves the query params for the posts collection.

sanitize_post_statuses()
(array

Sanitizes and validates the list of post statuses, including whether the

Parameters: $statuses: mixed, $request: mixed, $parameter: mixed
prepare_tax_query()
array

Prepares the 'tax_query' for a collection of posts.

Parameters: $args: array, $request: WP_REST_Request
prepare_taxonomy_limit_schema()
array

Prepares the collection schema for including and excluding items by terms.

Parameters: $query_params: array

Properties

Property / Type Description
$post_type
mixed
public
No description available.
$meta
mixed
public
No description available.
$password_check_passed
mixed
public
No description available.
$allow_batch
mixed
public
No description available.

Class Information

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