WordPress.org

Make WordPress Core

Ticket #12295: 12295.006.diff

File 12295.006.diff, 10.9 KB (added by pampfelimetten, 5 years ago)

Update to latest trunk

  • wp-admin/user-edit.php

     
    178178<?php if ( $wp_http_referer ) : ?> 
    179179        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> 
    180180<?php endif; ?> 
    181 <p> 
     181 
    182182<input type="hidden" name="from" value="profile" /> 
    183183<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 
    184 </p> 
    185184 
    186 <h3><?php _e('Personal Options'); ?></h3> 
     185<?php 
    187186 
     187$user_personal_options = _wp_get_user_personal_options($user_can_edit);   
     188//print_r($user_personal_options); 
     189 
     190if (!empty($user_personal_options)) { ?> 
     191   
     192<div id="profile-personal-options">   
     193   
     194<h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3> 
     195 
    188196<table class="form-table"> 
    189 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?> 
    190         <tr> 
    191                 <th scope="row"><?php _e('Visual Editor')?></th> 
    192                 <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> 
    193         </tr> 
    194 <?php endif; ?> 
    195 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> 
    196 <tr> 
    197 <th scope="row"><?php _e('Admin Color Scheme')?></th> 
    198 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td> 
    199 </tr> 
     197 
    200198<?php 
    201 endif; // $_wp_admin_css_colors 
    202 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 
    203 <tr> 
    204 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 
    205 <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> 
     199        foreach ($user_personal_options as $code) { 
     200?>   
     201<tr id="profile-personal-options-<?php echo $code['name']; ?>">   
     202        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters('user_'.$code['name'].'_label', $code['desc']); ?></label></th>   
     203        <td><?php if ($code['code']=='admin_color_scheme_picker') do_action( 'admin_color_scheme_picker' ); else echo $code['code']; ?></td> 
    206204</tr> 
    207 <?php endif; ?> 
    208 <tr class="show-admin-bar"> 
    209 <th scope="row"><?php _e('Show Admin Bar')?></th> 
    210 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Show Admin Bar') ?></span></legend> 
    211 <label for="admin_bar_front"> 
    212 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1" <?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> 
    213 <?php /* translators: Show admin bar when viewing site */ _e( 'when viewing site' ); ?></label><br /> 
    214 <label for="admin_bar_admin"> 
    215 <input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" <?php checked( _get_admin_bar_pref( 'admin', $profileuser->ID ) ); ?> /> 
    216 <?php /* translators: Show admin bar in dashboard */ _e( 'in dashboard' ); ?></label> 
    217 </td> 
    218 </tr> 
     205<?php 
     206}; //end foreach 
     207?> 
     208 
    219209<?php do_action('personal_options', $profileuser); ?> 
    220210</table> 
    221211<?php 
    222212        if ( IS_PROFILE_PAGE ) 
    223213                do_action('profile_personal_options', $profileuser); 
    224214?> 
     215</div> 
     216<?php 
     217}; //end ifempty 
    225218 
    226 <h3><?php _e('Name') ?></h3> 
     219// For backwards compatibility    
     220function user_label_add_required($desc){    
     221        return  $desc.' <span class="description">'. __('(required)').'</span>';    
     222}    
     223add_filter('user_user_email_label','user_label_add_required');    
     224add_filter('user_nickname_label','user_label_add_required');    
     225$user_namefields = _wp_get_user_namefields(); 
    227226 
    228 <table class="form-table"> 
    229         <tr> 
    230                 <th><label for="user_login"><?php _e('Username'); ?></label></th> 
    231                 <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> 
    232         </tr> 
     227if (!empty($user_namefields)) { ?>  
     228<div id="profile-name">    
     229<h3 id="profile-name-title"><?php _e('Name') ?></h3>    
     230    
     231<table class="form-table" >    
     232    
     233<?php     
     234        foreach ($user_namefields as $name => $desc) {    
     235?>    
     236<tr id="profile-name-<?php echo $name; ?>">    
     237        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>    
     238        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>    
     239</tr>    
     240<?php    
     241        }; //end foreach 
     242?> 
    233243 
    234244<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> 
    235245<tr><th><label for="role"><?php _e('Role:') ?></label></th> 
     
    252262</select> 
    253263<?php endif; //!IS_PROFILE_PAGE 
    254264 
    255 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> 
    256 <tr><th><label for="role"><?php _e('Super Admin'); ?></label></th> 
    257 <td> 
    258 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) ) : ?> 
    259 <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> 
    260 <?php else : ?> 
    261 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 
    262 <?php endif; ?> 
    263 </td></tr> 
    264 <?php } ?> 
    265  
    266 <tr> 
    267         <th><label for="first_name"><?php _e('First Name') ?></label></th> 
    268         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td> 
    269 </tr> 
    270  
    271 <tr> 
    272         <th><label for="last_name"><?php _e('Last Name') ?></label></th> 
    273         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td> 
    274 </tr> 
    275  
    276 <tr> 
    277         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
    278         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td> 
    279 </tr> 
    280  
    281 <tr> 
     265?> 
     266<tr id="profile-name-display-name"> 
    282267        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> 
    283268        <td> 
    284269                <select name="display_name" id="display_name"> 
     
    307292                </select> 
    308293        </td> 
    309294</tr> 
     295 
    310296</table> 
     297</div> 
     298<?php    
     299        }; //end if not empty 
     300?> 
    311301 
     302 
     303 
    312304<h3><?php _e('Contact Info') ?></h3> 
    313305 
    314306<table class="form-table"> 
     
    411403</script> 
    412404<?php 
    413405include( ABSPATH . 'wp-admin/admin-footer.php'); 
    414 ?> 
     406?> 
     407 No newline at end of file 
  • wp-includes/user.php

     
    16171617        return apply_filters( 'user_contactmethods', $user_contactmethods, $user ); 
    16181618} 
    16191619 
    1620 ?> 
     1620/**  
     1621 * Setup the default name fields  
     1622 *  
     1623 * @access private  
     1624 * @since  
     1625 *  
     1626 * @return array $user_namefields Array of contact methods and their labels.  
     1627 */  
     1628function _wp_get_user_namefields() {  
     1629        $user_namefields = array(  
     1630                'user_login' => __('Username'),  
     1631                'first_name' => __('First Name'),  
     1632                'last_name' => __('Last Name'),  
     1633                'nickname' => __('Nickname'),  
     1634        );  
     1635        return apply_filters('user_namefields',$user_namefields);  
     1636}  
     1637  
     1638/**  
     1639 * Setup the default personal options  
     1640 *  
     1641 * @access private  
     1642 * @since  
     1643 *  
     1644 * @return array $user_personal_options Array of personal options and their input code  
     1645 */  
     1646function _wp_get_user_personal_options($user_can_edit) {  
     1647        global $user_id;  
     1648        $profileuser = get_user_to_edit($user_id);  
     1649 
     1650        if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) { // don't bother showing the option if the editor has been removed 
     1651                $user_personal_options['rich_editing'] = array(  
     1652                                'name' => 'rich_editing',  
     1653                                'desc' => __('Visual Editor'),  
     1654                                '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>', 
     1655                                'scope' => ' scope="row"'                              
     1656                                );  
     1657        };  
     1658 
     1659        global $_wp_admin_css_colors;  
     1660        if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) {  
     1661                $user_personal_options['admin_color_scheme_picker'] = array(  
     1662                                'name' => 'admin_color_scheme_picker',  
     1663                                'desc' => __('Admin Color Scheme'),  
     1664                                'code' => 'admin_color_scheme_picker',  
     1665                                'scope' => ' scope="row"'  
     1666                );  
     1667        };  
     1668 
     1669        if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) {          
     1670                if ( !empty($profileuser->comment_shortcuts) ) $checked = checked('true', $profileuser->comment_shortcuts, false); 
     1671                $user_personal_options['comment_shortcuts'] = array(  
     1672                                'name' => 'rich_editing',  
     1673                                'desc' => __('Keyboard Shortcuts'),  
     1674                                '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>')  
     1675                );  
     1676        }; 
     1677 
     1678        $user_personal_options['admin_bar'] = array( 
     1679                                'name' => 'show-admin-bar',  
     1680                                'desc' => __('Show Admin Bar'),  
     1681                                'code' => '<fieldset><legend class="screen-reader-text"><span>'.__('Show Admin Bar').'</span></legend> 
     1682<label for="admin_bar_front"> 
     1683<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"'.checked('1', _get_admin_bar_pref( 'front', $profileuser->ID ), false ).' /> 
     1684'.__( 'when viewing site' ).'</label><br /> 
     1685<label for="admin_bar_admin"> 
     1686<input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" '.checked('1', _get_admin_bar_pref( 'admin', $profileuser->ID ), false ).' /> 
     1687'.__( 'in dashboard' ).'</label>', 
     1688                                'scope' => ' scope="row"'            
     1689                ); 
     1690 
     1691        return apply_filters('user_personal_options', $user_personal_options);  
     1692}; 
     1693?> 
     1694 No newline at end of file