remove redundancy
Source Link
fuxia
  • 103.9k
  • 34
  • 238
  • 432

disable active plugins for specific theme wordpress

I want to disable some plugins from a specific wordpress theme.I am using deactivate_pluginsdeactivate_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.

disable active plugins for specific theme wordpress

I want to disable some plugins from a specific wordpress 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.

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.

Source Link

disable active plugins for specific theme wordpress

I want to disable some plugins from a specific wordpress 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.