I18n for custom post type labels. Props demetris, dimadin. Fixes #12968
git-svn-id: http://svn.automattic.com/wordpress/trunk@14571 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
00c831f44a
commit
46afe7c285
|
@ -137,8 +137,6 @@ if ( isset($_GET['doaction']) || isset($_GET['doaction2']) || isset($_GET['delet
|
|||
exit;
|
||||
}
|
||||
|
||||
$title = sprintf(__('Edit %s'), $post_type_object->label);
|
||||
|
||||
wp_enqueue_script('inline-edit-post');
|
||||
|
||||
$user_posts = false;
|
||||
|
@ -165,7 +163,7 @@ else
|
|||
|
||||
<div class="wrap">
|
||||
<?php screen_icon(); ?>
|
||||
<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> <?php
|
||||
<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
|
||||
if ( isset($_GET['s']) && $_GET['s'] )
|
||||
printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', get_search_query() ); ?>
|
||||
</h2>
|
||||
|
@ -262,9 +260,9 @@ endif;
|
|||
</ul>
|
||||
|
||||
<p class="search-box">
|
||||
<label class="screen-reader-text" for="post-search-input"><?php printf( _x('Search %s', '%s: post type name'), $post_type_object->label ); ?>:</label>
|
||||
<label class="screen-reader-text" for="post-search-input"><?php echo $post_type_object->labels->search_items; ?>:</label>
|
||||
<input type="text" id="post-search-input" name="s" value="<?php the_search_query(); ?>" />
|
||||
<input type="submit" value="<?php echo esc_attr( sprintf( _x('Search %s', '%s: post type name'), $post_type_object->label ) ); ?>" class="button" />
|
||||
<input type="submit" value="<?php echo esc_attr( $post_type_object->labels->search_items ); ?>" class="button" />
|
||||
</p>
|
||||
|
||||
<input type="hidden" name="post_status" class="post_status_page" value="<?php echo !empty($_GET['post_status']) ? esc_attr($_GET['post_status']) : 'all'; ?>" />
|
||||
|
@ -410,9 +408,9 @@ if ( $page_links )
|
|||
<div class="clear"></div>
|
||||
<p><?php
|
||||
if ( isset($_GET['post_status']) && 'trash' == $_GET['post_status'] )
|
||||
printf( __( 'No %s found in the Trash.' ), $post_type_object->label );
|
||||
echo $post_type_object->labels->not_found_in_trash;
|
||||
else
|
||||
printf( __( 'No %s found.' ), $post_type_object->label );
|
||||
echo $post_type_object->labels->not_found;
|
||||
?></p>
|
||||
<?php } ?>
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ foreach ( (array) $authors as $author ) {
|
|||
<select name="post_type" id="post_type">
|
||||
<option value="all" selected="selected"><?php _e('All Content'); ?></option>
|
||||
<?php foreach ( get_post_types( array( 'public' => true, 'can_export' => true ), 'objects' ) as $post_type_obj ) { ?>
|
||||
<option value="<?php echo $post_type_obj->name; ?>"><?php echo $post_type_obj->label; ?></option>
|
||||
<option value="<?php echo $post_type_obj->name; ?>"><?php echo $post_type_obj->labels->name; ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
|
|
|
@ -59,7 +59,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
$original_title = $original_object->post_title;
|
||||
}
|
||||
?>
|
||||
<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 )); ?>">
|
||||
<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 ); ?>">
|
||||
<dl class="menu-item-bar <?php
|
||||
if ( isset($_GET['edit-menu-item']) && $item_id == $_GET['edit-menu-item'] )
|
||||
echo 'menu-item-edit-active';
|
||||
|
@ -69,7 +69,7 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<dt class="menu-item-handle">
|
||||
<span class="item-title"><?php echo esc_html( $item->title ); ?></span>
|
||||
<span class="item-controls">
|
||||
<span class="item-type"><?php echo esc_html( $item->append ); ?></span>
|
||||
<span class="item-type"><?php echo esc_html( $item->type_label ); ?></span>
|
||||
<span class="item-order">
|
||||
<a href="<?php
|
||||
echo wp_nonce_url(
|
||||
|
@ -161,10 +161,8 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
|
||||
<div class="menu-item-actions description-wide submitbox">
|
||||
<?php if( 'custom' != $item->type ) : ?>
|
||||
<p class="link-to-original"><?php
|
||||
_e('Original ');
|
||||
echo esc_html( $item->append );
|
||||
echo ":"; ?>
|
||||
<p class="link-to-original">
|
||||
<?php _e('Original:'); ?>
|
||||
<a href="<?php echo esc_attr( $item->url ); ?>">
|
||||
<?php echo esc_html($original_title); ?>
|
||||
</a>
|
||||
|
@ -184,7 +182,6 @@ class Walker_Nav_Menu_Edit extends Walker_Nav_Menu {
|
|||
<input class="button-primary save-menu-item" name="save_menu_item" type="submit" value="<?php esc_attr_e('Save Menu Item'); ?>" />
|
||||
</div>
|
||||
|
||||
<input class="menu-item-data-append" type="hidden" name="menu-item-append[<?php echo $item_id; ?>]" value="<?php echo $item->append; ?>" />
|
||||
<input class="menu-item-data-db-id" type="hidden" name="menu-item-db-id[<?php echo $item_id; ?>]" value="<?php echo $item_id; ?>" />
|
||||
<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 ); ?>" />
|
||||
<input class="menu-item-data-object" type="hidden" name="menu-item-object[<?php echo $item_id; ?>]" value="<?php echo esc_attr( $item->object ); ?>" />
|
||||
|
@ -374,7 +371,7 @@ function wp_nav_menu_post_type_meta_boxes() {
|
|||
$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );
|
||||
if ( $post_type ) {
|
||||
$id = $post_type->name;
|
||||
add_meta_box( "add-{$id}", $post_type->label, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
|
||||
add_meta_box( "add-{$id}", $post_type->labels->name, 'wp_nav_menu_item_post_type_meta_box', 'nav-menus', 'side', 'default', $post_type );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -544,7 +541,7 @@ function wp_nav_menu_item_post_type_meta_box( $object, $post_type ) {
|
|||
));
|
||||
|
||||
if ( !$posts )
|
||||
$error = '<li id="error">'. sprintf( __( 'No %s exists' ), $post_type['args']->label ) .'</li>';
|
||||
$error = '<li id="error">'. $post_type['args']->labels->not_found .'</li>';
|
||||
|
||||
$current_tab = 'all';
|
||||
if ( isset( $_REQUEST[$post_type_name . '-tab'] ) && in_array( $_REQUEST[$post_type_name . '-tab'], array('all', 'search') ) ) {
|
||||
|
@ -865,7 +862,6 @@ function wp_save_nav_menu_item( $menu_id = 0, $menu_data = array() ) {
|
|||
'menu-item-parent-id' => ( isset( $_item_object_data['menu-item-parent-id'] ) ? $_item_object_data['menu-item-parent-id'] : '' ),
|
||||
'menu-item-position' => ( isset( $_item_object_data['menu-item-position'] ) ? $_item_object_data['menu-item-position'] : '' ),
|
||||
'menu-item-type' => ( isset( $_item_object_data['menu-item-type'] ) ? $_item_object_data['menu-item-type'] : '' ),
|
||||
'menu-item-append' => ( isset( $_item_object_data['menu-item-append'] ) ? $_item_object_data['menu-item-append'] : '' ),
|
||||
'menu-item-title' => ( isset( $_item_object_data['menu-item-title'] ) ? $_item_object_data['menu-item-title'] : '' ),
|
||||
'menu-item-url' => ( isset( $_item_object_data['menu-item-url'] ) ? $_item_object_data['menu-item-url'] : '' ),
|
||||
'menu-item-description' => ( isset( $_item_object_data['menu-item-description'] ) ? $_item_object_data['menu-item-description'] : '' ),
|
||||
|
|
|
@ -1079,14 +1079,8 @@ function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
|
|||
list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug);
|
||||
|
||||
if ( 'publish' == $post->post_status ) {
|
||||
if ( 'post' == $post->post_type ) {
|
||||
$view_post = __('View Post');
|
||||
} elseif ( 'page' == $post->post_type ) {
|
||||
$view_post = __('View Page');
|
||||
} else {
|
||||
$ptype = get_post_type_object($post->post_type);
|
||||
$view_post = sprintf(__('View %s'), $ptype->singular_label);
|
||||
}
|
||||
$view_post = $ptype->labels->view_item;
|
||||
$title = __('Click to edit this part of the permalink');
|
||||
} else {
|
||||
$title = __('Temporary permalink. Click to edit this part.');
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
*
|
||||
* @since 2.7
|
||||
*
|
||||
* Outputs the HTML for the hidden table rows used in Categories, Link Categories and Tags quick edit.
|
||||
* Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
|
||||
*
|
||||
* @param string $type "edit-tags", "categories" or "edit-link-categories"
|
||||
* @param string $type "edit-tags", "categoried" or "edit-link-categories"
|
||||
* @param string $taxonomy The taxonomy of the row.
|
||||
* @return
|
||||
*/
|
||||
|
@ -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 );
|
||||
?>
|
||||
<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>
|
||||
<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>
|
||||
<?php
|
||||
$actions = array();
|
||||
if ( current_user_can($post_type_object->edit_cap, $page->ID) && $post->post_status != 'trash' ) {
|
||||
|
@ -3328,10 +3328,10 @@ function favorite_actions( $screen = null ) {
|
|||
if ( isset($post_type_object) ) {
|
||||
switch ( $screen->id ) {
|
||||
case $post_type_object->name:
|
||||
$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));
|
||||
$default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->edit_type_cap));
|
||||
break;
|
||||
case "edit-{$post_type_object->name}":
|
||||
$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));
|
||||
$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));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -3746,7 +3746,7 @@ function screen_options($screen) {
|
|||
if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array('public' => true ) ) ) )
|
||||
$post_type = $_GET['post_type'];
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
$per_page_label = $post_type_object->label;
|
||||
$per_page_label = $post_type_object->labels->name;
|
||||
break;
|
||||
case 'ms-sites':
|
||||
$per_page_label = __('Sites');
|
||||
|
|
|
@ -809,7 +809,6 @@ var wpNavMenu;
|
|||
'menu-item-parent-id',
|
||||
'menu-item-position',
|
||||
'menu-item-type',
|
||||
'menu-item-append',
|
||||
'menu-item-title',
|
||||
'menu-item-url',
|
||||
'menu-item-description',
|
||||
|
|
|
@ -129,10 +129,9 @@ foreach ( (array) get_post_types( array('show_ui' => true) ) as $ptype ) {
|
|||
while ( isset($menu[$ptype_menu_position]) || in_array($ptype_menu_position, $core_menu_positions) )
|
||||
$ptype_menu_position++;
|
||||
|
||||
$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 );
|
||||
$submenu["edit.php?post_type=$ptype"][5] = array( __('Edit'), $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype");
|
||||
/* translators: add new custom post type */
|
||||
$submenu["edit.php?post_type=$ptype"][10] = array( _x('Add New', 'post'), $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" );
|
||||
$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 );
|
||||
$submenu["edit.php?post_type=$ptype"][5] = array( $ptype_obj->labels->edit, $ptype_obj->edit_type_cap, "edit.php?post_type=$ptype");
|
||||
$submenu["edit.php?post_type=$ptype"][10] = array( $ptype_obj->labels->add_new, $ptype_obj->edit_type_cap, "post-new.php?post_type=$ptype" );
|
||||
|
||||
$i = 15;
|
||||
foreach ( $wp_taxonomies as $tax ) {
|
||||
|
|
|
@ -299,7 +299,7 @@ switch ( $action ) {
|
|||
|
||||
if ( ! is_wp_error( $_menu_object ) ) {
|
||||
$menu_items = wp_get_nav_menu_items( $nav_menu_selected_id, array('orderby' => 'ID', 'output' => ARRAY_A, 'output_key' => 'ID') );
|
||||
$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' );
|
||||
$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' );
|
||||
wp_defer_term_counting(true);
|
||||
// Loop through all the menu items' POST variables
|
||||
if ( ! empty( $_POST['menu-item-db-id'] ) ) {
|
||||
|
|
|
@ -26,7 +26,7 @@ if ( 'post' != $post_type ) {
|
|||
|
||||
$post_type_object = get_post_type_object($post_type);
|
||||
|
||||
$title = sprintf(__('Add New %s'), $post_type_object->singular_label);
|
||||
$title = $post_type_object->labels->add_new_item;
|
||||
|
||||
$editing = true;
|
||||
|
||||
|
|
|
@ -177,7 +177,7 @@ case 'edit':
|
|||
wp_enqueue_script('autosave');
|
||||
}
|
||||
|
||||
$title = sprintf(__('Edit %s'), $post_type_object->singular_label);
|
||||
$title = $post_type_object->labels->edit_item;
|
||||
$post = get_post_to_edit($post_id);
|
||||
|
||||
if ( post_type_supports($post_type, 'comments') ) {
|
||||
|
|
|
@ -155,10 +155,8 @@ class Walker_Nav_Menu_Checklist extends Walker_Nav_Menu {
|
|||
$output .= '<input type="hidden" class="menu-item-object" name="menu-item[' . $possible_object_id . '][menu-item-object]" value="'. esc_attr( $item->object ) .'" />';
|
||||
$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 ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-type" name="menu-item[' . $possible_object_id . '][menu-item-type]" value="'. esc_attr( $item->type ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-title" name="menu-item[' . $possible_object_id . '][menu-item-title]" value="'. esc_attr( $item->title ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-url" name="menu-item[' . $possible_object_id . '][menu-item-url]" value="'. esc_attr( $item->url ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-append" name="menu-item[' . $possible_object_id . '][menu-item-append]" value="'. esc_attr( $item->append ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-target" name="menu-item[' . $possible_object_id . '][menu-item-target]" value="'. esc_attr( $item->target ) .'" />';
|
||||
$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 ) .'" />';
|
||||
$output .= '<input type="hidden" class="menu-item-description" name="menu-item[' . $possible_object_id . '][menu-item-description]" value="'. esc_attr( $item->description ) .'" />';
|
||||
|
|
|
@ -231,7 +231,6 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
|||
'menu-item-parent-id' => 0,
|
||||
'menu-item-position' => 0,
|
||||
'menu-item-type' => 'custom',
|
||||
'menu-item-append' => 'custom',
|
||||
'menu-item-title' => '',
|
||||
'menu-item-url' => '',
|
||||
'menu-item-description' => '',
|
||||
|
@ -277,10 +276,6 @@ function wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0, $menu_item
|
|||
$original_title = $original_object->post_title;
|
||||
|
||||
if ( 'trash' == get_post_status( $args['menu-item-object-id'] ) ) {
|
||||
$post_type_object = get_post_type_object( $args['menu-item-object'] );
|
||||
if ( isset( $post_type_object->singular_label ) )
|
||||
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 ) );
|
||||
else
|
||||
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'] ) );
|
||||
}
|
||||
}
|
||||
|
@ -485,7 +480,7 @@ function wp_get_nav_menu_items( $menu, $args = array() ) {
|
|||
* - object_id: The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories.
|
||||
* - type: The family of objects originally represented, such as "post_type" or "taxonomy."
|
||||
* - object: The type of object originally represented, such as "category," "post", or "attachment."
|
||||
* - append: The singular label used to describe this type of menu item.
|
||||
* - type_label: The singular label used to describe this type of menu item.
|
||||
* - post_parent: The DB ID of the original object's parent object, if any (0 otherwise).
|
||||
* - menu_item_parent: The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise.
|
||||
* - url: The URL to which this menu item points.
|
||||
|
@ -512,7 +507,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
|||
|
||||
if ( 'post_type' == $menu_item->type ) {
|
||||
$object = get_post_type_object( $menu_item->object );
|
||||
$menu_item->append = $object->singular_label;
|
||||
$menu_item->type_label = $object->labels->singular_name;
|
||||
$menu_item->url = get_permalink( $menu_item->object_id );
|
||||
|
||||
$original_object = get_post( $menu_item->object_id );
|
||||
|
@ -521,14 +516,14 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
|||
|
||||
} elseif ( 'taxonomy' == $menu_item->type ) {
|
||||
$object = get_taxonomy( $menu_item->object );
|
||||
$menu_item->append = $object->singular_label;
|
||||
$menu_item->type_label = $object->singular_label;
|
||||
$menu_item->url = get_term_link( (int) $menu_item->object_id, $menu_item->object );
|
||||
|
||||
$original_title = get_term_field( 'name', $menu_item->object_id, $menu_item->object, 'raw' );
|
||||
$menu_item->title = '' == $menu_item->post_title ? $original_title : $menu_item->post_title;
|
||||
|
||||
} else {
|
||||
$menu_item->append = __('Custom');
|
||||
$menu_item->type_label = __('Custom');
|
||||
$menu_item->title = $menu_item->post_title;
|
||||
$menu_item->url = get_post_meta( $menu_item->ID, '_menu_item_url', true );
|
||||
}
|
||||
|
@ -548,7 +543,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
|||
|
||||
$object = get_post_type_object( $menu_item->post_type );
|
||||
$menu_item->object = $object->name;
|
||||
$menu_item->append = strtolower( $object->singular_label );
|
||||
$menu_item->type_label = $object->labels->singular_name;
|
||||
|
||||
$menu_item->title = $menu_item->post_title;
|
||||
$menu_item->url = get_permalink( $menu_item->ID );
|
||||
|
@ -569,7 +564,7 @@ function wp_setup_nav_menu_item( $menu_item ) {
|
|||
|
||||
$object = get_taxonomy( $menu_item->taxonomy );
|
||||
$menu_item->object = $object->name;
|
||||
$menu_item->append = strtolower( $object->singular_label );
|
||||
$menu_item->type_label = $object->singular_label;
|
||||
|
||||
$menu_item->title = $menu_item->name;
|
||||
$menu_item->url = get_term_link( $menu_item, $menu_item->taxonomy );
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
function create_initial_post_types() {
|
||||
register_post_type( 'post', array(
|
||||
'label' => __( 'Posts' ),
|
||||
'singular_label' => __( 'Post' ),
|
||||
'public' => true,
|
||||
'show_ui' => false,
|
||||
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
|
||||
|
@ -30,8 +28,6 @@ function create_initial_post_types() {
|
|||
) );
|
||||
|
||||
register_post_type( 'page', array(
|
||||
'label' => __( 'Pages' ),
|
||||
'singular_label' => __( 'Page' ),
|
||||
'public' => true,
|
||||
'show_ui' => false,
|
||||
'_builtin' => true, /* internal use only. don't use this when registering your own post type. */
|
||||
|
@ -769,35 +765,33 @@ function get_post_types( $args = array(), $output = 'names', $operator = 'and' )
|
|||
*
|
||||
* Optional $args contents:
|
||||
*
|
||||
* label - A (plural) descriptive name for the post type marked for translation. Defaults to $post_type.
|
||||
* singular_label - A (singular) descriptive name for the post type marked for translation. Defaults to $label.
|
||||
* 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.
|
||||
* 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.
|
||||
* publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as.
|
||||
* 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.
|
||||
* menu_position - The position in the menu order the post type should appear. Defaults to the bottom.
|
||||
* menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon.
|
||||
* inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
|
||||
* capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
|
||||
* edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post).
|
||||
* edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts).
|
||||
* 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).
|
||||
* publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts).
|
||||
* read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post).
|
||||
* delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
|
||||
* hierarchical - Whether the post type is hierarchical. Defaults to false.
|
||||
* supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
|
||||
* 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.
|
||||
* 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().
|
||||
* - 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.
|
||||
* - 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.
|
||||
* - publicly_queryable - Whether post_type queries can be performed from the front page. Defaults to whatever public is set as.
|
||||
* - 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.
|
||||
* - menu_position - The position in the menu order the post type should appear. Defaults to the bottom.
|
||||
* - menu_icon - The url to the icon to be used for this menu. Defaults to use the posts icon.
|
||||
* - inherit_type - The post type from which to inherit the edit link and capability type. Defaults to none.
|
||||
* - capability_type - The post type to use for checking read, edit, and delete capabilities. Defaults to "post".
|
||||
* - edit_cap - The capability that controls editing a particular object of this post type. Defaults to "edit_$capability_type" (edit_post).
|
||||
* - edit_type_cap - The capability that controls editing objects of this post type as a class. Defaults to "edit_ . $capability_type . s" (edit_posts).
|
||||
* - 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).
|
||||
* - publish_others_cap - The capability that controls publishing objects of this post type. Defaults to "publish_ . $capability_type . s" (publish_posts).
|
||||
* - read_cap - The capability that controls reading a particular object of this post type. Defaults to "read_$capability_type" (read_post).
|
||||
* - delete_cap - The capability that controls deleting a particular object of this post type. Defaults to "delete_$capability_type" (delete_post).
|
||||
* - hierarchical - Whether the post type is hierarchical. Defaults to false.
|
||||
* - supports - An alias for calling add_post_type_support() directly. See add_post_type_support() for Documentation. Defaults to none.
|
||||
* - 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.
|
||||
* - 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().
|
||||
* - 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.
|
||||
*
|
||||
* @package WordPress
|
||||
* @subpackage Post
|
||||
* @since 2.9.0
|
||||
* @uses $wp_post_types Inserts new post type object into the list
|
||||
*
|
||||
* @param string $post_type Name of the post type.
|
||||
* @param array|string $args See above description.
|
||||
* @return object the registered post type object
|
||||
*/
|
||||
function register_post_type($post_type, $args = array()) {
|
||||
global $wp_post_types, $wp_rewrite, $wp;
|
||||
|
@ -806,7 +800,13 @@ function register_post_type($post_type, $args = array()) {
|
|||
$wp_post_types = array();
|
||||
|
||||
// Args prefixed with an underscore are reserved for internal use.
|
||||
$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 );
|
||||
$defaults = array(
|
||||
'labels' => array(), '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,
|
||||
);
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
$args = (object) $args;
|
||||
|
||||
|
@ -825,12 +825,6 @@ function register_post_type($post_type, $args = array()) {
|
|||
if ( null === $args->exclude_from_search )
|
||||
$args->exclude_from_search = !$args->public;
|
||||
|
||||
if ( false === $args->label )
|
||||
$args->label = $post_type;
|
||||
|
||||
if ( false === $args->singular_label )
|
||||
$args->singular_label = $args->label;
|
||||
|
||||
if ( empty($args->capability_type) )
|
||||
$args->capability_type = 'post';
|
||||
if ( empty($args->edit_cap) )
|
||||
|
@ -880,6 +874,13 @@ function register_post_type($post_type, $args = array()) {
|
|||
if ( $args->register_meta_box_cb )
|
||||
add_action('add_meta_boxes_' . $post_type, $args->register_meta_box_cb, 10, 1);
|
||||
|
||||
$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->singular_label = $args->labels->singular_name;
|
||||
|
||||
$wp_post_types[$post_type] = $args;
|
||||
|
||||
add_action( 'future_' . $post_type, '_future_post_hook', 5, 2 );
|
||||
|
@ -891,6 +892,61 @@ function register_post_type($post_type, $args = array()) {
|
|||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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:
|
||||
* - name - general name for the post type, usually plural. Default is Posts/Pages
|
||||
* - 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_item - Default is Add New Post/Add New Page
|
||||
* - edit_item - Default is Edit Post/Edit Page
|
||||
* - 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>
|
||||
* - new_item - Default is New Post/New Page
|
||||
* - view_item - Default is View Post/View Page
|
||||
* - 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:
|
||||
*
|
||||
* Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages.)
|
||||
*
|
||||
* @since 3.0.0
|
||||
* @param object $post_type_object
|
||||
* @return object object with all the labels as member variables
|
||||
*/
|
||||
function get_post_type_labels( $post_type_object ) {
|
||||
$nohier_vs_hier_defaults = array(
|
||||
'name' => array( _x('Posts', 'post type general name'), _x('Pages', 'post type general name') ),
|
||||
'singular_name' => array( _x('Post', 'post type singular name'), _x('Page', 'post type singular name') ),
|
||||
'add_new' => array( _x('Add New', 'post'), _x('Add New', 'page') ),
|
||||
'add_new_item' => array( __('Add New Post'), __('Add New Page') ),
|
||||
'edit_item' => array( __('Edit Post'), __('Edit Page') ),
|
||||
'edit' => array( _x('Edit', 'post'), _x('Edit', 'page') ),
|
||||
'new_item' => array( __('New Post'), __('New Page') ),
|
||||
'view_item' => array( __('View Post'), __('View Page') ),
|
||||
'search_items' => array( __('Search Posts'), __('Search Pages') ),
|
||||
'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:') )
|
||||
);
|
||||
|
||||
// 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( $post_type_object->labels['singular_name'] ) && isset( $post_type_object->singular_label ) ) {
|
||||
$post_type_object->labels['singular_name'] = $post_type_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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register support of certain features for a post type.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue