Large Network ‘My Sites’ menu replacement

<?php

/**
 * Loading all sites menu for large multisite
 * is inefficient and bad news
 */
function large_network_remove_wp_admin_bar_my_sites_menu() {
    remove_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
}
add_action( 'add_admin_bar_menus', 'large_network_remove_wp_admin_bar_my_sites_menu' );

/**
 * Let's replace that menu with one that has
 * links to the network dashboard instead.
 */
function large_network_replacement_my_sites_menu( $wp_admin_bar ) {
    if ( ! current_user_can( 'manage_network' ) ) {
        // bail.. no network menu for you!
        return;
    }
    
    $wp_admin_bar->add_menu( array(
        'id'    => 'prefix-my-sites',
        'title' => __( 'My Sites' ),
        'href'  => admin_url( 'my-sites.php' ),
    ));

    $wp_admin_bar->add_menu( array(
        'id'    => 'prefix-network-admin',
        'parent' => 'prefix-my-sites',
        'title' => __( 'Network Dashboard' ),
        'href'  => network_admin_url(),
    ));

    $wp_admin_bar->add_menu( array(
        'id'    => 'prefix-network-sites',
        'parent' => 'prefix-my-sites',
        'title' => __( 'Network Sites' ),
        'href'  => network_admin_url( 'sites.php' ),
    ));

    $wp_admin_bar->add_menu( array(
        'id'    => 'prefix-network-users',
        'parent' => 'prefix-my-sites',
        'title' => __( 'Network Users' ),
        'href'  => network_admin_url( 'users.php' ),
    ));
}
add_action( 'admin_bar_menu', 'large_network_replacement_my_sites_menu', 20 );