mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Consult exclude_from_search when retrieving post_status = any. see #9674
git-svn-id: http://svn.automattic.com/wordpress/trunk@13052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
534e797399
commit
f147d89df7
@ -86,12 +86,14 @@ function create_initial_post_types() {
|
||||
|
||||
register_post_status( 'trash', array( 'label' => _x('Trash', 'post'),
|
||||
'public' => true,
|
||||
'exclude_from_search' => 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'),
|
||||
'public' => false,
|
||||
'exclude_from_search' => true,
|
||||
'_builtin' => true,
|
||||
'label_count' => _n_noop('Auto-Draft <span class="count">(%s)</span>', 'Auto-Drafts <span class="count">(%s)</span>')
|
||||
) );
|
||||
|
@ -2097,9 +2097,10 @@ class WP_Query {
|
||||
$q_status = explode(',', $q['post_status']);
|
||||
$r_status = array();
|
||||
$p_status = array();
|
||||
$e_status = array();
|
||||
if ( $q['post_status'] == 'any' ) {
|
||||
// @todo Use register_post_status() data to determine which states should be excluded.
|
||||
$r_status[] = "$wpdb->posts.post_status <> 'trash'";
|
||||
foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
|
||||
$e_status[] = "$wpdb->posts.post_status <> '$status'";
|
||||
} else {
|
||||
foreach ( get_post_stati() as $status ) {
|
||||
if ( in_array( $status, $q_status ) ) {
|
||||
@ -2116,6 +2117,9 @@ class WP_Query {
|
||||
unset($p_status);
|
||||
}
|
||||
|
||||
if ( !empty($e_status) ) {
|
||||
$statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
|
||||
}
|
||||
if ( !empty($r_status) ) {
|
||||
if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type_cap}s") )
|
||||
$statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";
|
||||
|
Loading…
Reference in New Issue
Block a user