Returns true if a plugin has been activated.
public isPluginActivated ( string $name ) : boolean | ||
$name | string | Name of plugin, eg, `'Actions'`. |
return | boolean |
public function test_deactivatePlugin() { $this->assertFalse($this->manager->isPluginActivated('ExampleTheme')); $this->manager->activatePlugin('ExampleTheme'); $this->assertTrue($this->manager->isPluginActivated('ExampleTheme')); $this->manager->deactivatePlugin('ExampleTheme'); $this->assertFalse($this->manager->isPluginActivated('ExampleTheme')); }
/** * Returns true if it is ok to show some Piwik PRO advertising in the Piwik UI. * @return bool */ public function arePiwikProAdsEnabled() { if ($this->pluginManager->isPluginActivated('EnterpriseAdmin') || $this->pluginManager->isPluginActivated('LoginAdmin') || $this->pluginManager->isPluginActivated('CloudAdmin') || $this->pluginManager->isPluginActivated('WhiteLabel')) { return false; } $showAds = $this->config->General['piwik_pro_ads_enabled']; return !empty($showAds); }
private function isPluginActivated($pluginName) { if (in_array($pluginName, $this->activatedPluginNames)) { return true; } return $this->pluginManager->isPluginActivated($pluginName); }
public function uploadPlugin() { static::dieIfPluginsAdminIsDisabled(); Piwik::checkUserHasSuperUserAccess(); $nonce = Common::getRequestVar('nonce', null, 'string'); if (!Nonce::verifyNonce(MarketplaceController::INSTALL_NONCE, $nonce)) { throw new \Exception($this->translator->translate('General_ExceptionNonceMismatch')); } Nonce::discardNonce(MarketplaceController::INSTALL_NONCE); if (empty($_FILES['pluginZip'])) { throw new \Exception('You did not specify a ZIP file.'); } if (!empty($_FILES['pluginZip']['error'])) { throw new \Exception('Something went wrong during the plugin file upload. Please try again.'); } $file = $_FILES['pluginZip']['tmp_name']; if (!file_exists($file)) { throw new \Exception('Something went wrong during the plugin file upload. Please try again.'); } $view = $this->configureView('@CorePluginsAdmin/uploadPlugin'); $pluginMetadata = $this->pluginInstaller->installOrUpdatePluginFromFile($file); $view->nonce = Nonce::getNonce(static::ACTIVATE_NONCE); $view->plugin = array('name' => $pluginMetadata->name, 'version' => $pluginMetadata->version, 'isTheme' => !empty($pluginMetadata->theme), 'isActivated' => $this->pluginManager->isPluginActivated($pluginMetadata->name)); return $view->render(); }
private function canPluginBeInstalled($plugin) { if (empty($plugin['isDownloadable'])) { return false; } $pluginName = $plugin['name']; $isAlreadyInstalled = $this->pluginManager->isPluginInstalled($pluginName) || $this->pluginManager->isPluginLoaded($pluginName) || $this->pluginManager->isPluginActivated($pluginName); return !$isAlreadyInstalled; }
private function getLoadedAndActivated($pluginName) { if (!$this->pluginManager->isPluginLoaded($pluginName)) { return; } try { if (!$this->pluginManager->isPluginActivated($pluginName)) { return; } $plugin = $this->pluginManager->getLoadedPlugin($pluginName); } catch (\Exception $e) { // we are not allowed to use possible settings from this plugin, plugin is not active return; } return $plugin; }
/** * Get the widget defined by the given module and action. * * @param string $module Aka plugin name, eg 'CoreHome' * @param string $action An action eg 'renderMe' * @return Widget|null * @throws \Exception Throws an exception if the widget is not enabled. */ public function factory($module, $action) { if (empty($module) || empty($action)) { return; } try { if (!$this->pluginManager->isPluginActivated($module)) { return; } $plugin = $this->pluginManager->getLoadedPlugin($module); } catch (\Exception $e) { // we are not allowed to use possible widgets, plugin is not active return; } /** @var Widget[] $widgetContainer */ $widgets = $plugin->findMultipleComponents('Widgets', 'Piwik\\Widget\\Widget'); foreach ($widgets as $widgetClass) { $config = $this->getWidgetConfigForClassName($widgetClass); if ($config->getAction() === $action) { $config->checkIsEnabled(); return StaticContainer::get($widgetClass); } } }
public function exec() { if (!$this->pluginManager->isPluginActivated($this->pluginName)) { $this->pluginManager->activatePlugin($this->pluginName); } }
protected function isPluginActivated($pluginName) { return $this->pluginManager->isPluginActivated($pluginName); }
private function makeSiteSearchCategory(Plugin\Manager $pluginManager) { return $this->makeProperty('sitesearch_category_parameters', $default = array(), FieldConfig::TYPE_ARRAY, function (FieldConfig $field) use($pluginManager) { $field->title = Piwik::translate('SitesManager_SearchCategoryLabel'); $field->uiControl = FieldConfig::UI_CONTROL_TEXT; $field->inlineHelp = Piwik::translate('Goals_Optional') . '<br /><br />' . Piwik::translate('SitesManager_SearchCategoryParametersDesc'); $hasCustomVars = (int) $pluginManager->isPluginActivated('CustomVariables'); $field->condition = $hasCustomVars . ' && sitesearch && !use_default_site_search_params'; }); }