wp_new_comment_via_rest_notify_postauthor()
云策文档标注
概述
wp_new_comment_via_rest_notify_postauthor() 是一个 WordPress 函数,用于在通过 REST API 添加新注释时向文章作者发送通知。它检查评论类型是否为 'note',并调用 wp_new_comment_notify_postauthor() 来触发通知。
关键要点
- 函数 wp_new_comment_via_rest_notify_postauthor() 在 WordPress 6.9.0 版本中引入。
- 它接受一个 WP_Comment 对象作为参数,仅当评论类型为 'note' 时才发送通知。
- 内部调用 wp_new_comment_notify_postauthor() 函数来处理实际的通知发送。
- 适用于通过 REST API 添加的注释,确保作者能及时收到更新提醒。
代码示例
function wp_new_comment_via_rest_notify_postauthor( $comment ) {
if ( $comment instanceof WP_Comment && 'note' === $comment->comment_type ) {
wp_new_comment_notify_postauthor( (int) $comment->comment_ID );
}
}
原文内容
Send a notification to the post author when a new note is added via the REST API.
Parameters
$commentWP_Commentrequired-
The comment object.
Source
function wp_new_comment_via_rest_notify_postauthor( $comment ) {
if ( $comment instanceof WP_Comment && 'note' === $comment->comment_type ) {
wp_new_comment_notify_postauthor( (int) $comment->comment_ID );
}
}
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |