Disables the given plugin.

@param \CMS\Core\Package\PluginPackage $plugin The plugin to disable
@return bool True on success
171220
protected function _disable(PluginPackage $plugin)
    {
        $requiredBy = Plugin::checkReverseDependency($plugin->name);
        if (!empty($requiredBy)) {
            $names = [];
            foreach ($requiredBy as $p) {
                $names[] = $p->name();
            }

            $this->err(__d('installer', 'Plugin "{0}" cannot be disabled as it is required by: {1}', $plugin->humanName, implode(', ', $names)));

            return false;
        }

        if (!$this->params['no-callbacks']) {
            $trigger = $this->_triggerBeforeEvents($plugin);
            if (!$trigger) {
                return false;
            }
        }

        return $this->_finish($plugin);
    }
194083
public function disable() {

        global $wp_filesystem;

        $plugin = $GLOBALS[ 'redisObjectCache' ];

        if ( ! $plugin->object_cache_dropin_exists() ) {

            WP_CLI::error( __( 'No object cache drop-in found.', 'redis-cache' ) );

        } else {

            if ( ! $plugin->validate_object_cache_dropin() ) {

                WP_CLI::error( __( 'An unknown object cache drop-in was found. To use Redis run: wp redis update-dropin.', 'redis-cache' ) );

            } else {

                WP_Filesystem();

                if ( $wp_filesystem->delete( WP_CONTENT_DIR . '/object-cache.php' ) ) {
                    WP_CLI::success( __( 'Object cache disabled.', 'redis-cache' ) );
                } else {
                    WP_CLI::error( __( 'Object cache could not be disabled.', 'redis-cache' ) );
                }

            }

        }

    }
1033026
public function disablePlugins() {
		$plugins = func_get_args();
		if (is_array(current($plugins))) $plugins = current($plugins);

		foreach ($plugins as $plugin) {
			if(array_key_exists($plugin, $this->plugins)) {
				unset($this->plugins[$plugin]);
			}
		}
		return $this;
	}
1009671
def discard_plugin_preset(self):
        
        if self.has_plugin_preset:
            for name, plugin in list(self._active_plugins.items()):
                if id(plugin) in self._provided_by_preset:
                    self.release_plugin(name)
            self._active_preset.deactivate(self)
        self._active_preset = None
268670
public static function unload($plugin = null)
    {
        if (self::loaded($plugin)) {
            $locales = Configure::read('App.paths.locales');
            foreach ($locales as $key => $path) {
                if ($path == self::getLocalePath($plugin)) {
                    unset($locales[$key]);
                }
            }

            Configure::write('App.paths.locales', $locales);
        }

        parent::unload($plugin);
    }
817659
public function disablePlugin($pluginName)
	{
		if (isset($this->pluginsConfig[$pluginName]))
		{
			// Copy the plugin's config to remove the reference
			$pluginConfig = $this->pluginsConfig[$pluginName];
			unset($this->pluginsConfig[$pluginName]);

			// Update the value and replace the plugin's config
			$pluginConfig['isDisabled'] = true;
			$this->pluginsConfig[$pluginName] = $pluginConfig;
		}
	}
75090
private function executePluginInstall(Plugin $plugin)
    {
        try {
            $plugin->install();
        } catch (\Exception $e) {
            throw new \Piwik\Plugin\PluginException($plugin->getPluginName(), $e->getMessage());
        }
    }
1064924
private function registerPlugin(Plugin $plugin): void
    {
        if ($this->hasPlugin($plugin->getName())) {
            return;
        }

        $this->plugins[$plugin->getName()] = $plugin;
    }
750391
protected function uninstallAspects(Plugin $plugin)
    {
        $dto     = new DTO(array('PluginID'=>$plugin->PluginID));
        $aspects = $this->AspectService->findAll($dto)->getResults();

        foreach ($aspects as $aspect) {
            $this->AspectService->delete($aspect->Slug);
        }

    }
926190
public function disableAction(Plugin $plugin)
    {
        $this->pluginManager->disable($plugin);

        return new JsonResponse(
            $this->pluginManager->getPluginsData()
        );
    }
