In a Child Theme functions.php (or create your custom function) use this example where the default is “Howdy” and is replaced with “Welcome”:
function cust_replace_howdy( $text ) {
$newtext = 'Welcome';
if ( is_user_logged_in() ) {
$text = str_replace( 'Howdy', $newtext, $text );
}
return $text;
}
add_filter( 'gettext', 'cust_replace_howdy' );
You can also use this to show or hide the admin bar for non-admin users:
if ( current_user_can( 'manage_options') ) {
add_filter ('show_admin_bar', '__return_true');
} else {
add_filter ('show_admin_bar', '__return_false');
}
Thank you, that worked a treat. And it got me to thinking about adding a little bit of magic to it.
function howdy_message($translated_text, $text, $domain) {
$message = public_holiday();
$new_message = str_replace('Howdy', $message, $text);
return $new_message;
}
add_filter('gettext', 'howdy_message', 10, 3);
//
function public_holiday() {
$date = date('d-m');
switch($date) {
case '01-01':
$message = 'Happy New Years';
break;
case '21-06':
$message = 'Happy Yule';
break;
case '21-12':
$message = 'Happy Summer Solstice';
break;
case '25-12':
$message = 'Merry Christmas';
break;
default:
$message = 'Kia ora';
}
return $message;
}
The thing is, up until the latest WordPress update New Zealand WP sites said “Kia Ora” – not “G’day” which, as kiwihawk said, is Australian. Kia Ora is our traditional greeting and was correct. Is there a reason it was changed in the latest update?
Is there a reason it was changed in the latest update?
You would have to ask core folks that, or whoever provided the language file.