Have you ever worked with a client where you try to customize the WordPress backend experience for them? Maybe you've added a custom panel widget, removed menu items, or even created custom writing panels. Well, Greg Kerstin (@graphicagenda) was working on a project where he wanted to modify the WordPress admin bar text. It usually says Howdy, Username. He was kind enough to send us a snippet where he shows how to change the text and replace it with Welcome..
All you have to do is paste the following code into your theme's functions.php file, or create a plugin for the site.
add_action ('admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11); función wp_admin_bar_my_custom_account_menu ($ wp_admin_bar) $ user_id = get_current_user_id (); $ current_user = wp_get_current_user (); $ profile_url = get_edit_profile_url ($ user_id); if (0! = $ user_id) / * Agrega el menú "Mi cuenta" * / $ avatar = get_avatar ($ user_id, 28); $ howdy = sprintf (__ ('Bienvenido,% 1 $ s'), $ current_user-> display_name); $ class = empty ($ avatar)? ": 'with-avatar'; $ wp_admin_bar-> add_menu (array ('id' => 'my-account', 'parent' => 'top-secundario', 'título' => $ howdy. $ avatar, 'href' => $ profile_url, 'meta' => array ('class' => $ class,),));
And you're done.