PHP 클래스 WP_REST_Posts_Controller, wordpress

또한 보기: WP_REST_Controller
부터: 4.7.0
상속: extends WP_REST_Controller
파일 보기 프로젝트 열기: johnpbloch/wordpress 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$meta WP_REST_Post_Meta_Fields Instance of a post meta fields object.
$post_type string Post type.

공개 메소드들

메소드 설명
__construct ( string $post_type ) Constructor.
can_access_password_content ( WP_Post $post, WP_REST_Request $request ) : boolean Checks if the user can access password-protected content.
check_read_permission ( object $post ) : boolean Checks if a post can be read.
create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Creates a single post.
create_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to create a post.
delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Deletes a single post.
delete_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to delete a post.
get_collection_params ( ) : array Retrieves the query params for the posts collection.
get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves a single post.
get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error Checks if a given request has access to read a post.
get_item_schema ( ) : array Retrieves the post's schema, conforming to JSON Schema.
get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Retrieves a collection of posts.
get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to read posts.
handle_template ( string $template, integer $post_id ) Sets the template for a post.
prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response Prepares a single post output for response.
protected_title_format ( ) : string Overwrites the default protected title format.
register_routes ( ) Registers the routes for the objects of the controller.
sanitize_post_statuses ( string | array $statuses, WP_REST_Request $request, string $parameter ) : array | WP_Error Sanitizes and validates the list of post statuses, including whether the user can query private statuses.
update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error Updates a single post.
update_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error Checks if a given request has access to update a post.

보호된 메소드들

메소드 설명
check_assign_terms_permission ( WP_REST_Request $request ) : boolean Checks whether current user can assign all terms sent with the current request.
check_create_permission ( object $post ) : boolean Checks if a post can be created.
check_delete_permission ( object $post ) : boolean Checks if a post can be deleted.
check_is_post_type_allowed ( object | string $post_type ) : boolean Checks if a given post type can be viewed or managed.
check_update_permission ( object $post ) : boolean Checks if a post can be edited.
handle_featured_media ( integer $featured_media, integer $post_id ) : boolean | WP_Error Determines the featured media based on a request param.
handle_status_param ( string $post_status, object $post_type ) : string | WP_Error Determines validity and normalizes the given status parameter.
handle_terms ( integer $post_id, WP_REST_Request $request ) : null | WP_Error Updates the post's terms from a REST request.
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_item_for_database ( WP_REST_Request $request ) : stdClass | WP_Error Prepares a single post for create or update.
prepare_items_query ( array $prepared_args = [], WP_REST_Request $request = null ) : array Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.
prepare_links ( WP_Post $post ) : array Prepares links for the request.

메소드 상세

__construct() 공개 메소드

Constructor.
부터: 4.7.0
public __construct ( string $post_type )
$post_type string Post type.

can_access_password_content() 공개 메소드

This method determines whether we need to override the regular password check in core with a filter.
부터: 4.7.0
public can_access_password_content ( WP_Post $post, WP_REST_Request $request ) : boolean
$post WP_Post Post to check against.
$request WP_REST_Request Request data to check.
리턴 boolean True if the user can access password-protected content, otherwise false.

check_assign_terms_permission() 보호된 메소드

Checks whether current user can assign all terms sent with the current request.
부터: 4.7.0
protected check_assign_terms_permission ( WP_REST_Request $request ) : boolean
$request WP_REST_Request The request object with post and terms data.
리턴 boolean Whether the current user can assign the provided terms.

check_create_permission() 보호된 메소드

Checks if a post can be created.
부터: 4.7.0
protected check_create_permission ( object $post ) : boolean
$post object Post object.
리턴 boolean Whether the post can be created.

check_delete_permission() 보호된 메소드

Checks if a post can be deleted.
부터: 4.7.0
protected check_delete_permission ( object $post ) : boolean
$post object Post object.
리턴 boolean Whether the post can be deleted.

check_is_post_type_allowed() 보호된 메소드

Checks if a given post type can be viewed or managed.
부터: 4.7.0
protected check_is_post_type_allowed ( object | string $post_type ) : boolean
$post_type object | string Post type name or object.
리턴 boolean Whether the post type is allowed in REST.

check_read_permission() 공개 메소드

Correctly handles posts with the inherit status.
부터: 4.7.0
public check_read_permission ( object $post ) : boolean
$post object Post object.
리턴 boolean Whether the post can be read.

check_update_permission() 보호된 메소드

Checks if a post can be edited.
부터: 4.7.0
protected check_update_permission ( object $post ) : boolean
$post object Post object.
리턴 boolean Whether the post can be edited.

create_item() 공개 메소드

Creates a single post.
부터: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
리턴 WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

create_item_permissions_check() 공개 메소드

Checks if a given request has access to create a post.
부터: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
리턴 true | WP_Error True if the request has access to create items, WP_Error object otherwise.

delete_item() 공개 메소드

Deletes a single post.
부터: 4.7.0
public delete_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
리턴 WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

delete_item_permissions_check() 공개 메소드

Checks if a given request has access to delete a post.
부터: 4.7.0
public delete_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
리턴 true | WP_Error True if the request has access to delete the item, WP_Error object otherwise.

