GetSimple Support Forum

Full Version: In theme, how can I check if a plugin is enabled?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
}
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.
}
I would use:
Code:
if (function_exists('get_i18n_navigation')) {
  ...
@carlo, yup, much better !!
Thank you both. I didn't think about PHP having a built-in tool for checking. Feeling slightly sheepish, but very grateful Smile