Validate the plugin

Ensure we have a widget.

@param  mixed $plugin

@return true
@throws \Exception
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))
        ));
    }
484900
protected function activatePlugin(string $plugin): void
    {
        require_once WPMU_PLUGIN_DIR.'/'.$plugin;

        do_action('activate_'.$plugin);

        $plugins = $this->getActivePlugins();
        $plugins[] = $plugin;

        $this->setActivePlugins($plugins);
    }
1342689
protected function loadPlugin($plugin)
    {
        $pluginName = get_class($plugin);

        $apiVersion = self::API_VERSION_0_9;
        if ($plugin instanceof PicoPluginInterface) {
            if (defined($pluginName . '::API_VERSION')) {
                $apiVersion = $pluginName::API_VERSION;
            } else {
                $apiVersion = self::API_VERSION_1_0;
            }
        }

        if (!isset($this->plugins[$apiVersion][$pluginName])) {
            // PicoDeprecated currently supports all previous API versions
            $this->plugins[$apiVersion][$pluginName] = $plugin;
        }
    }
784438
def valid_api_plugin(self, plugin):
        
        if (issubclass(plugin, APIPlugin)       and
            hasattr(plugin, 'plugin_type')      and plugin.plugin_type == 'api' and
            hasattr(plugin, 'request')          and plugin.request != None and
            hasattr(plugin, 'request_class')    and plugin.request_class != None and
            hasattr(plugin, 'response_class')   and plugin.response_class != None):
            return True
        return False
276745
public function validatePlugin($plugin)
    {
        if ($plugin instanceof DomainServiceInterface) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create domain service for %s; '
                . 'Domain service must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            DomainServiceInterface::class
        ));
    }
852704
public function validatePlugin($plugin)
    {
        if ($plugin instanceof MapperInterface) {
            return; // we're okay
        }

        throw new \InvalidArgumentException(sprintf(
            'Can\'t create mapper for %s; Mapper must implement %s',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            MapperInterface::class
        ));
    }
1351729
function validateService($pluginInstance)
    {
        if (!is_object($pluginInstance))
            throw new \Exception(sprintf('Can`t resolve to (%s) Instance.', $pluginInstance));

        if (!$pluginInstance instanceof iGuard)
            throw new exContainerInvalidServiceType('Invalid Plugin Of Content Object Provided.');

    }
1015951
public function register(PluginBundleInterface $plugin)
    {
        $this->validate($plugin, false);

        return $this->dbWriter->insert($plugin, $this->validator->getPluginConfiguration());
    }
683255
public static function isEnabled($plugin)
    {
        $plugin_list = static::getPluginList();

        return (is_array($plugin_list) && in_array($plugin, $plugin_list)) ? true : false;
    }
73418
private function installPluginIfNecessary(Plugin $plugin)
    {
        $pluginName = $plugin->getPluginName();
        $saveConfig = false;

        // is the plugin already installed or is it the first time we activate it?
        $pluginsInstalled = $this->getInstalledPluginsName();

        if (!$this->isPluginInstalled($pluginName)) {
            $this->executePluginInstall($plugin);
            $pluginsInstalled[] = $pluginName;
            $this->updatePluginsInstalledConfig($pluginsInstalled);
            $updater = new Updater();
            $updater->markComponentSuccessfullyUpdated($plugin->getPluginName(), $plugin->getVersion(), $isNew = true);
            $saveConfig = true;

            /**
             * Event triggered after a new plugin has been installed.
             *
             * Note: Might be triggered more than once if the config file is not writable
             *
             * @param string $pluginName The plugin that has been installed.
             */
            Piwik::postEvent('PluginManager.pluginInstalled', array($pluginName));
        }

        if ($saveConfig) {
            PiwikConfig::getInstance()->forceSave();
            $this->clearCache($pluginName);
        }
    }
1063084
public function unloadPlugin($plugin)
    {
        $this->resetTransientCache();

        if (!($plugin instanceof Plugin)) {
            $oPlugin = $this->loadPlugin($plugin);
            if ($oPlugin === null) {
                unset($this->loadedPlugins[$plugin]);
                return;
            }

            $plugin = $oPlugin;
        }

        unset($this->loadedPlugins[$plugin->getPluginName()]);
    }
1060890
private function filter($plugin)
    {
        return ($plugin->noajax  && !(is_object($this->output) && $this->output->type == 'html'))
             || ($plugin->task && !preg_match('/^('.$plugin->task.')$/i', $this->task))
             || ($plugin->noframe && !empty($_REQUEST['_framed']));
    }
83885
protected function getPlugin($plugin)
    {
        try {
            list($vendor, $package) = explode('/', $plugin);

            return $this->get('anime_db.api.client')->getPlugin($vendor, $package);
        } catch (\RuntimeException $e) {
            return;
        }
    }
441857
public static function registerRedactorPlugin(string $plugin)
    {
        if (isset(self::$_registeredPlugins[$plugin])) {
            return;
        }

        $paths = self::redactorPluginPaths();

        foreach ($paths as $registeredPath) {
            foreach (["{$registeredPath}/{$plugin}", $registeredPath] as $path) {
                if (file_exists("{$path}/{$plugin}.js")) {
                    $view = Craft::$app->getView();
                    $baseUrl = Craft::$app->getAssetManager()->getPublishedUrl($path, true);
                    $view->registerJsFile("{$baseUrl}/{$plugin}.js", [
                        'depends' => RedactorAsset::class
                    ]);
                    // CSS file too?
                    if (file_exists("{$path}/{$plugin}.css")) {
                        $view->registerCssFile("{$baseUrl}/{$plugin}.css");
                    }
                    // Don't do this twice
                    self::$_registeredPlugins[$plugin] = true;
                    return;
                }
            }
        }

        throw new InvalidConfigException('Redactor plugin not found: '.$plugin);
    }
633654
public function validate( $license ) {
		try {
			$url      = untrailingslashit( home_url( '' ) );
			$guid     = $this->guid;
			$response = wp_remote_post( $this->validate_url, [
				'body' => [
					'license' => $license,
					'url'     => $url,
				],
			] );
			if ( is_wp_error( $response ) ) {
				return $response;
			}
			if ( 200 === $response['response']['code'] ) {
				return true;
			} else {
				$body = json_decode( $response['body'] );
				return new \WP_Error( $response['response']['code'], $body->message );
			}
		} catch ( \Exception $e ) {
			return new \WP_Error( $e->getCode(), $e->getMessage() );
		}
	}
438782
public function validatePlugin($plugin)
    {
        if ($plugin instanceof UiAdapter\UiAdapterInterface) {
            // we're okay
            return;
        }

        throw new Exception\InvalidArgumentException(sprintf(
            'Plugin of type %s is invalid; must extend %s\UiAdapter\UiAdapterInterface',
            (is_object($plugin) ? get_class($plugin) : gettype($plugin)),
            __NAMESPACE__
        ));
    }
946811
public function registerPlugin($plugin)
    {
        if ($plugin instanceof IOrmPlugin) {
            $this->plugins[] = $plugin;
        } elseif (is_string($plugin) && $this->iocContainer) {
            $this->plugins[] = $this->iocContainer->get($plugin);
        } else {
            throw InvalidArgumentException::format(
                'Invalid plugin supplied to %s: ioc container must be available to resolve class',
                __METHOD__
            );
        }
    }