<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[17587] trunk: Fix display of apostrophes in the user'
 s first and last names on the User Profile page, partial props andrewryno,
  see #17004</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/17587">17587</a></dd>
<dt>Author</dt> <dd>azaozz</dd>
<dt>Date</dt> <dd>2011-04-01 20:40:16 +0000 (Fri, 01 Apr 2011)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix display of apostrophes in the user's first and last names on the User Profile page, partial props andrewryno, see <a href="http://trac.wordpress.org/ticket/17004">#17004</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminjsuserprofiledevjs">trunk/wp-admin/js/user-profile.dev.js</a></li>
<li><a href="#trunkwpadminjsuserprofilejs">trunk/wp-admin/js/user-profile.js</a></li>
<li><a href="#trunkwpadminusereditphp">trunk/wp-admin/user-edit.php</a></li>
<li><a href="#trunkwpincludesscriptloaderphp">trunk/wp-includes/script-loader.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminjsuserprofiledevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/user-profile.dev.js (17586 => 17587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.dev.js        2011-04-01 19:44:37 UTC (rev 17586)
+++ trunk/wp-admin/js/user-profile.dev.js        2011-04-01 20:40:16 UTC (rev 17587)
</span><span class="lines">@@ -29,37 +29,36 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><del>-        $(document).ready( function() {
</del><ins>+        $(document).ready(function() {
</ins><span class="cx">                 $('#pass1').val('').keyup( check_pass_strength );
</span><span class="cx">                 $('#pass2').val('').keyup( check_pass_strength );
</span><span class="cx">                 $('#pass-strength-result').show();
</span><span class="cx">                 $('.color-palette').click(function(){$(this).siblings('input[name=admin_color]').attr('checked', 'checked')});
</span><del>-                $('#nickname').blur(function(){
-                        var str = $(this).val() || $('#user_login').val();
-                        var select = $('#display_name');
-                        var sel = select.children('option:selected').attr('id');
-                        select.children('#display_nickname').remove();
-                        if ( ! select.children('option[value=' + str + ']').length )
-                                select.append('&lt;option id=&quot;display_nickname&quot; value=&quot;' + str + '&quot;&gt;' + str + '&lt;/option&gt;');
-                        $('#'+sel).attr('selected', 'selected');
-                });
-                $('#first_name, #last_name').blur(function(){
-                        var select = $('#display_name');
-                        var first = $('#first_name').val(), last = $('#last_name').val();
-                        var sel = select.children('option:selected').attr('id');
-                        $('#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst').remove();
-                        if ( first &amp;&amp; ! select.children('option[value=' + first + ']').length )
-                                select.append('&lt;option id=&quot;display_firstname&quot; value=&quot;' + first + '&quot;&gt;' + first + '&lt;/option&gt;');
-                        if ( last &amp;&amp; ! select.children('option[value=' + last + ']').length )
-                                select.append('&lt;option id=&quot;display_lastname&quot; value=&quot;' + last + '&quot;&gt;' + last + '&lt;/option&gt;');
-                        if ( first &amp;&amp; last ) {
-                                if ( ! select.children('option[value=' + first + ' ' + last + ']').length )
-                                        select.append('&lt;option id=&quot;display_firstlast&quot; value=&quot;' + first + ' ' + last + '&quot;&gt;' + first + ' ' + last + '&lt;/option&gt;');
-                                if ( ! select.children('option[value=' + last + ' ' + first + ']').length )
-                                        select.append('&lt;option id=&quot;display_lastfirst&quot; value=&quot;' + last + ' ' + first + '&quot;&gt;' + last + ' ' + first + '&lt;/option&gt;');
</del><ins>+                $('#first_name, #last_name, #nickname').blur(function(){
+                        var select = $('#display_name'), current = select.find('option:selected').attr('id'), dub = [],
+                                inputs = {
+                                        display_nickname : $('#nickname').val(),
+                                        display_username : $('#user_login').val(),
+                                        display_firstname : $('#first_name').val(),
+                                        display_lastname : $('#last_name').val()
+                                };
+
+                        if ( inputs.display_firstname &amp;&amp; inputs.display_lastname ) {
+                                inputs['display_firstlast'] = inputs.display_firstname + ' ' + inputs.display_lastname;
+                                inputs['display_lastfirst'] = inputs.display_lastname + ' ' + inputs.display_firstname;
</ins><span class="cx">                         }
</span><del>-                        $('#'+sel).attr('selected', 'selected');
</del><ins>+
+                        $('option', select).remove();
+                        $.each(inputs, function( id, value ) {
+                                var selected;
+
+                                if ( inputs[id].length &amp;&amp; $.inArray( value, dub ) == -1 ) {
+                                        dub.push(value);
+                                        selected = id == current ? 'selected=&quot;selected&quot;' : '';
+                                        select.append('&lt;option id=&quot;' + id + '&quot; ' + selected + '&quot;&gt;' + value + '&lt;/option&gt;');
+                                }
+                        });
</ins><span class="cx">                 });
</span><del>-    });
</del><ins>+        });
</ins><span class="cx"> 
</span><span class="cx"> })(jQuery);
</span></span></pre></div>
<a id="trunkwpadminjsuserprofilejs"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/js/user-profile.js (17586 => 17587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/js/user-profile.js        2011-04-01 19:44:37 UTC (rev 17586)
+++ trunk/wp-admin/js/user-profile.js        2011-04-01 20:40:16 UTC (rev 17587)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(a){function b(){var e=a(&quot;#pass1&quot;).val(),d=a(&quot;#user_login&quot;).val(),c=a(&quot;#pass2&quot;).val(),f;a(&quot;#pass-strength-result&quot;).removeClass(&quot;short bad good strong&quot;);if(!e){a(&quot;#pass-strength-result&quot;).html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a(&quot;#pass-strength-result&quot;).addClass(&quot;bad&quot;).html(pwsL10n.bad);break;case 3:a(&quot;#pass-strength-result&quot;).addClass(&quot;good&quot;).html(pwsL10n.good);break;case 4:a(&quot;#pass-strength-result&quot;).addClass(&quot;strong&quot;).html(pwsL10n.strong);break;case 5:a(&quot;#pass-strength-result&quot;).addClass(&quot;short&quot;).html(pwsL10n.mismatch);break;default:a(&quot;#pass-strength-result&quot;).addClass(&quot;short&quot;).html(pwsL10n[&quot;short&quot;])}}a(document).ready(function(){a(&quot;#pass1&quot;).val(&quot;&quot;).keyup(b);a(&quot;#pass2&quot;).val(&quot;&quot;).keyup(b);a(&quot;#pass-strength-result&quot;).show();a(&quot;.color-palette&quot;).click(function(){a(this).siblings(&quot;input[name=admin_color]&quot;).attr(&quot;checked&quot;,&quot;checked&quot;)});a(&quot;#nickname&quot;).blur(function(){var e=a(this).val()||a(&quot;#user_login&quot;).val();var c=a(&quot;#display_name&quot;);var d=c.children(&quot;option:selected&quot;).attr(&quot;id&quot;);c.children(&quot;#display_nickname&quot;).remove();if(!c.children(&quot;option[value=&quot;+e+&quot;]&quot;).length){c.append('&lt;option id=&quot;display_nickname&quot; value=&quot;'+e+'&quot;&gt;'+e+&quot;&lt;/option&gt;&quot;)}a(&quot;#&quot;+d).attr(&quot;selected&quot;,&quot;selected&quot;)});a(&quot;#first_name, #last_name&quot;).blur(function(){var c=a(&quot;#display_name&quot;);var f=a(&quot;#first_name&quot;).val(),d=a(&quot;#last_name&quot;).val();var e=c.children(&quot;option:selected&quot;).attr(&quot;id&quot;);a(&quot;#display_firstname, #display_lastname, #display_firstlast, #display_lastfirst&quot;).remove();if(f&amp;&amp;!c.children(&quot;option[value=&quot;+f+&quot;]&quot;).length){c.append('&lt;option id=&quot;display_firstname&quot; value=&quot;'+f+'&quot;&gt;'+f+&quot;&lt;/option&gt;&quot;)}if(d&amp;&amp;!c.children(&quot;option[value=&quot;+d+&quot;]&quot;).length){c.append('&lt;option id=&quot;display_lastname&quot; value=&quot;'+d+'&quot;&gt;'+d+&quot;&lt;/option&gt;&quot;)}if(f&amp;&amp;d){if(!c.children(&quot;option[value=&quot;+f+&quot; &quot;+d+&quot;]&quot;).length){c.append('&lt;option id=&quot;display_firstlast&quot; value=&quot;'+f+&quot; &quot;+d+'&quot;&gt;'+f+&quot; &quot;+d+&quot;&lt;/option&gt;&quot;)}if(!c.children(&quot;option[value=&quot;+d+&quot; &quot;+f+&quot;]&quot;).length){c.append('&lt;option id=&quot;display_lastfirst&quot; value=&quot;'+d+&quot; &quot;+f+'&quot;&gt;'+d+&quot; &quot;+f+&quot;&lt;/option&gt;&quot;)}}a(&quot;#&quot;+e).attr(&quot;selected&quot;,&quot;selected&quot;)})})})(jQuery);
</del><span class="cx">\ No newline at end of file
</span><ins>+(function(a){function b(){var e=a(&quot;#pass1&quot;).val(),d=a(&quot;#user_login&quot;).val(),c=a(&quot;#pass2&quot;).val(),f;a(&quot;#pass-strength-result&quot;).removeClass(&quot;short bad good strong&quot;);if(!e){a(&quot;#pass-strength-result&quot;).html(pwsL10n.empty);return}f=passwordStrength(e,d,c);switch(f){case 2:a(&quot;#pass-strength-result&quot;).addClass(&quot;bad&quot;).html(pwsL10n.bad);break;case 3:a(&quot;#pass-strength-result&quot;).addClass(&quot;good&quot;).html(pwsL10n.good);break;case 4:a(&quot;#pass-strength-result&quot;).addClass(&quot;strong&quot;).html(pwsL10n.strong);break;case 5:a(&quot;#pass-strength-result&quot;).addClass(&quot;short&quot;).html(pwsL10n.mismatch);break;default:a(&quot;#pass-strength-result&quot;).addClass(&quot;short&quot;).html(pwsL10n[&quot;short&quot;])}}a(document).ready(function(){a(&quot;#pass1&quot;).val(&quot;&quot;).keyup(b);a(&quot;#pass2&quot;).val(&quot;&quot;).keyup(b);a(&quot;#pass-strength-result&quot;).show();a(&quot;.color-palette&quot;).click(function(){a(this).siblings(&quot;input[name=admin_color]&quot;).attr(&quot;checked&quot;,&quot;checked&quot;)});a(&quot;#first_name, #last_name, #nickname&quot;).blur(function(){var c=a(&quot;#display_name&quot;),e=c.find(&quot;option:selected&quot;).attr(&quot;id&quot;),f=[],d={display_nickname:a(&quot;#nickname&quot;).val(),display_username:a(&quot;#user_login&quot;).val(),display_firstname:a(&quot;#first_name&quot;).val(),display_lastname:a(&quot;#last_name&quot;).val()};if(d.display_firstname&amp;&amp;d.display_lastname){d.display_firstlast=d.display_firstname+&quot; &quot;+d.display_lastname;d.display_lastfirst=d.display_lastname+&quot; &quot;+d.display_firstname}a(&quot;option&quot;,c).remove();a.each(d,function(i,h){var g;if(d[i].length&amp;&amp;a.inArray(h,f)==-1){f.push(h);g=i==e?'selected=&quot;selected&quot;':&quot;&quot;;c.append('&lt;option id=&quot;'+i+'&quot; '+g+'&quot;&gt;'+h+&quot;&lt;/option&gt;&quot;)}})})})})(jQuery);
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpadminusereditphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/user-edit.php (17586 => 17587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/user-edit.php        2011-04-01 19:44:37 UTC (rev 17586)
+++ trunk/wp-admin/user-edit.php        2011-04-01 20:40:16 UTC (rev 17587)
</span><span class="lines">@@ -281,23 +281,29 @@
</span><span class="cx">                 &lt;select name=&quot;display_name&quot; id=&quot;display_name&quot;&gt;
</span><span class="cx">                 &lt;?php
</span><span class="cx">                         $public_display = array();
</span><ins>+                        $public_display['display_nickname']  = $profileuser-&gt;nickname;
</ins><span class="cx">                         $public_display['display_username']  = $profileuser-&gt;user_login;
</span><del>-                        $public_display['display_nickname']  = $profileuser-&gt;nickname;
</del><ins>+
</ins><span class="cx">                         if ( !empty($profileuser-&gt;first_name) )
</span><span class="cx">                                 $public_display['display_firstname'] = $profileuser-&gt;first_name;
</span><ins>+
</ins><span class="cx">                         if ( !empty($profileuser-&gt;last_name) )
</span><span class="cx">                                 $public_display['display_lastname'] = $profileuser-&gt;last_name;
</span><ins>+
</ins><span class="cx">                         if ( !empty($profileuser-&gt;first_name) &amp;&amp; !empty($profileuser-&gt;last_name) ) {
</span><span class="cx">                                 $public_display['display_firstlast'] = $profileuser-&gt;first_name . ' ' . $profileuser-&gt;last_name;
</span><span class="cx">                                 $public_display['display_lastfirst'] = $profileuser-&gt;last_name . ' ' . $profileuser-&gt;first_name;
</span><span class="cx">                         }
</span><ins>+
</ins><span class="cx">                         if ( !in_array( $profileuser-&gt;display_name, $public_display ) ) // Only add this if it isn't duplicated elsewhere
</span><span class="cx">                                 $public_display = array( 'display_displayname' =&gt; $profileuser-&gt;display_name ) + $public_display;
</span><ins>+
</ins><span class="cx">                         $public_display = array_map( 'trim', $public_display );
</span><span class="cx">                         $public_display = array_unique( $public_display );
</span><ins>+
</ins><span class="cx">                         foreach ( $public_display as $id =&gt; $item ) {
</span><span class="cx">                 ?&gt;
</span><del>-                        &lt;option id=&quot;&lt;?php echo $id; ?&gt;&quot; value=&quot;&lt;?php echo esc_attr($item); ?&gt;&quot;&lt;?php selected( $profileuser-&gt;display_name, $item ); ?&gt;&gt;&lt;?php echo $item; ?&gt;&lt;/option&gt;
</del><ins>+                        &lt;option id=&quot;&lt;?php echo $id; ?&gt;&quot;&lt;?php selected( $profileuser-&gt;display_name, $item ); ?&gt;&gt;&lt;?php echo $item; ?&gt;&lt;/option&gt;
</ins><span class="cx">                 &lt;?php
</span><span class="cx">                         }
</span><span class="cx">                 ?&gt;
</span></span></pre></div>
<a id="trunkwpincludesscriptloaderphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/script-loader.php (17586 => 17587)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/script-loader.php        2011-04-01 19:44:37 UTC (rev 17586)
+++ trunk/wp-includes/script-loader.php        2011-04-01 20:40:16 UTC (rev 17587)
</span><span class="lines">@@ -259,7 +259,7 @@
</span><span class="cx">                 'l10n_print_after' =&gt; 'try{convertEntities(pwsL10n);}catch(e){};'
</span><span class="cx">         ) );
</span><span class="cx"> 
</span><del>-        $scripts-&gt;add( 'user-profile', &quot;/wp-admin/js/user-profile$suffix.js&quot;, array( 'jquery', 'password-strength-meter' ), '20110113' );
</del><ins>+        $scripts-&gt;add( 'user-profile', &quot;/wp-admin/js/user-profile$suffix.js&quot;, array( 'jquery', 'password-strength-meter' ), '20110401' );
</ins><span class="cx">         $scripts-&gt;add_data( 'user-profile', 'group', 1 );
</span><span class="cx"> 
</span><span class="cx">         $scripts-&gt;add( 'admin-bar', &quot;/wp-includes/js/admin-bar$suffix.js&quot;, false, '20110131' );
</span></span></pre>
</div>
</div>

</body>
</html>