Make WordPress Core

Opened 12 years ago

Last modified 5 years ago

#23207 reopened enhancement

Add $labels argument to register_post_status()

Reported by: ramiy's profile ramiy Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0
Component: Posts, Post Types Keywords: has-patch dev-feedback needs-refresh
Focuses: Cc:

Description (last modified by SergeyBiryukov)

WordPress functions register_taxonomy() and register_post_type() has labels argument. Why not add labels to register_post_status()?

The current way to add status:

$args = array(
	'label'                     => __( 'draft', 'text_domain' ),
	'label_count'               => _n_noop( 'Draft (%s)',  'Drafts (%s)', 'text_domain' ),
	'public'                    => false,
	'show_in_admin_all_list'    => true,
	'show_in_admin_status_list' => true,
	'exclude_from_search'       => true,
);

register_post_status( 'draft', $args );

The new way (using labels):

$labels = array(
	'name'                      => __( 'Draft', 'text_domain' ),
	'singular_count'            => __( 'Draft (%s)', 'text_domain' ),
	'plural_count'              => __( 'Drafts (%s)', 'text_domain' ),
	'any_other_label'           => __( 'Any Other Label', 'text_domain' )
);
$args = array(
	'labels'                    => $labels,
	'public'                    => false,
	'show_in_admin_all_list'    => true,
	'show_in_admin_status_list' => true,
	'exclude_from_search'       => true,
);

register_post_status( 'draft', $args );

Attachments (1)

23207.diff (1.9 KB) - added by theorboman 10 years ago.
Add an optional $labels paramater to register_post_status()

Download all attachments as: .zip

Change History (14)

#1 @ramiy
12 years ago

Related #12706

#2 @SergeyBiryukov
12 years ago

  • Description modified (diff)
  • Summary changed from Add $labes argument to register_post_status() to Add $labels argument to register_post_status()

#3 @kovshenin
12 years ago

  • Cc kovshenin added
  • Keywords editorial-flow added

#4 follow-up: @kovshenin
12 years ago

Just a note that singular_count and plural_count will probably not work that way, because many languages have more than one plural form, and in order to know which form is used, it has to be given a number. That's why _n_noop is used in the first place, which maintains the structure and is then translated with translate_nooped_plural. I think :)

#5 in reply to: ↑ 4 @SergeyBiryukov
12 years ago

Replying to kovshenin:

That's why _n_noop is used in the first place, which maintains the structure and is then translated with translate_nooped_plural. I think :)

Correct.

#6 @ramiy
12 years ago

Good point.

But the goal is not this string or that string, the goal is to create a standard way to add translation strings to register_{taxonomy|post_type|post_status}() functions.

The new code with _n_noop():

$labels = array(
	'name'                      => __( 'Draft', 'text_domain' ),
	'count'                     => _n_noop( 'Draft (%s)',  'Drafts (%s)', 'text_domain' ),
	'any_other_label'           => __( 'Any Other Label', 'text_domain' )
);
$args = array(
	'labels'                    => $labels,
	'public'                    => false,
	'show_in_admin_all_list'    => true,
	'show_in_admin_status_list' => true,
	'exclude_from_search'       => true,
);

register_post_status( 'draft', $args );

#7 follow-up: @kovshenin
12 years ago

  • Keywords needs-patch added
  • Version changed from 3.5 to 3.0

#8 in reply to: ↑ 7 @maor
11 years ago

  • Cc maorhaz@… added

Replying to kovshenin:

Did you mean to set the version to 3.6? (:

@theorboman
10 years ago

Add an optional $labels paramater to register_post_status()

#9 @theorboman
10 years ago

  • Keywords has-patch dev-feedback added; needs-patch removed

Here's a patch for the above. The diff adds an optional $labels parameter to

register_post_status()

$labels is an associative array which expects the keys 'name' and 'count' which (if present) will be used in place of the 'label' and 'label_count' arguments respectively.

#10 @theorboman
10 years ago

  • Version 3.0 deleted

#11 @chriscct7
9 years ago

  • Keywords needs-refresh added
  • Version set to 3.0

#14 @ramiy
5 years ago

  • Keywords bulk-reopened added
  • Resolution set to wontfix
  • Status changed from new to closed

6 years old ticket

#15 @desrosj
5 years ago

  • Keywords editorial-flow bulk-reopened removed
  • Resolution wontfix deleted
  • Status changed from closed to reopened

Even though this ticket is old, I think that the original request still has merit.

Note: See TracTickets for help on using tickets.