Skip to content

Instantly share code, notes, and snippets.

@samargulies
Created August 15, 2011 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samargulies/1146907 to your computer and use it in GitHub Desktop.
Save samargulies/1146907 to your computer and use it in GitHub Desktop.
Add a Network Admin link to the Admin Bar
<?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