Opened 4 months ago
Last modified 2 months ago
#23207 new enhancement
Add $labels argument to register_post_status()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Post Types | Version: | 3.0 |
| Severity: | normal | Keywords: | editorial-flow needs-patch |
| Cc: | kovshenin, maorhaz@… |
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 );
Change History (8)
comment:2
SergeyBiryukov — 4 months ago
- Description modified (diff)
- Summary changed from Add $labes argument to register_post_status() to Add $labels argument to register_post_status()
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 :)
comment:5
in reply to:
↑ 4
SergeyBiryukov — 4 months 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.
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 );
- Keywords needs-patch added
- Version changed from 3.5 to 3.0

Related #12706