WordPress.org

Make WordPress Core

Ticket #12295: 12295.5.diff

File 12295.5.diff, 13.6 KB (added by ericlewis, 9 years ago)
  • wp-admin/user-edit.php

     
    5656
    5757$wp_http_referer = remove_query_arg(array('update', 'delete_count'), $wp_http_referer );
    5858
    59 $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
    60 
    6159/**
    6260 * Optional SSL preference that can be turned on by hooking to the 'personal_options' action.
    6361 *
     
    194192<?php if ( $wp_http_referer ) : ?>
    195193        <input type="hidden" name="wp_http_referer" value="<?php echo esc_url($wp_http_referer); ?>" />
    196194<?php endif; ?>
    197 <p>
     195
    198196<input type="hidden" name="from" value="profile" />
    199197<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    200 </p>
    201198
    202 <h3><?php _e('Personal Options'); ?></h3>
     199<?php
     200$user_personal_options = _wp_get_user_personal_options();
    203201
     202if ( ! empty( $user_personal_options ) ) { ?>
     203
     204<div id="profile-personal-options">
     205<h3 id="profile-personal-options-title"><?php _e( 'Personal Options' ); ?></h3>
    204206<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>
     207<?php foreach ( $user_personal_options as $user_personal_option ) { ?>
     208        <tr id="profile-personal-options-<?php echo esc_attr( $user_personal_option['name'] ); ?>">
     209                <th scope="<?php echo esc_attr( $user_personal_option['scope'] ); ?>">
     210                        <label for="<?php echo esc_attr( $user_personal_option['name'] ); ?>"><?php echo apply_filters( 'user_' . $user_personal_option['name'] . '_label', esc_html( $user_personal_option['desc'] ) ); ?></label>
     211                </th>
     212                <td>
     213                <?php
     214                if ( ! empty( $user_personal_option['code'] ) )
     215                        echo $user_personal_option['code'];
     216                else if ( ! empty( $user_personal_option['action'] ) )
     217                        do_action( $user_personal_option['action'] );
     218                ?>
     219                </td>
    209220        </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>
    216 <?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>
    222 </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>
     221<?php } ?>
    233222<?php do_action('personal_options', $profileuser); ?>
    234 </table>
     223</table><!-- .form-table -->
    235224<?php
    236225        if ( IS_PROFILE_PAGE )
    237226                do_action('profile_personal_options', $profileuser);
    238227?>
     228</div><!-- #profile-personal-options -->
    239229
    240 <h3><?php _e('Name') ?></h3>
     230<?php
     231} //end if ! empty( $user_personal_options )
    241232
    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>
     233$user_namefields = _wp_get_user_namefields();
    247234
     235if ( ! empty( $user_namefields ) ) { ?>
     236<div id="profile-name">
     237        <h3 id="profile-name-title"><?php _e( 'Name' ) ?></h3>
     238
     239        <table class="form-table">
     240
     241        <?php foreach ( $user_namefields as $namefield ) { ?>
     242                <tr id="profile-name-<?php echo esc_attr( $namefield['name'] ) ?>">
     243                        <th><label for="<?php echo esc_attr( $namefield['name'] ) ?>"><?php echo esc_html( $namefield['title'] ) ?></label></th>
     244                        <td><input type="text" name="<?php echo esc_attr( $namefield['name'] ) ?>" id="<?php echo esc_attr( $namefield['name'] ); ?>" value="<?php echo esc_attr( $profileuser->$namefield['name'] ) ?>" <?php disabled( true, $namefield['disabled'] ) ?> class="regular-text" /></td>
     245                </tr>
     246        <?php } ?>
     247
    248248<?php if ( !IS_PROFILE_PAGE && !is_network_admin() ) : ?>
    249249<tr><th><label for="role"><?php _e('Role') ?></label></th>
    250250<td><select name="role" id="role">
     
    264264        echo '<option value="" selected="selected">' . __('&mdash; No role for this site &mdash;') . '</option>';
    265265?>
    266266</select></td></tr>
    267 <?php endif; //!IS_PROFILE_PAGE
     267<?php endif; //!IS_PROFILE_PAGE ?>
    268268
    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>
     269<tr id="profile-name-display-name">
    296270        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    297271        <td>
    298272                <select name="display_name" id="display_name">
     
    326300                ?>
    327301                </select>
    328302        </td>
    329 </tr>
     303</tr><!-- #profile-name-display-name -->
    330304</table>
     305</div><!-- #profile-name -->
    331306
     307<?php
     308} //end if ! empty( $user_namefields )
     309
     310$user_contactmethods = _wp_get_user_contactmethods( $profileuser );
     311if ( ! empty( $user_contactmethods ) ) {
     312?>
     313
     314<div id="profile-contact">
    332315<h3><?php _e('Contact Info') ?></h3>
    333316
    334317<table class="form-table">
    335 <tr>
     318<tr id="profile-contact-email">
    336319        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    337320        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" />
    338321        <?php
     
    345328        </td>
    346329</tr>
    347330
    348 <tr>
     331<tr id="profile-contact-website">
    349332        <th><label for="url"><?php _e('Website') ?></label></th>
    350333        <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
    351334</tr>
    352335
    353336<?php
    354         foreach (_wp_get_user_contactmethods( $profileuser ) as $name => $desc) {
     337        foreach ( _wp_get_user_contactmethods( $profileuser ) as $name => $desc ) {
    355338?>
    356 <tr>
    357         <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
    358         <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
     339<tr id="profile-contact-<?php echo esc_attr( $name ); ?>">
     340        <th><label for="<?php echo esc_attr( $name ); ?>"><?php echo esc_html( $desc ); ?></label></th>
     341        <td><input type="text" name="<?php echo esc_attr( $name ); ?>" id="<?php echo esc_attr( $name ); ?>" value="<?php echo esc_attr( $profileuser->$name ) ?>" class="regular-text" /></td>
    359342</tr>
    360343<?php
    361344        }
    362345?>
    363346</table>
     347</div><!-- #profile-contact -->
    364348
     349<?php } // end if not empty ?>
     350<div id="profile-about">
    365351<h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
    366352
    367353<table class="form-table">
    368 <tr>
     354<tr id="profile-about-description">
    369355        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    370356        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description; // textarea_escaped ?></textarea><br />
    371357        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
     
    375361$show_password_fields = apply_filters('show_password_fields', true, $profileuser);
    376362if ( $show_password_fields ) :
    377363?>
    378 <tr id="password">
     364<tr id="profile-about-password">
    379365        <th><label for="pass1"><?php _e('New Password'); ?></label></th>
    380366        <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 />
    381367                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
     
    385371</tr>
    386372<?php endif; ?>
    387373</table>
     374</div><!-- #profile-about -->
    388375
    389376<?php
    390377        if ( IS_PROFILE_PAGE )
  • wp-includes/user.php

     
    15481548        }
    15491549        return apply_filters( 'user_contactmethods', $user_contactmethods, $user );
    15501550}
     1551
     1552/**
     1553 * Setup the default name fields
     1554 *
     1555 * @access private
     1556 * @since 3.5.0
     1557 *
     1558 * @return array $user_namefields Array of contact methods and their labels.
     1559 */
     1560function _wp_get_user_namefields() {
     1561        $user_namefields = array(
     1562                array(
     1563                        'name' => 'user_login',
     1564                        'title' => __( 'Username' ),
     1565                        'disabled' => true,
     1566                ),
     1567                array(
     1568                        'name' => 'first_name',
     1569                        'title' => __( 'First Name' ),
     1570                        'disabled' => false,
     1571                ),
     1572                array(
     1573                        'name' => 'last_name',
     1574                        'title' => __( 'Last Name' ),
     1575                        'disabled' => false,
     1576                ),
     1577                array(
     1578                        'name' => 'nickname',
     1579                        'title' => __( 'Nickname' ),
     1580                        'disabled' => false,
     1581                ),
     1582        );
     1583        return apply_filters( 'user_namefields', $user_namefields );
     1584}
     1585
     1586/**
     1587 * Setup the default personal options
     1588 *
     1589 * @access private
     1590 * @since 3.5.0
     1591 *
     1592 * @return array $user_personal_options The personal options and their details
     1593 */
     1594function _wp_get_user_personal_options() {
     1595        global $user_id, $_wp_admin_css_colors;
     1596
     1597        $profileuser = get_user_to_edit( $user_id );
     1598        $user_can_edit = current_user_can( 'edit_posts' ) || current_user_can( 'edit_pages' );
     1599
     1600        if ( rich_edit_exists() && ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) { // don't bother showing the option if the editor has been removed
     1601                $user_personal_options['rich_editing'] = array(
     1602                        'name'  => 'rich_editing',
     1603                        'desc'  => __( 'Visual Editor' ),
     1604                        '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>',
     1605                        'scope' => 'row',
     1606                );
     1607        }
     1608
     1609        if ( count( $_wp_admin_css_colors ) > 1 && has_action( 'admin_color_scheme_picker' ) ) {
     1610                $user_personal_options['admin_color_scheme_picker'] = array(
     1611                        'name'  => 'admin_color_scheme_picker',
     1612                        'desc'  => __( 'Admin Color Scheme' ),
     1613                        'action'  => 'admin_color_scheme_picker',
     1614                        'scope' => 'row',
     1615                );
     1616        }
     1617
     1618        if ( ! ( IS_PROFILE_PAGE && ! $user_can_edit ) ) {
     1619                if ( ! empty( $profileuser->comment_shortcuts ) )
     1620                        $checked = checked( 'true', $profileuser->comment_shortcuts, false );
     1621                $user_personal_options['comment_shortcuts'] = array(
     1622                        'name' => 'rich_editing',
     1623                        'desc' => __( 'Keyboard Shortcuts' ),
     1624                        '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>' ),
     1625                        'scope' => 'row',
     1626                );
     1627        }
     1628
     1629        $user_personal_options['admin_bar'] = array(
     1630                'name' => 'show-admin-bar',
     1631                'desc' => __( 'Show Toolbar' ),
     1632                'code' => '<fieldset><legend class="screen-reader-text"><span>' . __( 'Show Toolbar' ) . '</span></legend>
     1633<label for="admin_bar_front">
     1634        <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 />
     1635<label for="admin_bar_admin">
     1636        <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>',
     1637                'scope' => 'row'
     1638        );
     1639
     1640        return apply_filters( 'user_personal_options', $user_personal_options );
     1641}