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?

1 Answer 1

6

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

3
  • I think that has to be a record for the fastest correct answer of all time :) Thank you Robin, that's perfect. Dec 29, 2017 at 17:48
  • Any tips on how to determine a plugin's handle?
    – Henry
    Mar 26, 2020 at 20:43
  • @Henry the plugins table in the database has a handle column Dec 24, 2020 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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