PHP Class WP_REST_Revisions_Controller, wordpress

Inheritance: extends WP_REST_Controller
Exibir arquivo Open project: johnpbloch/wordpress Class Usage Examples

Public Methods

Method Description
__construct ( string $parent_post_type ) Constructor.
delete_item ( WP_REST_Request $request ) : true | WP_Error Deletes a single revision.
delete_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a given request has access to delete a revision.
get_collection_params ( ) : array Retrieves the query params for collections.
get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves one revision from the collection.
get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a given request has access to get a specific revision.
get_item_schema ( ) : array Retrieves the revision's schema, conforming to JSON Schema.
get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Gets a collection of revisions.
get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to get revisions.
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response Prepares the revision for the REST response.
register_routes ( ) Registers routes for revisions based on post types supporting revisions.

Protected Methods

Method Description
prepare_date_response ( string $date_gmt, string | null $date = null ) : string | null Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.
prepare_excerpt_response ( string $excerpt, WP_Post $post ) : string Checks the post excerpt and prepare it for single post output.

Method Details

__construct() public method

Constructor.
Since: 4.7.0
public __construct ( string $parent_post_type )
$parent_post_type string Post type of the parent.

delete_item() public method

Deletes a single revision.
Since: 4.7.0
public delete_item ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
return true | WP_Error True on success, or WP_Error object on failure.

delete_item_permissions_check() public method

Checks if a given request has access to delete a revision.
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, WP_Error object otherwise.

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

Retrieves one revision from the collection.
Since: 4.7.0
public get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full data 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 given request has access to get a specific revision.
Since: 4.7.0
public get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full data about the request.
return boolean | WP_Error True if the request has read access for the item, WP_Error object otherwise.

get_item_schema() public method

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

get_items() public method

Gets a collection of revisions.
Since: 4.7.0
public get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full data 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 given request has access to get revisions.
Since: 4.7.0
public get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full data about the request.
return true | WP_Error True if the request has read access, WP_Error object otherwise.

prepare_date_response() protected method

Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.
Since: 4.7.0
protected prepare_date_response ( string $date_gmt, string | null $date = null ) : string | null
$date_gmt string GMT publication time.
$date string | null Optional. Local publication time. Default null.
return string | null ISO8601/RFC3339 formatted datetime, otherwise null.

prepare_excerpt_response() protected method

Checks the post excerpt and prepare it for single post output.
Since: 4.7.0
protected prepare_excerpt_response ( string $excerpt, WP_Post $post ) : string
$excerpt string The post excerpt.
$post WP_Post Post revision object.
return string Prepared excerpt or empty string.

prepare_item_for_response() public method

Prepares the revision for the REST response.
Since: 4.7.0
public prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response
$post WP_Post Post revision object.
$request WP_REST_Request Request object.
return WP_REST_Response Response object.

register_routes() public method

Registers routes for revisions based on post types supporting revisions.
See also: register_rest_route()
Since: 4.7.0
public register_routes ( )