Answers.Body: <p>I just a test of this locally in a sample plugin and I get expected behavior.</p>
  
  <p>If I install and enable the plugin in Craft and use this in a template:</p>
  
  <pre><code>{% 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' }}
  </code></pre>
  
  <p>I get this output:</p>
  
  <pre><code>plugin enabled 
  plugin installed 
  plugin true
  </code></pre>
  
  <p>If I add a Twig Extension class to the plugin, then register a <code>myPluginTestFunction</code> function that outputs "It Works"... i.e.</p>
  
  <pre><code>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';
  }
  </code></pre>
  
  <p>Then I do this is a template:</p>
  
  <pre><code>{{ craft.myPlugin is defined ? myPluginTestFunction() }}
  </code></pre>
  
  <p>Then I get the expected output of:</p>
  
  <pre><code>It Works
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-08-03T19:31:34.977Z
Answers.LastActivityDate: 2017-08-03T19:31:34.977Z
Answers.UserDisplayName: Brad Bell
Body: <p>A while ago I asked how to check <a href="https://craftcms.stackexchange.com/questions/10632/how-can-i-check-if-a-plugin-is-installed-and-enabled">if a plugin is enabled/installed</a>. I've since used a couple methods to do my checks:</p>
  
  <pre><code>{% 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' }}
  </code></pre>
  
  <p>Now I <a href="https://craftcms.stackexchange.com/questions/11899/is-there-a-fallback-when-a-twig-extension-is-not-enabled">recall this working with Twig Extension functions and filters too</a>. It wasn't pretty, but it worked. </p>
  
  <p>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:</p>
  
  <pre><code>{{ craft.myPlugin is defined ? myFunction() }}
  </code></pre>
  
  <p>or </p>
  
  <pre><code>{{ craft.myPlugin is defined ? someVariable|myFilter() }}
  </code></pre>
  
  <p>(myFunction being a twig function, and myFilter being a twig filter)... I get an error:</p>
  
  <blockquote>
    <p>Unknown "myFunction" function</p>
  </blockquote>
  
  <p>Another new <em>change/bug</em> 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. </p>
  
  <blockquote>
    <p>Unknown "myFunction" function in "_layouts/main" at line 85.</p>
  </blockquote>
  
  <p>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?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-09T19:50:28.807Z
Comments.Text: I'm also experiencing some what Mark Bolton is seeing... that is if a plugin is _disabled_ or _not installed_: the conditionals fail with the `Unknown "myFunction" function`. For example, trying to confirm that [Cookies](https://github.com/nystudio107/cookies/) is installed & enabled, following throws the Unknown function error if it's not installed: `{{ craft.cookies is defined ? getCookie() }}` However, the following does not throw the error: `{{ craft.cookies is defined ? craft.cookies.get() }}` Skimming through the Cookies code, I don't see anything immediately obvious as to the difference
Comments.UserDisplayName: user7830
Tags: <plugins>
Title: Checking if a plugin is installed or enabled are ignored by Twig Extensions
ThreadText: # Checking if a plugin is installed or enabled are ignored by Twig Extensions
  
  (Asked by: username_0 on 2017-08-02)
  
  A while ago I asked how to check [if a plugin is enabled/installed](https://craftcms.stackexchange.com/questions/10632/how-can-i-check-if-a-plugin-is-installed-and-enabled). I've since used a couple methods to do my checks:
  
  ```
  {% set plugin = craft.plugins.getPlugin('myPlugin', false) %}
  
  {{ plugin.isEnabled() ? 'plugin enabled' : 'plugin disabled'}} <br/>
  {{ plugin.isInstalled() ? 'plugin installed' : 'plugin not installed'}} <br/>
  
  {{ craft.myPlugin is defined ? 'plugin true' : 'plugin false' }}
  
  ```
  
  Now I [recall this working with Twig Extension functions and filters too](https://craftcms.stackexchange.com/questions/11899/is-there-a-fallback-when-a-twig-extension-is-not-enabled). 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?
  
  **Tags:** plugins
  
  > **Comments:**
  > **username_1**: I'm also experiencing some what Mark Bolton is seeing... that is if a plugin is _disabled_ or _not installed_: the conditionals fail with the `Unknown "myFunction" function`. For example, trying to confirm that [Cookies](https://github.com/nystudio107/cookies/) is installed & enabled, following throws the Unknown function error if it's not installed: `{{ craft.cookies is defined ? getCookie() }}` However, the following does not throw the error: `{{ craft.cookies is defined ? craft.cookies.get() }}` Skimming through the Cookies code, I don't see anything immediately obvious as to the difference  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2017-08-03. Score: 2
  
  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'}}<br/>
  {{ plugin.isInstalled() ? 'plugin installed' : 'plugin not installed'}}<br/>
  
  {{ 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' => new Twig_Filter_Method($this, 'myPluginTestFunction', array('is_safe' => 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
  
  ```
  
  
  ---
  
  