4

In a question I asked a few years ago, it was very simple to perform a check on wether a plugin was installed or not.

As of Craft 3, the same methods don't seem to work. The likes of this always returns true:

{{ craft.myPlugin is defined ? 'Installed' : 'Not Installed' }}

Is there another way to determine if a specific plugin is installed and enabled?

5

PHP

\Craft::$app->plugins->isPluginInstalled('plugin-handle')

Twig

{% set installed = craft.app.plugins.isPluginInstalled('plugin-handle') %}

There is also a isPluginDisabled and a isPluginEnabled function. Here is a class reference craft\services\Plugins

  • I think that has to be a record for the fastest correct answer of all time :) Thank you Robin, that's perfect. – Mark Notton Dec 29 '17 at 17:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.