Keep label as a quick way to set up a taxonomy/post type, without diving into the labels array. Deprecate singular_label while there. Props nacin. Fixes #13357

git-svn-id: http://svn.automattic.com/wordpress/trunk@14619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nbachiyski 2010-05-14 02:13:49 +00:00
parent 7bd274899d
commit c1dea00b62
2 changed files with 7 additions and 17 deletions

View File

@ -771,6 +771,7 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' )
* *
* Optional $args contents: * Optional $args contents:
* *
* - label - Name of the post type shown in the menu. Usually plural. If not set, labels['name'] will be used.
* - description - A short descriptive summary of what the post type is. Defaults to blank. * - description - A short descriptive summary of what the post type is. Defaults to blank.
* - public - Whether posts of this type should be shown in the admin UI. Defaults to false. * - public - Whether posts of this type should be shown in the admin UI. Defaults to false.
* - exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public. * - exclude_from_search - Whether to exclude posts with this post type from search results. Defaults to true if the type is not public, false if the type is public.
@ -869,11 +870,7 @@ function register_post_type($post_type, $args = array()) {
add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1); add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
$args->labels = get_post_type_labels( $args ); $args->labels = get_post_type_labels( $args );
// we keep these two only for backwards compatibility
// TODO: remove in 3.1
$args->label = $args->labels->name; $args->label = $args->labels->name;
$args->singular_label = $args->labels->singular_name;
$wp_post_types[$post_type] = $args; $wp_post_types[$post_type] = $args;
@ -920,7 +917,7 @@ function get_post_type_capabilities( $args ) {
* Builds an object with all post type labels out of a post type object * Builds an object with all post type labels out of a post type object
* *
* Accepted keys of the label array in the post type object: * Accepted keys of the label array in the post type object:
* - name - general name for the post type, usually plural. Default is Posts/Pages * - name - general name for the post type, usually plural. The same and overriden by $post_type_object->label. Default is Posts/Pages
* - singular_name - name for one object of this post type. Default is Post/Page * - singular_name - name for one object of this post type. Default is Post/Page
* - add_new - Default is Add New for both hierarchical and non-hierarchical types. When internationalizing this string, please use a {@link http://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context gettext context} matching your post type. Example: <code>_x('Add New', 'product');</code> * - add_new - Default is Add New for both hierarchical and non-hierarchical types. When internationalizing this string, please use a {@link http://codex.wordpress.org/I18n_for_WordPress_Developers#Disambiguation_by_context gettext context} matching your post type. Example: <code>_x('Add New', 'product');</code>
* - add_new_item - Default is Add New Post/Add New Page * - add_new_item - Default is Add New Post/Add New Page
@ -965,15 +962,9 @@ function get_post_type_labels( $post_type_object ) {
*/ */
function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) { function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
// try to get missing (singular_)?name from older style (singular_)?label member variables if ( isset( $object->label ) ) {
// we keep that for backwards compatibility
// TODO: remove in 3.1
if ( !isset( $object->labels['name'] ) && isset( $object->label ) ) {
$object->labels['name'] = $object->label; $object->labels['name'] = $object->label;
} }
if ( !isset( $object->labels['singular_name'] ) && isset( $object->singular_label ) ) {
$object->labels['singular_name'] = $object->singular_label;
}
if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) { if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
$object->labels['singular_name'] = $object->labels['name']; $object->labels['singular_name'] = $object->labels['name'];

View File

@ -211,6 +211,8 @@ function is_taxonomy_hierarchical($taxonomy) {
* *
* Optional $args contents: * Optional $args contents:
* *
* label - Name of the taxonomy shown in the menu. Usually plural. If not set, labels['name'] will be used.
*
* hierarchical - has some defined purpose at other parts of the API and is a * hierarchical - has some defined purpose at other parts of the API and is a
* boolean value. * boolean value.
* *
@ -297,12 +299,9 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
$args['name'] = $taxonomy; $args['name'] = $taxonomy;
$args['object_type'] = (array) $object_type; $args['object_type'] = (array) $object_type;
$args['labels'] = get_taxonomy_labels( (object) $args );
// we keep these two only for backwards compatibility $args['labels'] = get_taxonomy_labels( (object) $args );
// TODO: remove in 3.1
$args['label'] = $args['labels']->name; $args['label'] = $args['labels']->name;
$args['singular_label'] = $args['labels']->singular_name;
$wp_taxonomies[$taxonomy] = (object) $args; $wp_taxonomies[$taxonomy] = (object) $args;
@ -314,7 +313,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
* Builds an object with all taxonomy labels out of a taxonomy object * Builds an object with all taxonomy labels out of a taxonomy object
* *
* Accepted keys of the label array in the taxonomy object: * Accepted keys of the label array in the taxonomy object:
* - name - general name for the taxonomy, usually plural. Default is Post Tags/Categories * - name - general name for the taxonomy, usually plural. The same as and overriden by $tax->label. Default is Post Tags/Categories
* - singular_name - name for one object of this taxonomy. Default is Post Tag/Category * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category
* - search_items - Default is Search Tags/Search Categories * - search_items - Default is Search Tags/Search Categories
* - popular_items - Default is Popular Tags/Popular Categories * - popular_items - Default is Popular Tags/Popular Categories