[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/rest-api/endpoints/ -> class-wp-rest-comments-controller.php (summary)

REST API: WP_REST_Comments_Controller class

File Size: 1907 lines (57 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_REST_Comments_Controller:: (26 methods):
  __construct()
  register_routes()
  get_items_permissions_check()
  get_items()
  get_comment()
  get_item_permissions_check()
  get_item()
  create_item_permissions_check()
  create_item()
  update_item_permissions_check()
  update_item()
  delete_item_permissions_check()
  delete_item()
  prepare_item_for_response()
  prepare_links()
  normalize_query_param()
  prepare_status_response()
  prepare_item_for_database()
  get_item_schema()
  get_collection_params()
  handle_status_param()
  check_read_post_permission()
  check_read_permission()
  check_edit_permission()
  check_comment_author_email()
  check_is_comment_content_allowed()


Class: WP_REST_Comments_Controller  - X-Ref

Core controller used to access comments via the REST API.

__construct()   X-Ref
Constructor.

since: 4.7.0

register_routes()   X-Ref
Registers the routes for comments.

since: 4.7.0

get_items_permissions_check( $request )   X-Ref
Checks if a given request has access to read comments.

return: true|WP_Error True if the request has read access, error object otherwise.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

get_items( $request )   X-Ref
Retrieves a list of comment items.

return: WP_REST_Response|WP_Error Response object on success, or error object on failure.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

get_comment( $id )   X-Ref
Get the comment, if the ID is valid.

return: WP_Comment|WP_Error Comment object if ID is valid, WP_Error otherwise.
param: int $id Supplied ID.
since: 4.7.2

get_item_permissions_check( $request )   X-Ref
Checks if a given request has access to read the comment.

return: true|WP_Error True if the request has read access for the item, error object otherwise.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

get_item( $request )   X-Ref
Retrieves a comment.

return: WP_REST_Response|WP_Error Response object on success, or error object on failure.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

create_item_permissions_check( $request )   X-Ref
Checks if a given request has access to create a comment.

return: true|WP_Error True if the request has access to create items, error object otherwise.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

create_item( $request )   X-Ref
Creates a comment.

return: WP_REST_Response|WP_Error Response object on success, or error object on failure.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

update_item_permissions_check( $request )   X-Ref
Checks if a given REST request has access to update a comment.

return: true|WP_Error True if the request has access to update the item, error object otherwise.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

update_item( $request )   X-Ref
Updates a comment.

return: WP_REST_Response|WP_Error Response object on success, or error object on failure.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

delete_item_permissions_check( $request )   X-Ref
Checks if a given request has access to delete a comment.

return: true|WP_Error True if the request has access to delete the item, error object otherwise.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

delete_item( $request )   X-Ref
Deletes a comment.

return: WP_REST_Response|WP_Error Response object on success, or error object on failure.
param: WP_REST_Request $request Full details about the request.
since: 4.7.0

prepare_item_for_response( $item, $request )   X-Ref
Prepares a single comment output for response.

return: WP_REST_Response Response object.
param: WP_Comment      $item    Comment object.
param: WP_REST_Request $request Request object.
since: 4.7.0
since: 5.9.0 Renamed `$comment` to `$item` to match parent class for PHP 8 named parameter support.

prepare_links( $comment )   X-Ref
Prepares links for the request.

return: array Links for the given comment.
param: WP_Comment $comment Comment object.
since: 4.7.0

normalize_query_param( $query_param )   X-Ref
Prepends internal property prefix to query parameters to match our response fields.

return: string The normalized query parameter.
param: string $query_param Query parameter.
since: 4.7.0

prepare_status_response( $comment_approved )   X-Ref
Checks comment_approved to set comment status for single comment output.

return: string Comment status.
param: string|int $comment_approved comment status.
since: 4.7.0

prepare_item_for_database( $request )   X-Ref
Prepares a single comment to be inserted into the database.

return: array|WP_Error Prepared comment, otherwise WP_Error object.
param: WP_REST_Request $request Request object.
since: 4.7.0

get_item_schema()   X-Ref
Retrieves the comment's schema, conforming to JSON Schema.

return: array
since: 4.7.0

get_collection_params()   X-Ref
Retrieves the query params for collections.

return: array Comments collection parameters.
since: 4.7.0

handle_status_param( $new_status, $comment_id )   X-Ref
Sets the comment_status of a given comment object when creating or updating a comment.

return: bool Whether the status was changed.
param: string|int $new_status New comment status.
param: int        $comment_id Comment ID.
since: 4.7.0

check_read_post_permission( $post, $request )   X-Ref
Checks if the post can be read.

Correctly handles posts with the inherit status.

return: bool Whether post can be read.
param: WP_Post         $post    Post object.
param: WP_REST_Request $request Request data to check.
since: 4.7.0

check_read_permission( $comment, $request )   X-Ref
Checks if the comment can be read.

return: bool Whether the comment can be read.
param: WP_Comment      $comment Comment object.
param: WP_REST_Request $request Request data to check.
since: 4.7.0

check_edit_permission( $comment )   X-Ref
Checks if a comment can be edited or deleted.

return: bool Whether the comment can be edited or deleted.
param: WP_Comment $comment Comment object.
since: 4.7.0

check_comment_author_email( $value, $request, $param )   X-Ref
Checks a comment author email for validity.

Accepts either a valid email address or empty string as a valid comment
author email address. Setting the comment author email to an empty
string is allowed when a comment is being updated.

return: string|WP_Error The sanitized email address, if valid,
param: string          $value   Author email value submitted.
param: WP_REST_Request $request Full details about the request.
param: string          $param   The parameter name.
since: 4.7.0

check_is_comment_content_allowed( $prepared_comment )   X-Ref
If empty comments are not allowed, checks if the provided comment content is not empty.

return: bool True if the content is allowed, false otherwise.
param: array $prepared_comment The prepared comment data.
since: 5.6.0



Generated: Sat Nov 23 01:00:02 2024 Cross-referenced by PHPXref 0.7.1