WordPress.org

Make WordPress Core

Ticket #12295: 12295.2.diff

File 12295.2.diff, 12.3 KB (added by Japh, 20 months ago)

Refreshed

  • wp-includes/user.php

     
    15411541        ); 
    15421542        return apply_filters( 'user_contactmethods', $user_contactmethods, $user ); 
    15431543} 
     1544 
     1545/** 
     1546 * Setup the default name fields 
     1547 * 
     1548 * @access private 
     1549 * @since 
     1550 * 
     1551 * @return array $user_namefields Array of contact methods and their labels. 
     1552 */ 
     1553function _wp_get_user_namefields() { 
     1554        $user_namefields = array( 
     1555                'user_login' => __('Username'), 
     1556                'first_name' => __('First Name'), 
     1557                'last_name' => __('Last Name'), 
     1558                'nickname' => __('Nickname'), 
     1559        ); 
     1560        return apply_filters( 'user_namefields', $user_namefields ); 
     1561} 
     1562 
     1563/** 
     1564 * Setup the default personal options 
     1565 * 
     1566 * @access private 
     1567 * @since 
     1568 * 
     1569 * @return array $user_personal_options Array of personal options and their input code 
     1570 */ 
     1571function _wp_get_user_personal_options( $user_can_edit ) { 
     1572        global $user_id; 
     1573        $profileuser = get_user_to_edit( $user_id ); 
     1574 
     1575        if ( rich_edit_exists() && ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) { // don't bother showing the option if the editor has been removed 
     1576                $user_personal_options['rich_editing'] = array( 
     1577                        'name' => 'rich_editing', 
     1578                        'desc' => __('Visual Editor'), 
     1579                        '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>', 
     1580                        'scope' => ' scope="row"' 
     1581                ); 
     1582        } 
     1583 
     1584        global $_wp_admin_css_colors; 
     1585        if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) { 
     1586                $user_personal_options['admin_color_scheme_picker'] = array( 
     1587                        'name' => 'admin_color_scheme_picker', 
     1588                        'desc' => __('Admin Color Scheme'), 
     1589                        'code' => 'admin_color_scheme_picker', 
     1590                        'scope' => ' scope="row"' 
     1591                ); 
     1592        } 
     1593 
     1594        if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) { 
     1595                if ( ! empty( $profileuser->comment_shortcuts ) ) 
     1596                        $checked = checked( 'true', $profileuser->comment_shortcuts, false ); 
     1597                $user_personal_options['comment_shortcuts'] = array( 
     1598                        'name' => 'rich_editing', 
     1599                        'desc' => __('Keyboard Shortcuts'), 
     1600                        '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" target="_blank">More information</a>') 
     1601                ); 
     1602        } 
     1603 
     1604        $user_personal_options['admin_bar'] = array( 
     1605                'name' => 'show-admin-bar', 
     1606                'desc' => __('Show Admin Bar'), 
     1607                'code' => '<fieldset><legend class="screen-reader-text"><span>' . __('Show Admin Bar') . '</span></legend> 
     1608<label for="admin_bar_front"> 
     1609        <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" ' . checked( '1', _get_admin_bar_pref( 'front', $profileuser->ID ), false ) . ' />' . __( 'when viewing site' ) . '</label><br /> 
     1610<label for="admin_bar_admin"> 
     1611        <input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" ' . checked('1', _get_admin_bar_pref( 'admin', $profileuser->ID ), false ) . ' />' . __( 'in dashboard' ) . '</label>', 
     1612                'scope' => ' scope="row"' 
     1613        ); 
     1614 
     1615        return apply_filters( 'user_personal_options', $user_personal_options ); 
     1616} 
  • wp-admin/user-edit.php

     
    194194<?php if ( $wp_http_referer ) : ?> 
    195195        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> 
    196196<?php endif; ?> 
    197 <p> 
     197 
    198198<input type="hidden" name="from" value="profile" /> 
    199199<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 
    200 </p> 
    201200 
    202 <h3><?php _e('Personal Options'); ?></h3> 
     201<?php 
     202$user_personal_options = _wp_get_user_personal_options( $user_can_edit ); 
    203203 
     204if ( ! empty( $user_personal_options ) ) { ?> 
     205 
     206<div id="profile-personal-options"> 
     207        <h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3> 
     208 
    204209<table class="form-table"> 
    205 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?> 
    206         <tr> 
    207                 <th scope="row"><?php _e('Visual Editor')?></th> 
    208                 <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> 
    209         </tr> 
    210 <?php endif; ?> 
    211 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> 
    212 <tr> 
    213 <th scope="row"><?php _e('Admin Color Scheme')?></th> 
    214 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td> 
    215 </tr> 
     210 
    216211<?php 
    217 endif; // $_wp_admin_css_colors 
    218 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 
    219 <tr> 
    220 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 
    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> 
     212        foreach ( $user_personal_options as $code ) { 
     213?> 
     214<tr id="profile-personal-options-<?php echo $code['name']; ?>"> 
     215        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters( 'user_' . $code['name'] . '_label', $code['desc'] ); ?></label></th> 
     216        <td><?php if ( $code['code'] == 'admin_color_scheme_picker' ) { do_action( 'admin_color_scheme_picker' ); } else { echo $code['code']; } ?></td> 
    222217</tr> 
    223 <?php endif; ?> 
    224 <tr class="show-admin-bar"> 
    225 <th scope="row"><?php _e('Toolbar')?></th> 
    226 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Toolbar') ?></span></legend> 
    227 <label for="admin_bar_front"> 
    228 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> 
    229 <?php _e( 'Show Toolbar when viewing site' ); ?></label><br /> 
    230 </fieldset> 
    231 </td> 
    232 </tr> 
     218<?php 
     219        }; //end foreach 
     220?> 
    233221<?php do_action('personal_options', $profileuser); ?> 
    234222</table> 
    235223<?php 
    236224        if ( IS_PROFILE_PAGE ) 
    237225                do_action('profile_personal_options', $profileuser); 
    238226?> 
     227</div><!--#profile-personal-options--> 
    239228 
    240 <h3><?php _e('Name') ?></h3> 
     229<?php 
     230}; //end ifempty 
    241231 
    242 <table class="form-table"> 
    243         <tr> 
    244                 <th><label for="user_login"><?php _e('Username'); ?></label></th> 
    245                 <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> 
    246         </tr> 
     232// For backwards compatibility 
     233function user_label_add_required( $desc ) { 
     234        return $desc . ' <span class="description">' . __( '(required)' ) . '</span>'; 
     235} 
     236add_filter( 'user_user_email_label', 'user_label_add_required' ); 
     237add_filter( 'user_nickname_label', 'user_label_add_required' ); 
     238$user_namefields = _wp_get_user_namefields(); 
    247239 
     240if ( ! empty( $user_namefields ) ) { ?> 
     241<div id="profile-name"> 
     242        <h3 id="profile-name-title"><?php _e('Name') ?></h3> 
     243 
     244        <table class="form-table"> 
     245 
     246        <?php 
     247        foreach ( $user_namefields as $name => $desc ) { 
     248                ?> 
     249                <tr id="profile-name-<?php echo $name; ?>"> 
     250                        <th><label for="<?php echo $name; ?>"><?php echo apply_filters( 'user_' . $name . '_label', $desc ); ?></label></th> 
     251                        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $profileuser->$name ); ?>" class="regular-text" /></td> 
     252                </tr> 
     253                <?php 
     254        }; //end foreach 
     255        ?> 
     256 
    248257<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> 
    249258<tr><th><label for="role"><?php _e('Role') ?></label></th> 
    250259<td><select name="role" id="role"> 
     
    264273        echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>'; 
    265274?> 
    266275</select></td></tr> 
    267 <?php endif; //!IS_PROFILE_PAGE 
     276<?php endif; //!IS_PROFILE_PAGE ?> 
    268277 
    269 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> 
    270 <tr><th><?php _e('Super Admin'); ?></th> 
    271 <td> 
    272 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) || ! is_super_admin( $profileuser->ID ) ) : ?> 
    273 <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> 
    274 <?php else : ?> 
    275 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 
    276 <?php endif; ?> 
    277 </td></tr> 
    278 <?php } ?> 
    279  
    280 <tr> 
    281         <th><label for="first_name"><?php _e('First Name') ?></label></th> 
    282         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td> 
    283 </tr> 
    284  
    285 <tr> 
    286         <th><label for="last_name"><?php _e('Last Name') ?></label></th> 
    287         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td> 
    288 </tr> 
    289  
    290 <tr> 
    291         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
    292         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td> 
    293 </tr> 
    294  
    295 <tr> 
     278<tr id="profile-name-display-name"> 
    296279        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> 
    297280        <td> 
    298281                <select name="display_name" id="display_name"> 
     
    328311        </td> 
    329312</tr> 
    330313</table> 
     314</div><!--#profile-name-display-name--> 
    331315 
     316<?php    
     317}; //end if not empty 
     318?> 
     319  
     320<div id="profile-contact"> 
    332321<h3><?php _e('Contact Info') ?></h3> 
    333322 
    334323<table class="form-table"> 
    335 <tr> 
     324<tr id="profile-contact-email"> 
    336325        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
    337326        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /> 
    338327        <?php 
     
    345334        </td> 
    346335</tr> 
    347336 
    348 <tr> 
     337<tr id="profile-contact-website"> 
    349338        <th><label for="url"><?php _e('Website') ?></label></th> 
    350339        <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td> 
    351340</tr> 
     
    353342<?php 
    354343        foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) { 
    355344?> 
    356 <tr> 
     345<tr id="profile-contact-<?php echo $name; ?>"> 
    357346        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th> 
    358347        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> 
    359348</tr> 
     
    361350        } 
    362351?> 
    363352</table> 
     353</div><!--#profile-contact--> 
    364354 
     355<div id="profile-about"> 
    365356<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3> 
    366357 
    367358<table class="form-table"> 
    368 <tr> 
     359<tr id="profile-about-description"> 
    369360        <th><label for="description"><?php _e('Biographical Info'); ?></label></th> 
    370361        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea><br /> 
    371362        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td> 
     
    375366$show_password_fields = apply_filters('show_password_fields', true, $profileuser); 
    376367if ( $show_password_fields ) : 
    377368?> 
    378 <tr id="password"> 
     369<tr id="profile-about-password"> 
    379370        <th><label for="pass1"><?php _e('New Password'); ?></label></th> 
    380371        <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?></span><br /> 
    381372                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br /> 
     
    385376</tr> 
    386377<?php endif; ?> 
    387378</table> 
     379</div><!--#profile-about--> 
    388380 
    389381<?php 
    390382        if ( IS_PROFILE_PAGE )