Make WordPress Core

Ticket #6286: 6286.3.diff

File 6286.3.diff, 9.9 KB (added by DrewAPicture, 12 years ago)

Help text update, user-edit options indentation

  • 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

     
    3737        $parent_file = 'profile.php';
    3838
    3939$profile_help = '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
    40         '<p>' . __('You can change your password, turn on keyboard shortcuts, change the color scheme of your WordPress administration screens, and turn off the WYSIWYG (Visual) editor, among other things. You can hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.') . '</p>' .
    41         '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts.') . '</p>' .
     40        '<p>' . __('Your username cannot be changed, but you can use other fields to enter your real name or a nickname, and change which name to display on your posts. You can also change your password on this screen.') . '</p>' .
    4241        '<p>' . __('Required fields are indicated; the rest are optional. Profile information will only be displayed if your theme is set up to do so.') . '</p>' .
    4342        '<p>' . __('Remember to click the Update Profile button when you are finished.') . '</p>';
    4443
     
    4847        'content' => $profile_help,
    4948) );
    5049
     50$personal_options = '<p>' . __( 'Personal options allow you to customize your WordPress experience. Among other things, you can:' ) . '</p>' .
     51        '<ul><li>' . __( 'Turn off the WYSIWYG (Visual) editor' ) . '</li>' .
     52        '<li>' . __( 'Change the color scheme of your WordPress administration screens' ) . '</li>' .
     53        '<li>' . __( 'Turn on keyboard shortcuts' ) . '</li>' .
     54        '<li>' . __( 'Manage email notification settings' ) . '</li></ul>' .
     55        '<p>' . __( 'You can also hide the Toolbar (formerly called the Admin Bar) from the front end of your site, however it cannot be disabled on the admin screens.' ) . '</p>';
     56
     57get_current_screen()->add_help_tab( array(
     58        'id'            => 'personal-options',
     59        'title'         => __( 'Personal Options' ),
     60        'content'       => $personal_options
     61) );
     62
    5163get_current_screen()->set_help_sidebar(
    5264    '<p><strong>' . __('For more information:') . '</strong></p>' .
    5365    '<p>' . __('<a href="http://codex.wordpress.org/Users_Your_Profile_Screen" target="_blank">Documentation on User Profiles</a>') . '</p>' .
     
    221233<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>
    222234</tr>
    223235<?php endif; ?>
     236
     237<?php if ( user_can( $profileuser->ID, 'moderate_comments' ) ) : ?>
     238        <tr valign="top">
     239        <th scope="row"><?php _e( 'E-mail me whenever:' ) ?></th>
     240                <td><fieldset>
     241                        <legend class="screen-reader-text">
     242                                <span><?php _e( 'E-mail me whenever' ) ?></span>
     243                        </legend><!-- .screen-reader-text -->
     244
     245                        <input type="hidden" name="email_notifications" value="1" />
     246                        <label for="comments_notify">
     247                                <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked( '1', get_user_option( 'comments_notify', $profileuser->ID ) ); ?> />
     248                                <?php _e( 'A comment is posted on one of my posts' ) ?>
     249                        </label><!-- comments_notify --><br/>
     250
     251                        <label for="moderation_notify">
     252                                <input name="moderation_notify" type="checkbox" id="moderation_notify" value="1" <?php checked( '1', get_user_option( 'moderation_notify', $profileuser->ID ) ); ?> />
     253                                <?php _e( 'A comment on one of my posts is held for moderation' ) ?>
     254                        </label><!-- moderation_notify --><br/>
     255
     256                        <label for="moderation_notify_all">
     257                                <input name="moderation_notify_all" type="checkbox" id="moderation_notify_all" value="1" <?php checked( '1', get_user_option( 'moderation_notify_all', $profileuser->ID ) ); ?> />
     258                                <?php _e( 'Any comment is held for moderation' ) ?>
     259                        </label><!-- moderation_notify_all -->
     260                </fieldset></td>
     261        </tr>
     262<?php endif; ?>
     263
    224264<tr class="show-admin-bar">
    225265<th scope="row"><?php _e('Toolbar')?></th>
    226266<td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend>