Ticket #8874: 8874.3.patch
| File 8874.3.patch, 5.2 KB (added by hakre, 4 years ago) |
|---|
-
wp-includes/post-template.php
723 723 /** 724 724 * Retrieve or display list of pages in list (li) format. 725 725 * 726 * The arguments are listed below. 727 * 728 * <ul> 729 * <li><strong>depth</strong> - Data Configuration: Depth Quantifier</li> 730 * <li><strong>show_date</strong> - Output Configuration: Show Date Flag</li> 731 * <li><strong>date_format</strong> - Output Configuration: Date Format String, defaults to the Blogs configuration</li> 732 * <li><strong>child_of</strong> - Data Configuration: Child Flag and Parent Identifier, defaults to 0</li> 733 * <li><strong>exclude</strong> - Data Configruation: Exclude List, defaults to an empty list ('')</li> 734 * <li><strong>title_li</strong> - Output Configuration: List Title, defaults to the translation of 'Pages'.</li> 735 * <li><strong>echo</strong> - Output Configuration: Echo Flag: Wether or not to echo the list, default is 1</li> 736 * <li><strong>authors</strong> - Data Configuration: Query Pages authored by the authors in list of author IDs, defaults to ''</li> 737 * <li><strong>sort_column</strong> - Data Configuration: Sort Column Identifier, default is 'menu_order, post_title'</li> 738 * <li><strong>link_before</strong> - Output Configuration: HTML Fragment before Link, defaults to ''</li> 739 * <li><strong>link_after</strong> - Output Configuration: HTML Fragment after Link, defaults to ''</li> 740 * <li><strong>fields</strong> - Data Configuration: Fields of Pages to query, defaults to '*', suggestion is 'ID, post_title, post_parent'</li> 741 * </ul> 742 * 726 743 * @since 1.5.0 744 * @see http://codex.wordpress.org/Template_Tags/wp_list_pages 727 745 * 728 * @param array|string $args Optional. Override default arguments.746 * @param array|string|object $args Optional. Override default arguments. 729 747 * @return string HTML content, if not displaying. 730 748 */ 731 749 function wp_list_pages($args = '') { … … 735 753 'child_of' => 0, 'exclude' => '', 736 754 'title_li' => __('Pages'), 'echo' => 1, 737 755 'authors' => '', 'sort_column' => 'menu_order, post_title', 738 'link_before' => '', 'link_after' => '' 756 'link_before' => '', 'link_after' => '', 757 'fields' => '*' 739 758 ); 740 759 741 760 $r = wp_parse_args( $args, $defaults ); … … 744 763 $output = ''; 745 764 $current_page = 0; 746 765 747 // sanitize, mostly to keep spaces out748 $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);749 750 766 // Allow plugins to filter an array of excluded pages 751 $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', explode(',', $r['exclude'])));767 $r['exclude'] = implode(',', apply_filters('wp_list_pages_excludes', array_map('intval', explode(',', $r['exclude'])))); 752 768 753 769 // Query pages. 754 770 $r['hierarchical'] = 0; … … 769 785 770 786 $output = apply_filters('wp_list_pages', $output); 771 787 772 if ( $ r['echo'])788 if ( $echo ) 773 789 echo $output; 774 790 else 775 791 return $output; -
wp-includes/post.php
2149 2149 * 2150 2150 * The defaults that can be overridden are the following: 'child_of', 2151 2151 * 'sort_order', 'sort_column', 'post_title', 'hierarchical', 'exclude', 2152 * 'include', 'meta_key', 'meta_value', and 'authors'.2152 * 'include', 'meta_key', 'meta_value', 'authors', 'parent', 'exclude_tree' and 'fields'. 2153 2153 * 2154 2154 * @since 1.5.0 2155 2155 * @uses $wpdb … … 2165 2165 'sort_column' => 'post_title', 'hierarchical' => 1, 2166 2166 'exclude' => '', 'include' => '', 2167 2167 'meta_key' => '', 'meta_value' => '', 2168 'authors' => '', 'parent' => -1, 'exclude_tree' => '' 2168 'authors' => '', 'parent' => -1, 'exclude_tree' => '', 2169 'fields' => '*' 2169 2170 ); 2170 2171 2171 2172 $r = wp_parse_args( $args, $defaults ); 2172 2173 extract( $r, EXTR_SKIP ); 2173 2174 2174 2175 $cache = array(); 2175 $key = md5( serialize( compact(array_keys($defaults)) ) ); 2176 if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) { 2177 if ( is_array($cache) && isset( $cache[ $key ] ) ) { 2178 $pages = apply_filters('get_pages', $cache[ $key ], $r ); 2179 return $pages; 2180 } 2176 if ( '*' == $fields ) { 2177 $key = md5( serialize( compact(array_keys($defaults)) ) ); 2178 if ( $cache = wp_cache_get( 'get_pages', 'posts' ) ) 2179 if ( is_array($cache) && isset( $cache[ $key ] ) ) 2180 return apply_filters('get_pages', $cache[ $key ], $r ); 2181 2181 } 2182 2182 2183 2183 if ( !is_array($cache) ) … … 2244 2244 $author_query = " AND ($author_query)"; 2245 2245 } 2246 2246 } 2247 2247 2248 2248 $join = ''; 2249 2249 $where = "$exclusions $inclusions "; 2250 2250 if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) { … … 2263 2263 if ( $parent >= 0 ) 2264 2264 $where .= $wpdb->prepare(' AND post_parent = %d ', $parent); 2265 2265 2266 $query = "SELECT *FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where ";2266 $query = "SELECT $fields FROM $wpdb->posts $join WHERE (post_type = 'page' AND post_status = 'publish') $where "; 2267 2267 $query .= $author_query; 2268 2268 $query .= " ORDER BY " . $sort_column . " " . $sort_order ; 2269 2269 … … 2296 2296 } 2297 2297 } 2298 2298 2299 $cache[ $key ] = $pages; 2300 wp_cache_set( 'get_pages', $cache, 'posts' ); 2299 if ( '*' == $fields ) { 2300 $cache[ $key ] = $pages; 2301 wp_cache_set( 'get_pages', $cache, 'posts' ); 2302 } 2301 2303 2302 2304 $pages = apply_filters('get_pages', $pages, $r); 2303 2305
