Activate / Deactivate plugin from theme


Paste the below code in your ‘functions.php’

function deactivate_plugin_conditional() {
    if ( is_plugin_active('plugin_folder_name/plugin_name.php') ) {
    activate_plugins('plugin_folder_name/plugin_name.php');    
    }
    else
    {
    deactivate_plugins('plugin_folder_name/plugin_name.php');    
    }
}
add_action( 'admin_init', 'deactivate_plugin_conditional' );
Advertisements

One thought on “Activate / Deactivate plugin from theme

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s