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.


Built from https://develop.svn.wordpress.org/trunk@25104


git-svn-id: http://core.svn.wordpress.org/trunk@25086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2013-08-23 19:36:10 +00:00
parent 9d113aab4a
commit 0adcab1f7f

View File

@ -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;
}