Module Overrides

Jetpack modules can be activated or deactivated from the Modules page or within the Jetpack Settings, so try that first. For cases where you want to force on or off a module, this is possible with some code snippets.

By default, modules are toggled on or off from the Jetpack user interface either from the Modules page or the Jetpack Settings. When a code snippet is applied to force on or off a module, the toggle in the Jetpack user interface for that module will be disabled. If a module is completely removed, it will not be shown within the Jetpack user interface.

If you want to disable some Jetpack modules, you will primarily do that from the Jetpack user interface, either from the Modules page or the Jetpack Settings. The module override code snippet is only to be used to force on or off a feature, when the code is applied, the toggle in the Jetpack user interface for that module will be disabled. If a module is completely removed, it will not be shown within the Jetpack user interface.

Force Modules to be Disabled

In cases where Jetpack has a feature that is incompatible on a hosting platform, plugin, or theme, it may be preferable to disable the module in Jetpack. This can be done with a filter in Jetpack, however, we caution developers to consider the user experience when disabling such functionality.

For example, if a user expects a commonly used module to be available, and it’s not, that could cause confusion for the user.

Disable module with popover explanation

To disable a module but not remove it from the Jetpack user interface, we’ll use the option_jetpack_active_modules filter.

Here’s an example:

add_filter( 'option_jetpack_active_modules', 'jetpack_test_module_override' );
function jetpack_test_module_override( $modules ) {
    $disabled_modules = array(
        'sitemaps',
        'sso',
    );

    foreach ( $disabled_modules as $module_slug ) {
        $found = array_search( $module_slug, $modules );
        if ( false !== $found ) {
            unset( $modules[ $found ] );
        }
    }

    return $modules;
}

Completely removing the module

To disable a module and remove it from the Jetpack user interface, we can use the jetpack_get_available_modules filter.

Here’s an example:

add_filter( 'jetpack_get_available_modules', 'jetpack_docs_filter_module_example' );
function jetpack_docs_filter_module_example( $modules ) {
    unset( $modules['photon'] );

    return $modules;
}

Force Modules to be Active

In some cases, forcing a module to be active may be desired.

For example, to minimize bandwidth, a developer could force the Image CDN (formerly Photon) module to be active. In these cases, it is possible to force a module on with the jetpack_active_modules filter.

Here’s an example:

add_filter( 'option_jetpack_active_modules', 'jetpack_docs_filter_active_modules' );
function jetpack_docs_filter_active_modules( $modules ) {
    return array_values( array_merge( $modules, array( 'photon' ) ) );
}

What is overriding my modules?

Because of how WordPress filters work, any plugin or theme could be modifying the Jetpack modules that are available and/or active, which would result in unexpected behaviors of Jetpack.

To figure out where the modules are being overridden, try the following:

  • Change the theme then refresh the Jetpack user interface
  • Disable plugins one-by-one and refresh the Jetpack user interface each time
  • Download the wp-content directory of your site via FTP or SFTP and then search for jetpack_active_modules or jetpack_get_available_modules in the directory