Advertisements

deactivate_plugins

Definition:
function deactivate_plugins( $plugins, $silent = false ) {}

Deactivate a single plugin or multiple plugins.
The deactivation hook is disabled by the plugin upgrader by using the $silent parameter.

Parameters

  • string|array $plugins: Single plugin or list of plugins to deactivate.
  • bool $silent: Prevent calling deactivation hooks. Default is false.

Defined actions

  • deactivate_plugin
    do_action( 'deactivate_plugin', $plugin, $network_wide );
  • deactivate_’.$plugin
    do_action( 'deactivate_' . $plugin, $network_wide );
  • deactivated_plugin
    do_action( 'deactivated_plugin', $plugin, $network_wide );

Source code

function deactivate_plugins( $plugins, $silent = false ) {

	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_wide = is_plugin_active_for_network( $plugin );



		if ( ! $silent )

			do_action( 'deactivate_plugin', $plugin, $network_wide );



		if ( $network_wide ) {

			$do_network = true;

			unset( $network_current[ $plugin ] );

		} else {

			$key = array_search( $plugin, $current );

			if ( false !== $key ) {

				$do_blog = true;

				array_splice( $current, $key, 1 );

			}

		}



		if ( ! $silent ) {

			do_action( 'deactivate_' . $plugin, $network_wide );

			do_action( 'deactivated_plugin', $plugin, $network_wide );

		}

	}



	if ( $do_blog )

		update_option('active_plugins', $current);

	if ( $do_network )

		update_site_option( 'active_sitewide_plugins', $network_current );

}

766

Advertisements

No comments yet... Be the first to leave a reply!

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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s

%d bloggers like this: