Make WordPress Core

Opened 9 years ago

Last modified 5 years ago

#35842 new enhancement

Register Post Type function label default

Reported by: moshiezz's profile moshiezz Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: 2nd-opinion
Focuses: Cc:

Description

When registering a Post type if the label or labels arguments are not set the label takes on a default of 'Posts' and not the Post type's name.

It states in the documentation that the label takes on the name of the Post type passed in as the first argument.

I believe the fix is as simple as updating the defaults variable in wp-includes/post.php on line 1017 with the label argument set to the post_type variable.

<?php
        $defaults = array(
                'label'                => $post_type,
                'labels'               => array(),
                'description'          => '',
                'public'               => false,
                'hierarchical'         => false,
                'exclude_from_search'  => null,
                'publicly_queryable'   => null,
                'show_ui'              => null,
                'show_in_menu'         => null,
                'show_in_nav_menus'    => null,
                'show_in_admin_bar'    => null,
                'menu_position'        => null,
                'menu_icon'            => null,
                'capability_type'      => 'post',
                'capabilities'         => array(),
                'map_meta_cap'         => null,
                'supports'             => array(),
                'register_meta_box_cb' => null,
                'taxonomies'           => array(),
                'has_archive'          => false,
                'rewrite'              => true,
                'query_var'            => true,
                'can_export'           => true,
                'delete_with_user'     => null,
                '_builtin'             => false,
                '_edit_link'           => 'post.php?post=%d',
        );

Change History (2)

#1 @moshiezz
9 years ago

I have just noticed that the labels are all lowercase perhaps:

<?php
    ucfirst($post_type);
Last edited 9 years ago by moshiezz (previous) (diff)

#2 @dd32
9 years ago

  • Keywords 2nd-opinion added
  • Type changed from defect (bug) to enhancement
  • Version 4.4.2 deleted

It states in the documentation that the label takes on the name of the Post type passed in as the first argument.

This is a bug in the codex documentation, rather than something WordPress should support IMHO (due to translation requirements)

I've updated the Codex Community Documentation to reflect the official reference.
I've updated this ticket to reflect this as a enhancement request rather than a bug.

Note: See TracTickets for help on using tickets.