Consult exclude_from_search when retrieving post_status = any. see #9674
git-svn-id: https://develop.svn.wordpress.org/trunk@13052 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2f7ef8196b
commit
b08985b209
@ -86,12 +86,14 @@ function create_initial_post_types() {
|
|||||||
|
|
||||||
register_post_status( 'trash', array( 'label' => _x('Trash', 'post'),
|
register_post_status( 'trash', array( 'label' => _x('Trash', 'post'),
|
||||||
'public' => true,
|
'public' => true,
|
||||||
|
'exclude_from_search' => true,
|
||||||
'_builtin' => true,
|
'_builtin' => true,
|
||||||
'label_count' => _n_noop('Trash <span class="count">(%s)</span>', 'Trash <span class="count">(%s)</span>')
|
'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'),
|
register_post_status( 'auto-draft', array( 'label' => _x('Auto-Draft', 'post'),
|
||||||
'public' => false,
|
'public' => false,
|
||||||
|
'exclude_from_search' => true,
|
||||||
'_builtin' => true,
|
'_builtin' => true,
|
||||||
'label_count' => _n_noop('Auto-Draft <span class="count">(%s)</span>', 'Auto-Drafts <span class="count">(%s)</span>')
|
'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']);
|
$q_status = explode(',', $q['post_status']);
|
||||||
$r_status = array();
|
$r_status = array();
|
||||||
$p_status = array();
|
$p_status = array();
|
||||||
|
$e_status = array();
|
||||||
if ( $q['post_status'] == 'any' ) {
|
if ( $q['post_status'] == 'any' ) {
|
||||||
// @todo Use register_post_status() data to determine which states should be excluded.
|
foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
|
||||||
$r_status[] = "$wpdb->posts.post_status <> 'trash'";
|
$e_status[] = "$wpdb->posts.post_status <> '$status'";
|
||||||
} else {
|
} else {
|
||||||
foreach ( get_post_stati() as $status ) {
|
foreach ( get_post_stati() as $status ) {
|
||||||
if ( in_array( $status, $q_status ) ) {
|
if ( in_array( $status, $q_status ) ) {
|
||||||
@ -2116,6 +2117,9 @@ class WP_Query {
|
|||||||
unset($p_status);
|
unset($p_status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !empty($e_status) ) {
|
||||||
|
$statuswheres[] = "(" . join( ' AND ', $e_status ) . ")";
|
||||||
|
}
|
||||||
if ( !empty($r_status) ) {
|
if ( !empty($r_status) ) {
|
||||||
if ( !empty($q['perm'] ) && 'editable' == $q['perm'] && !current_user_can("edit_others_{$post_type_cap}s") )
|
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 ) . "))";
|
$statuswheres[] = "($wpdb->posts.post_author = $user_ID " . "AND (" . join( ' OR ', $r_status ) . "))";
|
||||||
|
Loading…
Reference in New Issue
Block a user