Make WordPress Core

Opened 14 years ago

Closed 13 years ago

#14832 closed enhancement (fixed)

Allow separate label for menu text when registering post type

Reported by: husobj's profile husobj Owned by: nacin's profile nacin
Milestone: 3.1 Priority: normal
Severity: normal Version: 3.0.1
Component: Posts, Post Types Keywords: needs-patch
Focuses: Cc:

Description

When registering a post type the labels array allows you to provide various titles to display.

If you register a new post type with a long-ish label, you may want to provide a shorter label for display in the admin menu so that it doesn't wrap onto 2 lines. The current labels array does not provide an option to do this.

Attachments (1)

posttype_menu_label.diff (2.3 KB) - added by husobj 14 years ago.

Download all attachments as: .zip

Change History (16)

#1 @husobj
14 years ago

The attached patch adds a 'menu_label' to the labels array that can be used to provide a separate label for the admin menu. If you do not provide a menu_label, then it should default to just using the standard default label.

#2 @mfields
14 years ago

+1 This would be really handy to have.

#3 @nacin
14 years ago

  • Milestone changed from Awaiting Review to 3.1
  • Owner set to nacin
  • Status changed from new to accepted

#4 @demetris
14 years ago

I think we had discussed about something like that —name_short or label_short or something to that effect— in the 3.0 dev cycle, but it seems the idea somehow slipped among all the details of the implementation.

#5 @leewillis77
14 years ago

+1 from me - this would be very useful for a project I'm working on.

#6 @scribu
14 years ago

  • Keywords has-patch added

#7 @nacin
14 years ago

  • Keywords register_post_type removed

I'm not sure if this is how I want to do it. Feels like maybe we need a system to handle context and such, otherwise the labels array is going to keep growing as more requests and labels come in.

#8 @husobj
14 years ago

Do you think 'short_label' would be better than 'menu_label' as per the comment above by demetris? That way it would make more sense if used in other scenarios.

Or perhaps filter labels based on context so you could change the label when used in the menu context - is that sort of what you're suggesting nacin?

#9 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [16251]) Introduce menu_name label for taxonomies and post types. Defaults to name. fixes #14832.

#10 @scribu
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened
register_taxonomy('publisher', 'book', array('label' => 'Publisher'));

The Menu label remains "Post Tags".

#11 @scribu
13 years ago

  • Keywords needs-patch added; has-patch removed

#12 @nacin
13 years ago

Would be easier to patch this into get_post_type_labels, but it'd be better in _get_custom_object_labels.

#13 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [16268]) Properly set up menu_name. We're handling it differently because it defaults off other labels. fixes #14832.

#14 @nacin
13 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

menu_name doesn't work with show_in_menu = 'submenu'. Fixing.

#15 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [17197]) Have menu_name work with show_in_menu = submenu. fixes #14832.

Note: See TracTickets for help on using tickets.