Skip to content

Instantly share code, notes, and snippets.

@jackylamhk
Last active November 23, 2023 15:49
Show Gist options
  • Save jackylamhk/0fd7ce4b8e704710391967f4b8724458 to your computer and use it in GitHub Desktop.
Save jackylamhk/0fd7ce4b8e704710391967f4b8724458 to your computer and use it in GitHub Desktop.
Remove Multisite admin menu bar items
// !! DO NOT DISABLE
// The WP Admin UI enumerates all sites so if this
// is disabled the UI will take forever to load
function remove_admin_toolbar_items( $bar ) {
$bar -> remove_node( 'wp-logo' );
// Remove "My Sites" item if not primary site
if (get_current_blog_id() != 1 ) {
$bar -> remove_node( 'my-sites' );
}
}
add_action('admin_bar_menu', 'remove_admin_toolbar_items', 500);
@jackylamhk
Copy link
Author

jackylamhk commented Nov 23, 2023

With this snippet enabled, multisites WP Admin UI load time went from 30s to 5s.

To be honest I'm not sure why this works. I'm assuming that by removing the site enumeration, the object cache caches the admin menu bar item with the "My Sites" item taken out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment