Created
September 30, 2012 01:41
-
-
Save arod2634/3805606 to your computer and use it in GitHub Desktop.
Customize Wordpress Admin Toolbar
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 | |
// 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:[email protected]?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