Remove Jetpack menu when not connected on a WordPress Multisite subsite (individual blog)

September 16, 2014

I run my own decent sized WordPress Multisite with the Jetpack plugin enabled at the network level. This allows me to manage at a high level view all the Jetpack connected blogs from a single Jetpack connection. Not all the blogs need to be running Jetpack, however because Jetpack is enabled network wide all blogs see the Jetpack menu item. Because I manage the connection I do not want individual admins seeing the Jetpack menu unless it is connected.

I whipped up the following code, which will remove the menu if Jetpack is not connected (yes, the code says “active”, poor wording choice in Jetpack itself) and individual blog admins are not allowed to manage their Jetpack connection.

add_action( 'admin_menu', function() {
    $jpms = Jetpack_Network::init();
    
    if( !Jetpack::is_active() && !$jpms->get_option( 'sub-site-connection-override' ) ) {
        remove_menu_page( 'jetpack' );
    }   
}, 1000 );

2 thoughts on “Remove Jetpack menu when not connected on a WordPress Multisite subsite (individual blog)

  1. Jeremy (September 16, 2014)

    yes, the code says “active”, poor wording choice in Jetpack itself

    Now if only you knew of a way to let Jetpack developers know about it, or to propose a change… 😉

    1. Ben Lobaugh (blobaugh) (September 16, 2014)

      Lol, that was proposed by me. And rejected….Hehe