Skip to content

Instantly share code, notes, and snippets.

@rveitch
Last active August 29, 2015 14:27
Show Gist options
  • Save rveitch/92d0873cb6d686e24edd to your computer and use it in GitHub Desktop.
Save rveitch/92d0873cb6d686e24edd to your computer and use it in GitHub Desktop.
Block a network-activated plugin for a single WordPress Multisite blog site.
<?php
//NOTE: If filters do not work due to firing too late, change the hook to on "init"
//Example: The following will disable BuddyPress on blog with id 2.
add_filter('site_option_active_sitewide_plugins', 'modify_sitewide_plugins');
function modify_sitewide_plugins($value) {
global $current_blog;
if( $current_blog->blog_id == 2 ) {
unset($value['buddypress/bp-loader.php']);
}
return $value;
}
/*** ALTERNATIVE ***/
/**
* Disable plugin (this will network deactivate the plugin)
*/
function deactivate_plugin_conditional() {
if ( is_plugin_active('buddypress/bp-loader.php') ) {
deactivate_plugins('buddypress/bp-loader.php');
}
}
add_action( 'muplugins_loaded', 'deactivate_plugin_conditional' );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment