WordPress.org

Make WordPress Core

Changeset 13539


Ignore:
Timestamp:
03/01/10 22:34:43 (5 years ago)
Author:
nacin
Message:

Dynamically remove duplicates from the 'display name' profile.php option. fixes #10030

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/js/user-profile.dev.js

    r11449 r13539  
    3232        $('#nickname').blur(function(){ 
    3333            var str = $(this).val() || $('#user_login').val(); 
    34             $('#display_name #display_nickname').val(str).html(str); 
     34            var select = $('#display_name'); 
     35            var sel = select.children('option:selected').attr('id'); 
     36            select.children('#display_nickname').remove(); 
     37            if ( ! select.children('option[value=' + str + ']').length ) 
     38                select.append('<option id="display_nickname" value="' + str + '">' + str + '</option>'); 
     39            $('#'+sel).attr('selected', 'selected'); 
    3540        }); 
    3641        $('#first_name, #last_name').blur(function(){ 
     42            var select = $('#display_name'); 
    3743            var first = $('#first_name').val(), last = $('#last_name').val(); 
     44            var sel = select.children('option:selected').attr('id'); 
    3845            $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove(); 
     46            if ( first && ! select.children('option[value=' + first + ']').length ) 
     47                select.append('<option id="display_firstname" value="' + first + '">' + first + '</option>'); 
     48            if ( last && ! select.children('option[value=' + last + ']').length ) 
     49                select.append('<option id="display_lastname" value="' + last + '">' + last + '</option>'); 
    3950            if ( first && last ) { 
    40                 $('#display_name').append('<option id="display_firstname" value="' + first + '">' + first + '</option>' + 
    41                     '<option id="display_lastname" value="' + last + '">' + last + '</option>' + 
    42                     '<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>' + 
    43                     '<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>'); 
    44             } else if ( first && !last ) { 
    45                 $('#display_name').append('<option id="display_firstname" value="' + first + '">' + first + '</option>'); 
    46             } else if ( !first && last ) { 
    47                 $('#display_name').append('<option id="display_lastname" value="' + last + '">' + last + '</option>'); 
     51                if ( ! select.children('option[value=' + first + ' ' + last + ']').length ) 
     52                    select.append('<option id="display_firstlast" value="' + first + ' ' + last + '">' + first + ' ' + last + '</option>'); 
     53                if ( ! select.children('option[value=' + last + ' ' + first + ']').length ) 
     54                    select.append('<option id="display_lastfirst" value="' + last + ' ' + first + '">' + last + ' ' + first + '</option>'); 
    4855            } 
     56            $('#'+sel).attr('selected', 'selected'); 
    4957        }); 
    5058    }); 
  • trunk/wp-admin/js/user-profile.js

    r11449 r13539  
    1 (function(a){function b(){var d=a("#pass1").val(),c=a("#user_login").val(),e;a("#pass-strength-result").removeClass("short bad good strong");if(!d){a("#pass-strength-result").html(pwsL10n.empty);return}e=passwordStrength(d,c);switch(e){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var c=a(this).val()||a("#user_login").val();a("#display_name #display_nickname").val(c).html(c)});a("#first_name, #last_name").blur(function(){var d=a("#first_name").val(),c=a("#last_name").val();a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(d&&c){a("#display_name").append('<option id="display_firstname" value="'+d+'">'+d+'</option><option id="display_lastname" value="'+c+'">'+c+'</option><option id="display_firstlast" value="'+d+" "+c+'">'+d+" "+c+'</option><option id="display_lastfirst" value="'+c+" "+d+'">'+c+" "+d+"</option>")}else{if(d&&!c){a("#display_name").append('<option id="display_firstname" value="'+d+'">'+d+"</option>")}else{if(!d&&c){a("#display_name").append('<option id="display_lastname" value="'+c+'">'+c+"</option>")}}}})})})(jQuery); 
     1(function(a){function b(){var d=a("#pass1").val(),c=a("#user_login").val(),e;a("#pass-strength-result").removeClass("short bad good strong");if(!d){a("#pass-strength-result").html(pwsL10n.empty);return}e=passwordStrength(d,c);switch(e){case 2:a("#pass-strength-result").addClass("bad").html(pwsL10n.bad);break;case 3:a("#pass-strength-result").addClass("good").html(pwsL10n.good);break;case 4:a("#pass-strength-result").addClass("strong").html(pwsL10n.strong);break;default:a("#pass-strength-result").addClass("short").html(pwsL10n["short"])}}a(document).ready(function(){a("#pass1").val("").keyup(b);a(".color-palette").click(function(){a(this).siblings("input[name=admin_color]").attr("checked","checked")});a("#nickname").blur(function(){var e=a(this).val()||a("#user_login").val();var c=a("#display_name");var d=c.children("option:selected").attr("id");c.children("#display_nickname").remove();if(!c.children("option[value="+e+"]").length){c.append('<option id="display_nickname" value="'+e+'">'+e+"</option>")}a("#"+d).attr("selected","selected")});a("#first_name, #last_name").blur(function(){var c=a("#display_name");var f=a("#first_name").val(),d=a("#last_name").val();var e=c.children("option:selected").attr("id");a("#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst").remove();if(f&&!c.children("option[value="+f+"]").length){c.append('<option id="display_firstname" value="'+f+'">'+f+"</option>")}if(d&&!c.children("option[value="+d+"]").length){c.append('<option id="display_lastname" value="'+d+'">'+d+"</option>")}if(f&&d){if(!c.children("option[value="+f+" "+d+"]").length){c.append('<option id="display_firstlast" value="'+f+" "+d+'">'+f+" "+d+"</option>")}if(!c.children("option[value="+d+" "+f+"]").length){c.append('<option id="display_lastfirst" value="'+d+" "+f+'">'+d+" "+f+"</option>")}}a("#"+e).attr("selected","selected")})})})(jQuery); 
  • trunk/wp-admin/user-edit.php

    r13487 r13539  
    257257        <?php 
    258258            $public_display = array(); 
     259            $public_display['display_username']  = $profileuser->user_login; 
    259260            $public_display['display_nickname']  = $profileuser->nickname; 
    260             $public_display['display_username']  = $profileuser->user_login; 
    261261            if ( !empty($profileuser->first_name) ) 
    262262                $public_display['display_firstname'] = $profileuser->first_name; 
     
    267267                $public_display['display_lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name; 
    268268            } 
    269             if ( !in_array( $profileuser->display_name, $public_display ) )// Only add this if it isn't duplicated elsewhere 
     269            if ( !in_array( $profileuser->display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere 
    270270                $public_display = array( 'display_displayname' => $profileuser->display_name ) + $public_display; 
    271271            $public_display = array_map( 'trim', $public_display ); 
     272            $public_display = array_unique( $public_display ); 
    272273            foreach ( $public_display as $id => $item ) { 
    273274        ?> 
Note: See TracChangeset for help on using the changeset viewer.