PHP Класс WP_REST_Comments_Controller, wordpress

Наследование: extends WP_REST_Controller
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$meta WP_REST_Comment_Meta_Fields Instance of a comment meta fields object.

Открытые методы

Метод Описание
__construct ( ) Constructor.
create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Creates a comment.
create_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean Checks if a given request has access to create a comment.
delete_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Deletes a comment.
delete_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean Checks if a given request has access to delete a comment.
get_collection_params ( ) : array Retrieves the query params for collections.
get_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Retrieves a comment.
get_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean Checks if a given request has access to read the comment.
get_item_schema ( ) : array Retrieves the comment's schema, conforming to JSON Schema.
get_items ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Retrieves a list of comment items.
get_items_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean Checks if a given request has access to read comments.
prepare_item_for_response ( WP_Comment $comment, WP_REST_Request $request ) : WP_REST_Response Prepares a single comment output for response.
register_routes ( ) Registers the routes for the objects of the controller.
update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response Updates a comment.
update_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean Checks if a given REST request has access to update a comment.

Защищенные методы

Метод Описание
check_edit_permission ( object $comment ) : boolean Checks if a comment can be edited or deleted.
check_read_permission ( WP_Comment $comment, WP_REST_Request $request ) : boolean Checks if the comment can be read.
check_read_post_permission ( WP_Post $post, WP_REST_Request $request ) : boolean Checks if the post can be read.
handle_status_param ( string | integer $new_status, integer $comment_id ) : boolean Sets the comment_status of a given comment object when creating or updating a comment.
normalize_query_param ( string $query_param ) : string Prepends internal property prefix to query parameters to match our response fields.
prepare_item_for_database ( WP_REST_Request $request ) : array | WP_Error Prepares a single comment to be inserted into the database.
prepare_links ( WP_Comment $comment ) : array Prepares links for the request.
prepare_status_response ( string | integer $comment_approved ) : string Checks comment_approved to set comment status for single comment output.

Описание методов

__construct() публичный Метод

Constructor.
С версии: 4.7.0
public __construct ( )

check_edit_permission() защищенный Метод

Checks if a comment can be edited or deleted.
С версии: 4.7.0
protected check_edit_permission ( object $comment ) : boolean
$comment object Comment object.
Результат boolean Whether the comment can be edited or deleted.

check_read_permission() защищенный Метод

Checks if the comment can be read.
С версии: 4.7.0
protected check_read_permission ( WP_Comment $comment, WP_REST_Request $request ) : boolean
$comment WP_Comment Comment object.
$request WP_REST_Request Request data to check.
Результат boolean Whether the comment can be read.

check_read_post_permission() защищенный Метод

Correctly handles posts with the inherit status.
С версии: 4.7.0
protected check_read_post_permission ( WP_Post $post, WP_REST_Request $request ) : boolean
$post WP_Post Post object.
$request WP_REST_Request Request data to check.
Результат boolean Whether post can be read.

create_item() публичный Метод

Creates a comment.
С версии: 4.7.0
public create_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, or error object on failure.

create_item_permissions_check() публичный Метод

Checks if a given request has access to create a comment.
С версии: 4.7.0
public create_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request.
Результат WP_Error | boolean True if the request has access to create items, error object otherwise.

delete_item() публичный Метод

Deletes a comment.
С версии: 4.7.0
public delete_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, or error object on failure.

delete_item_permissions_check() публичный Метод

Checks if a given request has access to delete a comment.
С версии: 4.7.0
public delete_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request.
Результат WP_Error | boolean True if the request has access to delete the item, error object otherwise.

get_collection_params() публичный Метод

Retrieves the query params for collections.
С версии: 4.7.0
public get_collection_params ( ) : array
Результат array Comments collection parameters.

get_item() публичный Метод

Retrieves a comment.
С версии: 4.7.0
public get_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, or error object on failure.

get_item_permissions_check() публичный Метод

Checks if a given request has access to read the comment.
С версии: 4.7.0
public get_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request.
Результат WP_Error | boolean True if the request has read access for the item, error object otherwise.

get_item_schema() публичный Метод

Retrieves the comment's schema, conforming to JSON Schema.
С версии: 4.7.0
public get_item_schema ( ) : array
Результат array

get_items() публичный Метод

Retrieves a list of comment items.
С версии: 4.7.0
public get_items ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, or error object on failure.

get_items_permissions_check() публичный Метод

Checks if a given request has access to read comments.
С версии: 4.7.0
public get_items_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request.
Результат WP_Error | boolean True if the request has read access, error object otherwise.

handle_status_param() защищенный Метод

Sets the comment_status of a given comment object when creating or updating a comment.
С версии: 4.7.0
protected handle_status_param ( string | integer $new_status, integer $comment_id ) : boolean
$new_status string | integer New comment status.
$comment_id integer Comment ID.
Результат boolean Whether the status was changed.

normalize_query_param() защищенный Метод

Prepends internal property prefix to query parameters to match our response fields.
С версии: 4.7.0
protected normalize_query_param ( string $query_param ) : string
$query_param string Query parameter.
Результат string The normalized query parameter.

prepare_item_for_database() защищенный Метод

Prepares a single comment to be inserted into the database.
С версии: 4.7.0
protected prepare_item_for_database ( WP_REST_Request $request ) : array | WP_Error
$request WP_REST_Request Request object.
Результат array | WP_Error Prepared comment, otherwise WP_Error object.

prepare_item_for_response() публичный Метод

Prepares a single comment output for response.
С версии: 4.7.0
public prepare_item_for_response ( WP_Comment $comment, WP_REST_Request $request ) : WP_REST_Response
$comment WP_Comment Comment object.
$request WP_REST_Request Request object.
Результат WP_REST_Response Response object.

prepare_status_response() защищенный Метод

Checks comment_approved to set comment status for single comment output.
С версии: 4.7.0
protected prepare_status_response ( string | integer $comment_approved ) : string
$comment_approved string | integer comment status.
Результат string Comment status.

register_routes() публичный Метод

Registers the routes for the objects of the controller.
С версии: 4.7.0
public register_routes ( )

update_item() публичный Метод

Updates a comment.
С версии: 4.7.0
public update_item ( WP_REST_Request $request ) : WP_Error | WP_REST_Response
$request WP_REST_Request Full details about the request.
Результат WP_Error | WP_REST_Response Response object on success, or error object on failure.

update_item_permissions_check() публичный Метод

Checks if a given REST request has access to update a comment.
С версии: 4.7.0
public update_item_permissions_check ( WP_REST_Request $request ) : WP_Error | boolean
$request WP_REST_Request Full details about the request.
Результат WP_Error | boolean True if the request has access to update the item, error object otherwise.

Описание свойств

$meta защищенное свойство

Instance of a comment meta fields object.
С версии: 4.7.0
protected WP_REST_Comment_Meta_Fields $meta
Результат WP_REST_Comment_Meta_Fields