Created
October 22, 2011 18:36
-
-
Save eteubert/1306338 to your computer and use it in GitHub Desktop.
WordPress How To: Change the Admin Greeting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# wp-admin/admin-header.php | |
$links = array(); | |
// Generate user profile and info links. | |
$links[5] = sprintf( __('Howdy, %1$s'), $user_identity ); | |
/** ... more $links definitions ... **/ | |
$links = apply_filters( 'admin_user_info_links', $links, $current_user ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rename_howdy_to_hello( $links, $current_user ) { | |
$links[ 5 ] = sprintf( __( 'Hello, %1$s' ), $current_user->user_nicename ); | |
return $links; | |
} | |
add_filter( 'admin_user_info_links', 'rename_howdy_to_hello', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function rename_howdy_to_funny_greetings( $links, $current_user ) { | |
$current_hour = date('G'); | |
// default greeting | |
$greeting = sprintf( __( 'Hello, %1$s' ); | |
// special greetings | |
if ( $current_hour >= 22 || $current_hour < 4 ) { | |
$greeting = sprintf( __( 'Hey, %1$s. Still working?' ); | |
} | |
if ( $current_hour >= 4 && $current_hour < 10 ) { | |
$greeting = sprintf( __( 'Good morning, %1$s!' ); | |
} | |
$links[ 5 ] = $greeting, $current_user->user_nicename ); | |
return $links; | |
} | |
add_filter( 'admin_user_info_links', 'rename_howdy_to_funny_greetings', 10, 2 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ericteubert: ~/Sites/wordpress-single | |
➜ ack Howdy | |
wp-admin/admin-header.php | |
154:$links[5] = sprintf( __('Howdy, %1$s'), $user_identity ); | |
wp-admin/network.php | |
111: '<p>' . __('Once you add this code and refresh your browser, multisite should be enabled. This screen will keep an archive of the added code. You can toggle between Network Admin and Site Admin by clicking on the Howdy (Username) dropdown in the upper right of the administration area.') . '</p>' . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment