[Solved] How to determine if a plugin is enabled?

Post Reply
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Sun Dec 31, 2017 3:54 am

Hi,

I'd like to add an RSS link in the footer of the theme I'm working on. However, this link will only make sense if the RSS plugin is enabled. How can I check to see if a given plugin is enabled? The contents of $plugins["all"]["pluginRSS"] doesn't seem to provide the enabled status of the plugin.

Thanks,
Jon
User avatar
Edi
Site Admin
Posts: 1263
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Sun Dec 31, 2017 7:41 pm

Why not use the plugin RSS Feed that comes with Bludit?
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Mon Jan 01, 2018 3:59 am

Edi wrote:
Sun Dec 31, 2017 7:41 pm
Why not use the plugin RSS Feed that comes with Bludit?
That's the one I'm talking about. How can I tell if it's enabled or not in PHP?
User avatar
Edi
Site Admin
Posts: 1263
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Mon Jan 01, 2018 8:29 pm

If a plugin is enabled or not is shown on the plugin page.

You can use a plugin in your theme always by adding a hook. The plugin RSS Feed uses the hook siteHead. Therefore there ha`s to be the helper Theme::plugins('siteHead') in the header section of the theme. Something like this:

Code: Select all

<head>
...
<?php
    Theme::plugins('siteHead');
?>
...
</head>
To show the RSS icon you can use something like this:

Code: Select all

if( $plugins['all']['pluginRSS']->installed() ) {
    echo '<a href="'.DOMAIN_BASE.'rss.xml'.'" class="fa-rss"><span class="label">RSS</span></a>';
}
An example for this gives the theme Log.
Last edited by Edi on Wed Jan 03, 2018 1:14 am, edited 1 time in total.
Reason: Correction of snippet to show RSS icon.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
jonathanholvey
Ssr. Bludit
Posts: 23
Joined: Mon May 22, 2017 10:15 pm

Tue Jan 02, 2018 6:37 am

Thanks. $plugins['all']['pluginRSS']->installed() is what I'm after.
User avatar
Edi
Site Admin
Posts: 1263
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Wed Jan 03, 2018 1:12 am

Sorry! I posted the wrong snippet. :oops:

It's corrected.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
Post Reply