Important changes to post type and tax registration
Earlier this week, Nikolay committed a change via #12968 that now allows a post type to register a series of custom labels, via a labels array. This is backwards compatible, as I advised that we leave the label and singular_label properties alone. Nikolay is following up with taxonomy labels in #13357.
However, other changes will be incompatible with development releases of 3.0. I’ve made some changes to custom capabilities for post types in #13358, and will be making similar changes for taxonomies as well.
More or less, edit_cap, edit_type_cap, delete_cap, etc., are all gone. Capabilities are now managed by the capability_type property (i.e. ‘post’, ‘page’), which then builds the corresponding capabilities. This is unchanged. If you want to do finer grained control, such as customizing the names of the individual primitive and meta capabilities, then you will need to pass this as a capabilities array.
Capabilities are now referenced in core as part of the cap property of the post type object, which in turn is an object of capabilities, keyed by what the capability would be called for posts. Thus, $post_type_object->cap->edit_post. Other properties include edit_posts, edit_others_posts, publish_posts, read_post, etc. (Yes, Nikolay and I discussed this in SF, and chaining like this is PHP4 compatible; this is also how the new labels are implemented.)
Andrew Nacin 4:49 am on May 13, 2010 Permalink
The capability changes have now been implemented for taxonomies: r14593
Andrew Nacin 2:24 am on May 14, 2010 Permalink
Also, singular_label is now gone for post types and taxonomies. r14619. This was introduced in 3.0, and is being phased out in favor of labels->singular_name. Originally, singular_label was used in various places like “Edit %s”, but no longer. We are however keeping the old “label” property, you can supply that or labels['name'] or both.
Milan 3:32 pm on May 13, 2010 Permalink
This should also be sent to wp-polyglots and wp-hackers as you did for wp-config. From phpdoc I understood basics but this should be explained to other translators too.
Even my understandings are maybe wrong:
for post and pages, we have new labels
developers should add them so that there is support for l10n
if they don’t add, default labels for posts and pages are used, depending on which is post type based
Andrew Nacin 3:45 pm on May 13, 2010 Permalink
Not a bad idea. I’ll send something out to hackers and testers now, and Nikolay can send something over polyglots once the taxonomy labels patch is in, if he deems it necessary.
Your understandings are correct, except that there aren’t new translatable strings in core at this point — we simply gathered up all of the relevant Post and Page strings in core and brought them into register_post_type directly.
Around the web | alexking.org 6:54 pm on May 16, 2010 Permalink
[...] Important changes to post type and tax registration – WordPress devs take note. [...]