[ 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. param: WP_REST_Request $request Full details about the request. return: true|WP_Error True if the request has read access, WP_Error object otherwise. |
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. param: bool $required Whether the post requires a password check. param: WP_Post $post The post been password checked. return: bool Result of password check taking into account REST API considerations. |
get_items( $request ) X-Ref |
Retrieves a collection of posts. param: WP_REST_Request $request Full details about the request. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
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. param: WP_REST_Request $request Full details about the request. return: bool|WP_Error True if the request has read access for the item, WP_Error object or false otherwise. |
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. param: WP_Post $post Post to check against. param: WP_REST_Request $request Request data to check. return: bool True if the user can access password-protected content, otherwise false. |
get_item( $request ) X-Ref |
Retrieves a single post. param: WP_REST_Request $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( $request ) X-Ref |
Checks if a given request has access to create a post. param: WP_REST_Request $request Full details about the request. return: true|WP_Error True if the request has access to create items, WP_Error object otherwise. |
create_item( $request ) X-Ref |
Creates a single post. param: WP_REST_Request $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( $request ) X-Ref |
Checks if a given request has access to update a post. param: WP_REST_Request $request Full details about the request. return: true|WP_Error True if the request has access to update the item, WP_Error object otherwise. |
update_item( $request ) X-Ref |
Updates a single post. param: WP_REST_Request $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( $request ) X-Ref |
Checks if a given request has access to delete a post. param: WP_REST_Request $request Full details about the request. return: true|WP_Error True if the request has access to delete the item, WP_Error object otherwise. |
delete_item( $request ) X-Ref |
Deletes a single post. param: WP_REST_Request $request Full details about the request. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
prepare_items_query( $prepared_args = array() X-Ref |
Determines the allowed query_vars for a get_items() response and prepares them for WP_Query. param: array $prepared_args Optional. Prepared WP_Query arguments. Default empty array. param: WP_REST_Request $request Optional. Full details about the request. return: array Items query arguments. |
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. param: string $date_gmt GMT publication time. param: string|null $date Optional. Local publication time. Default null. return: string|null ISO8601/RFC3339 formatted datetime. |
prepare_item_for_database( $request ) X-Ref |
Prepares a single post for create or update. param: WP_REST_Request $request Request object. return: stdClass|WP_Error Post object or WP_Error. |
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. param: string $status The provided status. param: WP_REST_Request $request The request object. param: string $param The parameter name. return: true|WP_Error True if the status is valid, or WP_Error if not. |
handle_status_param( $post_status, $post_type ) X-Ref |
Determines validity and normalizes the given status parameter. param: string $post_status Post status. param: WP_Post_Type $post_type Post type. return: string|WP_Error Post status or WP_Error if lacking the proper permission. |
handle_featured_media( $featured_media, $post_id ) X-Ref |
Determines the featured media based on a request param. param: int $featured_media Featured Media ID. param: int $post_id Post ID. return: bool|WP_Error Whether the post thumbnail was successfully deleted, otherwise WP_Error. |
check_template( $template, $request ) X-Ref |
Checks whether the template is valid for the given post. param: string $template Page template filename. param: WP_REST_Request $request Request. 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. |
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. 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. return: null|WP_Error WP_Error on an error assigning any of the terms, otherwise null. |
check_assign_terms_permission( $request ) X-Ref |
Checks whether current user can assign all terms sent with the current request. param: WP_REST_Request $request The request object with post and terms data. return: bool Whether the current user can assign the provided terms. |
check_is_post_type_allowed( $post_type ) X-Ref |
Checks if a given post type can be viewed or managed. param: WP_Post_Type|string $post_type Post type name or object. return: bool Whether the post type is allowed in REST. |
check_read_permission( $post ) X-Ref |
Checks if a post can be read. Correctly handles posts with the inherit status. param: WP_Post $post Post object. return: bool Whether the post can be read. |
check_update_permission( $post ) X-Ref |
Checks if a post can be edited. param: WP_Post $post Post object. return: bool Whether the post can be edited. |
check_create_permission( $post ) X-Ref |
Checks if a post can be created. param: WP_Post $post Post object. return: bool Whether the post can be created. |
check_delete_permission( $post ) X-Ref |
Checks if a post can be deleted. param: WP_Post $post Post object. return: bool Whether the post can be deleted. |
prepare_item_for_response( $item, $request ) X-Ref |
Prepares a single post output for response. param: WP_Post $item Post object. param: WP_REST_Request $request Request object. return: WP_REST_Response Response 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. param: WP_Post $post Post object. return: array Links for the given post. |
get_available_actions( $post, $request ) X-Ref |
Gets the link relations available for the post and current user. param: WP_Post $post Post object. param: WP_REST_Request $request Request object. return: array List of link relations. |
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. 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. return: array|WP_Error A list of valid statuses, otherwise WP_Error object. |
prepare_tax_query( array $args, WP_REST_Request $request ) X-Ref |
Prepares the 'tax_query' for a collection of posts. param: array $args WP_Query arguments. param: WP_REST_Request $request Full details about the request. return: array Updated query arguments. |
prepare_taxonomy_limit_schema( array $query_params ) X-Ref |
Prepares the collection schema for including and excluding items by terms. param: array $query_params Collection schema. return: array Updated schema. |
Generated : Tue Dec 24 08:20:01 2024 | Cross-referenced by PHPXref |