Ticket #6286: 6286.2.diff
File 6286.2.diff, 7.5 KB (added by , 12 years ago) |
---|
-
wp-includes/comment.php
1407 1407 1408 1408 $post = get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 1409 1409 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'] ) ) 1411 1411 wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); 1412 1412 } 1413 1413 … … 1440 1440 case 'approve': 1441 1441 case '1': 1442 1442 $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 ); 1447 1447 break; 1448 1448 case 'spam': 1449 1449 $status = 'spam'; … … 1626 1626 return true; 1627 1627 } 1628 1628 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 **/ 1636 function 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 1629 1656 // 1630 1657 // Ping and trackback functions. 1631 1658 // -
wp-includes/pluggable.php
1094 1094 function wp_notify_moderator($comment_id) { 1095 1095 global $wpdb; 1096 1096 1097 if ( 0 == get_option( 'moderation_notify') )1097 if ( ! $recipients = wp_get_moderation_recipients( $comment_id ) ) 1098 1098 return true; 1099 1099 1100 $email_to = wp_list_pluck( $recipients, 'user_email' ); 1101 1100 1102 $comment = get_comment($comment_id); 1101 1103 $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;1107 1104 1108 1105 $comment_author_domain = @gethostbyaddr($comment->comment_author_IP); 1109 1106 $comments_waiting = $wpdb->get_var("SELECT count(comment_ID) FROM $wpdb->comments WHERE comment_approved = '0'"); … … 1112 1109 // we want to reverse this for the plain text arena of emails. 1113 1110 $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); 1114 1111 1115 switch ($comment->comment_type) 1116 { 1112 switch ($comment->comment_type) { 1117 1113 case 'trackback': 1118 1114 $notify_message = sprintf( __('A new trackback on the post "%s" is waiting for your approval'), $post->post_title ) . "\r\n"; 1119 1115 $notify_message .= get_permalink($comment->comment_post_ID) . "\r\n\r\n"; -
wp-admin/includes/user.php
161 161 $user_id = wp_insert_user( $user ); 162 162 wp_new_user_notification( $user_id, isset($_POST['send_password']) ? $pass1 : '' ); 163 163 } 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 164 171 return $user_id; 165 172 } 166 173 -
wp-admin/options-discussion.php
120 120 </fieldset></td> 121 121 </tr> 122 122 <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">135 123 <th scope="row"><?php _e('Before a comment appears'); ?></th> 136 124 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Before a comment appears'); ?></span></legend> 137 125 <label for="comment_moderation"> -
wp-admin/user-edit.php
221 221 <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> 222 222 </tr> 223 223 <?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 224 246 <tr class="show-admin-bar"> 225 247 <th scope="row"><?php _e('Toolbar')?></th> 226 248 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>