Make WordPress Core

Changeset 14614


Ignore:
Timestamp:
05/14/2010 12:34:04 AM (15 years ago)
Author:
nbachiyski
Message:

I18n for custom taxonomies. Fixes #13357

Location:
trunk
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r14593 r14614  
    282282
    283283    ob_start();
    284         wp_dropdown_categories( array( 'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => sprintf( __('— Parent %s —'), $taxonomy->singular_label ) ) );
     284        wp_dropdown_categories( array(
     285            'taxonomy' => $taxonomy->name, 'hide_empty' => 0, 'name' => 'new'.$taxonomy->name.'_parent', 'orderby' => 'name',
     286            'hierarchical' => 1, 'show_option_none' => '— '.$taxonomy->labels->parent_item.' —'
     287        ) );
    285288    $sup = ob_get_contents();
    286289    ob_end_clean();
  • trunk/wp-admin/edit-form-advanced.php

    r14585 r14614  
    113113        continue;
    114114
    115     $label = isset($taxonomy->label) ? esc_attr($taxonomy->label) : $tax_name;
     115    $label = $taxonomy->labels->name;
    116116
    117117    if ( !is_taxonomy_hierarchical($tax_name) )
  • trunk/wp-admin/edit-tag-form.php

    r14398 r14614  
    2525<div class="wrap">
    2626<?php screen_icon(); ?>
    27 <h2><?php printf(_x('Edit %s', '%s: singular taxonomy name'), $tax->singular_label); ?></h2>
     27<h2><?php echo $tax->labels->edit_item; ?></h2>
    2828<div id="ajax-response"></div>
    2929<form name="edittag" id="edittag" method="post" action="edit-tags.php" class="validate">
     
    7676do_action($taxonomy . '_edit_form', $tag, $taxonomy);
    7777?>
    78 <p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php echo esc_attr( sprintf(_x('Update %s', '%s: singular taxonomy name'), $tax->singular_label)); ?>" /></p>
     78<p class="submit"><input type="submit" class="button-primary" name="submit" value="<?php echo esc_attr( __( 'Update' ) ); ?>" /></p>
    7979</form>
    8080</div>
  • trunk/wp-admin/edit-tags.php

    r14594 r14614  
    2020$tax = get_taxonomy($taxonomy);
    2121
    22 $title = $tax->label;
     22$title = $tax->labels->name;
    2323
    2424if ( empty($post_type) || !in_array( $post_type, get_post_types( array('public' => true) ) ) )
     
    117117
    118118case 'edit':
    119     $title = sprintf(_x('Edit %s', '%s: singular taxonomy name'), $tax->singular_label);
     119    $title = $tax->labels->edit_item;
    120120
    121121    require_once ('admin-header.php');
     
    193193<input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" />
    194194<p class="search-box">
    195     <label class="screen-reader-text" for="tag-search-input"><?php printf(_x('Search %s', '%s: plural taxonomy name'), $tax->label); ?>:</label>
     195    <label class="screen-reader-text" for="tag-search-input"><?php echo $tax->labels->search_items; ?>:</label>
    196196    <input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
    197     <input type="submit" value="<?php echo esc_attr( sprintf(_x('Search %s', '%s: plural taxonomy name'), $tax->label) ); ?>" class="button" />
     197    <input type="submit" value="<?php echo esc_attr( $tax->labels->search_items ); ?>" class="button" />
    198198</p>
    199199</form>
     
    327327?>
    328328<div class="tagcloud">
    329 <h3><?php printf(_x('Popular %s', '%s: plural taxonomy name'), $tax->label); ?></h3>
     329<h3><?php echo $tax->labels->popular_items; ?></h3>
    330330<?php echo $tag_cloud; unset( $tag_cloud ); ?>
    331331</div>
     
    342342
    343343<div class="form-wrap">
    344 <h3><?php printf(_x('Add a New %s', '%s: singular taxonomy name'), $tax->singular_label); ?></h3>
     344<h3><?php echo $tax->labels->add_new_item; ?></h3>
    345345<form id="addtag" method="post" action="edit-tags.php" class="validate">
    346346<input type="hidden" name="action" value="add-tag" />
     
    380380do_action($taxonomy . '_add_form_fields', $taxonomy);
    381381?>
    382 <p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php echo esc_attr(sprintf(_x('Add %s', '%s: singular  taxonomy name'), $tax->singular_label)); ?>" /></p>
     382<p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" /></p>
    383383<?php
    384384if ( 'category' == $taxonomy )
  • trunk/wp-admin/export.php

    r14571 r14614  
    102102    $term_dropdown = wp_dropdown_categories( array( 'taxonomy' => $tax_obj->name, 'hide_if_empty' => true, 'show_option_all' => __( 'All Terms' ), 'name' => 'taxonomy[' . $tax_obj->name . ']', 'id' => 'taxonomy-' . $tax_obj->name, 'class' => '', 'echo' => false ) );
    103103    if ( $term_dropdown )
    104         echo '<label for="taxonomy-' . $tax_obj->name . '">' . $tax_obj->label . '</label>: ' . $term_dropdown . '<br/>';
     104        echo '<label for="taxonomy-' . $tax_obj->name . '">' . $tax_obj->labels->name . '</label>: ' . $term_dropdown . '<br/>';
    105105}
    106106?>
  • trunk/wp-admin/includes/meta-boxes.php

    r14593 r14614  
    297297    <div id="taxonomy-<?php echo $taxonomy; ?>" class="categorydiv">
    298298        <ul id="<?php echo $taxonomy; ?>-tabs" class="category-tabs">
    299             <li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php printf( __( 'All %s' ), $tax->label ); ?></a></li>
     299            <li class="tabs"><a href="#<?php echo $taxonomy; ?>-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
    300300            <li class="hide-if-no-js"><a href="#<?php echo $taxonomy; ?>-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
    301301        </ul>
     
    321321    <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
    322322            <div id="<?php echo $taxonomy; ?>-adder" class="wp-hidden-children">
    323                 <h4><a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
     323                <h4>
     324                    <a id="<?php echo $taxonomy; ?>-add-toggle" href="#<?php echo $taxonomy; ?>-add" class="hide-if-no-js" tabindex="3">
     325                        <?php
     326                            /* translators: %s: add new taxonomy label */
     327                            printf( __( '+ %s' ), $tax->labels->add_new_item );
     328                        ?>
     329                    </a>
     330                </h4>
    324331                <p id="<?php echo $taxonomy; ?>-add" class="category-add wp-hidden-child">
    325                     <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php printf( __( 'Add New %s' ), $tax->singular_label ); ?></label><input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( sprintf( 'New %s Name', $tax->singular_label ) ); ?>" tabindex="3" aria-required="true"/>
    326                     <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent"><?php printf( __('Parent %s'), $tax->singular_label ); ?>:</label><?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => sprintf( __('&mdash; Parent %s &mdash;'), $tax->singular_label ), 'tab_index' => 3 ) ); ?>
    327                     <input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
     332                    <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>"><?php echo $tax->labels->add_new_item; ?></label>
     333                    <input type="text" name="new<?php echo $taxonomy; ?>" id="new<?php echo $taxonomy; ?>" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
     334                    <label class="screen-reader-text" for="new<?php echo $taxonomy; ?>_parent">
     335                        <?php echo $tax->labels->parent_item_colon; ?>
     336                    </label>
     337                    <?php wp_dropdown_categories( array( 'taxonomy' => $taxonomy, 'hide_empty' => 0, 'name' => 'new'.$taxonomy.'_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
     338                    <input type="button" id="<?php echo $taxonomy; ?>-add-submit" class="add:<?php echo $taxonomy ?>checklist:<?php echo $taxonomy ?>-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
    328339                    <?php wp_nonce_field( 'add-'.$taxonomy, '_ajax_nonce', false ); ?>
    329340                    <span id="<?php echo $taxonomy; ?>-ajax-response"></span>
  • trunk/wp-admin/includes/nav-menu.php

    r14602 r14614  
    392392        if ( $tax ) {
    393393            $id = $tax->name;
    394             add_meta_box( "add-{$id}", $tax->label, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
     394            add_meta_box( "add-{$id}", $tax->labels->name, 'wp_nav_menu_item_taxonomy_meta_box', 'nav-menus', 'side', 'default', $tax );
    395395        }
    396396    }
  • trunk/wp-admin/includes/template.php

    r14593 r14614  
    6464    <p class="inline-edit-save submit">
    6565        <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
    66         <?php $update_text = sprintf( __('Update %s'), $tax->singular_label ); ?>
     66        <?php $update_text = $tax->labels->update_item; ?>
    6767        <a accesskey="s" href="#inline-edit" title="<?php echo esc_attr( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
    6868        <img class="waiting" style="display:none;" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
     
    977977<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
    978978
    979         <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->label) ?>
     979        <span class="title inline-edit-categories-label"><?php echo esc_html($taxonomy->labels->name) ?>
    980980            <span class="catshow"><?php _e('[more]'); ?></span>
    981981            <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
     
    10411041
    10421042        <label class="inline-edit-tags">
    1043             <span class="title"><?php echo esc_html($taxonomy->label) ?></span>
     1043            <span class="title"><?php echo esc_html($taxonomy->labels->name) ?></span>
    10441044            <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr($taxonomy->name)?>]" class="tax_input_<?php echo esc_attr($taxonomy->name)?>"></textarea>
    10451045        </label>
     
    15671567        $edit_link = get_edit_post_link( $page->ID );
    15681568        ?>
    1569         <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent . ' ' . esc_html($parent_name) : ''; ?></strong>
     1569        <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->cap->edit_post, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit &#8220;%s&#8221;'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html($parent_name) : ''; ?></strong>
    15701570        <?php
    15711571        $actions = array();
     
    37633763        case 'edit-tags':
    37643764            global $tax;
    3765             $per_page_label = $tax->label;
     3765            $per_page_label = $tax->labels->name;
    37663766            break;
    37673767        case 'plugins':
  • trunk/wp-admin/menu.php

    r14593 r14614  
    9090            continue;
    9191
    92         $submenu['edit.php'][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
     92        $submenu['edit.php'][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, 'edit-tags.php?taxonomy=' . $tax->name );
    9393    }
    9494    unset($tax);
     
    139139            continue;
    140140
    141         $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr($tax->label), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
     141        $submenu["edit.php?post_type=$ptype"][$i++] = array( esc_attr( $tax->labels->name ), $tax->cap->manage_terms, "edit-tags.php?taxonomy=$tax->name&amp;post_type=$ptype" );
    142142    }
    143143}
  • trunk/wp-admin/press-this.php

    r14593 r14614  
    489489
    490490                    <ul id="category-tabs" class="category-tabs">
    491                         <li class="tabs"><a href="#category-all" tabindex="3"><?php printf( __( 'All %s' ), $tax->label ); ?></a></li>
     491                        <li class="tabs"><a href="#category-all" tabindex="3"><?php echo $tax->labels->all_items; ?></a></li>
    492492                        <li class="hide-if-no-js"><a href="#category-pop" tabindex="3"><?php _e( 'Most Used' ); ?></a></li>
    493493                    </ul>
     
    510510                    <?php if ( current_user_can($tax->cap->edit_terms) ) : ?>
    511511                        <div id="category-adder" class="wp-hidden-children">
    512                             <h4><a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3"><?php printf( __( '+ Add New %s' ), $tax->singular_label ); ?></a></h4>
     512                            <h4>
     513                                <a id="category-add-toggle" href="#category-add" class="hide-if-no-js" tabindex="3">
     514                                    <?php printf( __( '+ %s' ), $tax->labels->add_new_item ); ?>
     515                                </a>
     516                            </h4>
    513517                            <p id="category-add" class="category-add wp-hidden-child">
    514                                 <label class="screen-reader-text" for="newcategory"><?php printf( __( 'Add New %s' ), $tax->singular_label ); ?></label><input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( sprintf( 'New %s Name', $tax->singular_label ) ); ?>" tabindex="3" aria-required="true"/>
    515                                 <label class="screen-reader-text" for="newcategory_parent"><?php printf( __('Parent %s'), $tax->singular_label ); ?>:</label><?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => sprintf( __('&mdash; Parent %s &mdash;'), $tax->singular_label ), 'tab_index' => 3 ) ); ?>
    516                                 <input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-sumbit" value="<?php esc_attr_e( 'Add' ); ?>" tabindex="3" />
     518                                <label class="screen-reader-text" for="newcategory"><?php echo $tax->labels->add_new_item; ?></label>
     519                                <input type="text" name="newcategory" id="newcategory" class="form-required form-input-tip" value="<?php echo esc_attr( $tax->labels->new_item_name ); ?>" tabindex="3" aria-required="true"/>
     520                                <label class="screen-reader-text" for="newcategory_parent">
     521                                    <?php echo $tax->labels->parent_item_colon; ?>
     522                                </label>
     523                                <?php wp_dropdown_categories( array( 'taxonomy' => 'category', 'hide_empty' => 0, 'name' => 'newcategory_parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => '&mdash; ' . $tax->labels->parent_item . ' &mdash;', 'tab_index' => 3 ) ); ?>
     524                                <input type="button" id="category-add-submit" class="add:categorychecklist:category-add button category-add-sumbit" value="<?php echo esc_attr( $tax->labels->add_new_item ); ?>" tabindex="3" />
    517525                                <?php wp_nonce_field( 'add-category', '_ajax_nonce', false ); ?>
    518526                                <span id="category-ajax-response"></span>
  • trunk/wp-includes/default-widgets.php

    r14607 r14614  
    10041004            } else {
    10051005                $tax = get_taxonomy($current_taxonomy);
    1006                 $title = $tax->label;
     1006                $title = $tax->labels->name;
    10071007            }
    10081008        }
     
    10331033    <?php foreach ( get_object_taxonomies('post') as $taxonomy ) :
    10341034                $tax = get_taxonomy($taxonomy);
    1035                 if ( !$tax->show_tagcloud || empty($tax->label) )
     1035                if ( !$tax->show_tagcloud || empty($tax->labels->name) )
    10361036                    continue;
    10371037    ?>
    1038         <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->label ?></option>
     1038        <option value="<?php echo esc_attr($taxonomy) ?>" <?php selected($taxonomy, $current_taxonomy) ?>><?php echo $tax->labels->name; ?></option>
    10391039    <?php endforeach; ?>
    10401040    </select></p><?php
  • trunk/wp-includes/general-template.php

    r14556 r14614  
    589589        $taxonomy = get_query_var( 'taxonomy' );
    590590        $tax = get_taxonomy( $taxonomy );
    591         $tax = $tax->label;
    592591        $term = $wp_query->get_queried_object();
    593592        $term = $term->name;
    594         $title = $tax . $t_sep . $term;
     593        $title = $tax->labels->name . $t_sep . $term;
    595594    }
    596595
  • trunk/wp-includes/nav-menu.php

    r14611 r14614  
    539539            } elseif ( 'taxonomy' == $menu_item->type ) {
    540540                $object = get_taxonomy( $menu_item->object );
    541                 $menu_item->type_label = $object->singular_label;
     541                $menu_item->type_label = $object->labels->singular_name;
    542542                $term_url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
    543543                $menu_item->url = !is_wp_error( $term_url ) ? $term_url : '';
     
    588588        $object = get_taxonomy( $menu_item->taxonomy );
    589589        $menu_item->object = $object->name;
    590         $menu_item->type_label = $object->singular_label;
     590        $menu_item->type_label = $object->labels->singular_name;
    591591
    592592        $menu_item->title = $menu_item->name;
  • trunk/wp-includes/post.php

    r14602 r14614  
    4141
    4242    register_post_type( 'attachment', array(
    43         'label' => __( 'Media' ),
     43        'labels' => array(
     44            'name' => __( 'Media' ),
     45        ),
    4446        'public' => true,
    4547        'show_ui' => false,
     
    5456
    5557    register_post_type( 'revision', array(
    56         'label' => __( 'Revisions' ),
    57         'singular_label' => __( 'Revision' ),
     58        'labels' => array(
     59            'name' => __( 'Revisions' ),
     60            'singular_name' => __( 'Revision' ),
     61        ),
    5862        'public' => false,
    5963        '_builtin' => true, /* internal use only. don't use this when registering your own post type. */
     
    6670
    6771    register_post_type( 'nav_menu_item', array(
    68         'label' => __( 'Navigation Menu Items' ),
    69         'singular_label' => __( 'Navigation Menu Item' ),
     72        'labels' => array(
     73            'name' => __( 'Navigation Menu Items' ),
     74            'singular_name' => __( 'Navigation Menu Item' ),
     75        ),
    7076        'public' => false,
    7177        'show_ui' => false,
     
    926932 * - not_found - Default is No posts found/No pages found
    927933 * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash
    928  * - parent - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
     934 * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
    929935 *
    930936 * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages.)
     
    948954        'not_found_in_trash' => array( __('No posts found in Trash'), __('No pages found in Trash') ),
    949955        'view' => array( __('View Post'), __('View Page') ),
    950         'parent' => array( null, __('Parent Page:') )
     956        'parent_item_colon' => array( null, __('Parent Page:') )
    951957    );
     958    return _get_custom_object_labels( $post_type_object, $nohier_vs_hier_defaults );
     959}
     960
     961/**
     962 * Builds an object with custom-something object (post type, taxonomy) labels out of a custom-something object
     963 *
     964 * @access private
     965 */
     966function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) {
    952967   
    953968    // try to get missing (singular_)?name from older style (singular_)?label member variables
    954969    // we keep that for backwards compatibility
    955970    // TODO: remove in 3.1
    956     if ( !isset( $post_type_object->labels['name'] ) && isset( $post_type_object->label ) ) {
    957         $post_type_object->labels['name'] = $post_type_object->label;
    958     }
    959     if ( !isset( $post_type_object->labels['singular_name'] ) && isset( $post_type_object->singular_label ) ) {
    960         $post_type_object->labels['singular_name'] = $post_type_object->singular_label;
     971    if ( !isset( $object->labels['name'] ) && isset( $object->label ) ) {
     972        $object->labels['name'] = $object->label;
     973    }
     974    if ( !isset( $object->labels['singular_name'] ) && isset( $object->singular_label ) ) {
     975        $object->labels['singular_name'] = $object->singular_label;
    961976    }
    962977   
    963     $defaults = array_map( create_function( '$x', $post_type_object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
    964     $labels = array_merge( $defaults, $post_type_object->labels );
    965     return (object)$labels;
     978    if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
     979        $object->labels['singular_name'] = $object->labels['name'];
     980    }
     981   
     982    $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
     983    $labels = array_merge( $defaults, $object->labels );
     984    return (object)$labels;
    966985}
    967986
  • trunk/wp-includes/taxonomy.php

    r14606 r14614  
    1919        'hierarchical' => true,
    2020        'update_count_callback' => '_update_post_term_count',
    21         'label' => __( 'Categories' ),
    22         'singular_label' => __( 'Category' ),
    2321        'query_var' => false,
    2422        'rewrite' => false,
     
    3129        'hierarchical' => false,
    3230        'update_count_callback' => '_update_post_term_count',
    33         'label' => __( 'Post Tags' ),
    34         'singular_label' => __( 'Post Tag' ),
    3531        'query_var' => false,
    3632        'rewrite' => false,
     
    4238    register_taxonomy( 'nav_menu', 'nav_menu_item', array(
    4339        'hierarchical' => false,
    44         'label' => __( 'Navigation Menus' ),
    45         'singular_label' => __( 'Navigation Menu' ),
     40        'labels' => array(
     41            'name' => __( 'Navigation Menus' ),
     42            'singular_name' => __( 'Navigation Menu' ),
     43        ),
    4644        'query_var' => false,
    4745        'rewrite' => false,
     
    5250    register_taxonomy( 'link_category', 'link', array(
    5351        'hierarchical' => false,
    54         'label' => __( 'Categories' ),
     52        'labels' => array(
     53            'name' => __( 'Categories' ),
     54            'singular_name' => __( 'Category' ),
     55        ),
    5556        'query_var' => false,
    5657        'rewrite' => false,
     
    231232 * show_tagcloud - false to prevent the taxonomy being listed in the Tag Cloud Widget;
    232233 * 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.
    233236 *
    234237 * @package WordPress
     
    255258                        'public' => true,
    256259                        'show_ui' => null,
    257                         'label' => null,
    258260                        'show_tagcloud' => null,
    259261                        '_builtin' => false,
     262                        'labels' => array(),
    260263                        'capabilities' => array(),
    261                         );
     264                    );
    262265    $args = wp_parse_args($args, $defaults);
    263266
     
    283286    if ( is_null($args['show_tagcloud']) )
    284287        $args['show_tagcloud'] = $args['show_ui'];
    285 
    286     if ( is_null($args['label'] ) )
    287         $args['label'] = $taxonomy;
    288288
    289289    $default_caps = array(
     
    296296    unset( $args['capabilities'] );
    297297
    298     if ( empty($args['singular_label']) )
    299         $args['singular_label'] = $args['label'];
    300 
    301298    $args['name'] = $taxonomy;
    302299    $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   
    303307    $wp_taxonomies[$taxonomy] = (object) $args;
    304308
    305309    // register callback handling for metabox
    306310    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
     336function 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 );
    307352}
    308353
     
    26132658    return false;
    26142659}
    2615 
    2616 
    2617 ?>
Note: See TracChangeset for help on using the changeset viewer.