Changeset 14571
- Timestamp:
- 05/11/2010 07:52:50 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit.php
r14374 r14571 138 138 } 139 139 140 $title = sprintf(__('Edit %s'), $post_type_object->label);141 142 140 wp_enqueue_script('inline-edit-post'); 143 141 … … 166 164 <div class="wrap"> 167 165 <?php screen_icon(); ?> 168 <h2><?php echo esc_html( $ title ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html_x('Add New', 'post'); ?></a> <?php166 <h2><?php echo esc_html( $post_type_object->labels->edit_item ); ?> <a href="<?php echo $post_new_file ?>" class="button add-new-h2"><?php echo esc_html($post_type_object->labels->add_new); ?></a> <?php 169 167 if ( isset($_GET['s']) && $_GET['s'] ) 170 168 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?> … … 263 261 264 262 <p class="search-box"> 265 <label class="screen-reader-text" for="post-search-input"><?php printf( _x('Search %s', '%s: post type name'), $post_type_object->label ); ?>:</label>263 <label class="screen-reader-text" for="post-search-input"><?php echo $post_type_object->labels->search_items; ?>:</label> 266 264 <input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" /> 267 <input type="submit" value="<?php echo esc_attr( sprintf( _x('Search %s', '%s: post type name'), $post_type_object->label )); ?>" class="button" />265 <input type="submit" value="<?php echo esc_attr( $post_type_object->labels->search_items ); ?>" class="button" /> 268 266 </p> 269 267 … … 411 409 <p><?php 412 410 if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] ) 413 printf( __( 'No %s found in the Trash.' ), $post_type_object->label );411 echo $post_type_object->labels->not_found_in_trash; 414 412 else 415 printf( __( 'No %s found.' ), $post_type_object->label );413 echo $post_type_object->labels->not_found; 416 414 ?></p> 417 415 <?php } ?> -
trunk/wp-admin/export.php
r14509 r14571 113 113 <option value="all" selected="selected"><?php _e('All Content'); ?></option> 114 114 <?php foreach ( get_post_types( array( 'public' => true, 'can_export' => true ), 'objects' ) as $post_type_obj ) { ?> 115 <option value="<?php echo $post_type_obj->name; ?>"><?php echo $post_type_obj->label ; ?></option>115 <option value="<?php echo $post_type_obj->name; ?>"><?php echo $post_type_obj->labels->name; ?></option> 116 116 <?php } ?> 117 117 </select> -
trunk/wp-admin/includes/nav-menu.php
r14569 r14571 60 60 } 61 61 ?> 62 <li id="menu-item-<?php echo $item_id; ?>" class="menu-item menu-item-depth-<?php echo $depth; ?> menu-item-<?php echo strtolower(esc_attr( $item->append )); ?>">62 <li id="menu-item-<?php echo $item_id; ?>" class="menu-item menu-item-depth-<?php echo $depth; ?> menu-item-<?php echo esc_attr( $item->object ); ?>"> 63 63 <dl class="menu-item-bar <?php 64 64 if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] ) … … 70 70 <span class="item-title"><?php echo esc_html( $item->title ); ?></span> 71 71 <span class="item-controls"> 72 <span class="item-type"><?php echo esc_html( $item-> append); ?></span>72 <span class="item-type"><?php echo esc_html( $item->type_label ); ?></span> 73 73 <span class="item-order"> 74 74 <a href="<?php … … 162 162 <div class="menu-item-actions description-wide submitbox"> 163 163 <?php if( 'custom' != $item->type ) : ?> 164 <p class="link-to-original"><?php 165 _e('Original '); 166 echo esc_html( $item->append ); 167 echo ":"; ?> 164 <p class="link-to-original"> 165 <?php _e('Original:'); ?> 168 166 <a href="<?php echo esc_attr( $item->url ); ?>"> 169 167 <?php echo esc_html($original_title); ?> … … 185 183 </div> 186 184 187 <input class="menu-item-data-append" type="hidden" name="menu-item-append[<?php echo $item_id; ?>]" value="<?php echo $item->append; ?>" />188 185 <input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" /> 189 186 <input class="menu-item-data-object-id" type="hidden" name="menu-item-object-id[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object_id ); ?>" /> … … 375 372 if ( $post_type ) { 376 373 $id = $post_type->name; 377 add_meta_box( "add-{$id}", $post_type->label , 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );374 add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type ); 378 375 } 379 376 } … … 545 542 546 543 if ( !$posts ) 547 $error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ).'</li>';544 $error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>'; 548 545 549 546 $current_tab = 'all'; … … 866 863 'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ), 867 864 'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ), 868 'menu-item-append' => ( isset( $_item_object_data['menu-item-append'] ) ? $_item_object_data['menu-item-append'] : '' ),869 865 'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ), 870 866 'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ), -
trunk/wp-admin/includes/post.php
r14551 r14571 1080 1080 1081 1081 if ( 'publish' == $post->post_status ) { 1082 if ( 'post' == $post->post_type ) { 1083 $view_post = __('View Post'); 1084 } elseif ( 'page' == $post->post_type ) { 1085 $view_post = __('View Page'); 1086 } else { 1087 $ptype = get_post_type_object($post->post_type); 1088 $view_post = sprintf(__('View %s'), $ptype->singular_label); 1089 } 1082 $ptype = get_post_type_object($post->post_type); 1083 $view_post = $ptype->labels->view_item; 1090 1084 $title = __('Click to edit this part of the permalink'); 1091 1085 } else { -
trunk/wp-admin/includes/template.php
r14524 r14571 14 14 * @since 2.7 15 15 * 16 * Outputs the HTML for the hidden table rows used in Categories, Link Ca tegories and Tags quick edit.17 * 18 * @param string $type "edit-tags", "categorie s" or "edit-link-categories"16 * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit. 17 * 18 * @param string $type "edit-tags", "categoried" or "edit-link-categories" 19 19 * @param string $taxonomy The taxonomy of the row. 20 20 * @return … … 1567 1567 $edit_link = get_edit_post_link( $page->ID ); 1568 1568 ?> 1569 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $title)); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states($page); echo isset($parent_name) ? ' | ' . __('Parent Page: '). esc_html($parent_name) : ''; ?></strong>1569 <td <?php echo $attributes ?>><strong><?php if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr(sprintf(__('Edit “%s”'), $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> 1570 1570 <?php 1571 1571 $actions = array(); … … 3329 3329 switch ( $screen->id ) { 3330 3330 case $post_type_object->name: 3331 $default_action = array('edit.php?post_type=' . $post_type_object->name => array( sprintf(__('Edit %s'), $post_type_object->label), $post_type_object->edit_type_cap));3331 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->edit_type_cap)); 3332 3332 break; 3333 3333 case "edit-{$post_type_object->name}": 3334 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array( sprintf(__('New %s'), $post_type_object->singular_label), $post_type_object->edit_type_cap));3334 $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->edit_type_cap)); 3335 3335 break; 3336 3336 } … … 3747 3747 $post_type = $_GET['post_type']; 3748 3748 $post_type_object = get_post_type_object($post_type); 3749 $per_page_label = $post_type_object->label ;3749 $per_page_label = $post_type_object->labels->name; 3750 3750 break; 3751 3751 case 'ms-sites': -
trunk/wp-admin/js/nav-menu.dev.js
r14531 r14571 810 810 'menu-item-position', 811 811 'menu-item-type', 812 'menu-item-append',813 812 'menu-item-title', 814 813 'menu-item-url', -
trunk/wp-admin/menu.php
r14299 r14571 130 130 $ptype_menu_position++; 131 131 132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->label ), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon ); 133 $submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype"); 134 /* translators: add new custom post type */ 135 $submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" ); 132 $menu[$ptype_menu_position] = array( esc_attr( $ptype_obj->labels->name ), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype", '', 'menu-top menu-icon-' . $ptype_class, 'menu-' . $ptype_class, $menu_icon ); 133 $submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype"); 134 $submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" ); 136 135 137 136 $i = 15; -
trunk/wp-admin/nav-menus.php
r14562 r14571 300 300 if ( ! is_wp_error( $_menu_object ) ) { 301 301 $menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') ); 302 $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item- append', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' );302 $post_fields = array( 'menu-item-db-id', 'menu-item-object-id', 'menu-item-object', 'menu-item-parent-id', 'menu-item-position', 'menu-item-type', 'menu-item-title', 'menu-item-url', 'menu-item-description', 'menu-item-attr-title', 'menu-item-target', 'menu-item-classes', 'menu-item-xfn' ); 303 303 wp_defer_term_counting(true); 304 304 // Loop through all the menu items' POST variables -
trunk/wp-admin/post-new.php
r14107 r14571 27 27 $post_type_object = get_post_type_object($post_type); 28 28 29 $title = sprintf(__('Add New %s'), $post_type_object->singular_label);29 $title = $post_type_object->labels->add_new_item; 30 30 31 31 $editing = true; -
trunk/wp-admin/post.php
r14167 r14571 178 178 } 179 179 180 $title = sprintf(__('Edit %s'), $post_type_object->singular_label);180 $title = $post_type_object->labels->edit_item; 181 181 $post = get_post_to_edit($post_id); 182 182 -
trunk/wp-includes/nav-menu-template.php
r14559 r14571 156 156 $output .= '<input type="hidden" class="menu-item-parent-id" name="menu-item[' . $possible_object_id . '][menu-item-parent-id]" value="'. esc_attr( $item->menu_item_parent ) .'" />'; 157 157 $output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />'; 158 $output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';159 158 $output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />'; 160 159 $output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />'; 161 $output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';162 160 $output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />'; 163 161 $output .= '<input type="hidden" class="menu-item-attr_title" name="menu-item[' . $possible_object_id . '][menu-item-attr_title]" value="'. esc_attr( $item->attr_title ) .'" />'; -
trunk/wp-includes/nav-menu.php
r14560 r14571 232 232 'menu-item-position' => 0, 233 233 'menu-item-type' => 'custom', 234 'menu-item-append' => 'custom',235 234 'menu-item-title' => '', 236 235 'menu-item-url' => '', … … 278 277 279 278 if ( 'trash' == get_post_status( $args['menu-item-object-id'] ) ) { 280 $post_type_object = get_post_type_object( $args['menu-item-object'] ); 281 if ( isset( $post_type_object->singular_label ) ) 282 return new WP_Error('update_nav_menu_item_failed', sprintf(__('The menu item "%1$s" belongs to a %2$s that is in the trash, so it cannot be updated.'), $args['menu-item-title'], $post_type_object->singular_label ) ); 283 else 284 return new WP_Error('update_nav_menu_item_failed', sprintf(__('The menu item "%1$s" belongs to something that is in the trash, so it cannot be updated.'), $args['menu-item-title'] ) ); 279 return new WP_Error('update_nav_menu_item_failed', sprintf(__('The menu item "%1$s" belongs to something that is in the trash, so it cannot be updated.'), $args['menu-item-title'] ) ); 285 280 } 286 281 } … … 486 481 * - type: The family of objects originally represented, such as "post_type" or "taxonomy." 487 482 * - object: The type of object originally represented, such as "category," "post", or "attachment." 488 * - append:The singular label used to describe this type of menu item.483 * - type_label: The singular label used to describe this type of menu item. 489 484 * - post_parent: The DB ID of the original object's parent object, if any (0 otherwise). 490 485 * - menu_item_parent: The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise. … … 513 508 if ( 'post_type' == $menu_item->type ) { 514 509 $object = get_post_type_object( $menu_item->object ); 515 $menu_item-> append = $object->singular_label;510 $menu_item->type_label = $object->labels->singular_name; 516 511 $menu_item->url = get_permalink( $menu_item->object_id ); 517 512 … … 522 517 } elseif ( 'taxonomy' == $menu_item->type ) { 523 518 $object = get_taxonomy( $menu_item->object ); 524 $menu_item-> append= $object->singular_label;519 $menu_item->type_label = $object->singular_label; 525 520 $menu_item->url = get_term_link( (int) $menu_item->object_id, $menu_item->object ); 526 521 … … 529 524 530 525 } else { 531 $menu_item-> append= __('Custom');526 $menu_item->type_label = __('Custom'); 532 527 $menu_item->title = $menu_item->post_title; 533 528 $menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true ); … … 549 544 $object = get_post_type_object( $menu_item->post_type ); 550 545 $menu_item->object = $object->name; 551 $menu_item-> append = strtolower( $object->singular_label );546 $menu_item->type_label = $object->labels->singular_name; 552 547 553 548 $menu_item->title = $menu_item->post_title; … … 570 565 $object = get_taxonomy( $menu_item->taxonomy ); 571 566 $menu_item->object = $object->name; 572 $menu_item-> append = strtolower( $object->singular_label );567 $menu_item->type_label = $object->singular_label; 573 568 574 569 $menu_item->title = $menu_item->name; -
trunk/wp-includes/post.php
r14561 r14571 17 17 function create_initial_post_types() { 18 18 register_post_type( 'post', array( 19 'label' => __( 'Posts' ),20 'singular_label' => __( 'Post' ),21 19 'public' => true, 22 20 'show_ui' => false, … … 31 29 32 30 register_post_type( 'page', array( 33 'label' => __( 'Pages' ),34 'singular_label' => __( 'Page' ),35 31 'public' => true, 36 32 'show_ui' => false, … … 770 766 * Optional $args contents: 771 767 * 772 * label - A (plural) descriptive name for the post type marked for translation. Defaults to $post_type. 773 * singular_label - A (singular) descriptive name for the post type marked for translation. Defaults to $label. 774 * description - A short descriptive summary of what the post type is. Defaults to blank. 775 * public - Whether posts of this type should be shown in the admin UI. Defaults to false. 776 * 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. 777 * publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as. 778 * show_ui - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public. 779 * menu_position - The position in the menu order the post type should appear. Defaults to the bottom. 780 * menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon. 781 * inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 782 * capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 783 * edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 784 * edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 785 * edit_others_cap - The capability that controls editing objects of this post type that are owned by other users. Defaults to "edit_others_ . $capability_type . s" (edit_others_posts). 786 * publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 787 * read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 788 * delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 789 * hierarchical - Whether the post type is hierarchical. Defaults to false. 790 * supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. 791 * register_meta_box_cb - Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback. 792 * taxonomies - An array of taxonomy identifiers that will be registered for the post type. Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type(). 793 * 794 * @package WordPress 795 * @subpackage Post 768 * - description - A short descriptive summary of what the post type is. Defaults to blank. 769 * - public - Whether posts of this type should be shown in the admin UI. Defaults to false. 770 * - 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. 771 * - publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as. 772 * - show_ui - Whether to generate a default UI for managing this post type. Defaults to true if the type is public, false if the type is not public. 773 * - menu_position - The position in the menu order the post type should appear. Defaults to the bottom. 774 * - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon. 775 * - inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none. 776 * - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post". 777 * - edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post). 778 * - edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts). 779 * - edit_others_cap - The capability that controls editing objects of this post type that are owned by other users. Defaults to "edit_others_ . $capability_type . s" (edit_others_posts). 780 * - publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts). 781 * - read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post). 782 * - delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post). 783 * - hierarchical - Whether the post type is hierarchical. Defaults to false. 784 * - supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none. 785 * - register_meta_box_cb - Provide a callback function that will be called when setting up the meta boxes for the edit form. Do remove_meta_box() and add_meta_box() calls in the callback. 786 * - taxonomies - An array of taxonomy identifiers that will be registered for the post type. Default is no taxonomies. Taxonomies can be registered later with register_taxonomy() or register_taxonomy_for_object_type(). 787 * - labels - An array of labels for this post type. You can see accepted values in {@link get_post_type_labels()}. By default post labels are used for non-hierarchical types and page labels for hierarchical ones. 788 * 796 789 * @since 2.9.0 797 790 * @uses $wp_post_types Inserts new post type object into the list … … 799 792 * @param string $post_type Name of the post type. 800 793 * @param array|string $args See above description. 794 * @return object the registered post type object 801 795 */ 802 796 function register_post_type($post_type, $args = array()) { … … 807 801 808 802 // Args prefixed with an underscore are reserved for internal use. 809 $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK, 'can_export' => true ); 803 $defaults = array( 804 'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 805 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 806 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 807 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 808 'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 809 ); 810 810 $args = wp_parse_args($args, $defaults); 811 811 $args = (object) $args; … … 825 825 if ( null === $args->exclude_from_search ) 826 826 $args->exclude_from_search = !$args->public; 827 828 if ( false === $args->label )829 $args->label = $post_type;830 831 if ( false === $args->singular_label )832 $args->singular_label = $args->label;833 827 834 828 if ( empty($args->capability_type) ) … … 881 875 add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1); 882 876 877 $args->labels = get_post_type_labels( $args ); 878 879 // we keep these two only for backwards compatibility 880 // TODO: remove in 3.1 881 $args->label = $args->labels->name; 882 $args->singular_label = $args->labels->singular_name; 883 883 884 $wp_post_types[$post_type] = $args; 884 885 … … 890 891 891 892 return $args; 893 } 894 895 /** 896 * Builds an object with all post type labels out of a post type object 897 * 898 * Accepted keys of the label array in the post type object: 899 * - name - general name for the post type, usually plural. Default is Posts/Pages 900 * - singular_name - name for one object of this post type. Default is Post/Page 901 * - 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> 902 * - add_new_item - Default is Add New Post/Add New Page 903 * - edit_item - Default is Edit Post/Edit Page 904 * - edit - Default is Edit. 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('Edit', 'product');</code> 905 * - new_item - Default is New Post/New Page 906 * - view_item - Default is View Post/View Page 907 * - search_items - Default is Search Posts/Search Pages 908 * - not_found - Default is No posts found/No pages found 909 * - not_found_in_trash - Default is No posts found in Trash/No pages found in Trash 910 * - parent - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page: 911 * 912 * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages.) 913 * 914 * @since 3.0.0 915 * @param object $post_type_object 916 * @return object object with all the labels as member variables 917 */ 918 function get_post_type_labels( $post_type_object ) { 919 $nohier_vs_hier_defaults = array( 920 'name' => array( _x('Posts', 'post type general name'), _x('Pages', 'post type general name') ), 921 'singular_name' => array( _x('Post', 'post type singular name'), _x('Page', 'post type singular name') ), 922 'add_new' => array( _x('Add New', 'post'), _x('Add New', 'page') ), 923 'add_new_item' => array( __('Add New Post'), __('Add New Page') ), 924 'edit_item' => array( __('Edit Post'), __('Edit Page') ), 925 'edit' => array( _x('Edit', 'post'), _x('Edit', 'page') ), 926 'new_item' => array( __('New Post'), __('New Page') ), 927 'view_item' => array( __('View Post'), __('View Page') ), 928 'search_items' => array( __('Search Posts'), __('Search Pages') ), 929 'not_found' => array( __('No posts found'), __('No pages found') ), 930 'not_found_in_trash' => array( __('No posts found in Trash'), __('No pages found in Trash') ), 931 'view' => array( __('View Post'), __('View Page') ), 932 'parent' => array( null, __('Parent Page:') ) 933 ); 934 935 // try to get missing (singular_)?name from older style (singular_)?label member variables 936 // we keep that for backwards compatibility 937 // TODO: remove in 3.1 938 if ( !isset( $post_type_object->labels['name'] ) && isset( $post_type_object->label ) ) { 939 $post_type_object->labels['name'] = $post_type_object->label; 940 } 941 if ( !isset( $post_type_object->labels['singular_name'] ) && isset( $post_type_object->singular_label ) ) { 942 $post_type_object->labels['singular_name'] = $post_type_object->singular_label; 943 } 944 945 $defaults = array_map( create_function( '$x', $post_type_object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults ); 946 $labels = array_merge( $defaults, $post_type_object->labels ); 947 return (object)$labels; 892 948 } 893 949
Note: See TracChangeset
for help on using the changeset viewer.