384882
def deactivate(name):
    
    if name in plugins:
        plugins[name].deactivate()
    else:
        raise Exception("plugin {} not found".format(name))
968222
public function validatePlugin($plugin)
    {
        if ($plugin instanceof WidgetInterface)
            return true;

        throw new \Exception(sprintf(
            'yimaWidgetator of type %s is invalid; must implement yimaWidgetator\Widget\WidgetInterface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin))
        ));
    }
949762
public static function isPluginAvailable($plugin)
    {
        $plugin = ucfirst($plugin);
        $dirs = self::path(self::get('atomik.dirs.plugins'));
        if (self::findFile("$plugin.php", $dirs) === false) {
            return self::findFile($plugin, $dirs) !== false;
        }
        return true;
    }
7652
public function disablePlugins($plugin)
    {
        $plugins = func_get_args();
        if (is_array(current($plugins))) {
            $plugins = current($plugins);
        }
        foreach ($plugins as $name) {
            unset($this->plugins[$name]);
        }
        return $this;
    }
1301850
protected function _finish(PluginPackage $plugin)
    {
        $pluginEntity = $this->Plugins
            ->find()
            ->where(['name' => $plugin->name])
            ->first();
        $pluginEntity->set('status', $this->params['status'] === 'enable' ? true : false);

        if (!$this->Plugins->save($pluginEntity)) {
            if ($this->params['status'] === 'enable') {
                $this->err(__d('installer', 'Plugin "{0}" could not be enabled due to an internal error.', $plugin->humanName));
            } else {
                $this->err(__d('installer', 'Plugin "{0}" could not be disabled due to an internal error.', $plugin->humanName));
            }

            return false;
        }

        snapshot();

        if (!$this->params['no-callbacks']) {
            $this->_triggerAfterEvents($plugin);
        }

        return true;
    }
93733
public function validatePlugin($plugin)
    {
        if ($plugin instanceof ObjectManagerInterface) {
            return;
        }

        throw new Exception\RuntimeException(sprintf(
            'Plugin of type %s is invalid; must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            DoctrineObjectManager::class
        ));
    }
445871
function _deactivate_plugin_hook() {
            $this->_logger->entrance( 'slug = ' . $this->_slug );

            if ( ! $this->is_user_admin() ) {
                return;
            }

            $is_network_deactivation  = fs_is_network_admin();
            $storage_keys_for_removal = array();

            $this->_admin_notices->clear_all_sticky();

            $storage_keys_for_removal[] = 'sticky_optin_added';
            if ( isset( $this->_storage->sticky_optin_added ) ) {
                unset( $this->_storage->sticky_optin_added );
            }

            if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
                // Remember that plugin was already installed.
                $this->_storage->is_plugin_new_install = false;
            }

            // Hook to plugin uninstall.
            register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );

            $this->clear_module_main_file_cache();
            $this->clear_sync_cron( $this->_is_network_active );
            $this->clear_install_sync_cron();

            if ( $this->is_registered() ) {
                if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
                    FS_Plugin_Updater::instance( $this )->delete_update_data();
                }

                if ( $is_network_deactivation ) {
                    // Send deactivation event.
                    $this->sync_installs( array(
                        'is_active' => false,
                    ) );
                } else {
                    // Send deactivation event.
                    $this->sync_install( array(
                        'is_active' => false,
                    ) );
                }
            } else {
                if ( ! $this->has_api_connectivity() ) {
                    // Reset connectivity test cache.
                    unset( $this->_storage->connectivity_test );

                    $storage_keys_for_removal[] = 'connectivity_test';
                }
            }

            if ( $is_network_deactivation ) {
                if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
                    unset( $this->_storage->sticky_optin_added_ms );
                }

                if ( ! empty( $storage_keys_for_removal ) ) {
                    $sites = self::get_sites();

                    foreach ( $sites as $site ) {
                        $blog_id = self::get_site_blog_id( $site );

                        foreach ( $storage_keys_for_removal as $key ) {
                            $this->_storage->remove( $key, false, $blog_id );
                        }

                        $this->_storage->save( $blog_id );
                    }
                }
            }

            // Clear API cache on deactivation.
            FS_Api::clear_cache();

            $this->remove_sdk_reference();
        }