Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_post_type_labels( $post_type_object ) {
- return _get_custom_object_labels( $post_type_object );
- }
- function _get_custom_object_labels( $object ) {
- if ( isset( $object->label ) ) {
- $object->labels['name'] = $object->label;
- }
- if ( !isset( $object->labels['singular_name'] ) && isset( $object->labels['name'] ) ) {
- $object->labels['singular_name'] = $object->labels['name'];
- }
- $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') ),
- 'new_item' => array( __('New Post'), __('New Page') ),
- 'view_item' => array( __('View Post'), __('View Page') ),
- 'search_items' => array( __('Search '.(isset($object->labels['name'])?$object->labels['name']:'Posts')), __('Search '.(isset($object->labels['name'])?$object->labels['name']:'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_item_colon' => array( null, __('Parent Page:') )
- );
- $defaults = array_map( create_function( '$x', $object->hierarchical? 'return $x[1];' : 'return $x[0];' ), $nohier_vs_hier_defaults );
- $labels = array_merge( $defaults, $object->labels );
- return (object)$labels;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement