WordPress.org

Make WordPress Core

Ticket #12295: 12295.003.diff

File 12295.003.diff, 11.4 KB (added by pampfelimetten, 8 years ago)

First Cut, missing only the about yourself section

  • user-edit.php

     
    175175<input type="hidden" name="checkuser_id" value="<?php echo $user_ID ?>" />
    176176</p>
    177177
    178 <h3><?php _e('Personal Options'); ?></h3>
     178<?php
    179179
     180$user_personal_options = _wp_get_user_personal_options($user_can_edit);
     181
     182if (!empty($user_personal_options)) { ?>
     183
     184<div id="profile-personal-options">
     185
     186<h3 id="profile-personal-options-title"><?php _e('Personal Options'); ?></h3>
     187
    180188<table class="form-table">
    181 <?php if ( rich_edit_exists() && !( IS_PROFILE_PAGE && !$user_can_edit ) ) : // don't bother showing the option if the editor has been removed ?>
    182         <tr>
    183                 <th scope="row"><?php _e('Visual Editor')?></th>
    184                 <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>
    185         </tr>
    186 <?php endif; ?>
    187 <?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
    188 <tr>
    189 <th scope="row"><?php _e('Admin Color Scheme')?></th>
    190 <td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
     189
     190<?php
     191        foreach ($user_personal_options as $code) {
     192?>
     193<tr id="profile-personal-options-<?php echo $code['name']; ?>">
     194        <th<?php echo $code['scope']; ?>><label for="<?php echo $code['name']; ?>"><?php echo apply_filters('user_'.$code['name'].'_label', $code['desc']); ?></label></th>
     195        <td><?php if ($code['code']=='admin_color_scheme_picker') do_action( 'admin_color_scheme_picker' ); else echo $code['code']; ?></td>
    191196</tr>
    192197<?php
    193 endif; // $_wp_admin_css_colors
    194 if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
    195 <tr>
    196 <th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>
    197 <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>
    198 </tr>
    199 <?php
    200 endif;
    201 do_action('personal_options', $profileuser);
     198        }
     199
     200        do_action('personal_options', $profileuser);
    202201?>
    203202</table>
    204203<?php
     
    206205                do_action('profile_personal_options', $profileuser);
    207206?>
    208207
    209 <h3><?php _e('Name') ?></h3>
     208</div>
    210209
    211 <table class="form-table">
    212         <tr>
    213                 <th><label for="user_login"><?php _e('Username'); ?></label></th>
    214                 <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('Your username cannot be changed.'); ?></span></td>
    215         </tr>
    216 
    217 <?php if ( !IS_PROFILE_PAGE ): ?>
    218 <tr><th><label for="role"><?php _e('Role:') ?></label></th>
    219 <td><select name="role" id="role">
    220210<?php
    221 // Get the highest/primary role for this user
    222 // TODO: create a function that does this: wp_get_user_role()
    223 $user_roles = $profileuser->roles;
    224 $user_role = array_shift($user_roles);
     211}
    225212
    226 // print the full list of roles with the primary one selected.
    227 wp_dropdown_roles($user_role);
     213// For backwards compatibility
     214function user_label_add_required($desc){
     215        return  $desc.' <span class="description">'. __('(required)').'</span>';
     216}
     217add_filter('user_user_email_label','user_label_add_required');
     218add_filter('user_nickname_label','user_label_add_required');
    228219
    229 // print the 'no role' option. Make it selected if the user has no role yet.
    230 if ( $user_role )
    231         echo '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    232 else
    233         echo '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
    234 ?>
    235 </select></td></tr>
    236 <?php endif; //!IS_PROFILE_PAGE ?>
     220$user_namefields = _wp_get_user_namefields();
    237221
    238 <tr>
    239         <th><label for="first_name"><?php _e('First Name') ?></label></th>
    240         <td><input type="text" name="first_name" id="first_name" value="<?php echo esc_attr($profileuser->first_name) ?>" class="regular-text" /></td>
    241 </tr>
     222if (!empty($user_namefields)) { ?>
    242223
    243 <tr>
    244         <th><label for="last_name"><?php _e('Last Name') ?></label></th>
    245         <td><input type="text" name="last_name" id="last_name" value="<?php echo esc_attr($profileuser->last_name) ?>" class="regular-text" /></td>
    246 </tr>
     224<div id="profile-name">
    247225
    248 <tr>
    249         <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    250         <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
     226<h3 id="profile-name-title"><?php _e('Name') ?></h3>
     227
     228<table class="form-table" >
     229
     230<?php
     231        foreach ($user_namefields as $name => $desc) {
     232?>
     233<tr id="profile-name-<?php echo $name; ?>">
     234        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
     235        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
    251236</tr>
     237<?php
     238        }
     239?>
    252240
    253 <tr>
     241<tr id="profile-name-display-name">
    254242        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    255243        <td>
    256244                <select name="display_name" id="display_name">
     
    279267                </select>
    280268        </td>
    281269</tr>
     270
     271<?php if ( !IS_PROFILE_PAGE ): ?>
     272<tr id="profile-name-role"><th><label for="role"><?php _e('Role:') ?></label></th>
     273<td><select name="role" id="role">
     274<?php
     275// Get the highest/primary role for this user
     276// TODO: create a function that does this: wp_get_user_role()
     277$user_roles = $profileuser->roles;
     278$user_role = array_shift($user_roles);
     279
     280// print the full list of roles with the primary one selected.
     281wp_dropdown_roles($user_role);
     282
     283// print the 'no role' option. Make it selected if the user has no role yet.
     284if ( $user_role )
     285        echo '<option value="">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     286else
     287        echo '<option value="" selected="selected">' . __('&mdash; No role for this blog &mdash;') . '</option>';
     288?>
     289</select></td></tr>
     290<?php endif; //!IS_PROFILE_PAGE ?>
     291
    282292</table>
    283293
    284 <h3><?php _e('Contact Info') ?></h3>
     294</div>
    285295
    286 <table class="form-table">
    287 <tr>
    288         <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    289         <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /></td>
    290 </tr>
     296<?php
     297}
    291298
    292 <tr>
    293         <th><label for="url"><?php _e('Website') ?></label></th>
    294         <td><input type="text" name="url" id="url" value="<?php echo esc_attr($profileuser->user_url) ?>" class="regular-text code" /></td>
    295 </tr>
     299$user_contactmethods = _wp_get_user_contactmethods();
    296300
    297 <?php
    298         foreach (_wp_get_user_contactmethods() as $name => $desc) {
     301if (!empty($user_contactmethods)) {
    299302?>
    300 <tr>
     303
     304<div id="profile-contact-info">
     305
     306<h3 id="profile-contact-info-title"><?php _e('Contact Info') ?></h3>
     307
     308<table class="form-table">
     309
     310<?php
     311        foreach ($user_contactmethods as $name => $desc) {
     312?>
     313<tr id="profile-contact-info-<?php echo $name; ?>">
    301314        <th><label for="<?php echo $name; ?>"><?php echo apply_filters('user_'.$name.'_label', $desc); ?></label></th>
    302315        <td><input type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($profileuser->$name) ?>" class="regular-text" /></td>
    303316</tr>
     
    306319?>
    307320</table>
    308321
    309 <h3><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     322</div>
     323<?php
     324}
     325?>
    310326
     327<div id="profile-about-yourself">
     328
     329<h3 id="profile-about-yourself-title"><?php IS_PROFILE_PAGE ? _e('About Yourself') : _e('About the user'); ?></h3>
     330
    311331<table class="form-table">
    312 <tr>
     332<tr id="profile-about-yourself-description">
    313333        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    314334        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo esc_html($profileuser->description); ?></textarea><br />
    315335        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
     
    330350<?php endif; ?>
    331351</table>
    332352
     353</div>
     354
    333355<?php
    334356        if ( IS_PROFILE_PAGE ) {
    335357                do_action('show_user_profile', $profileuser);
     
    339361?>
    340362
    341363<?php if ( count($profileuser->caps) > count($profileuser->roles) && apply_filters('additional_capabilities_display', true, $profileuser) ) { ?>
     364<div id="profile-caps">
     365
    342366<br class="clear" />
    343367        <table width="99%" style="border: none;" cellspacing="2" cellpadding="3" class="editform">
    344368                <tr>
     
    356380                        ?></td>
    357381                </tr>
    358382        </table>
     383</div>
    359384<?php } ?>
    360385
    361386<p class="submit">
  • registration.php

     Index: 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?>