Replace “Howdy” in the admin bar
The admin bar greets users with just their name instead of “Howdy, name”.
<?php
add_action(
'admin_bar_menu',
static function ( $bar ) {
$node = $bar->get_node( 'my-account' );
if ( ! $node ) {
return;
}
$user = wp_get_current_user();
$title = str_replace(
/* translators: %s: current user's display name */
sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $user->display_name . '</span>' ),
'<span class="display-name">' . $user->display_name . '</span>',
(string) $node->title
);
$bar->add_node(
array(
'id' => 'my-account',
'title' => $title,
'meta' => array_merge( (array) $node->meta, array( 'menu_title' => $user->display_name ) ),
)
);
},
9999
);
In these packs
- More admin tweaks: Useful columns, a tidier admin bar, a welcome box for clients, and fewer menus for editors.