WordPress.org

Make WordPress Core

Changeset 17689


Ignore:
Timestamp:
04/23/2011 10:36:22 AM (7 years ago)
Author:
dd32
Message:

Allow WP_Query 'post_status' parameter to accept an array, as well as a singular value and comma separated list. Fixes #16824

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r17653 r17689  
    16261626        }
    16271627
    1628         if ( !empty($qv['post_status']) )
    1629             $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
     1628        if ( ! empty( $qv['post_status'] ) ) {
     1629            if ( is_array( $qv['post_status'] ) )
     1630                $qv['post_status'] = array_map('sanitize_key', $qv['post_status']);
     1631            else
     1632                $qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
     1633        }
    16301634
    16311635        if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
     
    23882392        }
    23892393
    2390         if ( isset($q['post_status']) && '' != $q['post_status'] ) {
     2394        if ( ! empty( $q['post_status'] ) ) {
    23912395            $statuswheres = array();
    2392             $q_status = explode(',', $q['post_status']);
     2396            $q_status = $q['post_status'];
     2397            if ( ! is_array( $q_status ) )
     2398                $q_status = explode(',', $q_status);
    23932399            $r_status = array();
    23942400            $p_status = array();
    23952401            $e_status = array();
    2396             if ( $q['post_status'] == 'any' ) {
     2402            if ( in_array('any', $q_status) ) {
    23972403                foreach ( get_post_stati( array('exclude_from_search' => true) ) as $status )
    23982404                    $e_status[] = "$wpdb->posts.post_status <> '$status'";
Note: See TracChangeset for help on using the changeset viewer.