[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

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

REST API: WP_REST_Comments_Controller class

File Size: 1915 lines (58 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.


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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

param: WP_Comment      $item    Comment object.
param: WP_REST_Request $request Request object.
return: WP_REST_Response Response object.

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

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

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

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

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

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

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

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

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

return: array

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

return: array Comments collection parameters.

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

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

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

Correctly handles posts with the inherit status.

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

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

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

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

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

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.

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

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

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



Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref