Keeping All Jetpack Modules Deactivated (Disabled) By Default In WordPress

When using Jetpack by WordPress.com plugin, whenever any new module is introduced, it gets automatically enabled on your WordPress installation and in-case of WordPress multisite network, all websites experiences the same issue.

In this lesson you will learn about keeping all Jetpack modules deactivated by default.

All you got to do is add following code in your theme’s function.php file or in Code Snippet plugin:

add_filter( ‘jetpack_get_default_modules’, ‘__return_empty_array’ );

Recently Jetpack has introduced a new filter that allows you to stop auto activation of specific Jetpack modules:

jetpack_get_default_modules

For instance: Suppose you want to disable auto activation of Widget Visibility module then use it like this:

// To disable the auto-activation of Jetpack's Widget Visibility module:
add_filter( 'jetpack_get_default_modules', 'disable_jetpack_widget_visibility_autoactivate' );
function disable_jetpack_widget_visibility_autoactivate( $modules ) {
    return array_diff( $modules, array( 'widget-visibility' ) );
}
// Or, to disable the functionality in your own plugin if the user activates it in Jetpack:
if ( ! class_exists( 'Jetpack' ) || ! Jetpack::is_module_active( 'widget-visibility' ) ) {
    // It's not there, do as you like!
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.