From b2a37f296556011e94e92b887ce6f27efa10f4b0 Mon Sep 17 00:00:00 2001 From: Andrew Nacin Date: Thu, 12 May 2011 03:53:46 +0000 Subject: [PATCH] Allow get_pages() to take multiple post statuses. see #8592. git-svn-id: https://develop.svn.wordpress.org/trunk@17889 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 934b310226..a930eda633 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3322,7 +3322,9 @@ function &get_pages($args = '') { return false; // Make sure we have a valid post status - if ( !in_array($post_status, get_post_stati()) ) + if ( !is_array( $post_status ) ) + $post_status = explode( ',', $post_status ); + if ( array_diff( $post_status, get_post_stati() ) ) return false; $cache = array(); @@ -3417,7 +3419,12 @@ function &get_pages($args = '') { if ( $parent >= 0 ) $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); - $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status ); + if ( 1 == count( $post_status ) ) { + $where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $post_type, array_shift( $post_status ) ); + } else { + $post_status = implode( "', '", $post_status ); + $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $post_type ); + } $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; $query .= $author_query;