[wp-hackers] Plugin dependency checking

Stephen Rider wp-hackers at striderweb.com
Thu Jun 11 21:57:56 GMT 2009


On Jun 11, 2009, at 3:00 PM, scribu wrote:

> A new field in the plugin header would be nice:
>
> /*
> Plugin Name: My Plugin
> Depends On: Spam Karma, scbFramework
> */
>
> WP would check if each plugin in the list is installed and active  
> and takes
> care of the loading order.

Two possibilities:

1) You can make a sub plugin for a plugin that registers itself as  
"sub-able".  Then you could do a header like your example.

2) otherwise you do a header like this:

	Depends On: spam-karma/spam_karma_plugin.php

Both 1 and 2 should work.  WordPress strongly follows a pattern like  
#1, but #2 would allow for more flexibility I think.  I can certainly  
imagine making a plugin that depends on another, even if the author of  
that other plugin doesn't anticipate that....

**
ALSO: Scribu -- I will definitely have to keep in mind your example,  
and the possibility that a plugin might be dependent on ***more than  
one*** other plugin.  In that situation the strict "sub plugin"  
concept doesn't quite work.  I think what I could do is set up the  
"dependency' system, and on top of that would be a second layer  
implementing the "sub plugin" idea.  The dependency part is universal,  
while the sub-plugin part really only affects how it appears under the  
Manage Plugins page.

That is, a sub-plugin is a special kind of dependent plugin.

In terms of interface, sub-plugins would fall under the collapsable  
area under their Master plugin.  Simply dependent plugins would look  
like regular plugins on the list.

**
What happens when I activate a dependent plugin and the master plugin  
is not active?  Automatically activate the master also?  Or give a  
"you can't do that" message?

**
ONE LAST THING:  You would have to be able to specify a minimum  
*version* of the master plugin.  "Depends on Spam Karma v2.0".  Don't  
want to run a plugin that needs v2.0 of another one, when v1.3 of that  
other is installed.

Stephen

-- 
Stephen Rider
http://striderweb.com/


More information about the wp-hackers mailing list