[wp-trac] [WordPress Trac] #38136: The docs for get_pages() - the post_status argument can also be an array

WordPress Trac noreply at wordpress.org
Thu Sep 22 23:16:06 UTC 2016


#38136: The docs for get_pages() - the post_status argument can also be an array
--------------------------+-----------------------------
 Reporter:  birgire       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:  docs          |
--------------------------+-----------------------------
 The documentation for {{{get_pages()}}} says:

 {{{
 * @type string  $post_status  A comma-separated list of post statuses
 types to include.
 }}}

 but the {{{post_status}}} argument can also be an array according to this
 part of {{{get_pages()}}}:

 {{{
 // Make sure we have a valid post status.
 if ( ! is_array( $post_status ) ) {
     $post_status = explode( ',', $post_status );
 }
 if ( array_diff( $post_status, get_post_stati() ) ) {
     return false;
 }

 ... cut ...

 if ( 1 == count( $post_status ) ) {
     $where_post_type = $wpdb->prepare( "post_type = %s AND post_status =
 %s", $r['post_type'], reset( $post_status ) );
 } else {
     $post_status = implode( "', '", $post_status );
     $where_post_type = $wpdb->prepare( "post_type = %s AND post_status IN
 ('$post_status')", $r['post_type'] );
 }
 }}}

 ps: I also adjusted the defaults array of {{{get_pages()}}} for better
 readability.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38136>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list