[wp-hackers] Plugin dependency checking
if.website at gmail.com
Fri Jun 12 15:12:27 GMT 2009
On Thu, Jun 11, 2009 at 11:43 AM, Stephen
Rider<wp-hackers at striderweb.com> wrote:
> Something you might try is make the plugin do nothing but hook a function to
> run at plugins_loaded. Then in that function you check that the "master"
> plugin is running, and if it is, load the dependent stuff.
Instead of using "plugins_loaded" (or some new action hook or
function), why not attach a callback to a custom action hook of the
So for example if "My Child Plugin" is dependent on "My Parent
Plugin," then fire the "my_parent_plugin_initialized" action when
"Parent Plugin" has loaded. Then "My Child Plugin" can attach its
initialization method to the "my_parent_plugin_initialized" hook. If
the parent has initialized, it does too; otherwise, it doesn't.
Such a custom action hook would let you toggle "My Child Plugin"
object properties, so that you could print error messages in the case
that someone activates "My Child Plugin" without a "My Parent Plugin,"
or when "My Parent Plugin" is out-of-date, etc.
No new core functionality necessary.
More information about the wp-hackers