From 88731bfc0ab89fae5d49bd9d7e2c4d7ce6a95bd5 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 08:11:59 -0700 Subject: [PATCH 1/6] Move wp_new_comment_via_rest_notify_postauthor -> comment.php --- src/wp-includes/comment.php | 13 +++++++++++++ .../endpoints/class-wp-rest-comments-controller.php | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index a6deb2db599f5..05ce5ff8b9aa8 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2458,6 +2458,19 @@ function wp_new_comment_notify_postauthor( $comment_id ) { return wp_notify_postauthor( $comment_id ); } +/** + * Send a notification to the post author when a new note is added via the REST API. + * + * @since 6.9.0 + * + * @param WP_Comment $comment The comment object. + */ +function wp_new_comment_via_rest_notify_postauthor( $comment ) { + if ( 'note' === $comment->comment_type ) { + wp_new_comment_notify_postauthor( $comment->comment_ID ); + } +} + /** * Sets the status of a comment. * diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index 0ef02aae4d0dc..7fe79b57c1b9b 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -36,18 +36,6 @@ public function __construct() { $this->meta = new WP_REST_Comment_Meta_Fields(); } - /** - * Send a notification to the post author when a new note is added via the REST API. - * - * @since 6.9.0 - * - * @param WP_Comment $comment The comment object. - */ - public static function wp_new_comment_via_rest_notify_postauthor( $comment ) { - if ( 'note' === $comment->comment_type ) { - wp_new_comment_notify_postauthor( $comment->comment_ID ); - } - } /** * Registers the routes for comments. * From 60a0681d9fc4490dcf9d14ee67a10acb927ca95f Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 08:27:17 -0700 Subject: [PATCH 2/6] Update callback --- src/wp-includes/default-filters.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 58ee4053e0752..68dccd979f2fe 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -522,7 +522,7 @@ // Email notifications. add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); -add_action( 'rest_insert_comment', array( 'WP_REST_Comments_Controller', 'wp_new_comment_via_rest_notify_postauthor' ) ); +add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' ); add_action( 'after_password_reset', 'wp_password_change_notification' ); add_action( 'register_new_user', 'wp_send_new_user_notifications' ); add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); From 4e9f2ef71ce43de5dea93baf4f9e7b9521da38c3 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 16:27:02 -0700 Subject: [PATCH 3/6] whitespace fix --- src/wp-admin/includes/schema.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/wp-admin/includes/schema.php b/src/wp-admin/includes/schema.php index 217d18d8275a0..9ef4078f89054 100644 --- a/src/wp-admin/includes/schema.php +++ b/src/wp-admin/includes/schema.php @@ -563,7 +563,6 @@ function populate_options( array $options = array() ) { // 6.9.0 'wp_notes_notify' => 1, - ); // 3.3.0 From 7cfb3c253fdf41210c1c7be236eea84a151d5368 Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 16:28:41 -0700 Subject: [PATCH 4/6] =?UTF-8?q?Ensure=20calls=20to=20get=5Foption(=20'wp?= =?UTF-8?q?=5Fnotes=5Fnotify=E2=80=99=E2=80=A6=20use=201=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wp-admin/options-discussion.php | 2 +- src/wp-includes/comment.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/options-discussion.php b/src/wp-admin/options-discussion.php index 3b4e1ac3a2313..0c350475fe176 100644 --- a/src/wp-admin/options-discussion.php +++ b/src/wp-admin/options-discussion.php @@ -162,7 +162,7 @@
diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 05ce5ff8b9aa8..902aa9e05b819 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2427,7 +2427,7 @@ function wp_new_comment_notify_postauthor( $comment_id ) { $comment = get_comment( $comment_id ); $is_note = ( $comment && 'note' === $comment->comment_type ); - $maybe_notify = $is_note ? get_option( 'wp_notes_notify' ) : get_option( 'comments_notify' ); + $maybe_notify = $is_note ? get_option( 'wp_notes_notify', 1 ) : get_option( 'comments_notify' ); /** * Filters whether to send the post author new comment notification emails, From c67de29d31a102f74dddd9d89a1a128d27179ef9 Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Fri, 7 Nov 2025 16:29:37 -0700 Subject: [PATCH 5/6] Update src/wp-includes/comment.php Co-authored-by: Dovid Levine --- src/wp-includes/comment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 902aa9e05b819..a2711cb0abf41 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2467,7 +2467,7 @@ function wp_new_comment_notify_postauthor( $comment_id ) { */ function wp_new_comment_via_rest_notify_postauthor( $comment ) { if ( 'note' === $comment->comment_type ) { - wp_new_comment_notify_postauthor( $comment->comment_ID ); + wp_new_comment_notify_postauthor( (int) $comment->comment_ID ); } } From cdf50687051ce293e62cd8817d00fd2645593fde Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Mon, 10 Nov 2025 08:01:16 -0700 Subject: [PATCH 6/6] Ensure $comment is WP_Comment --- src/wp-includes/comment.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index a2711cb0abf41..49c9c6b2cb966 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2466,7 +2466,7 @@ function wp_new_comment_notify_postauthor( $comment_id ) { * @param WP_Comment $comment The comment object. */ function wp_new_comment_via_rest_notify_postauthor( $comment ) { - if ( 'note' === $comment->comment_type ) { + if ( $comment instanceof WP_Comment && 'note' === $comment->comment_type ) { wp_new_comment_notify_postauthor( (int) $comment->comment_ID ); } }