[wp-hackers] Plugins using post types with localization

Dion Hulse (dd32) wordpress at dd32.id.au
Mon Jul 4 05:10:16 UTC 2011


On 4 July 2011 14:58, Diana K. Cury <dianakac at gmail.com> wrote:

> Thanks Hulse, I don't undertand too much about all this, quite adapted the
> plugin from many sources.
>
> I think your note on priority can be helpful (no tested yet).
> I don't understand how register post is being loaded before anything or the
> post types are always handled firstly, by default !?
>
>
My apologies, It looks like i've misread the code, It's hard skimming code
where indentation isn't consistent.
The post type isn't being registered before init, it's being registered on
init.

However, The post type structure,
http://plugins.trac.wordpress.org/browser/ada-plugin/trunk/creation/pet_post_type.php?rev=404248#L14IS
being run on plugin inclusion basically.. It's creating the $labels
array
before the language files are loaded, so __(something, 'ADA') is returning
'something' since at that point in time, the translations functions havn't
been loaded..

So;
 * PETPostType() is run at plugin inclusion time, this sets the labels and
attemptt to translate them (and fails);
 * Then on init, adafunc_setup() is called loading the translations.
 * And then, on init again, PETPostType::register() is called, registering
the post type, with the previously "untranslated" strings from step 1.

That combined with the priorities, should be able to get you on the right
line.. Make sense?


More information about the wp-hackers mailing list