Make WordPress Core

Changeset 17889


Ignore:
Timestamp:
05/12/2011 03:53:46 AM (15 years ago)
Author:
nacin
Message:

Allow get_pages() to take multiple post statuses. see #8592.

File:
1 edited

Legend:

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

    r17864 r17889  
    33233323
    33243324        // Make sure we have a valid post status
    3325         if ( !in_array($post_status, get_post_stati()) )
     3325        if ( !is_array( $post_status ) )
     3326                $post_status = explode( ',', $post_status );
     3327        if ( array_diff( $post_status, get_post_stati() ) )
    33263328                return false;
    33273329
     
    34183420                $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
    34193421
    3420         $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status );
     3422        if ( 1 == count( $post_status ) ) {
     3423                $where_post_type = $wpdb->prepare( "post_type = %s AND post_status = %s", $post_type, array_shift( $post_status ) );
     3424        } else {
     3425                $post_status = implode( "', '", $post_status );
     3426                $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN ('$post_status')", $post_type );
     3427        }
    34213428
    34223429        $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
Note: See TracChangeset for help on using the changeset viewer.