Last active
November 23, 2023 15:49
-
-
Save jackylamhk/0fd7ce4b8e704710391967f4b8724458 to your computer and use it in GitHub Desktop.
Remove Multisite admin menu bar items
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
// !! 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.