Skip to content

Commit b3487af

Browse files
Only notify on notes REST insert
1 parent 6faacfe commit b3487af

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/wp-includes/comment.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,19 @@ function wp_new_comment_notify_postauthor( $comment_id ) {
24572457
return wp_notify_postauthor( $comment_id );
24582458
}
24592459

2460+
/**
2461+
* Send a notification to the post author when a new note is added via the REST API.
2462+
*
2463+
* @since 6.9.1
2464+
*
2465+
* @param WP_Comment $comment The comment object.
2466+
*/
2467+
function wp_new_comment_via_rest_notify_postauthor( $comment ) {
2468+
if ( 'note' === $comment->comment_type ) {
2469+
wp_new_comment_notify_postauthor( $comment->comment_ID );
2470+
}
2471+
}
2472+
24602473
/**
24612474
* Sets the status of a comment.
24622475
*

src/wp-includes/default-filters.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@
522522
// Email notifications.
523523
add_action( 'comment_post', 'wp_new_comment_notify_moderator' );
524524
add_action( 'comment_post', 'wp_new_comment_notify_postauthor' );
525-
add_action( 'rest_insert_comment', 'wp_new_comment_notify_moderator' );
525+
add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' );
526526

527527
add_action( 'after_password_reset', 'wp_password_change_notification' );
528528
add_action( 'register_new_user', 'wp_send_new_user_notifications' );

0 commit comments

Comments
 (0)