Skip to content

Instantly share code, notes, and snippets.

@joshualynch
Created September 17, 2012 05:31
Show Gist options
  • Save joshualynch/3735711 to your computer and use it in GitHub Desktop.
Save joshualynch/3735711 to your computer and use it in GitHub Desktop.
Replace WordPress "My Sites" Menu for Super Admins
<?php
/*
* Disable My Sites menu in toolbar for Super Admins & replace with custom menu
* Docs: http://codex.wordpress.org/Class_Reference/WP_Admin_Bar
*/
function jpl_remove_my_sites( $wp_admin_bar ) {
if (current_user_can('manage_network'))
$wp_admin_bar->remove_node('my-sites');
}
add_action( 'admin_bar_menu', 'jpl_remove_my_sites', 999 );
function jpl_my_sites($admin_bar) {
if (current_user_can('manage_network'))
$admin_bar->add_menu( array(
'id' => 'jpl-my-sites',
'title' => 'My Sites',
'href' => admin_url('my-sites.php'),
'meta' => array(
'title' => __('My Sites'),
),
));
$admin_bar->add_menu( array(
'id' => 'jpl-network-admin',
'parent' => 'jpl-my-sites',
'title' => 'Network Dashboard',
'href' => network_admin_url(),
));
$admin_bar->add_menu( array(
'id' => 'jpl-network-sites',
'parent' => 'jpl-my-sites',
'title' => 'Network Sites',
'href' => network_admin_url('sites.php'),
));
$admin_bar->add_menu( array(
'id' => 'jpl-network-users',
'parent' => 'jpl-my-sites',
'title' => 'Network Users',
'href' => network_admin_url('users.php'),
));
}
add_action('admin_bar_menu', 'jpl_my_sites', 20);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment