[wp-hackers] Getting user info as early as possible.

Jamie Talbot wphackers at jamietalbot.com
Sat Mar 18 09:47:09 GMT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Andy Skelton wrote:
> On 3/17/06, Jamie Talbot <wphackers at jamietalbot.com> wrote:
> Plugin loading time is not the time to execute code. It is the time to
> define functions and add actions/filters for later execution.

> The reason for this is simple and it will not be argued here: the
> program is not completely loaded until after the plugins and pluggable
> functions are loaded. 

Sure, I can appreciate the logic of that and I agree in the vast majority of cases.

> Refer to wp-settings.php to see which hooks
> happen where.

Yeah, I've almost memorised it I think!  Red Alt's X-Ref is a fantastic programming aid which I'm
referring to constantly.  My question was kind of rhetorical - you can't do guarantee the order in
which plugins are registered, can you? (What would people's thoughts be on allowing this?)

> Most plugins shouldn't actually do anything until init or later.
> 
> There are exceptions.

In this case however, I'm dynamically setting the locale based on the current user's preference.
Because the locale filter is only executed the first time get_locale is called, other localised
plugins can potentially cause get_locale to run unfiltered before I register it.

In fact, allowing get_locale to re-run locale filters would allow me to register the filter in the
setup and then cause the locale to be re-evaluated when my own load_plugin_textdomain call runs in
init.  This would be after pluggable_functions has loaded and all would be well.  Of course, there
is the potential that a plugin's high priority locale filter could trump another's, but at least
then it's not a lottery based on which one is registered first.

Cheers,

Jamie.

- --
http://jamietalbot.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEG9cdrovxfShShFARArecAJ4x61RY6880Ecy3ifdCnsCdWPvtNACgj84S
agd7j/VmuCmc1duO159hRYQ=
=hCWL
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list