bb_deactivate_plugins

Deactivate a single plugin or multiple plugins.

Description

bb_deactivate_plugins( (string|array) $plugins, (bool) $silent = false ); 

The deactivation hook is disabled by the plugin upgrader by using the $silent parameter.

Parameters (2)

0. $plugins (string|array)
Single plugin or list of plugins to deactivate.
1. $silent — Optional. (bool) => false
Optional, default is false. Prevent calling deactivate hook.

Usage

  1. if ( !function_exists( 'bb_deactivate_plugins' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-forums/bbpress/bb-admin/includes/functions.bb-plugin.php'; 
  3.  
  4. // Single plugin or list of plugins to deactivate. 
  5. $plugins = null; 
  6.  
  7. // Optional, default is false. Prevent calling deactivate hook. 
  8. $silent = false; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bb_deactivate_plugins($plugins, $silent); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-forums/bbpress/bb-admin/includes/functions.bb-plugin.php  
  1. function bb_deactivate_plugins( $plugins, $silent = false ) { 
  2. $active_plugins = (array) bb_get_option( 'active_plugins' ); 
  3.  
  4. if ( !is_array( $plugins ) ) { 
  5. $plugins = array( $plugins ); 
  6.  
  7. foreach ( $plugins as $plugin ) { 
  8. $plugin = bb_plugin_basename( trim( $plugin ) ); 
  9. if ( !in_array( $plugin, $active_plugins ) ) { 
  10. continue; 
  11. // Remove the deactivated plugin 
  12. array_splice( $active_plugins, array_search( $plugin, $active_plugins ), 1 ); 
  13. if ( !$silent ) { 
  14.  
  15. bb_update_option( 'active_plugins', $active_plugins );