Make WordPress Core


Ignore:
Timestamp:
05/14/2009 05:01:04 PM (17 years ago)
Author:
azaozz
Message:

Don't display empty values in the user display name drop-down, props Simek, fix js to add newly entered First Name and Last Name, fixes #9813

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/user-edit.php

    r11312 r11330  
    1515        $is_profile_page = false;
    1616
    17 /**
    18  * Display JavaScript for profile page.
    19  *
    20  * @since 2.5.0
    21  */
    22 function profile_js ( ) {
    23 ?>
    24 <script type="text/javascript">
    25 (function($){
    26 
    27         function check_pass_strength () {
    28 
    29                 var pass = $('#pass1').val();
    30                 var user = $('#user_login').val();
    31 
    32                 $('#pass-strength-result').removeClass('short bad good strong');
    33                 if ( ! pass ) {
    34                         $('#pass-strength-result').html( pwsL10n.empty );
    35                         return;
    36                 }
    37 
    38                 var strength = passwordStrength(pass, user);
    39 
    40                 if ( 2 == strength )
    41                         $('#pass-strength-result').addClass('bad').html( pwsL10n.bad );
    42                 else if ( 3 == strength )
    43                         $('#pass-strength-result').addClass('good').html( pwsL10n.good );
    44                 else if ( 4 == strength )
    45                         $('#pass-strength-result').addClass('strong').html( pwsL10n.strong );
    46                 else
    47                         // this catches 'Too short' and the off chance anything else comes along
    48                         $('#pass-strength-result').addClass('short').html( pwsL10n.short );
    49 
    50         }
    51 
    52         $(document).ready( function() {
    53                 $('#pass1').val('').keyup( check_pass_strength );
    54                 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
    55                 $('#nickname').change(function(){
    56                         $('#display_name').fadeOut('normal',function(){
    57                                 $(this).fadeIn();
    58                                 $('#display_nickname').html($('#nickname').val()).val($('#nickname').val());
    59                         });
    60                 });
    61                 $('#first_name').change(function(){
    62                         $('#display_name').fadeOut('normal',function(){
    63                                 $('#display_firstname').html($('#first_name').val()).val($('#first_name').val());
    64                                 $('#display_firstlast').html($('#first_name').val()+' '+$('#last_name').val()).val($('#first_name').val()+' '+$('#last_name').val());
    65                                 $('#display_lastfirst').html($('#last_name').val()+' '+$('#first_name').val()).val($('#last_name').val()+' '+$('#first_name').val());
    66                                 $(this).fadeIn();
    67                         });
    68                 });
    69                 $('#last_name').change(function(){
    70                         $('#display_name').fadeOut('normal',function(){
    71                                 $('#display_firstlast').html($('#first_name').val()+' '+$('#last_name').val()).val($('#first_name').val()+' '+$('#last_name').val());
    72                                 $('#display_lastfirst').html($('#last_name').val()+' '+$('#first_name').val()).val($('#last_name').val()+' '+$('#first_name').val());
    73                                 $(this).fadeIn();
    74                         });
    75                 });
    76     });
    77 })(jQuery);
    78 </script>
    79 <?php
    80 }
    81 
    8217if ( $is_profile_page ) {
    83         add_action('admin_head', 'profile_js');
    84         wp_enqueue_script('jquery');
     18        wp_enqueue_script('user-profile');
    8519        wp_enqueue_script('password-strength-meter');
    8620}
     
    249183        <tr>
    250184                <th><label for="user_login"><?php _e('Username'); ?></label></th>
    251                 <td><input type="text" name="user_login" id="user_login" value="<?php echo esc_attr($profileuser->user_login); ?>" disabled="disabled" class="regular-text" /> <?php _e('Your username cannot be changed.'); ?></td>
     185                <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>
    252186        </tr>
    253187
     
    284218
    285219<tr>
    286         <th><label for="nickname"><?php _e('Nickname') ?></label></th>
     220        <th><label for="nickname"><?php _e('Nickname'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
    287221        <td><input type="text" name="nickname" id="nickname" value="<?php echo esc_attr($profileuser->nickname) ?>" class="regular-text" /></td>
    288222</tr>
    289223
    290224<tr>
    291         <th><label for="display_name"><?php _e('Display name publicly&nbsp;as') ?></label></th>
     225        <th><label for="display_name"><?php _e('Display name publicly as') ?></label></th>
    292226        <td>
    293227                <select name="display_name" id="display_name">
     
    296230                        $public_display['display_nickname']  = $profileuser->nickname;
    297231                        $public_display['display_username']  = $profileuser->user_login;
    298                         $public_display['display_firstname'] = $profileuser->first_name;
    299                         $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
    300                         $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
     232                        if ( !empty($profileuser->first_name) )
     233                                $public_display['display_firstname'] = $profileuser->first_name;
     234                        if ( !empty($profileuser->last_name) )
     235                                $public_display['display_lastname'] = $profileuser->last_name;
     236                        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
     237                                $public_display['display_firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
     238                                $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
     239                        }
    301240                        if ( !in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere
    302241                                $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display;
     
    317256<table class="form-table">
    318257<tr>
    319         <th><label for="email"><?php _e('E-mail') ?></label></th>
    320         <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /> <?php _e('Required.');?></td>
     258        <th><label for="email"><?php _e('E-mail'); ?> <span class="description"><?php _e('(required)'); ?></span></label></th>
     259        <td><input type="text" name="email" id="email" value="<?php echo esc_attr($profileuser->user_email) ?>" class="regular-text" /></td>
    321260</tr>
    322261
     
    347286<tr>
    348287        <th><label for="description"><?php _e('Biographical Info'); ?></label></th>
    349         <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br /><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></td>
     288        <td><textarea name="description" id="description" rows="5" cols="30"><?php echo $profileuser->description ?></textarea><br />
     289        <span class="description"><?php _e('Share a little biographical information to fill out your profile. This may be shown publicly.'); ?></span></td>
    350290</tr>
    351291
     
    356296<tr id="password">
    357297        <th><label for="pass1"><?php _e('New Password'); ?></label></th>
    358         <td><input type="password" name="pass1" id="pass1" size="16" value="" autocomplete="off" /> <?php _e("If you would like to change the password type a new one. Otherwise leave this blank."); ?><br />
    359                 <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <?php _e("Type your new password again."); ?><br />
     298        <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 />
     299                <input type="password" name="pass2" id="pass2" size="16" value="" autocomplete="off" /> <span class="description"><?php _e("Type your new password again."); ?></span><br />
    360300        <?php if ( $is_profile_page ): ?>
    361301                <div id="pass-strength-result"><?php _e('Strength indicator'); ?></div>
    362                 <p><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
    363         <?php endif; ?>
    364         </td>
     302                <p class="description indicator-hint"><?php _e('Hint: Your password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &amp; ).'); ?></p>
     303        <?php endif; ?></td>
    365304</tr>
    366305<?php endif; ?>
Note: See TracChangeset for help on using the changeset viewer.