WordPress.org

Make WordPress Core

Ticket #12295: 12295.005.diff

File 12295.005.diff, 13.4 KB (added by pampfelimetten, 8 years ago)

Updated to latest trunk

  • wp-includes/registration.php

     
    323323 */
    324324function _wp_get_user_contactmethods() {
    325325        $user_contactmethods = array(
     326                'user_email' => __('E-Mail'),
     327                'user_url' => __('Website'),
    326328                'aim' => __('AIM'),
    327329                'yim' => __('Yahoo IM'),
    328330                'jabber' => __('Jabber / Google Talk')
     
    330332        return apply_filters('user_contactmethods',$user_contactmethods);
    331333}
    332334
     335/**
     336 * Setup the default name fields
     337 *
     338 * @access private
     339 * @since
     340 *
     341 * @return array $user_namefields Array of contact methods and their labels.
     342 */
     343function _wp_get_user_namefields() {
     344        $user_namefields = array(
     345                'user_login' => __('Username'),
     346                'first_name' => __('First Name'),
     347                'last_name' => __('Last Name'),
     348                'nickname' => __('Nickname'),
     349        );
     350        return apply_filters('user_namefields',$user_namefields);
     351}
     352
     353/**
     354 * Setup the default personal options
     355 *
     356 * @access private
     357 * @since
     358 *
     359 * @return array $user_personal_options Array of personal options and their input code
     360 */
     361function _wp_get_user_personal_options($user_can_edit) {
     362        global $user_id;
     363        $profileuser = get_user_to_edit($user_id);
     364        if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) { // don't bother showing the option if the editor has been removed
     365                $user_personal_options['rich_editing'] = array(
     366                                'name' => 'rich_editing',
     367                                'desc' => __('Visual Editor'),
     368                                'code' => '<label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" '.checked('false', $profileuser->rich_editing, false).' /> '. __('Disable the visual editor when writing').'</label>'
     369                                );
     370        };
     371        global $_wp_admin_css_colors;
     372        if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) {
     373                $user_personal_options['admin_color_scheme_picker'] = array(
     374                                'name' => 'admin_color_scheme_picker',
     375                                'desc' => __('Admin Color Scheme'),
     376                                'code' => 'admin_color_scheme_picker',
     377                                'scope' => ' scope="row"'
     378                );
     379        };
     380        if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) {       
     381                if ( !empty($profileuser->comment_shortcuts) ) $checked = checked('true', $profileuser->comment_shortcuts, false);
     382                $user_personal_options['comment_shortcuts'] = array(
     383                                'name' => 'rich_editing',
     384                                'desc' => __('Keyboard Shortcuts'),
     385                                'code' => '<label for="comment_shortcuts"><input type="checkbox" name="comment_shortcuts" id="comment_shortcuts" value="true" '.$checked.' /> '. __('Enable keyboard shortcuts for comment moderation.').'</label> '. __('<a href="http://codex.wordpress.org/Keyboard_Shortcuts">More information</a>')
     386                );
     387        };     
     388        return apply_filters('user_personal_options', $user_personal_options);
     389}
     390
    333391?>
  • wp-admin/user-edit.php

     
    187187<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    188188</p>
    189189
    190 <h3><?php _e('Personal Options'); ?></h3>
     190<?php 
     191 
     192$user_personal_options = _wp_get_user_personal_options($user_can_edit);
     193 
     194if (!empty($user_personal_options)) { ?>
     195 
     196<div id="profile-personal-options">
     197 
     198<h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3>
    191199
    192200<table class="form-table">
    193 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?>
    194         <tr>
    195                 <th scope="row"><?php _e('Visual Editor')?></th>
    196                 <td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
    197         </tr>
    198 <?php endif; ?>
    199 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
    200 <tr>
    201 <th scope="row"><?php _e('Admin Color Scheme')?></th>
    202 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
     201 
     202<?php 
     203        foreach ($user_personal_options as $code) {
     204?>
     205<tr id="profile-personal-options-<?php echo $code['name']; ?>">
     206        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters('user_'.$code['name'].'_label', $code['desc']); ?></label></th>
     207        <td><?php if ($code['code']=='admin_color_scheme_picker') do_action( 'admin_color_scheme_picker' ); else echo $code['code']; ?></td>
    203208</tr>
    204209<?php
    205 endif; // $_wp_admin_css_colors
    206 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
    207 <tr>
    208 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    209 <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">More information</a>'); ?></td>
    210 </tr>
    211 <?php
    212 endif;
    213 do_action('personal_options', $profileuser);
     210        }
     211 
     212        do_action('personal_options', $profileuser);
    214213?>
    215214</table>
    216215<?php
     
    218217                do_action('profile_personal_options', $profileuser);
    219218?>
    220219
    221 <h3><?php _e('Name') ?></h3>
     220</div>
    222221
    223 <table class="form-table">
    224         <tr>
    225                 <th><label for="user_login"><?php _e('Username'); ?></label></th>
    226                 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <span class="description"><?php _e('Usernames cannot be changed.'); ?></span></td>
    227         </tr>
    228 
    229 <?php if ( !IS_PROFILE_PAGE ): ?>
    230 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
    231 <td><select name="role" id="role">
    232222<?php
    233 // Get the highest/primary role for this user
    234 // TODO: create a function that does this: wp_get_user_role()
    235 $user_roles = $profileuser->roles;
    236 $user_role = array_shift($user_roles);
    237223
    238 // print the full list of roles with the primary one selected.
    239 wp_dropdown_roles($user_role);
     224}
    240225
    241 // print the 'no role' option. Make it selected if the user has no role yet.
    242 if ( $user_role )
    243         echo '<option value="">' . __('&mdash; No role for this site &mdash;') . '</option>';
    244 else
    245         echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
    246 ?>
    247 </select>
    248 <?php if ( is_multisite() && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?>
    249 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.'); ?></label></p>
    250 <?php } ?>
    251 </td></tr>
    252 <?php endif; //!IS_PROFILE_PAGE ?>
     226// For backwards compatibility 
     227function user_label_add_required($desc){ 
     228        return  $desc.' <span class="description">'. __('(required)').'</span>'; 
     229
     230add_filter('user_user_email_label','user_label_add_required'); 
     231add_filter('user_nickname_label','user_label_add_required'); 
     232$user_namefields = _wp_get_user_namefields();
    253233
    254 <tr>
    255         <th><label for="first_name"><?php _e('First Name') ?></label></th>
    256         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
    257 </tr>
     234if (!empty($user_namefields)) { ?>
    258235
    259 <tr>
    260         <th><label for="last_name"><?php _e('Last Name') ?></label></th>
    261         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
    262 </tr>
     236<div id="profile-name"> 
     237<h3 id="profile-name-title"><?php _e('Name') ?></h3> 
     238 
     239<table class="form-table" > 
     240 
     241<?php   
     242        foreach ($user_namefields as $name => $desc) { 
     243?> 
     244<tr id="profile-name-<?php echo $name; ?>"> 
     245        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th> 
     246        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> 
     247</tr> 
     248<?php 
     249        } 
     250?>
    263251
    264 <tr>
    265         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    266         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
    267 </tr>
    268 
    269 <tr>
     252<tr id="profile-name-display-name">
    270253        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    271254        <td>
    272255                <select name="display_name" id="display_name">
     
    295278                </select>
    296279        </td>
    297280</tr>
     281
     282 
     283<?php if ( !IS_PROFILE_PAGE ): ?>
     284<tr id="profile-name-role"><th><label for="role"><?php _e('Role:') ?></label></th>
     285<td><select name="role" id="role">
     286<?php
     287// Get the highest/primary role for this user
     288$user_roles = $profileuser->roles;
     289$user_role = array_shift($user_roles);
     290 
     291// print the full list of roles with the primary one selected.
     292wp_dropdown_roles($user_role);
     293 
     294// print the 'no role' option. Make it selected if the user has no role yet.
     295if ( $user_role )
     296        echo '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     297else
     298        echo '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     299?>
     300</select><?php if ( is_multisite() && is_super_admin() ) { ?>
     301<p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.'); ?></label></p>
     302<?php } ?>
     303</td></tr>
     304<?php endif; //!IS_PROFILE_PAGE ?>
     305
    298306</table>
    299307
    300 <h3><?php _e('Contact Info') ?></h3>
     308</div>
    301309
    302 <table class="form-table">
    303 <tr>
    304         <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    305         <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
     310<?php
     311}
     312
     313$user_contactmethods = _wp_get_user_contactmethods();
     314
     315if (!empty($user_contactmethods)) { ?>
     316
     317 
     318<div id="profile-contact-info">
     319 
     320<h3 id="profile-contact-info-title"><?php _e('Contact Info') ?></h3>
     321 
     322<table class="form-table">
     323 
     324<?php 
     325        foreach ($user_contactmethods as $name => $desc) {
     326?>
     327<tr id="profile-contact-info-<?php echo $name; ?>">
     328        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
     329        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" />
    306330        <?php
    307         $new_email = get_option( $current_user->ID . '_new_email' );
    308         if ( $new_email && $new_email != $current_user->user_email ) : ?>
    309         <div class="updated inline">
    310         <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
    311         </div>
    312         <?php endif; ?>
    313         </td>
     331        if ($name="user_email") {
     332                $new_email = get_option( $current_user->ID . '_new_email' );
     333                if ( $new_email && $new_email != $current_user->user_email ) : ?>
     334                <div class="updated inline">
     335                <p><?php printf( __('There is a pending change of your e-mail to <code>%1$s</code>. <a href="%2$s">Cancel</a>'), $new_email['newemail'], esc_url( admin_url( 'profile.php?dismiss=' . $current_user->ID . '_new_email' ) ) ); ?></p>
     336                </div>
     337                <?php endif;
     338        };
     339        ?>
     340        </td>
    314341</tr>
    315342
    316 <tr>
    317         <th><label for="url"><?php _e('Website') ?></label></th>
    318         <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
    319 </tr>
    320 
    321343<?php
    322         foreach (_wp_get_user_contactmethods() as $name => $desc) {
    323 ?>
    324 <tr>
    325         <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
    326         <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
    327 </tr>
    328 <?php
    329344        }
    330345?>
    331346</table>
    332347
    333 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     348</div>
     349<?php
     350}
     351?>
    334352
     353<div id="profile-about-yourself">
     354
     355<h3 id="profile-about-yourself-title"><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     356
    335357<table class="form-table">
    336 <tr>
     358<tr id="profile-about-yourself-description">
    337359        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    338360        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html($profileuser->description); ?></textarea><br />
    339361        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
     
    354376<?php endif; ?>
    355377</table>
    356378
     379</div>
     380
    357381<?php
    358382        if ( IS_PROFILE_PAGE )
    359383                do_action( 'show_user_profile', $profileuser );
     
    362386?>
    363387
    364388<?php if ( count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true, $profileuser) ) { ?>
     389<div id="profile-caps">
     390
    365391<br class="clear" />
    366392        <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
    367393                <tr>
     
    379405                        ?></td>
    380406                </tr>
    381407        </table>
     408</div>
    382409<?php } ?>
    383410
    384411<p class="submit">