Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Customize Wordpress Admin Toolbar
<?php
// Customize Admin toolbar if you do desiced to keep it around...
function change_toolbar($wp_toolbar) {
$wp_toolbar->remove_node('comments');
$wp_toolbar->add_node(array(
'id' => 'myhelp',
'title' => 'Help',
'meta' => array('target' => 'help')
));
$wp_toolbar->add_node(array(
'id' => 'mysupport',
'title' => 'Email Support Team',
'parent' => 'myhelp',
'href' => 'mailto:myemailaddress@mywebsite.com?subject='.get_bloginfo('name').'%20Support%20Request'
));
}
add_action('admin_bar_menu', 'change_toolbar', 999);
// Remove toolbar menu items
function my_admin_bar() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo');
$wp_admin_bar->remove_menu('about');
$wp_admin_bar->remove_menu('wporg');
$wp_admin_bar->remove_menu('documentation');
$wp_admin_bar->remove_menu('support-forums');
$wp_admin_bar->remove_menu('feedback');
$wp_admin_bar->remove_menu('customize');
$wp_admin_bar->remove_menu('themes');
}
add_action( 'wp_before_admin_bar_render', 'my_admin_bar' );
//Change the "Howdy" Text in admin bar
function wp_admin_bar_integrity_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 ) {
/* Add the "My Account" menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Hello - %1$s' , 'themeName'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array(
'class' => $class,
),
) );
}
}
add_action( 'admin_bar_menu', 'wp_admin_bar_integrity_custom_account_menu', 11 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment