@@ -320,11 +320,22 @@ function post_categories_meta_box( $post, $box ) {
cap->edit_terms) ) : ?>
-
+
-
- $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => sprintf( __('— Parent %s —'), $tax->singular_label ), 'tab_index' => 3 ) ); ?>
-
+
+
+
+ $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>
+
diff --git a/wp-admin/includes/nav-menu.php b/wp-admin/includes/nav-menu.php
index d73ccaa2e0..9235801dac 100644
--- a/wp-admin/includes/nav-menu.php
+++ b/wp-admin/includes/nav-menu.php
@@ -391,7 +391,7 @@ function wp_nav_menu_taxonomy_meta_boxes() {
$tax = apply_filters( 'nav_menu_meta_box_object', $tax );
if ( $tax ) {
$id = $tax->name;
- add_meta_box( "add-{$id}", $tax->label, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
+ add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
}
}
}
diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php
index cc27ee59f9..594cde9273 100644
--- a/wp-admin/includes/template.php
+++ b/wp-admin/includes/template.php
@@ -63,7 +63,7 @@ function inline_edit_term_row($type, $taxonomy) {
- singular_label ); ?>
+ labels->update_item; ?>
@@ -976,7 +976,7 @@ if ( !$bulk ) :
- label) ?>
+ labels->name) ?>
@@ -1040,7 +1040,7 @@ endif; // $post_type_object->hierarchical ?>
@@ -1566,7 +1566,7 @@ foreach ( $posts_columns as $column_name => $column_display_name ) {
$attributes = 'class="post-title page-title column-title"' . $style;
$edit_link = get_edit_post_link( $page->ID );
?>
-
>cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?>labels->parent . ' ' . esc_html($parent_name) : ''; ?>
+ | >cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?>labels->parent_item_colon . ' ' . esc_html($parent_name) : ''; ?>
cap->edit_post, $page->ID) && $post->post_status != 'trash' ) {
@@ -3762,7 +3762,7 @@ function screen_options($screen) {
break;
case 'edit-tags':
global $tax;
- $per_page_label = $tax->label;
+ $per_page_label = $tax->labels->name;
break;
case 'plugins':
$per_page_label = __('Plugins');
diff --git a/wp-admin/menu.php b/wp-admin/menu.php
index 2bbc18ea36..b3428dc018 100644
--- a/wp-admin/menu.php
+++ b/wp-admin/menu.php
@@ -89,7 +89,7 @@ $menu[5] = array( __('Posts'), 'edit_posts', 'edit.php', '', 'open-if-no-js menu
if ( ! $tax->show_ui || ! in_array('post', (array) $tax->object_type, true) )
continue;
- $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
+ $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
}
unset($tax);
@@ -138,7 +138,7 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) {
if ( ! $tax->show_ui || ! in_array($ptype, (array) $tax->object_type, true) )
continue;
- $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" );
+ $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&post_type=$ptype" );
}
}
unset($ptype, $ptype_obj);
diff --git a/wp-admin/press-this.php b/wp-admin/press-this.php
index 23f7989b27..04e0360179 100644
--- a/wp-admin/press-this.php
+++ b/wp-admin/press-this.php
@@ -488,7 +488,7 @@ var photostorage = false;
@@ -509,11 +509,19 @@ var photostorage = false;
cap->edit_terms) ) : ?>
-
+
-
- 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => sprintf( __('— Parent %s —'), $tax->singular_label ), 'tab_index' => 3 ) ); ?>
-
+
+
+
+ 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '— ' . $tax->labels->parent_item . ' —', 'tab_index' => 3 ) ); ?>
+
diff --git a/wp-includes/default-widgets.php b/wp-includes/default-widgets.php
index 1e472d0167..303e95c531 100644
--- a/wp-includes/default-widgets.php
+++ b/wp-includes/default-widgets.php
@@ -1003,7 +1003,7 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
$title = __('Tags');
} else {
$tax = get_taxonomy($current_taxonomy);
- $title = $tax->label;
+ $title = $tax->labels->name;
}
}
$title = apply_filters('widget_title', $title, $instance, $this->id_base);
@@ -1032,10 +1032,10 @@ class WP_Widget_Tag_Cloud extends WP_Widget {
label;
$term = $wp_query->get_queried_object();
$term = $term->name;
- $title = $tax . $t_sep . $term;
+ $title = $tax->labels->name . $t_sep . $term;
}
//If it's a search
diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php
index 2a6cdd9e28..5b442f238c 100644
--- a/wp-includes/nav-menu.php
+++ b/wp-includes/nav-menu.php
@@ -538,7 +538,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
} elseif ( 'taxonomy' == $menu_item->type ) {
$object = get_taxonomy( $menu_item->object );
- $menu_item->type_label = $object->singular_label;
+ $menu_item->type_label = $object->labels->singular_name;
$term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
$menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
@@ -587,7 +587,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
$object = get_taxonomy( $menu_item->taxonomy );
$menu_item->object = $object->name;
- $menu_item->type_label = $object->singular_label;
+ $menu_item->type_label = $object->labels->singular_name;
$menu_item->title = $menu_item->name;
$menu_item->url = get_term_link( $menu_item, $menu_item->taxonomy );
diff --git a/wp-includes/post.php b/wp-includes/post.php
index 348ddc491f..f17f98f301 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -40,7 +40,9 @@ function create_initial_post_types() {
) );
register_post_type( 'attachment', array(
- 'label' => __( 'Media' ),
+ 'labels' => array(
+ 'name' => __( 'Media' ),
+ ),
'public' => true,
'show_ui' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -53,8 +55,10 @@ function create_initial_post_types() {
) );
register_post_type( 'revision', array(
- 'label' => __( 'Revisions' ),
- 'singular_label' => __( 'Revision' ),
+ 'labels' => array(
+ 'name' => __( 'Revisions' ),
+ 'singular_name' => __( 'Revision' ),
+ ),
'public' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
'_edit_link' => 'revision.php?revision=%d', /* internal use only. don't use this when registering your own post type. */
@@ -65,8 +69,10 @@ function create_initial_post_types() {
) );
register_post_type( 'nav_menu_item', array(
- 'label' => __( 'Navigation Menu Items' ),
- 'singular_label' => __( 'Navigation Menu Item' ),
+ 'labels' => array(
+ 'name' => __( 'Navigation Menu Items' ),
+ 'singular_name' => __( 'Navigation Menu Item' ),
+ ),
'public' => false,
'show_ui' => false,
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
@@ -925,7 +931,7 @@ function get_post_type_capabilities( $args ) {
* - search_items - Default is Search Posts/Search Pages
* - not_found - Default is No posts found/No pages found
* - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash
- * - parent - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
+ * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
*
* Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages.)
*
@@ -947,22 +953,35 @@ function get_post_type_labels( $post_type_object ) {
'not_found' => array( __('No posts found'), __('No pages found') ),
'not_found_in_trash' => array( __('No posts found in Trash'), __('No pages found in Trash') ),
'view' => array( __('View Post'), __('View Page') ),
- 'parent' => array( null, __('Parent Page:') )
+ 'parent_item_colon' => array( null, __('Parent Page:') )
);
+ return _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
+}
+
+/**
+ * Builds an object with custom-something object (post type, taxonomy) labels out of a custom-something object
+ *
+ * @access private
+ */
+function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
// try to get missing (singular_)?name from older style (singular_)?label member variables
// we keep that for backwards compatibility
// TODO: remove in 3.1
- if ( !isset( $post_type_object->labels['name'] ) && isset( $post_type_object->label ) ) {
- $post_type_object->labels['name'] = $post_type_object->label;
+ if ( !isset( $object->labels['name'] ) && isset( $object->label ) ) {
+ $object->labels['name'] = $object->label;
}
- if ( !isset( $post_type_object->labels['singular_name'] ) && isset( $post_type_object->singular_label ) ) {
- $post_type_object->labels['singular_name'] = $post_type_object->singular_label;
+ if ( !isset( $object->labels['singular_name'] ) && isset( $object->singular_label ) ) {
+ $object->labels['singular_name'] = $object->singular_label;
}
- $defaults = array_map( create_function( '$x', $post_type_object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
- $labels = array_merge( $defaults, $post_type_object->labels );
- return (object)$labels;
+ if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
+ $object->labels['singular_name'] = $object->labels['name'];
+ }
+
+ $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
+ $labels = array_merge( $defaults, $object->labels );
+ return (object)$labels;
}
/**
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index 20db89064b..5473ebbfd9 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -18,8 +18,6 @@ function create_initial_taxonomies() {
register_taxonomy( 'category', 'post', array(
'hierarchical' => true,
'update_count_callback' => '_update_post_term_count',
- 'label' => __( 'Categories' ),
- 'singular_label' => __( 'Category' ),
'query_var' => false,
'rewrite' => false,
'public' => true,
@@ -30,8 +28,6 @@ function create_initial_taxonomies() {
register_taxonomy( 'post_tag', 'post', array(
'hierarchical' => false,
'update_count_callback' => '_update_post_term_count',
- 'label' => __( 'Post Tags' ),
- 'singular_label' => __( 'Post Tag' ),
'query_var' => false,
'rewrite' => false,
'public' => true,
@@ -41,8 +37,10 @@ function create_initial_taxonomies() {
register_taxonomy( 'nav_menu', 'nav_menu_item', array(
'hierarchical' => false,
- 'label' => __( 'Navigation Menus' ),
- 'singular_label' => __( 'Navigation Menu' ),
+ 'labels' => array(
+ 'name' => __( 'Navigation Menus' ),
+ 'singular_name' => __( 'Navigation Menu' ),
+ ),
'query_var' => false,
'rewrite' => false,
'show_ui' => false,
@@ -51,7 +49,10 @@ function create_initial_taxonomies() {
register_taxonomy( 'link_category', 'link', array(
'hierarchical' => false,
- 'label' => __( 'Categories' ),
+ 'labels' => array(
+ 'name' => __( 'Categories' ),
+ 'singular_name' => __( 'Category' ),
+ ),
'query_var' => false,
'rewrite' => false,
'public' => false,
@@ -230,6 +231,8 @@ function is_taxonomy_hierarchical($taxonomy) {
*
* show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
* defaults to show_ui which defalts to public.
+ *
+ * labels - An array of labels for this taxonomy. You can see accepted values in {@link get_taxonomy_labels()}. By default tag labels are used for non-hierarchical types and category labels for hierarchical ones.
*
* @package WordPress
* @subpackage Taxonomy
@@ -254,11 +257,11 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
'query_var' => $taxonomy,
'public' => true,
'show_ui' => null,
- 'label' => null,
'show_tagcloud' => null,
'_builtin' => false,
+ 'labels' => array(),
'capabilities' => array(),
- );
+ );
$args = wp_parse_args($args, $defaults);
if ( false !== $args['query_var'] && !empty($wp) ) {
@@ -283,9 +286,6 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
if ( is_null($args['show_tagcloud']) )
$args['show_tagcloud'] = $args['show_ui'];
- if ( is_null($args['label'] ) )
- $args['label'] = $taxonomy;
-
$default_caps = array(
'manage_terms' => 'manage_categories',
'edit_terms' => 'manage_categories',
@@ -295,17 +295,62 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
$args['cap'] = (object) array_merge( $default_caps, $args['capabilities'] );
unset( $args['capabilities'] );
- if ( empty($args['singular_label']) )
- $args['singular_label'] = $args['label'];
-
$args['name'] = $taxonomy;
$args['object_type'] = (array) $object_type;
+ $args['labels'] = get_taxonomy_labels( (object) $args );
+
+ // we keep these two only for backwards compatibility
+ // TODO: remove in 3.1
+ $args['label'] = $args['labels']->name;
+ $args['singular_label'] = $args['labels']->singular_name;
+
$wp_taxonomies[$taxonomy] = (object) $args;
// register callback handling for metabox
add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term');
}
+/**
+ * Builds an object with all taxonomy labels out of a 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
+ * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category
+ * - search_items - Default is Search Tags/Search Categories
+ * - popular_items - Default is Popular Tags/Popular Categories
+ * - all_items - Default is All Tags/All Categories
+ * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category
+ * - parent_item_colon - The same as parent_item , but with colon : in the end
+ * - edit_item - Default is Edit Tag/Edit Category
+ * - update_item - Default is Update Tag/Update Category
+ * - add_new_item - Default is Add New Tag/Add New Category
+ * - new_item_name - Default is New Tag Name/New Category Name
+ *
+ * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.)
+ *
+ * @since 3.0.0
+ * @param object $tax Taxonomy object
+ * @return object object with all the labels as member variables
+ */
+
+function get_taxonomy_labels( $tax ) {
+ $nohier_vs_hier_defaults = array(
+ 'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ),
+ 'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ),
+ 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ),
+ 'popular_items' => array( __( 'Popular Tags' ), __( 'Popular Category' ) ),
+ 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ),
+ 'parent_item' => array( null, __( 'Parent Category' ) ),
+ 'parent_item_colon' => array( null, __( 'Parent Category:' ) ),
+ 'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ),
+ 'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ),
+ 'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ),
+ 'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ),
+ );
+
+ return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults );
+}
+
/**
* Add an already registered taxonomy to an object type.
*
@@ -2612,6 +2657,3 @@ function is_object_in_taxonomy($object_type, $taxonomy) {
return false;
}
-
-
-?>
|