deactivate_plugins

The timeline below displays how wordpress function deactivate_plugins has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Deactivates a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|string[] $plugins      Single plugin or list of plugins to deactivate.
 * @param bool            $silent       Prevent calling deactivation hooks. Default false.
 * @param bool|null       $network_wide Whether to deactivate the plugin for all sites in the network.
 *                                      A value of null will deactivate plugins for both the network
 *                                      and the current site. Multisite only. Default null.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = false;
    $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current, true);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if ($do_blog && wp_is_recovery_mode()) {
            list($extension) = explode('/', $plugin);
            wp_paused_plugins()->delete($extension);
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 5.5

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|string[] $plugins      Single plugin or list of plugins to deactivate.
 * @param bool            $silent       Prevent calling deactivation hooks. Default false.
 * @param bool|null       $network_wide Whether to deactivate the plugin for all sites in the network.
 *                                      A value of null will deactivate plugins for both the network
 *                                      and the current site. Multisite only. Default null.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = false;
    $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current, true);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if ($do_blog && wp_is_recovery_mode()) {
            list($extension) = explode('/', $plugin);
            wp_paused_plugins()->delete($extension);
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 5.4

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|string[] $plugins      Single plugin or list of plugins to deactivate.
 * @param bool            $silent       Prevent calling deactivation hooks. Default false.
 * @param bool|null       $network_wide Whether to deactivate the plugin for all sites in the network.
 *                                      A value of null will deactivate plugins for both the network
 *                                      and the current site. Multisite only. Default null.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = false;
    $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if ($do_blog && wp_is_recovery_mode()) {
            list($extension) = explode('/', $plugin);
            wp_paused_plugins()->delete($extension);
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 5.3

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 *  A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = false;
    $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if ($do_blog && wp_is_recovery_mode()) {
            list($extension) = explode('/', $plugin);
            wp_paused_plugins()->delete($extension);
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network.
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 5.2

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 *  A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if ($do_blog && wp_is_recovery_mode()) {
            list($extension) = explode('/', $plugin);
            wp_paused_plugins()->delete($extension);
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network.
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 5.1

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 *  A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the plugin file relative to the plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network.
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 4.8

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the main plugin file from plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Path to the main plugin file from plugins directory.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network.
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 4.7

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action("deactivate_{$plugin}", $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin basename.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 4.6

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by register_deactivation_hook().
             * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update), this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_' . $plugin, $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin basename.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 4.1

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by
             * {@see register_deactivation_hook()}. The dynamic portion of the
             * hook name, `$plugin`, refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_' . $plugin, $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin basename.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 3.9

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires before a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires as a specific plugin is being deactivated.
             *
             * This hook is the "deactivation" hook used internally by
             * register_deactivation_hook(). The dynamic portion of the
             * hook name, $plugin. refers to the plugin basename.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_' . $plugin, $network_deactivating);
            /**
             * Fires after a plugin is deactivated.
             *
             * If a plugin is silently deactivated (such as during an update),
             * this hook does not fire.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin basename.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}

WordPress Version: 3.7

/**
 * Deactivate a single plugin or multiple plugins.
 *
 * The deactivation hook is disabled by the plugin upgrader by using the $silent
 * parameter.
 *
 * @since 2.5.0
 *
 * @param string|array $plugins Single plugin or list of plugins to deactivate.
 * @param bool $silent Prevent calling deactivation hooks. Default is false.
 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
 * 	A value of null (the default) will deactivate plugins for both the site and the network.
 */
function deactivate_plugins($plugins, $silent = false, $network_wide = null)
{
    if (is_multisite()) {
        $network_current = get_site_option('active_sitewide_plugins', array());
    }
    $current = get_option('active_plugins', array());
    $do_blog = $do_network = false;
    foreach ((array) $plugins as $plugin) {
        $plugin = plugin_basename(trim($plugin));
        if (!is_plugin_active($plugin)) {
            continue;
        }
        $network_deactivating = false !== $network_wide && is_plugin_active_for_network($plugin);
        if (!$silent) {
            /**
             * Fires for each plugin being deactivated in deactivate_plugins(), before deactivation
             * and when the $silent parameter is false.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_plugin', $plugin, $network_deactivating);
        }
        if (false !== $network_wide) {
            if (is_plugin_active_for_network($plugin)) {
                $do_network = true;
                unset($network_current[$plugin]);
            } elseif ($network_wide) {
                continue;
            }
        }
        if (true !== $network_wide) {
            $key = array_search($plugin, $current);
            if (false !== $key) {
                $do_blog = true;
                unset($current[$key]);
            }
        }
        if (!$silent) {
            /**
             * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation
             * and when the $silent parameter is false.
             *
             * The action concatenates the 'deactivate_' prefix with the plugin's basename
             * to create a dynamically-named action.
             *
             * @since 2.0.0
             *
             * @param bool $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                   or just the current site. Multisite only. Default is false.
             */
            do_action('deactivate_' . $plugin, $network_deactivating);
            /**
             * Fires for each plugin being deactivated in deactivate_plugins(), after deactivation
             * and when the $silent parameter is false.
             *
             * @since 2.9.0
             *
             * @param string $plugin               Plugin path to main plugin file with plugin data.
             * @param bool   $network_deactivating Whether the plugin is deactivated for all sites in the network
             *                                     or just the current site. Multisite only. Default is false.
             */
            do_action('deactivated_plugin', $plugin, $network_deactivating);
        }
    }
    if ($do_blog) {
        update_option('active_plugins', $current);
    }
    if ($do_network) {
        update_site_option('active_sitewide_plugins', $network_current);
    }
}