Created
August 15, 2011 14:50
-
-
Save samargulies/1146907 to your computer and use it in GitHub Desktop.
Add a Network Admin link to the Admin Bar
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 | |
/** | |
* Add a Network Admin link to the Admin Bar. | |
*/ | |
function network_admin_adminbar() { | |
if( is_super_admin() ) { | |
global $wp_admin_bar; | |
// Remove the logout link so we can re-add it as the last item | |
$wp_admin_bar->remove_menu('logout'); | |
// Add the network admin link | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'my-account-with-avatar', | |
'id' => 'network_admin_adminbar', | |
'title' => __( 'Network Admin' ), | |
'href' => admin_url( 'network' ) | |
)); | |
// Finally, add the logout link back | |
$wp_admin_bar->add_menu( array( | |
'parent' => 'my-account-with-avatar', | |
'id' => 'logout', | |
'title' => __( 'Logout' ), | |
'href' => wp_logout_url() | |
)); | |
} | |
} | |
add_action( 'wp_before_admin_bar_render', 'network_admin_adminbar' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment