Skip to content
Closed
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
13 changes: 6 additions & 7 deletions src/wp-includes/admin-bar.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ function wp_admin_bar_sidebar_toggle( $wp_admin_bar ) {
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance.
*/
function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$user_id = get_current_user_id();

if ( ! $user_id ) {
return;
Expand All @@ -275,10 +274,11 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
$profile_url = false;
}

$avatar = get_avatar( $user_id, 26 );
$avatar = get_avatar( $user_id, 26 );
$current_user = wp_get_current_user();

/* translators: %s: Current user's display name. */
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
Comment on lines +278 to 281
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the $current_user is only used once, I'll update as follows in commit:

Suggested change
$current_user = wp_get_current_user();
/* translators: %s: Current user's display name. */
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $current_user->display_name . '</span>' );
/* translators: %s: Current user's display name. */
$howdy = sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . wp_get_current_user()->display_name . '</span>' );

$class = empty( $avatar ) ? '' : 'with-avatar';

$wp_admin_bar->add_node(
array(
Expand All @@ -287,9 +287,8 @@ function wp_admin_bar_my_account_item( $wp_admin_bar ) {
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
/* translators: %s: Current user's display name. */
'menu_title' => sprintf( __( 'Howdy, %s' ), $current_user->display_name ),
'class' => empty( $avatar ) ? '' : 'with-avatar',
'menu_title' => wp_strip_all_tags( $howdy ),
'tabindex' => ( false !== $profile_url ) ? '' : 0,
),
)
Expand Down
Loading