• Create new php file in root folder, and paste this code, ex: plugionaction.php

    if (isset($_GET['act'])) {
        include("wp-load.php");
        if ($_GET['act'] == 'active') {
            run_activate_plugin('akismet/akismet.php');
        }
        if ($_GET['act'] == "deactive") {
            deactivate_plugins('akismet/akismet.php');
        }
    }
    
    function run_activate_plugin($plugin) {
        $current = get_option('active_plugins');
        $plugin = plugin_basename(trim($plugin));
    
        if (!in_array($plugin, $current)) {
            $current[] = $plugin;
            sort($current);
            do_action('activate_plugin', trim($plugin));
            update_option('active_plugins', $current);
            do_action('activate_' . trim($plugin));
            do_action('activated_plugin', trim($plugin));
        }
    
        return null;
    }

    Now we can run:
    https://yourwebsite.com/plugionaction.php?act=active
    https://yourwebsite.com/plugionaction.php?act=deactive

    [sig moderated as per the Forum Rules]

  • The topic ‘Active and Deactive Plugin with Code’ is closed to new replies.