rest_prepare_comment
云策文档标注
概述
rest_prepare_comment 是一个 WordPress REST API 过滤器,用于在评论数据返回前进行修改。它允许开发者自定义从 REST API 获取的评论响应。
关键要点
- 过滤器名称:rest_prepare_comment
- 作用:修改 REST API 返回的评论数据
- 参数:$response(WP_REST_Response 对象)、$comment(WP_Comment 对象)、$request(WP_REST_Request 对象)
- 相关函数:WP_REST_Comments_Controller::prepare_item_for_response()
- 引入版本:WordPress 4.7.0
原文内容
Filters a comment returned from the REST API.
Description
Allows modification of the comment right before it is returned.
Parameters
$responseWP_REST_Response-
The response object.
$commentWP_Comment-
The original comment object.
$requestWP_REST_Request-
Request used to generate the response.
Source
return apply_filters( 'rest_prepare_comment', $response, $comment, $request );
Changelog
| Version | Description |
|---|---|
| 4.7.0 | Introduced. |