disable active plugins for specific theme
I want to disable some plugins from a specific theme.I am using deactivate_plugins
hook to deactivate. following is my code.
add_action('wp_head','disable_plugins');
function disable_plugins(){
include_once(ABSPATH.'wp-admin/includes/plugin.php');
$current_theme = wp_get_theme();
$current_theme_name = $current_theme-Name;
if($current_theme_name == 'Twenty Sixteen'){
if ( is_plugin_active('press-release/init.php') ) {
deactivate_plugins('press-release/init.php');
}
}
}
This code deactivate plugins at wp_head hook but issue is I want active plugins to disable only when theme is Twenty Sixteen while wants to keep enable or disable as it was already on other themes.
But my code deactivates plugins for all themes. :(
Other solution was of deregistering css and js files of each plugin but its tough to find all css and js files for all plugins and it will also deregister for all themes while I want active plugins to disable on specific theme.
Please help me if you can in this case. Thanks.