From 1f24e6d76b14744c227d27e7395874c1508ab079 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Fri, 23 Aug 2013 19:35:04 +0000 Subject: [PATCH] Add filters to the recipients of emails sent by wp_notify_postauthor() and wp_notify_moderator(). The new filters are called comment_notification_recipients and comment_moderation_recipients. Add the context of $comment_id to the comment_moderation_headers filter, to match the comment_notification_headers filter. props chipbennett. fixes #22922, #20353. git-svn-id: https://develop.svn.wordpress.org/trunk@25104 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index effa374dc9..824863ecf4 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -1074,11 +1074,16 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) { if ( isset($reply_to) ) $message_headers .= $reply_to . "\n"; - $notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id); - $subject = apply_filters('comment_notification_subject', $subject, $comment_id); - $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); + $emails = array( $author->user_email ); - @wp_mail( $author->user_email, $subject, $notify_message, $message_headers ); + $emails = apply_filters( 'comment_notification_recipients', $emails, $comment_id ); + $notify_message = apply_filters( 'comment_notification_text', $notify_message, $comment_id ); + $subject = apply_filters( 'comment_notification_subject', $subject, $comment_id ); + $message_headers = apply_filters( 'comment_notification_headers', $message_headers, $comment_id ); + + foreach ( $emails as $email ) { + @wp_mail( $emails, $subject, $notify_message, $message_headers ); + } return true; } @@ -1104,9 +1109,9 @@ function wp_notify_moderator($comment_id) { $post = get_post($comment->comment_post_ID); $user = get_userdata( $post->post_author ); // Send to the administration and to the post author if the author can modify the comment. - $email_to = array( get_option('admin_email') ); + $emails = array( get_option('admin_email') ); if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) ) - $email_to[] = $user->user_email; + $emails[] = $user->user_email; $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); @@ -1156,12 +1161,14 @@ function wp_notify_moderator($comment_id) { $subject = sprintf( __('[%1$s] Please moderate: "%2$s"'), $blogname, $post->post_title ); $message_headers = ''; - $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id); - $subject = apply_filters('comment_moderation_subject', $subject, $comment_id); - $message_headers = apply_filters('comment_moderation_headers', $message_headers); + $emails = apply_filters( 'comment_moderation_recipients', $emails, $comment_id ); + $notify_message = apply_filters( 'comment_moderation_text', $notify_message, $comment_id ); + $subject = apply_filters( 'comment_moderation_subject', $subject, $comment_id ); + $message_headers = apply_filters( 'comment_moderation_headers', $message_headers, $comment_id ); - foreach ( $email_to as $email ) - @wp_mail($email, $subject, $notify_message, $message_headers); + foreach ( $emails as $email ) { + @wp_mail( $email, $subject, $notify_message, $message_headers ); + } return true; }