WordPress.org

Make WordPress Core

Ticket #12295: 12295.004.diff

File 12295.004.diff, 12.1 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

     
    177177<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    178178</p>
    179179
    180 <h3><?php _e('Personal Options'); ?></h3>
     180<?php
    181181
     182$user_personal_options = _wp_get_user_personal_options($user_can_edit);
     183
     184if (!empty($user_personal_options)) { ?>
     185
     186<div id="profile-personal-options">
     187
     188<h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3>
     189
    182190<table class="form-table">
    183 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?>
    184         <tr>
    185                 <th scope="row"><?php _e('Visual Editor')?></th>
    186                 <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>
    187         </tr>
    188 <?php endif; ?>
    189 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
    190 <tr>
    191 <th scope="row"><?php _e('Admin Color Scheme')?></th>
    192 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
     191
     192<?php
     193        foreach ($user_personal_options as $code) {
     194?>
     195<tr id="profile-personal-options-<?php echo $code['name']; ?>">
     196        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters('user_'.$code['name'].'_label', $code['desc']); ?></label></th>
     197        <td><?php if ($code['code']=='admin_color_scheme_picker') do_action( 'admin_color_scheme_picker' ); else echo $code['code']; ?></td>
    193198</tr>
    194199<?php
    195 endif; // $_wp_admin_css_colors
    196 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
    197 <tr>
    198 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    199 <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>
    200 </tr>
    201 <?php
    202 endif;
    203 do_action('personal_options', $profileuser);
     200        }
     201
     202        do_action('personal_options', $profileuser);
    204203?>
    205204</table>
    206205<?php
    207206        if ( IS_PROFILE_PAGE )
    208207                do_action('profile_personal_options', $profileuser);
    209208?>
     209</div>
    210210
    211 <h3><?php _e('Name') ?></h3>
    212 
    213 <table class="form-table">
    214         <tr>
    215                 <th><label for="user_login"><?php _e('Username'); ?></label></th>
    216                 <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>
    217         </tr>
    218 
    219 <?php if ( !IS_PROFILE_PAGE ): ?>
    220 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
    221 <td><select name="role" id="role">
    222211<?php
    223 // Get the highest/primary role for this user
    224 // TODO: create a function that does this: wp_get_user_role()
    225 $user_roles = $profileuser->roles;
    226 $user_role = array_shift($user_roles);
     212}
    227213
    228 // print the full list of roles with the primary one selected.
    229 wp_dropdown_roles($user_role);
     214// For backwards compatibility
     215function user_label_add_required($desc){
     216        return  $desc.' <span class="description">'. __('(required)').'</span>';
     217}
     218add_filter('user_user_email_label','user_label_add_required');
     219add_filter('user_nickname_label','user_label_add_required');
     220$user_namefields = _wp_get_user_namefields();
    230221
    231 // print the 'no role' option. Make it selected if the user has no role yet.
    232 if ( $user_role )
    233         echo '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    234 else
    235         echo '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    236 ?>
    237 </select>
    238 <?php if ( is_multisite() && is_super_admin() ) { ?>
    239 <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>
    240 <?php } ?>
    241 </td></tr>
    242 <?php endif; //!IS_PROFILE_PAGE ?>
     222if (!empty($user_namefields)) { ?>
    243223
    244 <tr>
    245         <th><label for="first_name"><?php _e('First Name') ?></label></th>
    246         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
    247 </tr>
     224<div id="profile-name">
     225<h3 id="profile-name-title"><?php _e('Name') ?></h3>
     226 
     227<table class="form-table" >
     228 
     229<?php 
     230        foreach ($user_namefields as $name => $desc) {
     231?>
     232<tr id="profile-name-<?php echo $name; ?>">
     233        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
     234        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
     235</tr>
     236<?php
     237        }
     238?>         
    248239
    249 <tr>
    250         <th><label for="last_name"><?php _e('Last Name') ?></label></th>
    251         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
    252 </tr>
    253 
    254 <tr>
    255         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    256         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
    257 </tr>
    258 
    259 <tr>
     240<tr id="profile-name-display-name">
    260241        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    261242        <td>
    262243                <select name="display_name" id="display_name">
     
    285266                </select>
    286267        </td>
    287268</tr>
     269
     270<?php if ( !IS_PROFILE_PAGE ): ?>
     271<tr id="profile-name-role"><th><label for="role"><?php _e('Role:') ?></label></th>
     272<td><select name="role" id="role">
     273<?php
     274// Get the highest/primary role for this user
     275// TODO: create a function that does this: wp_get_user_role()
     276$user_roles = $profileuser->roles;
     277$user_role = array_shift($user_roles);
     278
     279// print the full list of roles with the primary one selected.
     280wp_dropdown_roles($user_role);
     281
     282// print the 'no role' option. Make it selected if the user has no role yet.
     283if ( $user_role )
     284        echo '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     285else
     286        echo '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     287?>
     288</select><?php if ( is_multisite() && is_super_admin() ) { ?>
     289<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>
     290<?php } ?>
     291</td></tr>
     292<?php endif; //!IS_PROFILE_PAGE ?>
     293
    288294</table>
    289295
    290 <h3><?php _e('Contact Info') ?></h3>
     296</div>
    291297
    292 <table class="form-table">
    293 <tr>
    294         <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    295         <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /></td>
    296 </tr>
     298<?php
     299}
    297300
    298 <tr>
    299         <th><label for="url"><?php _e('Website') ?></label></th>
    300         <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
    301 </tr>
     301$user_contactmethods = _wp_get_user_contactmethods();
    302302
    303 <?php
    304         foreach (_wp_get_user_contactmethods() as $name => $desc) {
     303if (!empty($user_contactmethods)) {
    305304?>
    306 <tr>
     305
     306<div id="profile-contact-info">
     307
     308<h3 id="profile-contact-info-title"><?php _e('Contact Info') ?></h3>
     309
     310<table class="form-table">
     311
     312<?php
     313        foreach ($user_contactmethods as $name => $desc) {
     314?>
     315<tr id="profile-contact-info-<?php echo $name; ?>">
    307316        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
    308317        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
    309318</tr>
     
    312321?>
    313322</table>
    314323
    315 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     324</div>
     325<?php
     326}
     327?>
    316328
     329<div id="profile-about-yourself">
     330
     331<h3 id="profile-about-yourself-title"><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     332
    317333<table class="form-table">
    318 <tr>
     334<tr id="profile-about-yourself-description">
    319335        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    320336        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html($profileuser->description); ?></textarea><br />
    321337        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
     
    336352<?php endif; ?>
    337353</table>
    338354
     355</div>
     356
    339357<?php
    340358        if ( IS_PROFILE_PAGE )
    341359                do_action( 'show_user_profile', $profileuser );
     
    344362?>
    345363
    346364<?php if ( count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true, $profileuser) ) { ?>
     365<div id="profile-caps">
     366
    347367<br class="clear" />
    348368        <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
    349369                <tr>
     
    361381                        ?></td>
    362382                </tr>
    363383        </table>
     384</div>
    364385<?php } ?>
    365386
    366387<p class="submit">