Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
In theme, how can I check if a plugin is enabled?
#1
I'm writing a theme which integrates with the I18N Navigation plugin. However, I'd also like the theme to degrade gracefully and not throw errors if I18N Navigation isn't available or is disabled.

Is there a way I can query to see if a module is enabled, so that I run certain code only if it is? Something like:

if ('I18N Navigation' is present and enabled) {
Do some funky stuff that depends on I18N Navigation functions.
} else {
Do some less funky stuff.
}
Reply
#2
Use the $plugin_info array to see if the plugin is loaded.
and $live_plugins array to check if its active.


Code:
if (isset($plugin_info['customfields']) ) {
  Do some funky stuff that depends on I18N Navigation functions.
} else {
  Do some less funky stuff.
}
My Github Repos: Github
Website: DigiMute
Reply
#3
I would use:
Code:
if (function_exists('get_i18n_navigation')) {
  ...
Reply
#4
@carlo, yup, much better !!
My Github Repos: Github
Website: DigiMute
Reply
#5
Thank you both. I didn't think about PHP having a built-in tool for checking. Feeling slightly sheepish, but very grateful Smile
Reply




Users browsing this thread: 1 Guest(s)