
When developing a WordPress theme, you often want to rely on a plugin. For example, I have seen many themes which relied on the Wp-PageNavi plugin for their pagination. But if the end user do not have the plugin installed, the code is broken and you can’t use the theme. Happily, there’s a WP function named is_plugin_active() that you can use to test if a plugin is active.






WPRecipes.com is hosted by VidaHost. Use our exclusive coupon CATSWHOCODE to get a 10% discount on hosting! 








4 Responses
The problem here is that one could rename the plugin folder so you can’t really rely on that.
There are some workarounds such as:
1) storing an option in the DB via the activate hook and remove it on deactivate hook
2) use some filter which is run only when the plugin is active (otherwise no add_filter call)
3) check if a global var from the plugin is available
Great tip ! Now I will manage to show an alert on my sites when Maintenance Mode is activated !
Works only in Admin. To make it work in template, see Codex http://codex.wordpress.org/Function_Reference/is_plugin_active
It works perfectly fine with me. Thanks for it!
Trackbacks: