WordPress.org

Make WordPress Core

Ticket #12295: 12295.diff

File 12295.diff, 13.1 KB (added by JohnONolan, 4 years ago)

Updated patch to latest trunk + more IDs

  • wp-includes/user.php

     
    14821482        return apply_filters( 'user_contactmethods', $user_contactmethods, $user ); 
    14831483} 
    14841484 
    1485 ?> 
     1485/**  
     1486 * Setup the default name fields  
     1487 *  
     1488 * @access private  
     1489 * @since  
     1490 *  
     1491 * @return array $user_namefields Array of contact methods and their labels.  
     1492 */  
     1493function _wp_get_user_namefields() {  
     1494        $user_namefields = array(  
     1495                'user_login' => __('Username'),  
     1496                'first_name' => __('First Name'),  
     1497                'last_name' => __('Last Name'),  
     1498                'nickname' => __('Nickname'),  
     1499        );  
     1500        return apply_filters('user_namefields',$user_namefields);  
     1501}  
     1502  
     1503/**  
     1504 * Setup the default personal options  
     1505 *  
     1506 * @access private  
     1507 * @since  
     1508 *  
     1509 * @return array $user_personal_options Array of personal options and their input code  
     1510 */  
     1511function _wp_get_user_personal_options($user_can_edit) {  
     1512        global $user_id;  
     1513        $profileuser = get_user_to_edit($user_id);  
     1514 
     1515        if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) { // don't bother showing the option if the editor has been removed 
     1516                $user_personal_options['rich_editing'] = array(  
     1517                                'name' => 'rich_editing',  
     1518                                'desc' => __('Visual Editor'),  
     1519                                '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>', 
     1520                                'scope' => ' scope="row"'                              
     1521                                );  
     1522        };  
     1523 
     1524        global $_wp_admin_css_colors;  
     1525        if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) {  
     1526                $user_personal_options['admin_color_scheme_picker'] = array(  
     1527                                'name' => 'admin_color_scheme_picker',  
     1528                                'desc' => __('Admin Color Scheme'),  
     1529                                'code' => 'admin_color_scheme_picker',  
     1530                                'scope' => ' scope="row"'  
     1531                );  
     1532        };  
     1533 
     1534        if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) {          
     1535                if ( !empty($profileuser->comment_shortcuts) ) $checked = checked('true', $profileuser->comment_shortcuts, false); 
     1536                $user_personal_options['comment_shortcuts'] = array(  
     1537                                'name' => 'rich_editing',  
     1538                                'desc' => __('Keyboard Shortcuts'),  
     1539                                '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>')  
     1540                );  
     1541        }; 
     1542 
     1543        $user_personal_options['admin_bar'] = array( 
     1544                                'name' => 'show-admin-bar',  
     1545                                'desc' => __('Show Admin Bar'),  
     1546                                'code' => '<fieldset><legend class="screen-reader-text"><span>'.__('Show Admin Bar').'</span></legend> 
     1547<label for="admin_bar_front"> 
     1548<input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"'.checked('1', _get_admin_bar_pref( 'front', $profileuser->ID ), false ).' /> 
     1549'.__( 'when viewing site' ).'</label><br /> 
     1550<label for="admin_bar_admin"> 
     1551<input name="admin_bar_admin" type="checkbox" id="admin_bar_admin" value="1" '.checked('1', _get_admin_bar_pref( 'admin', $profileuser->ID ), false ).' /> 
     1552'.__( 'in dashboard' ).'</label>', 
     1553                                'scope' => ' scope="row"'            
     1554                ); 
     1555 
     1556        return apply_filters('user_personal_options', $user_personal_options);  
     1557}; 
     1558?> 
     1559 No newline at end of file 
  • wp-admin/user-edit.php

     
    185185<?php if ( $wp_http_referer ) : ?> 
    186186        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" /> 
    187187<?php endif; ?> 
    188 <p> 
     188 
    189189<input type="hidden" name="from" value="profile" /> 
    190190<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" /> 
    191 </p> 
    192191 
    193 <h3><?php _e('Personal Options'); ?></h3> 
     192<?php 
    194193 
     194$user_personal_options = _wp_get_user_personal_options($user_can_edit);   
     195//print_r($user_personal_options); 
     196 
     197if (!empty($user_personal_options)) { ?> 
     198   
     199<div id="profile-personal-options">   
     200   
     201<h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3> 
     202 
    195203<table class="form-table"> 
    196 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?> 
    197         <tr> 
    198                 <th scope="row"><?php _e('Visual Editor')?></th> 
    199                 <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> 
    200         </tr> 
    201 <?php endif; ?> 
    202 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?> 
    203 <tr> 
    204 <th scope="row"><?php _e('Admin Color Scheme')?></th> 
    205 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td> 
    206 </tr> 
     204 
    207205<?php 
    208 endif; // $_wp_admin_css_colors 
    209 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?> 
    210 <tr> 
    211 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th> 
    212 <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> 
     206        foreach ($user_personal_options as $code) { 
     207?>   
     208<tr id="profile-personal-options-<?php echo $code['name']; ?>">   
     209        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters('user_'.$code['name'].'_label', $code['desc']); ?></label></th>   
     210        <td><?php if ($code['code']=='admin_color_scheme_picker') do_action( 'admin_color_scheme_picker' ); else echo $code['code']; ?></td> 
    213211</tr> 
    214 <?php endif; ?> 
    215 <tr class="show-admin-bar"> 
    216 <th scope="row"><?php _e('Admin Bar')?></th> 
    217 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Admin Bar') ?></span></legend> 
    218 <label for="admin_bar_front"> 
    219 <input name="admin_bar_front" type="checkbox" id="admin_bar_front" value="1"<?php checked( _get_admin_bar_pref( 'front', $profileuser->ID ) ); ?> /> 
    220 <?php _e( 'Show Admin Bar when viewing site' ); ?></label><br /> 
    221 </fieldset> 
    222 </td> 
    223 </tr> 
     212<?php 
     213        }; //end foreach 
     214?> 
    224215<?php do_action('personal_options', $profileuser); ?> 
    225216</table> 
    226217<?php 
    227218        if ( IS_PROFILE_PAGE ) 
    228219                do_action('profile_personal_options', $profileuser); 
    229220?> 
     221</div><!--#profile-personal-options--> 
    230222 
    231 <h3><?php _e('Name') ?></h3> 
     223<?php  
     224}; //end ifempty 
    232225 
    233 <table class="form-table"> 
    234         <tr> 
    235                 <th><label for="user_login"><?php _e('Username'); ?></label></th> 
    236                 <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> 
    237         </tr> 
     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(); 
    238233 
     234if (!empty($user_namefields)) { ?>  
     235<div id="profile-name">    
     236<h3 id="profile-name-title"><?php _e('Name') ?></h3>    
     237    
     238<table class="form-table" >    
     239    
     240<?php     
     241        foreach ($user_namefields as $name => $desc) {    
     242?>    
     243<tr id="profile-name-<?php echo $name; ?>">    
     244        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>    
     245        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>    
     246</tr>    
     247<?php    
     248        }; //end foreach 
     249?> 
     250 
    239251<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?> 
    240252<tr><th><label for="role"><?php _e('Role:') ?></label></th> 
    241253<td><select name="role" id="role"> 
     
    257269</select> 
    258270<?php endif; //!IS_PROFILE_PAGE 
    259271 
    260 if ( is_multisite() && is_network_admin() && ! IS_PROFILE_PAGE && current_user_can( 'manage_network_options' ) && !isset($super_admins) ) { ?> 
    261 <tr><th><label for="role"><?php _e('Super Admin'); ?></label></th> 
    262 <td> 
    263 <?php if ( $profileuser->user_email != get_site_option( 'admin_email' ) ) : ?> 
    264 <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> 
    265 <?php else : ?> 
    266 <p><?php _e( 'Super admin privileges cannot be removed because this user has the network admin email.' ); ?></p> 
    267 <?php endif; ?> 
    268 </td></tr> 
    269 <?php } ?> 
    270  
    271 <tr> 
    272         <th><label for="first_name"><?php _e('First Name') ?></label></th> 
    273         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td> 
    274 </tr> 
    275  
    276 <tr> 
    277         <th><label for="last_name"><?php _e('Last Name') ?></label></th> 
    278         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td> 
    279 </tr> 
    280  
    281 <tr> 
    282         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
    283         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td> 
    284 </tr> 
    285  
    286 <tr> 
     272?> 
     273<tr id="profile-name-display-name"> 
    287274        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th> 
    288275        <td> 
    289276                <select name="display_name" id="display_name"> 
     
    318305                </select> 
    319306        </td> 
    320307</tr> 
     308 
    321309</table> 
     310</div><!--#profile-name-display-name--> 
     311<?php    
     312        }; //end if not empty 
     313?> 
    322314 
     315<div id="profile-contact"> 
    323316<h3><?php _e('Contact Info') ?></h3> 
    324317 
    325318<table class="form-table"> 
    326 <tr> 
     319<tr id="profile-contact-email"> 
    327320        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th> 
    328321        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /> 
    329322        <?php 
     
    336329        </td> 
    337330</tr> 
    338331 
    339 <tr> 
     332<tr id="profile-contact-website"> 
    340333        <th><label for="url"><?php _e('Website') ?></label></th> 
    341334        <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td> 
    342335</tr> 
     
    344337<?php 
    345338        foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) { 
    346339?> 
    347 <tr> 
     340<tr id="profile-contact-<?php echo $name; ?>"> 
    348341        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th> 
    349342        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td> 
    350343</tr> 
     
    352345        } 
    353346?> 
    354347</table> 
     348</div><!--#profile-contact--> 
    355349 
     350<div id="profile-about"> 
    356351<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3> 
    357352 
    358353<table class="form-table"> 
    359 <tr> 
     354<tr id="profile-about-description"> 
    360355        <th><label for="description"><?php _e('Biographical Info'); ?></label></th> 
    361356        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea><br /> 
    362357        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td> 
     
    366361$show_password_fields = apply_filters('show_password_fields', true, $profileuser); 
    367362if ( $show_password_fields ) : 
    368363?> 
    369 <tr id="password"> 
     364<tr id="profile-about-password"> 
    370365        <th><label for="pass1"><?php _e('New Password'); ?></label></th> 
    371366        <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 /> 
    372367                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br /> 
     
    376371</tr> 
    377372<?php endif; ?> 
    378373</table> 
     374</div><!--#profile-about--> 
    379375 
    380376<?php 
    381377        if ( IS_PROFILE_PAGE ) 
     
    422418</script> 
    423419<?php 
    424420include( ABSPATH . 'wp-admin/admin-footer.php'); 
    425 ?> 
     421?> 
     422 No newline at end of file