WordPress.org

Make WordPress Core

Changeset 25104


Ignore:
Timestamp:
08/23/2013 07:35:04 PM (5 years ago)
Author:
nacin
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/pluggable.php

    r24996 r25104  
    10751075        $message_headers .= $reply_to . "\n";
    10761076
    1077     $notify_message = apply_filters('comment_notification_text', $notify_message, $comment_id);
    1078     $subject = apply_filters('comment_notification_subject', $subject, $comment_id);
    1079     $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id);
    1080 
    1081     @wp_mail( $author->user_email, $subject, $notify_message, $message_headers );
     1077    $emails = array( $author->user_email );
     1078
     1079    $emails          = apply_filters( 'comment_notification_recipients', $emails,          $comment_id );
     1080    $notify_message  = apply_filters( 'comment_notification_text',       $notify_message,  $comment_id );
     1081    $subject         = apply_filters( 'comment_notification_subject',    $subject,         $comment_id );
     1082    $message_headers = apply_filters( 'comment_notification_headers',    $message_headers, $comment_id );
     1083
     1084    foreach ( $emails as $email ) {
     1085        @wp_mail( $emails, $subject, $notify_message, $message_headers );
     1086    }
    10821087
    10831088    return true;
     
    11051110    $user = get_userdata( $post->post_author );
    11061111    // Send to the administration and to the post author if the author can modify the comment.
    1107     $email_to = array( get_option('admin_email') );
     1112    $emails = array( get_option('admin_email') );
    11081113    if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) )
    1109         $email_to[] = $user->user_email;
     1114        $emails[] = $user->user_email;
    11101115
    11111116    $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
     
    11571162    $message_headers = '';
    11581163
    1159     $notify_message = apply_filters('comment_moderation_text', $notify_message, $comment_id);
    1160     $subject = apply_filters('comment_moderation_subject', $subject, $comment_id);
    1161     $message_headers = apply_filters('comment_moderation_headers', $message_headers);
    1162 
    1163     foreach ( $email_to as $email )
    1164         @wp_mail($email, $subject, $notify_message, $message_headers);
     1164    $emails          = apply_filters( 'comment_moderation_recipients', $emails,          $comment_id );
     1165    $notify_message  = apply_filters( 'comment_moderation_text',       $notify_message,  $comment_id );
     1166    $subject         = apply_filters( 'comment_moderation_subject',    $subject,         $comment_id );
     1167    $message_headers = apply_filters( 'comment_moderation_headers',    $message_headers, $comment_id );
     1168
     1169    foreach ( $emails as $email ) {
     1170        @wp_mail( $email, $subject, $notify_message, $message_headers );
     1171    }
    11651172
    11661173    return true;
Note: See TracChangeset for help on using the changeset viewer.