disable( $disable ); } // Add the filter to both single site and multisite plugin lists. add_filter( 'option_active_plugins', array( $this, 'do_disabling' ) ); add_filter( 'site_option_active_sitewide_plugins', array( $this, 'do_disabling' ) ); // Allow other plugins to access this instance self::$instance = $this; } /** * Adds a filename to the list of plugins to disable */ public function disable( $file ) { $this->disabled[] = $file; } /** * Hooks in to the option_active_plugins and site_option_active_sitewide_plugins * filter and does the disabling * @param array $plugins WP-provided list of plugin filenames * @return array The filtered array of plugin filenames */ public function do_disabling( $plugins ) { if( count( $this->disabled ) ) { foreach( (array)$this->disabled as $plugin ) { if( current_filter() == 'option_active_plugins' ) $key = array_search( $plugin, $plugins ); else $key = !empty( $plugins[$plugin] ) ? $plugin : false; if( false !== $key ) unset( $plugins[$key] ); } } return $plugins; } } /* Begin customization */ if( defined( 'WP_LOCAL_DEV' ) && WP_LOCAL_DEV ) { $_pluginsToAutoDisable = array( 'w3-total-cache/w3-total-cache.php', 'wordpress-seo/wp-seo.php', 'google-analytics-for-wordpress/googleanalytics.php', ); new CWS_Disable_Plugins_When_Local_Dev( $_pluginsToAutoDisable ); }