From d4d99d91ba4a80703eb7c565b1304a9f988ba67b Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 09:27:28 -0700 Subject: [PATCH 1/3] Use comment status and type to set $maybe_notify default --- src/wp-includes/comment.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index a6deb2db599f5..25f86165aee26 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2429,6 +2429,13 @@ function wp_new_comment_notify_postauthor( $comment_id ) { $maybe_notify = $is_note ? get_option( 'wp_notes_notify' ) : get_option( 'comments_notify' ); + // By default, only notify for approved comments and notes. + if ( + ! isset( $comment->comment_approved ) || + ( '1' !== $comment->comment_approved && ! $is_note ) ) { + $maybe_notify = false; + } + /** * Filters whether to send the post author new comment notification emails, * overriding the site setting. @@ -2448,13 +2455,6 @@ function wp_new_comment_notify_postauthor( $comment_id ) { return false; } - // Send notifications for approved comments and all notes. - if ( - ! isset( $comment->comment_approved ) || - ( '1' !== $comment->comment_approved && ! $is_note ) ) { - return false; - } - return wp_notify_postauthor( $comment_id ); } From bbb6e05c81f894267393ee0560e35274f21efefb Mon Sep 17 00:00:00 2001 From: adamsilverstein Date: Fri, 7 Nov 2025 09:36:31 -0700 Subject: [PATCH 2/3] Update filter doc block --- src/wp-includes/comment.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 25f86165aee26..145cf91a7c129 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2437,8 +2437,9 @@ function wp_new_comment_notify_postauthor( $comment_id ) { } /** - * Filters whether to send the post author new comment notification emails, - * overriding the site setting. + * Filters whether to send the post author new comment and note notification emails, + * overriding the site settings and defaults. By default, notifications are sent for + * all notes and for approved comments. * * @since 4.4.0 * From f276d5372df33eb40b7ade8646d28d0dbc43a64d Mon Sep 17 00:00:00 2001 From: Adam Silverstein Date: Mon, 10 Nov 2025 14:27:00 -0700 Subject: [PATCH 3/3] Update comment.php Co-authored-by: Aaron Jorbin --- src/wp-includes/comment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 145cf91a7c129..e0cfbc3b8d264 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -2442,6 +2442,7 @@ function wp_new_comment_notify_postauthor( $comment_id ) { * all notes and for approved comments. * * @since 4.4.0 + * @since 6.9.0 Comment approval status is checked before this filter. * * @param bool $maybe_notify Whether to notify the post author about the new comment. * @param int $comment_id The ID of the comment for the notification.