Changeset 14614 for trunk/wp-includes/post.php
- Timestamp:
- 05/14/2010 12:34:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r14602 r14614 41 41 42 42 register_post_type( 'attachment', array( 43 'label' => __( 'Media' ), 43 'labels' => array( 44 'name' => __( 'Media' ), 45 ), 44 46 'public' => true, 45 47 'show_ui' => false, … … 54 56 55 57 register_post_type( 'revision', array( 56 'label' => __( 'Revisions' ), 57 'singular_label' => __( 'Revision' ), 58 'labels' => array( 59 'name' => __( 'Revisions' ), 60 'singular_name' => __( 'Revision' ), 61 ), 58 62 'public' => false, 59 63 '_builtin' => true, /* internal use only. don't use this when registering your own post type. */ … … 66 70 67 71 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 ), 70 76 'public' => false, 71 77 'show_ui' => false, … … 926 932 * - not_found - Default is No posts found/No pages found 927 933 * - 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: 929 935 * 930 936 * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages.) … … 948 954 'not_found_in_trash' => array( __('No posts found in Trash'), __('No pages found in Trash') ), 949 955 'view' => array( __('View Post'), __('View Page') ), 950 'parent ' => array( null, __('Parent Page:') )956 'parent_item_colon' => array( null, __('Parent Page:') ) 951 957 ); 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 */ 966 function _get_custom_object_labels( $object, $nohier_vs_hier_defaults ) { 952 967 953 968 // try to get missing (singular_)?name from older style (singular_)?label member variables 954 969 // we keep that for backwards compatibility 955 970 // 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; 961 976 } 962 977 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; 966 985 } 967 986
Note: See TracChangeset
for help on using the changeset viewer.