[wp-hackers] plugin loading order (rfc)

Jamie Talbot wphackers at jamietalbot.com
Mon Mar 12 00:49:45 GMT 2007


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

Peter Westwood wrote:
> Jennifer Hodgdon wrote:
>>
>>> Could you expand this issue / or link to an example of the problem.
>>>
>>> I'm not sure how allowing control over the include order of plugins
>>> gives people any benifit apart from wining in the pluggable function
>>> definition battle.
>>
>> I can think of one possible use. A plugin I use makes a multi-lingual
>> blog, in part by having the locale of WordPress be dynamic. During the
>> load, so that it happens as early as possible, the plugin figures out
>> what language the user wants to view the blog in, and then sets the
>> WordPress locale.
>>
>> The problem is that other plugins could call load_plugin_text_domain
>> during their load phase (to load their internationalization). So if
>> they are loaded before the multilingual plugin, they will have loaded
>> the wrong locale. Maybe there is some way to reset their text domain
>> to the right locale, but I can't figure out a very smart way to do it.
>> So ensuring that the multilingual plugin loads first would be good.
>>
>> Or, ensuring that the plugins wait until later to call
>> load_plugin_text_domain, but that is up to the plugin author...
>>
> 
> If all plugins were written to do there initialisation on the init hook
> (which they should be but a lot are not!) then this should be as simple
> as adding you action to init with the highest priority and then you will
> get called first.
> 
> Alternatively we could have a special multi-lingual blog hook done in a
> similar way to the caching hook that can only be definition be provided
> by a single solution.
> 
> westi

I'm the author of Gengo, another multilingual plugin, and I came up against this problem a long time
ago.  At the time, I also advocated for a plugin priority, but came to the conclusion after input
from Ryan that it wasn't necessary.[1]  Jennifer is right that it's not really feasible to change a
plugin's locale once it's loaded, but it's not unreasonable to expect plugins to be coded to certain
standards, and it's not as though the information isn't out there.  The instruction to hook on the
init action has been given on this list a couple of times at least and there are articles on the web
about it.  There are of course lots of plugins that don't follow this information, but my reaction
is that they need to be fixed, rather than introducing a system to handle something that is
'broken'.  I've been trying to educate my users as to what is wrong with the other plugins and how
they can be fixed[2], and encouraging them to go to the authors and request those changes.  If all
the multilingual plugin authors adopted the same stance, perhaps we might see less problems in the
future.

I'm not sure what benefits a multilingual blog hook would provide, although it's Monday morning and
entirely possible I'm not fully awake yet...

Cheers,

Jamie.

[1] http://trac.wordpress.org/ticket/1175#comment:14
[2] http://jamietalbot.com/wp-hacks/forum/comments.php?DiscussionID=3&Focus=31#Comment_31
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF9KOprovxfShShFARAmyqAJsGktxInmhYGJO/xbuH02ifP7c4LQCcDaHw
lITG4h4yBk8jp9j4eRAfgi4=
=zeZ7
-----END PGP SIGNATURE-----


More information about the wp-hackers mailing list