stevegs
Forum Replies Created
-
Forum: Plugins
In reply to: [Admin and Site Enhancements (ASE)] Hide Howdy not workingNone of these suggestions so far have worked for me, though I’ve managed to sort it out based on that proposed by @ankitbnl406
It seems that WordPress has finally realised their 19th century cowboy greeting is not favoured this side of the Atlantic. Having managed to replace it for some time, mine started greeting me with the almost as naff “Hi, {username}” as from WP 6.6.1 – I assume I don’t get “Howdy” is because I have the British (dare I say ‘proper’) English dictionary installed. (Though I note the header on this page, when logged in, still greets me with “Howdy”.)
The following simple code in functions.php does exactly what I want – no need for a plugin:
function replace_howdy( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node('my-account');
$title = $my_account->title;
/* Look for a comma separator in $title:
If there isn't one, don't do anything, but if there is, split the greeting into two and discard the left half (ie. the comma and all that precedes it).
Then prepend the remainder with your chosen greeting, eg. in French it could be 'Bonjour'.
This will future-proof it in case WP changes the greeting again (though if the comma gets removed, we'll have to think again…)
If you want to keep the comma, use $x instead of $x + 1 below.
If you don't want anything, just set $newtitle to a NULL string. */
$x = strpos ($title, ',');
if ($x) {
$newtitle = 'Hello' . substr($title, $x + 1 );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
}
// Set the priority to 10000 or greater to stop PHP errors:
add_filter( 'admin_bar_menu', 'replace_howdy', 10000 );(Just realised this does what @ankitbnl406’s later post does in a different way.)
- This reply was modified 3 months ago by stevegs. Reason: Added last paragraph
Forum: Plugins
In reply to: [White Label CMS] Can not hide ‘Howdy’ with WP 6.6.1 anymoreNone of these suggestions so far have worked for me, though I’ve managed to sort it out based on that proposed by @ankitbnl406
It seems that WordPress has finally realised their 19th century cowboy greeting is not favoured this side of the Atlantic. Having managed to replace it for some time, mine started greeting me with the almost as naff “Hi, {username}” as from WP 6.6.1 – I assume this is because I have the British (dare I say ‘proper’) English dictionary installed. (Though I note the header on this page, when logged in, still greets me with “Howdy”.) The following simple code in functions.php does exactly what I want – no need for a plugin:
function replace_howdy( $wp_admin_bar ) {
$my_account = $wp_admin_bar->get_node('my-account');
$title = $my_account->title;
/* Look for a comma separator in $title: if there isn't one, don't do anything, but if there is, split the greeting into two and discard the left half (ie. the comma and all that precedes it). Then prepend the remainder with your chosen greeting, eg. in French it could be 'Bonjour'. This will future-proof it in case WP wants to change the greeting again (though if the comma gets removed, we'll have to think again…)
If you want to keep the comma, use $x instead of $x + 1 below. */
$x = strpos ($title, ',');
if ($x) {
$newtitle = 'Hello' . substr($title, $x + 1 );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
}
// Set the priority to 10000 or greater to stop PHP errors:
add_filter( 'admin_bar_menu', 'replace_howdy', 10000 );- This reply was modified 3 months ago by stevegs.