get_collection_params() 공개 메소드

Retrieves the query params for the posts collection.
부터: 4.7.0
public get_collection_params ( ) : array
리턴 array Collection parameters.

get_item() 공개 메소드

Retrieves a single post.
부터: 4.7.0
public get_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
리턴 WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_item_permissions_check() 공개 메소드

Checks if a given request has access to read a post.
부터: 4.7.0
public get_item_permissions_check ( WP_REST_Request $request ) : boolean | WP_Error
$request WP_REST_Request Full details about the request.
리턴 boolean | WP_Error True if the request has read access for the item, WP_Error object otherwise.

get_item_schema() 공개 메소드

Retrieves the post's schema, conforming to JSON Schema.
부터: 4.7.0
public get_item_schema ( ) : array
리턴 array Item schema data.

get_items() 공개 메소드

Retrieves a collection of posts.
부터: 4.7.0
public get_items ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
리턴 WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

get_items_permissions_check() 공개 메소드

Checks if a given request has access to read posts.
부터: 4.7.0
public get_items_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
리턴 true | WP_Error True if the request has read access, WP_Error object otherwise.

handle_status_param() 보호된 메소드

Determines validity and normalizes the given status parameter.
부터: 4.7.0
protected handle_status_param ( string $post_status, object $post_type ) : string | WP_Error
$post_status string Post status.
$post_type object Post type.
리턴 string | WP_Error Post status or WP_Error if lacking the proper permission.

handle_template() 공개 메소드

Sets the template for a post.
부터: 4.7.0
public handle_template ( string $template, integer $post_id )
$template string Page template filename.
$post_id integer Post ID.

handle_terms() 보호된 메소드

Updates the post's terms from a REST request.
부터: 4.7.0
protected handle_terms ( integer $post_id, WP_REST_Request $request ) : null | WP_Error
$post_id integer The post ID to update the terms form.
$request WP_REST_Request The request object with post and terms data.
리턴 null | WP_Error WP_Error on an error assigning any of the terms, otherwise null.

prepare_date_response() 보호된 메소드

Checks the post_date_gmt or modified_gmt and prepare any post or modified date for single post output.
부터: 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.
리턴 string | null ISO8601/RFC3339 formatted datetime.

prepare_item_for_database() 보호된 메소드

Prepares a single post for create or update.
부터: 4.7.0
protected prepare_item_for_database ( WP_REST_Request $request ) : stdClass | WP_Error
$request WP_REST_Request Request object.
리턴 stdClass | WP_Error Post object or WP_Error.

prepare_item_for_response() 공개 메소드

Prepares a single post output for response.
부터: 4.7.0
public prepare_item_for_response ( WP_Post $post, WP_REST_Request $request ) : WP_REST_Response
$post WP_Post Post object.
$request WP_REST_Request Request object.
리턴 WP_REST_Response Response object.

prepare_items_query() 보호된 메소드

Determines the allowed query_vars for a get_items() response and prepares them for WP_Query.
부터: 4.7.0
protected prepare_items_query ( array $prepared_args = [], WP_REST_Request $request = null ) : array
$prepared_args array Optional. Prepared WP_Query arguments. Default empty array.
$request WP_REST_Request Optional. Full details about the request.
리턴 array Items query arguments.

protected_title_format() 공개 메소드

By default, WordPress will show password protected posts with a title of "Protected: %s", as the REST API communicates the protected status of a post in a machine readable format, we remove the "Protected: " prefix.
public protected_title_format ( ) : string
리턴 string Protected title format.

register_routes() 공개 메소드

Registers the routes for the objects of the controller.
또한 보기: register_rest_route()
부터: 4.7.0
public register_routes ( )

sanitize_post_statuses() 공개 메소드

Sanitizes and validates the list of post statuses, including whether the user can query private statuses.
부터: 4.7.0
public sanitize_post_statuses ( string | array $statuses, WP_REST_Request $request, string $parameter ) : array | WP_Error
$statuses string | array One or more post statuses.
$request WP_REST_Request Full details about the request.
$parameter string Additional parameter to pass to validation.
리턴 array | WP_Error A list of valid statuses, otherwise WP_Error object.

update_item() 공개 메소드

Updates a single post.
부터: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_REST_Response | WP_Error
$request WP_REST_Request Full details about the request.
리턴 WP_REST_Response | WP_Error Response object on success, or WP_Error object on failure.

update_item_permissions_check() 공개 메소드

Checks if a given request has access to update a post.
부터: 4.7.0
public update_item_permissions_check ( WP_REST_Request $request ) : true | WP_Error
$request WP_REST_Request Full details about the request.
리턴 true | WP_Error True if the request has access to update the item, WP_Error object otherwise.

프로퍼티 상세

$meta 보호되어 있는 프로퍼티

Instance of a post meta fields object.
부터: 4.7.0
protected WP_REST_Post_Meta_Fields $meta
리턴 WP_REST_Post_Meta_Fields

$post_type 보호되어 있는 프로퍼티

Post type.
부터: 4.7.0
protected string $post_type
리턴 string