From 8136de990c32415902e40e39783b3fece0b66e12 Mon Sep 17 00:00:00 2001 From: dd32 Date: Sat, 13 Feb 2010 08:56:38 +0000 Subject: [PATCH] Introduce 'singular_label' for Post Types. Props scribu. See #12214 git-svn-id: http://svn.automattic.com/wordpress/trunk@13101 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/post-new.php | 2 +- wp-admin/post.php | 2 +- wp-includes/post.php | 13 ++++++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/wp-admin/post-new.php b/wp-admin/post-new.php index 9b8950419..62d74563f 100644 --- a/wp-admin/post-new.php +++ b/wp-admin/post-new.php @@ -24,7 +24,7 @@ if ( 'post' != $post_type ) { $post_type_object = get_post_type_object($post_type); -$title = sprintf(__('Add New %s'), $post_type_object->label); +$title = sprintf(__('Add New %s'), $post_type_object->singular_label); $editing = true; wp_enqueue_script('autosave'); diff --git a/wp-admin/post.php b/wp-admin/post.php index 3ae40af29..bb0ef961d 100644 --- a/wp-admin/post.php +++ b/wp-admin/post.php @@ -195,7 +195,7 @@ case 'edit': wp_enqueue_script('autosave'); } - $title = sprintf(__('Edit %s'), $post_type_object->label); + $title = sprintf(__('Edit %s'), $post_type_object->singular_label); $post = get_post_to_edit($post_id); include('edit-form-advanced.php'); diff --git a/wp-includes/post.php b/wp-includes/post.php index 18b04c69a..1001cbf5d 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -16,6 +16,7 @@ */ function create_initial_post_types() { register_post_type( 'post', array( 'label' => __('Posts'), + 'singular_label' => __('Post'), 'public' => true, 'show_ui' => false, '_builtin' => true, @@ -28,6 +29,7 @@ function create_initial_post_types() { ) ); register_post_type( 'page', array( 'label' => __('Pages'), + 'singular_label' => __('Page'), 'public' => true, 'show_ui' => false, '_builtin' => true, @@ -51,6 +53,7 @@ function create_initial_post_types() { ) ); register_post_type( 'revision', array( 'label' => __('Revisions'), + 'singular_label' => __('Revision'), 'public' => false, '_builtin' => true, '_edit_link' => 'revision.php?revision=%d', @@ -712,7 +715,8 @@ function get_post_types( $args = array(), $output = 'names' ) { * * Optional $args contents: * - * label - A descriptive name for the post type marked for translation. Defaults to $post_type. + * 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. @@ -746,7 +750,7 @@ 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, '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 ); + $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 ); $args = wp_parse_args($args, $defaults); $args = (object) $args; @@ -768,6 +772,9 @@ function register_post_type($post_type, $args = array()) { 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) ) @@ -4403,4 +4410,4 @@ function _show_post_preview() { add_filter('the_preview', '_set_preview'); } -} +} \ No newline at end of file