| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
REST API: WP_REST_Comments_Controller class
| File Size: | 2676 lines (85 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_REST_Comments_Controller:: (32 methods):
get_note_reaction_keys()
__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()
get_available_actions()
normalize_query_param()
prepare_status_response()
prepare_item_for_database()
get_item_schema()
get_collection_params()
handle_status_param()
check_read_post_permission()
prefetch_reaction_summaries()
check_read_permission()
check_edit_permission()
check_comment_author_email()
check_is_comment_content_allowed()
sanitize_comment_statuses()
check_target_post_permission()
check_post_type_supports_notes()
Class: WP_REST_Comments_Controller - X-Ref
Core controller used to access comments via the REST API.| get_note_reaction_keys() X-Ref |
| Retrieves the hex keys of the emoji a note reaction accepts. Each key is the emoji's lowercase code points, padded to four digits, matching the client's `emojiToHexKey()`. A reaction stores its key in `comment_content`. return: string[] Hex keys for thumbs up, plus, heart, celebration, smile, eyes and rocket. |
| __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. return: true|WP_Error True if the request has read access, error object otherwise. param: WP_REST_Request $request Full details about the request. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| 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. |
| prepare_links( $comment ) X-Ref |
| Prepares links for the request. return: array Links for the given comment. param: WP_Comment $comment Comment object. |
| get_available_actions( $comment, $request ) X-Ref |
| Gets the link relations available for the comment and current user. return: string[] List of link relations. param: WP_Comment $comment Comment object. param: WP_REST_Request $request Request object. |
| 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. |
| prepare_status_response( $comment_approved ) X-Ref |
| Checks comment_approved to set comment status for single comment output. return: string Comment status. param: string $comment_approved Comment status. |
| 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. |
| 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. return: bool Whether the status was changed. param: string|int $new_status New comment status. param: int $comment_id Comment ID. |
| 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. |
| prefetch_reaction_summaries( $note_ids ) X-Ref |
| Pre-fetches reaction summaries for a set of note IDs. Runs two aggregated queries (one for the per-emoji counts, one for the current user's own reactions) and stores the result in $this->reaction_summaries, keyed by note comment ID. This lets a batched note listing return reaction_summary for many notes without issuing a per-note query. param: int[] $note_ids Array of note comment IDs. |
| 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. |
| 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. |
| 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. |
| 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. |
| sanitize_comment_statuses( $statuses ) X-Ref |
| Sanitizes a single comment status or a list of comment statuses. return: string[] Sanitized array of comment statuses. param: string[]|string $statuses Comment status or array of comment statuses. |
| check_target_post_permission( int $post_id, WP_REST_Request $request, bool $is_note = false ) X-Ref |
| No description |
| check_post_type_supports_notes( $post_type ) X-Ref |
| Check if post type supports notes. return: bool True if post type supports notes, false otherwise. param: string $post_type Post type name. |
| Generated : Tue Nov 3 08:20:36 2026 | Cross-referenced by PHPXref |