[wp-hackers] plugin loading order (rfc)

Computer Guru computerguru at neosmart.net
Sun Mar 11 19:30:37 GMT 2007


Won't a simple require_once() command take care of it?

Say plugins X and B require plugin M.

Plugin B loads. First line of code has a require_once for a known plugin M 
require_once("m.php");
It's not loaded yet, so it gets loaded as a part of this routine.

Plugin X loads. It needs plugin M, which is already loaded.
require_once("m.php");
It's already loaded, nothing happens.

The only requirement is that you know the path to plugin M. But even if you
had a dependency system, you'd still have to know something about plugin M
to require it anyway.

Computer Guru
NeoSmart Technologies
http://neosmart.net/blog/


> -----Original Message-----
> From: wp-hackers-bounces at lists.automattic.com [mailto:wp-hackers-
> bounces at lists.automattic.com] On Behalf Of Peter Westwood
> Sent: Sunday, March 11, 2007 5:59 PM
> To: wp-hackers at lists.automattic.com
> Subject: Re: [wp-hackers] plugin loading order (rfc)
> 
> Sabin Iacob wrote:
> > While working on a plugin, I hit an interesting issue: there is no
> other
> > way to alter the order in which plugins are loaded than changing the
> > file name.
> >
> 
> This is true.
> 
> Why do you need to change the order in which you plugin is loaded
> compared to other plugins?
> 
> All you should be doing when you plugin is included is:
> 
>   1. Defining functions / classes.
>   2. Defining functions to replace those in pluggable functions.
>   3. Calling add_action to add yourself to a suitable hook(s) to run
> other code on.
> 
> The only reason why you need to get the order correct is if more than
> one plugin is trying to override the same pluggable functions - and
> then
> you are probably not both going to work at the same time anyway.
> 
> If you need to check for existance of other pluggins do in on the
> "init"
> hook - i.e. once everyone is loaded.
> 
> westi
> --
> Peter Westwood
> http://blog.ftwr.co.uk
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list