Checking if a plugin is installed or enabled are ignored by Twig Extensions A while ago I asked how to check if a plugin is enabled/installed. I've since used a couple methods to do my checks:

{% set plugin = craft.plugins.getPlugin('myPlugin', false) %}

{{ plugin.isEnabled() ? 'plugin enabled' : 'plugin disabled'}} &lt;br/&gt;
{{ plugin.isInstalled() ? 'plugin installed' : 'plugin not installed'}} &lt;br/&gt;

{{ craft.myPlugin is defined ? 'plugin true' : 'plugin false' }}


Now I recall this working with Twig Extension functions and filters too. It wasn't pretty, but it worked. 

I may wrong, but I think one of the Craft CMS Updates have broken this. Because as-of-late, when I do something like this:

{{ craft.myPlugin is defined ? myFunction() }}


or 

{{ craft.myPlugin is defined ? someVariable|myFilter() }}


(myFunction being a twig function, and myFilter being a twig filter)... I get an error:


  Unknown "myFunction" function


Another new change/bug I've noticed (related to this); if a database can't be connected to and devMode is off, I will get this instead of the 503 error template. 


  Unknown "myFunction" function in "_layouts/main" at line 85.


It's as if the Twig functions/filters get priority over anything else. Am I making this up, and this has always been the case? Or has something changed?
I just a test of this locally in a sample plugin and I get expected behavior.

If I install and enable the plugin in Craft and use this in a template:

{% set plugin = craft.plugins.getPlugin('myPlugin', false) %}

{{ plugin.isEnabled() ? 'plugin enabled' : 'plugin disabled'}}&lt;br/&gt;
{{ plugin.isInstalled() ? 'plugin installed' : 'plugin not installed'}}&lt;br/&gt;

{{ craft.myPlugin is defined ? 'plugin true' : 'plugin false' }}


I get this output:

plugin enabled 
plugin installed 
plugin true


If I add a Twig Extension class to the plugin, then register a myPluginTestFunction function that outputs "It Works"... i.e.

public function getFunctions()
{
    return array(
        'myPluginTestFunction' =&gt; new Twig_Filter_Method($this, 'myPluginTestFunction', array('is_safe' =&gt; array('html'))),
    );
}

public function myPluginTestFunction()
{
    return 'It Works';
}


Then I do this is a template:

{{ craft.myPlugin is defined ? myPluginTestFunction() }}


Then I get the expected output of:

It Works