[wp-trac] [WordPress Trac] #55895: Register custom post statuses
WordPress Trac
noreply at wordpress.org
Thu Jun 2 13:03:48 UTC 2022
#55895: Register custom post statuses
-------------------------------------------------+-------------------------
Reporter: angryjim | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
| Review
Component: Posts, Post Types | Version:
Severity: normal | Resolution:
Keywords: dev-feedback needs-patch needs- | Focuses:
testing post-status custom-post-status |
-------------------------------------------------+-------------------------
Comment (by angryjim):
Improvement suggestion on the {{{get_post_status()}}} so it can be used to
fetch all the registered post statues with a description label. Also add a
filter to let the dev change the description.
{{{#!php
<?php
/**
* ac_get_post_statuses()
*
* Return a list of registered post statuses core and custom with label
* Provides the post status name and label description
*
* @param array $status Array of default status labels keyed by their
status.
* @return string[] Array of post status labels keyed by their status.
*/
public function ac_get_post_statuses() : array {
$status = [
'draft' => __( 'Draft' ),
'pending' => __( 'Pending Review' ),
'private' => __( 'Private' ),
'publish' => __( 'Published' ),
];
foreach ( get_post_stati() as $post_status_name => $value ) {
if ( ! array_key_exists( $post_status_name, $status ) ) {
$status[ $post_status_name ] = $value;
}
}
return apply_filters( 'post_statuses_labels', $status );
}
?>
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55895#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list