Users: Update name in toolbar when changing user display name.
When changing the user name in Users -> Your Profile, update the name displayed in the toolbar dynamically using JavaScript. Props menakas, lukecavanagh, maguiar. Fixes #40342. git-svn-id: https://develop.svn.wordpress.org/trunk@40657 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
fd02381098
commit
0f4c1e88dd
|
@ -328,7 +328,9 @@
|
|||
|
||||
$(document).ready( function() {
|
||||
var $colorpicker, $stylesheet, user_id, current_user_id,
|
||||
select = $( '#display_name' );
|
||||
select = $( '#display_name' ),
|
||||
current_name = select.val(),
|
||||
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
|
||||
|
||||
$('#pass1').val('').on( inputEvent + ' pwupdate', check_pass_strength );
|
||||
$('#pass-strength-result').show();
|
||||
|
@ -370,6 +372,19 @@
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Replaces "Howdy, *" in the admin toolbar whenever the display name dropdown is updated for one's own profile.
|
||||
*/
|
||||
select.on( 'change', function() {
|
||||
if ( user_id !== current_user_id ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var display_name = $.trim( this.value ) || current_name;
|
||||
|
||||
greeting.text( display_name );
|
||||
} );
|
||||
}
|
||||
|
||||
$colorpicker = $( '#color-picker' );
|
||||
|
|
|
@ -214,7 +214,7 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
|
|||
|
||||
$avatar = get_avatar( $user_id, 26 );
|
||||
/* translators: %s: current user's display name */
|
||||
$howdy = sprintf( __( 'Howdy, %s' ), $current_user->display_name );
|
||||
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
|
||||
$class = empty( $avatar ) ? '' : 'with-avatar';
|
||||
|
||||
$wp_admin_bar->add_menu( array(
|
||||
|
|
Loading…
Reference in New Issue