WordPress.org

Make WordPress Core

Ticket #6286: 6286.2.diff

File 6286.2.diff, 7.5 KB (added by wonderboymusic, 3 years ago)
  • wp-includes/comment.php

     
    14071407 
    14081408                $post = get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 
    14091409 
    1410                 if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) 
     1410                if ( get_option( 'comments_notify', $post->post_author ) && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) 
    14111411                        wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); 
    14121412        } 
    14131413 
     
    14401440                case 'approve': 
    14411441                case '1': 
    14421442                        $status = '1'; 
    1443                         if ( get_option('comments_notify') ) { 
    1444                                 $comment = get_comment($comment_id); 
    1445                                 wp_notify_postauthor($comment_id, $comment->comment_type); 
    1446                         } 
     1443                        $comment = get_comment( $comment_id ); 
     1444                        $post = get_post( $comment->comment_post_ID ); 
     1445                        if ( get_user_option( 'comments_notify', $post->post_author ) ) 
     1446                                wp_notify_postauthor( $comment_id, $comment->comment_type ); 
    14471447                        break; 
    14481448                case 'spam': 
    14491449                        $status = 'spam'; 
     
    16261626        return true; 
    16271627} 
    16281628 
     1629/** 
     1630 * Gets the User IDs of the users who should be emailed if a 
     1631 * particular comment is held for moderation. 
     1632 * 
     1633 * @param int $comment_id The ID of the comment we want moderation recipients for 
     1634 * @return array An array of WP_User objects 
     1635 **/ 
     1636function wp_get_moderation_recipients( $comment_id ) { 
     1637        global $wpdb; 
     1638 
     1639        $comment = get_comment( $comment_id ); 
     1640        $post = get_post( $comment->comment_post_ID ); 
     1641 
     1642        // Find the IDs of the users who have requested moderation notifications in 
     1643        // one way or another. 
     1644        $sql = " SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s OR ( user_id = %d AND meta_key = %s ) "; 
     1645        $user_ids = $wpdb->get_col( $wpdb->prepare( $sql, 
     1646                $wpdb->prefix . 'moderation_notify', 
     1647                $post->post_author, 
     1648                $wpdb->prefix . 'moderation_notify_all' 
     1649        ) ); 
     1650 
     1651        $users = array_map( array( 'WP_User', '__construct' ), array_unique( $user_ids ) ); 
     1652 
     1653        return $users; 
     1654} 
     1655 
    16291656// 
    16301657// Ping and trackback functions. 
    16311658// 
  • wp-includes/pluggable.php

     
    10941094function wp_notify_moderator($comment_id) { 
    10951095        global $wpdb; 
    10961096 
    1097         if ( 0 == get_option( 'moderation_notify' ) ) 
     1097        if ( ! $recipients = wp_get_moderation_recipients( $comment_id ) ) 
    10981098                return true; 
    10991099 
     1100        $email_to = wp_list_pluck( $recipients, 'user_email' ); 
     1101 
    11001102        $comment = get_comment($comment_id); 
    11011103        $post = get_post($comment->comment_post_ID); 
    1102         $user = get_userdata( $post->post_author ); 
    1103         // Send to the administration and to the post author if the author can modify the comment. 
    1104         $email_to = array( get_option('admin_email') ); 
    1105         if ( user_can($user->ID, 'edit_comment', $comment_id) && !empty($user->user_email) && ( get_option('admin_email') != $user->user_email) ) 
    1106                 $email_to[] = $user->user_email; 
    11071104 
    11081105        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); 
    11091106        $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); 
     
    11121109        // we want to reverse this for the plain text arena of emails. 
    11131110        $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 
    11141111 
    1115         switch ($comment->comment_type) 
    1116         { 
     1112        switch ($comment->comment_type) { 
    11171113                case 'trackback': 
    11181114                        $notify_message  = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n"; 
    11191115                        $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; 
  • wp-admin/includes/user.php

     
    161161                $user_id = wp_insert_user( $user ); 
    162162                wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' ); 
    163163        } 
     164 
     165        if ( user_can( $user_id, 'moderate_comments' ) ) { 
     166                foreach ( array( 'comments_notify', 'moderation_notify', 'moderation_notify_all' ) as $option ) 
     167                        if ( isset( $_POST[$option] ) ) 
     168                                update_user_option( $user_id, $option, $_POST[$option] ); 
     169        } 
     170 
    164171        return $user_id; 
    165172} 
    166173 
  • wp-admin/options-discussion.php

     
    120120</fieldset></td> 
    121121</tr> 
    122122<tr valign="top"> 
    123 <th scope="row"><?php _e('E-mail me whenever'); ?></th> 
    124 <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend> 
    125 <label for="comments_notify"> 
    126 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> /> 
    127 <?php _e('Anyone posts a comment'); ?> </label> 
    128 <br /> 
    129 <label for="moderation_notify"> 
    130 <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked('1', get_option('moderation_notify')); ?> /> 
    131 <?php _e('A comment is held for moderation'); ?> </label> 
    132 </fieldset></td> 
    133 </tr> 
    134 <tr valign="top"> 
    135123<th scope="row"><?php _e('Before a comment appears'); ?></th> 
    136124<td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend> 
    137125<label for="comment_moderation"> 
  • wp-admin/user-edit.php

     
    221221<td><label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" <?php if ( !empty($profileuser->comment_shortcuts) ) checked('true', $profileuser->comment_shortcuts); ?> /> <?php _e('Enable keyboard shortcuts for comment moderation.'); ?></label> <?php _e('<a href="http://codex.wordpress.org/Keyboard_Shortcuts" target="_blank">More information</a>'); ?></td> 
    222222</tr> 
    223223<?php endif; ?> 
     224 
     225<?php if ( user_can( $profileuser->ID, 'moderate_comments' ) ) : ?> 
     226<tr valign="top"> 
     227<th scope="row"><?php _e('E-mail me whenever') ?></th> 
     228<td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever') ?></span></legend> 
     229<input type="hidden" name="email_notifications" value="1" /> 
     230<label for="comments_notify"> 
     231<input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked( '1', get_user_option( 'comments_notify', $profileuser->ID ) ); ?> /> 
     232<?php _e('A comment is posted on one of my posts') ?> 
     233</label><br/> 
     234 
     235<label for="moderation_notify"> 
     236<input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked( '1', get_user_option( 'moderation_notify', $profileuser->ID ) ); ?> /> 
     237<?php _e( 'A comment on one of my posts is held for moderation' ) ?></label><br/> 
     238 
     239<label for="moderation_notify_all"> 
     240<input name="moderation_notify_all" type="checkbox" id="moderation_notify_all" value="1" <?php checked( '1', get_user_option( 'moderation_notify_all', $profileuser->ID ) ); ?> /> 
     241<?php _e( 'Any comment is held for moderation' ) ?></label> 
     242</fieldset></td> 
     243</tr> 
     244<?php endif; ?> 
     245 
    224246<tr class="show-admin-bar"> 
    225247<th scope="row"><?php _e('Toolbar')?></th> 
    226248<td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>