Changeset 14614 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 05/14/2010 12:34:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r14606 r14614 19 19 'hierarchical' => true, 20 20 'update_count_callback' => '_update_post_term_count', 21 'label' => __( 'Categories' ),22 'singular_label' => __( 'Category' ),23 21 'query_var' => false, 24 22 'rewrite' => false, … … 31 29 'hierarchical' => false, 32 30 'update_count_callback' => '_update_post_term_count', 33 'label' => __( 'Post Tags' ),34 'singular_label' => __( 'Post Tag' ),35 31 'query_var' => false, 36 32 'rewrite' => false, … … 42 38 register_taxonomy( 'nav_menu', 'nav_menu_item', array( 43 39 'hierarchical' => false, 44 'label' => __( 'Navigation Menus' ), 45 'singular_label' => __( 'Navigation Menu' ), 40 'labels' => array( 41 'name' => __( 'Navigation Menus' ), 42 'singular_name' => __( 'Navigation Menu' ), 43 ), 46 44 'query_var' => false, 47 45 'rewrite' => false, … … 52 50 register_taxonomy( 'link_category', 'link', array( 53 51 'hierarchical' => false, 54 'label' => __( 'Categories' ), 52 'labels' => array( 53 'name' => __( 'Categories' ), 54 'singular_name' => __( 'Category' ), 55 ), 55 56 'query_var' => false, 56 57 'rewrite' => false, … … 231 232 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget; 232 233 * defaults to show_ui which defalts to public. 234 * 235 * 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. 233 236 * 234 237 * @package WordPress … … 255 258 'public' => true, 256 259 'show_ui' => null, 257 'label' => null,258 260 'show_tagcloud' => null, 259 261 '_builtin' => false, 262 'labels' => array(), 260 263 'capabilities' => array(), 261 264 ); 262 265 $args = wp_parse_args($args, $defaults); 263 266 … … 283 286 if ( is_null($args['show_tagcloud']) ) 284 287 $args['show_tagcloud'] = $args['show_ui']; 285 286 if ( is_null($args['label'] ) )287 $args['label'] = $taxonomy;288 288 289 289 $default_caps = array( … … 296 296 unset( $args['capabilities'] ); 297 297 298 if ( empty($args['singular_label']) )299 $args['singular_label'] = $args['label'];300 301 298 $args['name'] = $taxonomy; 302 299 $args['object_type'] = (array) $object_type; 300 $args['labels'] = get_taxonomy_labels( (object) $args ); 301 302 // we keep these two only for backwards compatibility 303 // TODO: remove in 3.1 304 $args['label'] = $args['labels']->name; 305 $args['singular_label'] = $args['labels']->singular_name; 306 303 307 $wp_taxonomies[$taxonomy] = (object) $args; 304 308 305 309 // register callback handling for metabox 306 310 add_filter('wp_ajax_add-'.$taxonomy, '_wp_ajax_add_hierarchical_term'); 311 } 312 313 /** 314 * Builds an object with all taxonomy labels out of a taxonomy object 315 * 316 * Accepted keys of the label array in the taxonomy object: 317 * - name - general name for the taxonomy, usually plural. Default is Post Tags/Categories 318 * - singular_name - name for one object of this taxonomy. Default is Post Tag/Category 319 * - search_items - Default is Search Tags/Search Categories 320 * - popular_items - Default is Popular Tags/Popular Categories 321 * - all_items - Default is All Tags/All Categories 322 * - parent_item - This string isn't used on non-hierarchical taxonomies. In hierarchical ones the default is Parent Category 323 * - parent_item_colon - The same as <code>parent_item</code>, but with colon <code>:</code> in the end 324 * - edit_item - Default is Edit Tag/Edit Category 325 * - update_item - Default is Update Tag/Update Category 326 * - add_new_item - Default is Add New Tag/Add New Category 327 * - new_item_name - Default is New Tag Name/New Category Name 328 * 329 * Above, the first default value is for non-hierarchical taxonomies (like tags) and the second one is for hierarchical taxonomies (like categories.) 330 * 331 * @since 3.0.0 332 * @param object $tax Taxonomy object 333 * @return object object with all the labels as member variables 334 */ 335 336 function get_taxonomy_labels( $tax ) { 337 $nohier_vs_hier_defaults = array( 338 'name' => array( _x( 'Post Tags', 'taxonomy general name' ), _x( 'Categories', 'taxonomy general name' ) ), 339 'singular_name' => array( _x( 'Post Tag', 'taxonomy singular name' ), _x( 'Category', 'taxonomy singular name' ) ), 340 'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), 341 'popular_items' => array( __( 'Popular Tags' ), __( 'Popular Category' ) ), 342 'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), 343 'parent_item' => array( null, __( 'Parent Category' ) ), 344 'parent_item_colon' => array( null, __( 'Parent Category:' ) ), 345 'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ), 346 'update_item' => array( __( 'Update Tag' ), __( 'Update Category' ) ), 347 'add_new_item' => array( __( 'Add New Tag' ), __( 'Add New Category' ) ), 348 'new_item_name' => array( __( 'New Tag Name' ), __( 'New Category Name' ) ), 349 ); 350 351 return _get_custom_object_labels( $tax, $nohier_vs_hier_defaults ); 307 352 } 308 353 … … 2613 2658 return false; 2614 2659 } 2615 2616 2617 ?>
Note: See TracChangeset
for help on using the changeset viewer.