Skip to content

Commit 099de2f

Browse files
Move notification hook so it is always available when action triggered
1 parent 98c2873 commit 099de2f

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

src/wp-includes/comment.php

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

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

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_via_rest_notify_postauthor' );
525+
add_action( 'rest_insert_comment', array( 'WP_REST_Comments_Controller', 'wp_new_comment_via_rest_notify_postauthor' ) );
526526
add_action( 'after_password_reset', 'wp_password_change_notification' );
527527
add_action( 'register_new_user', 'wp_send_new_user_notifications' );
528528
add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,20 @@ public function __construct() {
3636
$this->meta = new WP_REST_Comment_Meta_Fields();
3737
}
3838

39+
/**
40+
* Send a notification to the post author when a new note is added via the REST API.
41+
*
42+
* @since 6.9.0
43+
*
44+
* @param WP_Comment $comment The comment object.
45+
*/
46+
public static function wp_new_comment_via_rest_notify_postauthor( $comment ) {
47+
if ( 'note' === $comment->comment_type ) {
48+
wp_new_comment_notify_postauthor( $comment->comment_ID );
49+
}
50+
}
51+
52+
3953
/**
4054
* Registers the routes for comments.
4155
*

0 commit comments

Comments
 (0)