mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Add more visibility args to post status registration. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@12994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9de60f3644
commit
d0f8826c0b
@ -232,7 +232,7 @@ $total_posts = array_sum( (array) $num_posts ) - $num_posts->trash;
|
||||
$class = empty($class) && empty($_GET['post_status']) ? ' class="current"' : '';
|
||||
$status_links[] = "<li><a href='edit.php?post_type=$post_type{$allposts}'$class>" . sprintf( _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_posts, 'posts' ), number_format_i18n( $total_posts ) ) . '</a>';
|
||||
|
||||
foreach ( get_post_stati(array(), 'objects') as $status ) {
|
||||
foreach ( get_post_stati(array('show_in_admin_edit' => true), 'objects') as $status ) {
|
||||
$class = '';
|
||||
|
||||
$status_name = $status->name;
|
||||
|
@ -61,37 +61,37 @@ function create_initial_post_types() {
|
||||
) );
|
||||
|
||||
register_post_status( 'publish', array( 'label' => _x('Published', 'post'),
|
||||
'exclude_from_search' => false,
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Published <span class="count">(%s)</span>', 'Published <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
||||
register_post_status( 'future', array( 'label' => _x('Scheduled', 'post'),
|
||||
'exclude_from_search' => false,
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Scheduled <span class="count">(%s)</span>', 'Scheduled <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
||||
register_post_status( 'draft', array( 'label' => _x('Draft', 'post'),
|
||||
'exclude_from_search' => false,
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Draft <span class="count">(%s)</span>', 'Drafts <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
||||
register_post_status( 'private', array( 'label' => _x('Private', 'post'),
|
||||
'exclude_from_search' => false,
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Private <span class="count">(%s)</span>', 'Private <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
||||
register_post_status( 'trash', array( 'label' => _x('Trash', 'post'),
|
||||
'exclude_from_search' => false,
|
||||
'public' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
||||
register_post_status( 'auto-draft', array( 'label' => _x('Auto-Draft', 'post'),
|
||||
'exclude_from_search' => true,
|
||||
'public' => false,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Auto-Draft <span class="count">(%s)</span>', 'Auto-Drafts <span class="count">(%s)</span>')
|
||||
) );
|
||||
@ -521,22 +521,31 @@ function register_post_status($post_status, $args = array()) {
|
||||
$wp_post_statuses = array();
|
||||
|
||||
// Args prefixed with an underscore are reserved for internal use.
|
||||
$defaults = array('label' => false, 'label_count' => false, 'exclude_from_search' => true, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, '_show' => false);
|
||||
$defaults = array('label' => false, 'label_count' => false, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'publicly_queryable' => null, 'show_in_admin_edit' => null);
|
||||
$args = wp_parse_args($args, $defaults);
|
||||
$args = (object) $args;
|
||||
|
||||
$post_status = sanitize_user($post_status, true);
|
||||
$args->name = $post_status;
|
||||
|
||||
// If not set, default to the setting for public.
|
||||
if ( null === $args->publicly_queryable )
|
||||
$args->publicly_queryable = $args->public;
|
||||
|
||||
// If not set, default to true if not public, false if public.
|
||||
if ( null === $args->exclude_from_search )
|
||||
$args->exclude_from_search = !$args->public;
|
||||
|
||||
// If not set, default to the setting for public.
|
||||
if ( null === $args->show_in_admin_edit )
|
||||
$args->show_in_admin_edit = $args->public;
|
||||
|
||||
if ( false === $args->label )
|
||||
$args->label = $post_status;
|
||||
|
||||
if ( false === $args->label_count )
|
||||
$args->label_count = $args->label;
|
||||
|
||||
if ( !$args->_builtin && $args->public )
|
||||
$args->_show = true;
|
||||
|
||||
$wp_post_statuses[$post_status] = $args;
|
||||
|
||||
return $args;
|
||||
|
Loading…
Reference in New Issue
Block a user