-
-
Save robneu/7872308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* An array of Jetpack modules which will be whitelisted. | |
* | |
* This whitelist contains a list of all Jetpack modules which we would like users | |
* to have access to. Anything not listed here will be programmatically disabled. | |
* | |
* @author FAT Media, LLC | |
* @link http://wpbacon.com/disable-jetpack-modules/ | |
*/ | |
function prefix_jetpack_whitelist() { | |
$whitelist = array( | |
'publicize', | |
'enhanced-distribution', | |
'sharedaddy', | |
); | |
return $whitelist; | |
} | |
add_filter( 'jetpack_get_available_modules', 'prefix_make_non_whitelisted_unavailable' ); | |
/** | |
* Make all non-whitelisted Jetpack modules unavailable. | |
* | |
* This will prevent all non-whitelisted Jetpack modules from displaying. | |
* As long as this is in use only whitelisted modules can be seen by the user. | |
* | |
* @author FAT Media, LLC | |
*/ | |
function prefix_make_non_whitelisted_unavailable( $modules ) { | |
$whitelist = prefix_jetpack_whitelist(); | |
$modules = array_intersect_key( $modules, array_flip( $whitelist ) ); | |
return $modules; | |
} | |
add_action( 'init', 'prefix_force_deactivate_non_whitelisted' ); | |
/** | |
* Force disable all non-whitelisted Jetpack modules. | |
* | |
* This will force all non-whitelisted Jetpack modules to be disabled. | |
* As long as this is in use, only whitelisted modules can be activated. | |
* | |
* @author Jeremy Herve | |
* @author FAT Media, LLC | |
*/ | |
function prefix_force_deactivate_non_whitelisted() { | |
if ( ! class_exists( 'Jetpack_Options' ) ) { | |
return; | |
} | |
$whitelist = prefix_jetpack_whitelist(); | |
Jetpack_Options::update_option( 'active_modules', array_unique( $whitelist ) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment