WordPress.org

Make WordPress Core

Ticket #40650: 40650.diff

File 40650.diff, 1.7 KB (added by pbiron, 3 years ago)
  • wp-includes/post.php

    diff --git a/wp-includes/post.php b/wp-includes/post.php
    index 0d62400..647657d 100644
    a b function get_page_uri( $page = 0 ) { 
    44814481 * @global wpdb $wpdb WordPress database abstraction object.
    44824482 *
    44834483 * @since 1.5.0
     4484 * @since x.y.z Added 'any' as an accepted `$post_status`
    44844485 *
    44854486 * @param array|string $args {
    44864487 *     Optional. Array or string of arguments to retrieve pages.
    function get_page_uri( $page = 0 ) { 
    45134514 *                                      Default 0.
    45144515 *     @type string       $post_type    The post type to query. Default 'page'.
    45154516 *     @type string|array $post_status  A comma-separated list or array of post statuses to include.
    4516  *                                      Default 'publish'.
     4517 *                                      Default 'publish'.  If `$post_status` includes 'any' then any status
     4518 *                                      post status with 'exclude_from_search' will also be included.
    45174519 * }
    45184520 * @return array|false List of pages matching defaults or `$args`.
    45194521 */
    function get_pages( $args = array() ) { 
    45644566        if ( ! is_array( $post_status ) ) {
    45654567                $post_status = explode( ',', $post_status );
    45664568        }
    4567         if ( array_diff( $post_status, get_post_stati() ) ) {
    4568                 return false;
     4569        if ( in_array( 'any', $post_status ) ) {
     4570                $post_status = array_diff( $post_status, array( 'any' ) ) ;
     4571                foreach ( get_post_stati( array( 'exclude_from_search' => false ) ) as $status ) {
     4572                        if ( ! in_array( $status, $post_status ) ) {
     4573                                $post_status[] = $status;
     4574                        }
     4575                }
    45694576        }
    45704577
    45714578        // $args can be whatever, only use the args defined in defaults to compute the key.