[wp-hackers] Checking if a plugin exists

Andrew Nacin wp at andrewnacin.com
Sun Jul 25 21:19:48 UTC 2010


if (is_plugin_active('plugin-directory/plugin-file.php')) {
   //plugin is activated
}

That is generally a fine solution, though there are two others:

1. Checking for function or class existence is also a solid solution, one I
would probably use over is_plugin_active().

2. If you're building plugins that depend on others, then it is best to
attach the initialization of the sub-plugin to a hook in the parent plugin.
Then the sub-plugin will noop if the parent plugin is not activated.
BuddyPress does this. Of course, that means the parent plugin needs to have
hooks in place for that.


More information about the wp-hackers mailing list