[wp-hackers] Checking if a plugin exists

aesqe aesqe at skyphe.org
Sun Jul 25 21:33:51 UTC 2010

I've always found 1. to be the easiest. Just hook your function to 
'plugins_loaded' and check for a function or class name.

function check_for_plugin()
	if( function_exists('some_function') )
add_action('plugins_loaded', 'check_for_plugin');

is_plugin_active() requires a folder and a file name, and those might 
not be the same on all WP installations.

On 25.7.2010 23:19, Andrew Nacin wrote:
> 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.
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers

Bruno "Aesqe" Babic
http://skyphe.org .:. http://brlog.biz

More information about the wp-hackers mailing list