rest_prepare_comment
Filter HookDescription
Filters a comment returned from the REST API. Allows modification of the comment right before it is returned.Hook Information
File Location |
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
View on GitHub
|
Hook Type | Filter |
Line Number | 1157 |
Hook Parameters
Type | Name | Description |
---|---|---|
WP_REST_Response
|
$response
|
The response object. |
WP_Comment
|
$comment
|
The original comment object. |
WP_REST_Request
|
$request
|
Request used to generate the response. |
Usage Examples
Basic Usage
<?php
// Hook into rest_prepare_comment
add_filter('rest_prepare_comment', 'my_custom_filter', 10, 3);
function my_custom_filter($response, $comment, $request) {
// Your custom filtering logic here
return $response;
}
Source Code Context
wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php:1157
- How this hook is used in WordPress core
<?php
1152 *
1153 * @param WP_REST_Response $response The response object.
1154 * @param WP_Comment $comment The original comment object.
1155 * @param WP_REST_Request $request Request used to generate the response.
1156 */
1157 return apply_filters( 'rest_prepare_comment', $response, $comment, $request );
1158 }
1159
1160 /**
1161 * Prepares links for the request.
1162 *
PHP Documentation
<?php
/**
* Filters a comment returned from the REST API.
*
* Allows modification of the comment right before it is returned.
*
* @since 4.7.0
*
* @param WP_REST_Response $response The response object.
* @param WP_Comment $comment The original comment object.
* @param WP_REST_Request $request Request used to generate the response.
*/
Quick Info
- Hook Type: Filter
- Parameters: 3
- File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php
Related Hooks
Related hooks will be displayed here in future updates.