钩子文档

rest_preprocess_comment

💡 云策文档标注

概述

rest_preprocess_comment 是一个 WordPress 过滤器,用于在通过 REST API 添加的评论准备插入数据库后对其进行修改。它允许开发者在评论数据被插入前进行自定义处理。

关键要点

  • 过滤器名称:rest_preprocess_comment
  • 用途:修改通过 REST API 准备插入数据库的评论数据
  • 参数:$prepared_comment(数组,准备插入的评论数据)和 $request(WP_REST_Request 对象,当前请求)
  • 引入版本:WordPress 4.7.0
  • 相关函数:在 WP_REST_Comments_Controller::prepare_item_for_database() 中使用

📄 原文内容

Filters a comment added via the REST API after it is prepared for insertion into the database.

Description

Allows modification of the comment right after it is prepared for the database.

Parameters

$prepared_commentarray
The prepared comment data for wp_insert_comment.
$requestWP_REST_Request
The current request.

Source

return apply_filters( 'rest_preprocess_comment', $prepared_comment, $request );

Changelog

Version Description
4.7.0 Introduced.