[wp-hackers] Plugin dependency checking

wp-hackers at striderweb.com wp-hackers at striderweb.com
Fri Jun 12 22:28:51 GMT 2009


> On Fri, Jun 12, 2009 at 11:07 AM, scribu<scribu at gmail.com> wrote:
>> Another issue: what if the parent plugin is called Z and the child
>> plugin is
>> called A? The child plugin hooks would never fire.
>
> By "called Z" and "called A", I'm guessing that you're asking what
> would happen if the child plugin's file is included before the
> parent's file?
>
> In general, good WordPress plugin practice does not initialize the
> plugin when its files are first included, and that would be
> particularly true for a plugin that's consciously a "framework" or
> "parent" plugin.  Any other behavior can't really expect core WP
> support, anyways.
>
> So as long as the parent plugin's initialization event hook doesn't
> fire until all plugins are loaded, it's not an issue when particular
> files are loaded.

There are some problems here, due to a bug in WordPress (At least I think
it's a bug -- I've yet to hear a good explanation).

The earliest hook you can use after plugins load is "plugins_loaded". 
Unfortunately, the plugins_loaded hook is NOT the first thing that happens
after plugins are loaded.  First pluggable.php is called, then some
caching stuff happens.

So if your plugin wants to replace any of the pluggable.php functions, it
MUST do so immediately -- it can't run later on a do_action.

A second comment though -- your sugegstion regarding "is_being_activated"
helped me out on something else I've been working on (Strider Core
framework).  Thanks!  ;)

Stephen



More information about the wp-hackers mailing list