Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ParhamG
Last active January 25, 2016 02:50
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ParhamG/6494979 to your computer and use it in GitHub Desktop.
Save ParhamG/6494979 to your computer and use it in GitHub Desktop.
If you are annoyed with this automatic activation of Jetpack modules, specially on a multi-site setup, here is how to completely disable modules across the entire network without having to visit each site and disable modules one by one.Since version 2.4, Jetpack has introduced 'jetpack_get_available_modules' filter, which allows you to black lis…
<?php
/*
Plugin Name: Blacklist Jetpack Modules
Plugin URI: https://gist.github.com/ParhamG/6494979
Description: Blacklist Jetpack modules.
Author: Parham Ghaffarian
Author URI: http://parh.am
Version: 0.1.3.4.1
*/
function blacklist_jetpack_modules( $modules ){
$jp_mods_to_disable = array(
// 'shortcodes',
// 'widget-visibility',
// 'contact-form',
// 'shortlinks',
// 'infinite-scroll',
// 'wpcc',
// 'tiled-gallery',
// 'json-api',
// 'publicize',
// 'vaultpress',
// 'custom-css',
// 'post-by-email',
// 'widgets',
// 'comments',
// 'minileven',
// 'latex',
// 'gravatar-hovercards',
// 'enhanced-distribution',
// 'notes',
// 'subscriptions',
// 'stats',
// 'after-the-deadline',
// 'carousel',
// 'photon',
// 'sharedaddy',
// 'omnisearch',
// 'mobile-push',
// 'likes',
// 'videopress',
// 'gplus-authorship',
// 'sso',
// 'monitor',
// 'markdown',
// 'verification-tools',
// 'related-posts',
// 'custom-content-types',
// 'site-icon',
// 'protect',
);
foreach ( $jp_mods_to_disable as $mod ) {
if ( isset( $modules[$mod] ) ) {
unset( $modules[$mod] );
}
}
return $modules;
}
add_filter( 'jetpack_get_available_modules', 'blacklist_jetpack_modules' );
?>
@jaydansand
Copy link

Great snippet! Just because I hate PHP errors in my logs, and in case a given module has already been altered by another jetpack_get_available_modules filter, I added an isset() check on $modules[$mod] before attempting the unset():

foreach ( $jp_mods_to_disable as $mod ) {
  if ( isset( $modules[$mod] ) ) {
    unset( $modules[$mod] );
  }
}

@ParhamG
Copy link
Author

ParhamG commented Jan 3, 2014

Thanks @jaydansand! Just updated it with the isset() check and added the new modules introduced in v2.7.

@leslieg
Copy link

leslieg commented Jun 29, 2014

I couldn't get this to work. Can you confirm that it should work with recent 3.9.1 WP and most recent version of Jetpack? I have multisite set up, put the above file in mu-plugins and uncommented a few items. I end up seeing the code displayed in text near the top of the page in the admin interface and the jetpack modules are still there...

@ParhamG
Copy link
Author

ParhamG commented Aug 8, 2014

@leslieg Try the updated version. PHP tags were missing in the file and I just fixed that. The code is updated for the most recent version of Jetpack which is 3.1.1 as of now.

@mrjarbenne
Copy link

Thanks for this awesome snippet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment