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
This commit is contained in:
Andrew Nacin 2011-05-12 03:53:46 +00:00
parent b7af529e35
commit b2a37f2965
1 changed files with 9 additions and 2 deletions

View File

@ -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;