[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
REST API: WP_REST_Posts_Controller class
File Size: | 3299 lines (101 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 1 file wp-admin/includes/post.php |
WP_REST_Posts_Controller:: (40 methods):
__construct()
register_routes()
get_items_permissions_check()
check_password_required()
get_items()
get_post()
get_item_permissions_check()
can_access_password_content()
get_item()
create_item_permissions_check()
create_item()
update_item_permissions_check()
update_item()
delete_item_permissions_check()
delete_item()
prepare_items_query()
prepare_date_response()
prepare_item_for_database()
check_status()
handle_status_param()
handle_featured_media()
check_template()
handle_template()
handle_terms()
check_assign_terms_permission()
check_is_post_type_allowed()
check_read_permission()
check_update_permission()
check_create_permission()
check_delete_permission()
prepare_item_for_response()
protected_title_format()
prepare_links()
get_available_actions()
get_item_schema()
get_schema_links()
get_collection_params()
sanitize_post_statuses()
prepare_tax_query()
prepare_taxonomy_limit_schema()
Class: WP_REST_Posts_Controller - X-Ref
Core class to access posts via the REST API.__construct( $post_type ) X-Ref |
Constructor. param: string $post_type Post type. |
register_routes() X-Ref |
Registers the routes for posts. |
get_items_permissions_check( $request ) X-Ref |
Checks if a given request has access to read posts. return: true|WP_Error True if the request has read access, WP_Error object otherwise. param: WP_REST_Request $request Full details about the request. |
check_password_required( $required, $post ) X-Ref |
Overrides the result of the post password check for REST requested posts. Allow users to read the content of password protected posts if they have previously passed a permission check or if they have the `edit_post` capability for the post being checked. return: bool Result of password check taking into account REST API considerations. param: bool $required Whether the post requires a password check. param: WP_Post $post The post been password checked. |
get_items( $request ) X-Ref |
Retrieves a collection of posts. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. param: WP_REST_Request $request Full details about the request. |
get_post( $id ) X-Ref |
No description |
get_item_permissions_check( $request ) X-Ref |
Checks if a given request has access to read a post. return: bool|WP_Error True if the request has read access for the item, WP_Error object or false otherwise. param: WP_REST_Request $request Full details about the request. |
can_access_password_content( $post, $request ) X-Ref |
Checks if the user can access password-protected content. This method determines whether we need to override the regular password check in core with a filter. return: bool True if the user can access password-protected content, otherwise false. param: WP_Post $post Post to check against. param: WP_REST_Request $request Request data to check. |
get_item( $request ) X-Ref |
Retrieves a single post. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. param: WP_REST_Request $request Full details about the request. |
create_item_permissions_check( $request ) X-Ref |
Checks if a given request has access to create a post. return: true|WP_Error True if the request has access to create items, WP_Error object otherwise. param: WP_REST_Request $request Full details about the request. |
create_item( $request ) X-Ref |
Creates a single post. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. param: WP_REST_Request $request Full details about the request. |
update_item_permissions_check( $request ) X-Ref |
Checks if a given request has access to update a post. return: true|WP_Error True if the request has access to update the item, WP_Error object otherwise. param: WP_REST_Request $request Full details about the request. |
update_item( $request ) X-Ref |
Updates a single post. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. param: WP_REST_Request $request Full details about the request. |
delete_item_permissions_check( $request ) X-Ref |
Checks if a given request has access to delete a post. return: true|WP_Error True if the request has access to delete the item, WP_Error object otherwise. param: WP_REST_Request $request Full details about the request. |
delete_item( $request ) X-Ref |
Deletes a single post. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. param: WP_REST_Request $request Full details about the request. |
prepare_items_query( $prepared_args = array() X-Ref |
Determines the allowed query_vars for a get_items() response and prepares them for WP_Query. return: array Items query arguments. param: array $prepared_args Optional. Prepared WP_Query arguments. Default empty array. param: WP_REST_Request $request Optional. Full details about the request. |
prepare_date_response( $date_gmt, $date = null ) X-Ref |
Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output. return: string|null ISO8601/RFC3339 formatted datetime. param: string $date_gmt GMT publication time. param: string|null $date Optional. Local publication time. Default null. |
prepare_item_for_database( $request ) X-Ref |
Prepares a single post for create or update. return: stdClass|WP_Error Post object or WP_Error. param: WP_REST_Request $request Request object. |
check_status( $status, $request, $param ) X-Ref |
Checks whether the status is valid for the given post. Allows for sending an update request with the current status, even if that status would not be acceptable. return: true|WP_Error True if the status is valid, or WP_Error if not. param: string $status The provided status. param: WP_REST_Request $request The request object. param: string $param The parameter name. |
handle_status_param( $post_status, $post_type ) X-Ref |
Determines validity and normalizes the given status parameter. return: string|WP_Error Post status or WP_Error if lacking the proper permission. param: string $post_status Post status. param: WP_Post_Type $post_type Post type. |
handle_featured_media( $featured_media, $post_id ) X-Ref |
Determines the featured media based on a request param. return: bool|WP_Error Whether the post thumbnail was successfully deleted, otherwise WP_Error. param: int $featured_media Featured Media ID. param: int $post_id Post ID. |
check_template( $template, $request ) X-Ref |
Checks whether the template is valid for the given post. return: true|WP_Error True if template is still valid or if the same as existing value, or a WP_Error if template not supported. param: string $template Page template filename. param: WP_REST_Request $request Request. |
handle_template( $template, $post_id, $validate = false ) X-Ref |
Sets the template for a post. param: string $template Page template filename. param: int $post_id Post ID. param: bool $validate Whether to validate that the template selected is valid. |
handle_terms( $post_id, $request ) X-Ref |
Updates the post's terms from a REST request. return: null|WP_Error WP_Error on an error assigning any of the terms, otherwise null. param: int $post_id The post ID to update the terms form. param: WP_REST_Request $request The request object with post and terms data. |
check_assign_terms_permission( $request ) X-Ref |
Checks whether current user can assign all terms sent with the current request. return: bool Whether the current user can assign the provided terms. param: WP_REST_Request $request The request object with post and terms data. |
check_is_post_type_allowed( $post_type ) X-Ref |
Checks if a given post type can be viewed or managed. return: bool Whether the post type is allowed in REST. param: WP_Post_Type|string $post_type Post type name or object. |
check_read_permission( $post ) X-Ref |
Checks if a post can be read. Correctly handles posts with the inherit status. return: bool Whether the post can be read. param: WP_Post $post Post object. |
check_update_permission( $post ) X-Ref |
Checks if a post can be edited. return: bool Whether the post can be edited. param: WP_Post $post Post object. |
check_create_permission( $post ) X-Ref |
Checks if a post can be created. return: bool Whether the post can be created. param: WP_Post $post Post object. |
check_delete_permission( $post ) X-Ref |
Checks if a post can be deleted. return: bool Whether the post can be deleted. param: WP_Post $post Post object. |
prepare_item_for_response( $item, $request ) X-Ref |
Prepares a single post output for response. return: WP_REST_Response Response object. param: WP_Post $item Post object. param: WP_REST_Request $request Request object. |
protected_title_format() X-Ref |
Overwrites the default protected and private title format. By default, WordPress will show password protected or private posts with a title of "Protected: %s" or "Private: %s", as the REST API communicates the status of a post in a machine-readable format, we remove the prefix. return: string Title format. |
prepare_links( $post ) X-Ref |
Prepares links for the request. return: array Links for the given post. param: WP_Post $post Post object. |
get_available_actions( $post, $request ) X-Ref |
Gets the link relations available for the post and current user. return: array List of link relations. param: WP_Post $post Post object. param: WP_REST_Request $request Request object. |
get_item_schema() X-Ref |
Retrieves the post's schema, conforming to JSON Schema. return: array Item schema data. |
get_schema_links() X-Ref |
Retrieves Link Description Objects that should be added to the Schema for the posts collection. return: array |
get_collection_params() X-Ref |
Retrieves the query params for the posts collection. return: array Collection parameters. |
sanitize_post_statuses( $statuses, $request, $parameter ) X-Ref |
Sanitizes and validates the list of post statuses, including whether the user can query private statuses. return: array|WP_Error A list of valid statuses, otherwise WP_Error object. param: string|array $statuses One or more post statuses. param: WP_REST_Request $request Full details about the request. param: string $parameter Additional parameter to pass to validation. |
prepare_tax_query( array $args, WP_REST_Request $request ) X-Ref |
Prepares the 'tax_query' for a collection of posts. return: array Updated query arguments. param: array $args WP_Query arguments. param: WP_REST_Request $request Full details about the request. |
prepare_taxonomy_limit_schema( array $query_params ) X-Ref |
Prepares the collection schema for including and excluding items by terms. return: array Updated schema. param: array $query_params Collection schema. |
Generated : Sat Nov 23 08:20:01 2024 | Cross-referenced by PHPXref |