Make WordPress Core

Ticket #38136: get_pages.diff

File get_pages.diff, 6.7 KB (added by birgire, 10 years ago)
  • src/wp-includes/post.php

     
    43724372 * @param array|string $args {
    43734373 *     Optional. Array or string of arguments to retrieve pages.
    43744374 *
    4375  *     @type int          $child_of     Page ID to return child and grandchild pages of. Note: The value
    4376  *                                      of `$hierarchical` has no bearing on whether `$child_of` returns
    4377  *                                      hierarchical results. Default 0, or no restriction.
    4378  *     @type string       $sort_order   How to sort retrieved pages. Accepts 'ASC', 'DESC'. Default 'ASC'.
    4379  *     @type string       $sort_column  What columns to sort pages by, comma-separated. Accepts 'post_author',
    4380  *                                      'post_date', 'post_title', 'post_name', 'post_modified', 'menu_order',
    4381  *                                      'post_modified_gmt', 'post_parent', 'ID', 'rand', 'comment_count'.
    4382  *                                      'post_' can be omitted for any values that start with it.
    4383  *                                      Default 'post_title'.
    4384  *     @type bool         $hierarchical Whether to return pages hierarchically. If false in conjunction with
    4385  *                                      `$child_of` also being false, both arguments will be disregarded.
    4386  *                                      Default true.
    4387  *     @type array        $exclude      Array of page IDs to exclude. Default empty array.
    4388  *     @type array        $include      Array of page IDs to include. Cannot be used with `$child_of`,
    4389  *                                      `$parent`, `$exclude`, `$meta_key`, `$meta_value`, or `$hierarchical`.
    4390  *                                      Default empty array.
    4391  *     @type string       $meta_key     Only include pages with this meta key. Default empty.
    4392  *     @type string       $meta_value   Only include pages with this meta value. Requires `$meta_key`.
    4393  *                                      Default empty.
    4394  *     @type string       $authors      A comma-separated list of author IDs. Default empty.
    4395  *     @type int          $parent       Page ID to return direct children of. Default -1, or no restriction.
    4396  *     @type string|array $exclude_tree Comma-separated string or array of page IDs to exclude.
    4397  *                                      Default empty array.
    4398  *     @type int          $number       The number of pages to return. Default 0, or all pages.
    4399  *     @type int          $offset       The number of pages to skip before returning. Requires `$number`.
    4400  *                                      Default 0.
    4401  *     @type string       $post_type    The post type to query. Default 'page'.
    4402  *     @type string       $post_status  A comma-separated list of post status types to include.
    4403  *                                      Default 'publish'.
     4375 *     @type int                $child_of     Page ID to return child and grandchild pages of. Note: The value
     4376 *                                            of `$hierarchical` has no bearing on whether `$child_of` returns
     4377 *                                            hierarchical results. Default 0, or no restriction.
     4378 *     @type string             $sort_order   How to sort retrieved pages. Accepts 'ASC', 'DESC'. Default 'ASC'.
     4379 *     @type string             $sort_column  What columns to sort pages by, comma-separated. Accepts 'post_author',
     4380 *                                            'post_date', 'post_title', 'post_name', 'post_modified', 'menu_order',
     4381 *                                            'post_modified_gmt', 'post_parent', 'ID', 'rand', 'comment_count'.
     4382 *                                            'post_' can be omitted for any values that start with it.
     4383 *                                            Default 'post_title'.
     4384 *     @type bool               $hierarchical Whether to return pages hierarchically. If false in conjunction with
     4385 *                                           `$child_of` also being false, both arguments will be disregarded.
     4386 *                                            Default true.
     4387 *     @type array              $exclude      Array of page IDs to exclude. Default empty array.
     4388 *     @type array              $include      Array of page IDs to include. Cannot be used with `$child_of`,
     4389 *                                            `$parent`, `$exclude`, `$meta_key`, `$meta_value`, or `$hierarchical`.
     4390 *                                            Default empty array.
     4391 *     @type string             $meta_key     Only include pages with this meta key. Default empty.
     4392 *     @type string             $meta_value   Only include pages with this meta value. Requires `$meta_key`.
     4393 *                                            Default empty.
     4394 *     @type string             $authors      A comma-separated list of author IDs. Default empty.
     4395 *     @type int                $parent       Page ID to return direct children of. Default -1, or no restriction.
     4396 *     @type string|array       $exclude_tree Comma-separated string or array of page IDs to exclude.
     4397 *                                            Default empty array.
     4398 *     @type int                $number       The number of pages to return. Default 0, or all pages.
     4399 *     @type int                $offset       The number of pages to skip before returning. Requires `$number`.
     4400 *                                            Default 0.
     4401 *     @type string             $post_type    The post type to query. Default 'page'.
     4402 *     @type string|array       $post_status  A comma-separated list or array of post status types to include.
     4403 *                                            Default 'publish'.
    44044404 * }
    44054405 * @return array|false List of pages matching defaults or `$args`.
    44064406 */
     
    44084408        global $wpdb;
    44094409
    44104410        $defaults = array(
    4411                 'child_of' => 0, 'sort_order' => 'ASC',
    4412                 'sort_column' => 'post_title', 'hierarchical' => 1,
    4413                 'exclude' => array(), 'include' => array(),
    4414                 'meta_key' => '', 'meta_value' => '',
    4415                 'authors' => '', 'parent' => -1, 'exclude_tree' => array(),
    4416                 'number' => '', 'offset' => 0,
    4417                 'post_type' => 'page', 'post_status' => 'publish',
     4411                'child_of'      => 0,
     4412                'sort_order'    => 'ASC',
     4413                'sort_column'   => 'post_title',
     4414                'hierarchical'  => 1,
     4415                'exclude'       => array(),
     4416                'include'       => array(),
     4417                'meta_key'      => '',
     4418                'meta_value'    => '',
     4419                'authors'       => '',
     4420                'parent'        => -1,
     4421                'exclude_tree'  => array(),
     4422                'number'        => '',
     4423                'offset'        => 0,
     4424                'post_type'     => 'page',
     4425                'post_status'   => 'publish',
    44184426        );
    44194427
    44204428        $r = wp_parse_args( $args, $defaults );