Ticket #25787: 25787.diff
File 25787.diff, 16.1 KB (added by , 10 years ago) |
---|
-
wp-includes/post-template.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
999 999 * @param array|string $args { 1000 1000 * Array or string of arguments. Optional. 1001 1001 * 1002 * @type int $child_of Display only the sub-pages of a single page by ID. Default 0 (all pages). 1003 * @type string $authors Comma-separated list of author IDs. Default empty (all authors). 1004 * @type string $date_format PHP date format to use for the listed pages. Relies on the 'show_date' parameter. 1005 * Default is the value of 'date_format' option. 1006 * @type int $depth Number of levels in the hierarchy of pages to include in the generated list. 1007 * Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to 1008 * the given n depth). Default 0. 1009 * @type bool $echo Whether or not to echo the list of pages. Default true. 1010 * @type string $exclude Comma-separated list of page IDs to exclude. Default empty. 1011 * @type array $include Comma-separated list of page IDs to include. Default empty. 1012 * @type string $link_after Text or HTML to follow the page link label. Default null. 1013 * @type string $link_before Text or HTML to precede the page link label. Default null. 1014 * @type string $post_type Post type to query for. Default 'page'. 1015 * @type string $post_status Comma-separated list of post statuses to include. Default 'publish'. 1016 * @type string $show_date Whether to display the page publish or modified date for each page. Accepts 1017 * 'modified' or any other value. An empty value hides the date. Default empty. 1018 * @type string $sort_column Comma-separated list of column names to sort the pages by. Accepts 'post_author', 1019 * 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', 1020 * 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'. 1021 * @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list 1022 * will not be wrapped with unordered list `<ul>` tags. Default 'Pages'. 1023 * @type Walker $walker Walker instance to use for listing pages. Default empty (Walker_Page). 1002 * @type int $child_of Display only the sub-pages of a single page by ID. Default 0 (all pages). 1003 * @type string $authors Comma-separated list of author IDs. Default empty (all authors). 1004 * @type string $date_format PHP date format to use for the listed pages. Relies on the 'show_date' parameter. 1005 * Default is the value of 'date_format' option. 1006 * @type int $depth Number of levels in the hierarchy of pages to include in the generated list. 1007 * Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to 1008 * the given n depth). Default 0. 1009 * @type bool $echo Whether or not to echo the list of pages. Default true. 1010 * @type string $exclude Comma-separated list of page IDs to exclude. Default empty. 1011 * @type array $include Comma-separated list of page IDs to include. Default empty. 1012 * @type string $link_after Text or HTML to follow the page link label. Default null. 1013 * @type string $link_before Text or HTML to precede the page link label. Default null. 1014 * @type string $post_type Post type to query for. Default 'page'. 1015 * @type string $post_status Comma-separated list of post statuses to include. Default 'publish'. 1016 * @type string $show_date Whether to display the page publish or modified date for each page. Accepts 1017 * 'modified' or any other value. An empty value hides the date. Default empty. 1018 * @type string $sort_column Comma-separated list of column names to sort the pages by. Accepts 'post_author', 1019 * 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', 1020 * 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'. 1021 * @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list 1022 * will not be wrapped with unordered list `<ul>` tags. Default 'Pages'. 1023 * @type Walker $walker Walker instance to use for listing pages. Default empty (Walker_Page). 1024 * @type bool $optimize_query If set to true all page attributes are fetched from database. If set to false only 1025 * the minimal necessary page attributes are fetched from the database to serve the 1026 * function. Default false. 1024 1027 * } 1025 1028 * @return string HTML list of pages. 1026 1029 */ … … 1032 1035 'title_li' => __( 'Pages' ), 'echo' => 1, 1033 1036 'authors' => '', 'sort_column' => 'menu_order, post_title', 1034 1037 'link_before' => '', 'link_after' => '', 'walker' => '', 1038 'optimize_query' => 0 1035 1039 ); 1036 1040 1037 1041 $r = wp_parse_args( $args, $defaults ); 1038 1042 1043 $optimize_query = $r['optimize_query']; 1044 1039 1045 $output = ''; 1040 1046 $current_page = 0; 1041 1047 … … 1056 1062 1057 1063 // Query pages. 1058 1064 $r['hierarchical'] = 0; 1065 1066 if ($optimize_query) { 1067 1068 // The whole functionality needs only this page columns/attributes 1069 $r['restrict_columns'] = array('ID', 'post_date', 'post_title', 'post_modified', 'post_parent'); 1070 } 1071 1059 1072 $pages = get_pages( $r ); 1060 1073 1061 1074 if ( ! empty( $pages ) ) { … … 1111 1124 * Optional. Arguments to generate a page menu. {@see wp_list_pages()} 1112 1125 * for additional arguments. 1113 1126 * 1114 * @type string $sort_column How to short the list of pages. Accepts post column names. 1115 * Default 'menu_order, post_title'. 1116 * @type string $menu_class Class to use for the div ID containing the page list. Default 'menu'. 1117 * @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). 1118 * Default true. 1119 * @type string $link_before The HTML or text to prepend to $show_home text. Default empty. 1120 * @type string $link_after The HTML or text to append to $show_home text. Default empty. 1121 * @type int|string $show_home Whether to display the link to the home page. Can just enter the text 1122 * you'd like shown for the home link. 1|true defaults to 'Home'. 1127 * @type string $sort_column How to short the list of pages. Accepts post column names. 1128 * Default 'menu_order, post_title'. 1129 * @type string $menu_class Class to use for the div ID containing the page list. Default 'menu'. 1130 * @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). 1131 * Default true. 1132 * @type string $link_before The HTML or text to prepend to $show_home text. Default empty. 1133 * @type string $link_after The HTML or text to append to $show_home text. Default empty. 1134 * @type int|string $show_home Whether to display the link to the home page. Can just enter the text 1135 * you'd like shown for the home link. 1|true defaults to 'Home'. 1136 * @type bool $optimize_query If set to true all page attributes are fetched from database. If set to false only 1137 * the minimal necessary page attributes are fetched from the database to serve the 1138 * function. Default false. 1123 1139 * } 1124 1140 * @return string html menu 1125 1141 */ 1126 1142 function wp_page_menu( $args = array() ) { 1127 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 1143 $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 1144 'link_before' => '', 'link_after' => '', 'optimize_query' => 0); 1128 1145 $args = wp_parse_args( $args, $defaults ); 1129 1146 1130 1147 /** -
wp-includes/post.php
IDEA additional info: Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP <+>UTF-8
4382 4382 * @param array|string $args { 4383 4383 * Optional. Array or string of arguments to retrieve pages. 4384 4384 * 4385 * @type int $child_of Page ID to return child and grandchild pages of. 4386 * Default 0, or no restriction. 4387 * @type string $sort_order How to sort retrieved pages. Accepts 'ASC', 'DESC'. Default 'ASC'. 4388 * @type string $sort_column What columns to sort pages by, comma-separated. Accepts 'post_author', 4389 * 'post_date', 'post_title', 'post_name', 'post_modified', 'menu_order', 4390 * 'post_modified_gmt', 'post_parent', 'ID', 'rand', 'comment_count'. 4391 * 'post_' can be omitted for any values that start with it. 4392 * Default 'post_title'. 4393 * @type bool $hierarchical Whether to return pages hierarchically. Default true. 4394 * @type array $exclude Array of page IDs to exclude. Default empty array. 4395 * @type array $include Array of page IDs to include. Cannot be used with `$child_of`, 4396 * `$parent`, `$exclude`, `$meta_key`, `$meta_value`, or `$hierarchical`. 4397 * Default empty array. 4398 * @type string $meta_key Only include pages with this meta key. Default empty. 4399 * @type string $meta_value Only include pages with this meta value. Requires `$meta_key`. 4400 * Default empty. 4401 * @type string $authors A comma-separated list of author IDs. Default empty. 4402 * @type int $parent Page ID to return direct children of. `$hierarchical` must be false. 4403 * Default -1, or no restriction. 4404 * @type string|array $exclude_tree Comma-separated string or array of page IDs to exclude. 4405 * Default empty array. 4406 * @type int $number The number of pages to return. Default 0, or all pages. 4407 * @type int $offset The number of pages to skip before returning. Requires `$number`. 4408 * Default 0. 4409 * @type string $post_type The post type to query. Default 'page'. 4410 * @type string $post_status A comma-separated list of post status types to include. 4411 * Default 'publish'. 4385 * @type int $child_of Page ID to return child and grandchild pages of. 4386 * Default 0, or no restriction. 4387 * @type string $sort_order How to sort retrieved pages. Accepts 'ASC', 'DESC'. Default 'ASC'. 4388 * @type string $sort_column What columns to sort pages by, comma-separated. Accepts 'post_author', 4389 * 'post_date', 'post_title', 'post_name', 'post_modified', 'menu_order', 4390 * 'post_modified_gmt', 'post_parent', 'ID', 'rand', 'comment_count'. 4391 * 'post_' can be omitted for any values that start with it. 4392 * Default 'post_title'. 4393 * @type bool $hierarchical Whether to return pages hierarchically. Default true. 4394 * @type array $exclude Array of page IDs to exclude. Default empty array. 4395 * @type array $include Array of page IDs to include. Cannot be used with `$child_of`, 4396 * `$parent`, `$exclude`, `$meta_key`, `$meta_value`, or `$hierarchical`. 4397 * Default empty array. 4398 * @type string $meta_key Only include pages with this meta key. Default empty. 4399 * @type string $meta_value Only include pages with this meta value. Requires `$meta_key`. 4400 * Default empty. 4401 * @type string $authors A comma-separated list of author IDs. Default empty. 4402 * @type int $parent Page ID to return direct children of. `$hierarchical` must be false. 4403 * Default -1, or no restriction. 4404 * @type string|array $exclude_tree Comma-separated string or array of page IDs to exclude. 4405 * Default empty array. 4406 * @type int $number The number of pages to return. Default 0, or all pages. 4407 * @type int $offset The number of pages to skip before returning. Requires `$number`. 4408 * Default 0. 4409 * @type string $post_type The post type to query. Default 'page'. 4410 * @type string $post_status A comma-separated list of post status types to include. 4411 * Default 'publish'. 4412 * @type array $restrict_columns Array of column names from wp_posts. Only these columns will be fetched 4413 * from the database if the array is not empty. That means that the fields 4414 * in the returning "page" objects will be empty too. Default empty array. 4412 4415 * } 4413 4416 * @return array List of pages matching defaults or `$args`. 4414 4417 */ … … 4423 4426 'authors' => '', 'parent' => -1, 'exclude_tree' => array(), 4424 4427 'number' => '', 'offset' => 0, 4425 4428 'post_type' => 'page', 'post_status' => 'publish', 4429 'restrict_columns' => array() 4426 4430 ); 4427 4431 4428 4432 $r = wp_parse_args( $args, $defaults ); … … 4436 4440 $meta_value = $r['meta_value']; 4437 4441 $parent = $r['parent']; 4438 4442 $post_status = $r['post_status']; 4443 $restrict_columns = $r['restrict_columns']; 4439 4444 4440 4445 // Make sure the post type is hierarchical. 4441 4446 $hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) ); … … 4598 4603 $sort_order = 'ASC'; 4599 4604 } 4600 4605 4601 $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 4606 // select all columns by default 4607 $columns_to_select = '*'; 4608 4609 // all existing columns from wp_posts 4610 $existing_columns = array('ID', 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_title', 4611 'post_excerpt', 'post_status', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 4612 'pinged', 'post_modified', 'post_modified_gmt', 'post_content_filtered', 'post_parent', 'guid', 'menu_order', 4613 'post_type', 'post_mime_type', 'comment_count'); 4614 4615 // is the argument set? 4616 if (is_array($restrict_columns) && count($restrict_columns) > 0) { 4617 4618 // validate the columns (filter the argument) 4619 $restrict_columns_filtered = array_intersect($existing_columns, $restrict_columns); 4620 4621 // items left after filtering? -> replace the default select 4622 if (count($restrict_columns_filtered) > 0) { 4623 $columns_to_select = implode(',', $restrict_columns_filtered); 4624 } 4625 } 4626 4627 // build the query 4628 $query = "SELECT $columns_to_select FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 4602 4629 $query .= $author_query; 4603 $query .= " ORDER BY " . $sort_column . " " . $sort_order 4630 $query .= " ORDER BY " . $sort_column . " " . $sort_order; 4604 4631 4605 if ( ! empty( $number )) {4632 if (!empty($number)) { 4606 4633 $query .= ' LIMIT ' . $offset . ',' . $number; 4607 4634 } 4608 4635