Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/js/_enqueues/admin/user-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,14 @@

$( function() {
var $colorpicker, $stylesheet, user_id, current_user_id,
select = $( '#display_name' ),
username = $( '#user_login' ).val(),
greeting = $( '#wp-admin-bar-my-account' ).find( '.display-name' );
select = $( '#display_name' ),
username = $( '#user_login' ).val(),
myAccount = $( '#wp-admin-bar-my-account' ),
displayNames = myAccount.find( '.user-display-name' ),
usernameLine = myAccount.find( '#wp-admin-bar-user-info .username' ),
menus = myAccount.children( '.ab-sub-wrapper' ).children( '[role="menu"]' ).filter( function() {
return this.getAttribute( 'aria-label' ) === displayNames.first().text();
} );

$( '#pass1' ).val( '' ).on( 'input' + ' pwupdate', check_pass_strength );
$('#pass-strength-result').show();
Expand Down Expand Up @@ -549,7 +554,11 @@

var display_name = this.value.trim() || username;

greeting.text( display_name );
displayNames.text( display_name );
menus.attr( 'aria-label', display_name );
Comment thread
mcsf marked this conversation as resolved.
Resolved

// Only show the username when it differs from the display name.
usernameLine.prop( 'hidden', display_name === username );
} );
}

Expand Down
3 changes: 0 additions & 3 deletions src/wp-admin/css/colors/_admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -521,13 +521,10 @@ ul#adminmenu > li.current > a.current::after {
background-color: variables.$adminbar-avatar-frame;
}

#wpadminbar #wp-admin-bar-user-info .howdy,
#wpadminbar #wp-admin-bar-user-info .display-name {
color: variables.$menu-text;
}

#wpadminbar #wp-admin-bar-user-info a:hover .howdy,
#wpadminbar #wp-admin-bar-user-info a:focus .howdy,
#wpadminbar #wp-admin-bar-user-info a:hover .display-name,
#wpadminbar #wp-admin-bar-user-info a:focus .display-name {
color: variables.$menu-submenu-focus-text;
Expand Down
11 changes: 5 additions & 6 deletions src/wp-includes/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => '<span class="display-name">' . $display_name . '</span>' . $avatar,
'title' => '<span class="display-name user-display-name">' . $display_name . '</span>' . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => empty( $avatar ) ? '' : 'with-avatar',
Expand Down Expand Up @@ -335,14 +335,13 @@ function wp_admin_bar_my_account_menu( $wp_admin_bar ) {
}

/* translators: %s: Current user's display name. */
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $display_name . '</span>' );
$howdy = sprintf( __( 'Howdy, %s' ), "<span class='user-display-name'>" . $display_name . '</span>' );
Comment thread
mcsf marked this conversation as resolved.
Resolved

$user_info = get_avatar( $user_id, 64 );
$user_info .= '<span class="howdy">' . $howdy . '</span>';
$user_info .= "<span class='display-name howdy'>" . $howdy . '</span>';
Comment thread
fushar marked this conversation as resolved.
Resolved

if ( $display_name !== $current_user->user_login ) {
$user_info .= "<span class='username'>{$current_user->user_login}</span>";
}
$username_hidden = ( $display_name === $current_user->user_login ) ? ' hidden' : '';
$user_info .= "<span class='username'{$username_hidden}>{$current_user->user_login}</span>";

if ( false !== $profile_url ) {
$user_info .= "<span class='display-name edit-profile'>" . __( 'Edit Profile' ) . '</span>';
Expand Down
10 changes: 6 additions & 4 deletions src/wp-includes/css/admin-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -461,14 +461,17 @@ html:lang(he-il) .rtl #wpadminbar * {
height: 18px;
}

#wpadminbar #wp-admin-bar-user-info .howdy,
#wpadminbar #wp-admin-bar-user-info .display-name,
#wpadminbar #wp-admin-bar-user-info .username {
display: block;
}

#wpadminbar #wp-admin-bar-user-info .howdy .display-name {
display: inline;
#wpadminbar #wp-admin-bar-user-info .username[hidden] {
display: none;
}

#wpadminbar #wp-admin-bar-user-info .howdy .user-display-name {
font: inherit;
}

#wpadminbar #wp-admin-bar-user-info .username {
Expand Down Expand Up @@ -1044,7 +1047,6 @@ html:lang(he-il) .rtl #wpadminbar * {
margin: 0;
}

#wpadminbar #wp-admin-bar-user-info .howdy,
#wpadminbar #wp-admin-bar-user-info .display-name {
height: auto;
font-size: 16px;
Expand Down
4 changes: 3 additions & 1 deletion tests/phpunit/tests/adminbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,7 @@ public function test_my_account_has_greeting_in_user_info_only() {
$this->assertSame( 'John Doe', $node_my_account->meta['menu_title'] );

$this->assertSame( 'Howdy, John Doe' . $current_user->user_login . 'Edit Profile', wp_strip_all_tags( $node_user_info->title ) );
$this->assertStringContainsString( "<span class='username'>", $node_user_info->title );
}

/**
Expand All @@ -958,7 +959,8 @@ public function test_my_account_falls_back_to_user_login_when_display_name_is_em
$this->assertSame( $current_user->user_login, wp_strip_all_tags( $node_my_account->title ) );
$this->assertSame( $current_user->user_login, $node_my_account->meta['menu_title'] );

$this->assertSame( 'Howdy, ' . $current_user->user_login . 'Edit Profile', wp_strip_all_tags( $node_user_info->title ) );
$this->assertSame( 'Howdy, ' . $current_user->user_login . $current_user->user_login . 'Edit Profile', wp_strip_all_tags( $node_user_info->title ) );
$this->assertStringContainsString( "<span class='username' hidden>", $node_user_info->title );
}

/**
Expand Down
Loading