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?

Mark Notton
  • 2,337
  • 1
  • 15
  • 30

1 Answers1

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

Robin Schambach
  • 19,713
  • 1
  • 19
  • 44