Ban Jetpack from being installed on a site

Ban Jetpack from being installed on a site. After an end user creates a site, and runs the Woocommerce setup wizard, it is automatically installss the Jetpack plugin. Please advise on how to ban Jetpack from being installed on a site completely?

  • Ash
    • Code Norris

    Hello Dutchman

    I am not sure if that is even possible, I don’t see any hook to protect. But what you can do is to force deactivate the plugin.

    Please use the plugin code:

    add_action( 'init', function() {
    deactivate_plugins( WP_CONTENT_DIR . '/plugins/jetpack/jetpack.php' );
    } );

    You can use this code in your child theme’s functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,

    Ash