WordPress.org

Make WordPress Core

Ticket #8874: 8874.3.patch

File 8874.3.patch, 5.2 KB (added by hakre, 9 years ago)

Patch contained errors. Fixed.

  • wp-includes/post-template.php

     
    723723/**
    724724 * Retrieve or display list of pages in list (li) format.
    725725 *
     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 *
    726743 * @since 1.5.0
     744 * @see http://codex.wordpress.org/Template_Tags/wp_list_pages
    727745 *
    728  * @param array|string $args Optional. Override default arguments.
     746 * @param array|string|object $args Optional. Override default arguments.
    729747 * @return string HTML content, if not displaying.
    730748 */
    731749function wp_list_pages($args = '') {
     
    735753                'child_of' => 0, 'exclude' => '',
    736754                'title_li' => __('Pages'), 'echo' => 1,
    737755                'authors' => '', 'sort_column' => 'menu_order, post_title',
    738                 'link_before' => '', 'link_after' => ''
     756                'link_before' => '', 'link_after' => '',
     757                'fields' => '*'
    739758        );
    740759
    741760        $r = wp_parse_args( $args, $defaults );
     
    744763        $output = '';
    745764        $current_page = 0;
    746765
    747         // sanitize, mostly to keep spaces out
    748         $r['exclude'] = preg_replace('/[^0-9,]/', '', $r['exclude']);
    749 
    750766        // 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']))));
    752768
    753769        // Query pages.
    754770        $r['hierarchical'] = 0;
     
    769785
    770786        $output = apply_filters('wp_list_pages', $output);
    771787
    772         if ( $r['echo'] )
     788        if ( $echo )
    773789                echo $output;
    774790        else
    775791                return $output;
  • wp-includes/post.php

     
    21492149 *
    21502150 * The defaults that can be overridden are the following: 'child_of',
    21512151 * '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'.
    21532153 *
    21542154 * @since 1.5.0
    21552155 * @uses $wpdb
     
    21652165                'sort_column' => 'post_title', 'hierarchical' => 1,
    21662166                'exclude' => '', 'include' => '',
    21672167                'meta_key' => '', 'meta_value' => '',
    2168                 'authors' => '', 'parent' => -1, 'exclude_tree' => ''
     2168                'authors' => '', 'parent' => -1, 'exclude_tree' => '',
     2169                'fields' => '*'
    21692170        );
    21702171
    21712172        $r = wp_parse_args( $args, $defaults );
    21722173        extract( $r, EXTR_SKIP );
    21732174
    21742175        $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 );
    21812181        }
    21822182
    21832183        if ( !is_array($cache) )
     
    22442244                                $author_query = " AND ($author_query)";
    22452245                }
    22462246        }
    2247 
     2247       
    22482248        $join = '';
    22492249        $where = "$exclusions $inclusions ";
    22502250        if ( ! empty( $meta_key ) || ! empty( $meta_value ) ) {
     
    22632263        if ( $parent >= 0 )
    22642264                $where .= $wpdb->prepare(' AND post_parent = %d ', $parent);
    22652265
    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 ";
    22672267        $query .= $author_query;
    22682268        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
    22692269
     
    22962296                }
    22972297        }
    22982298
    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        }
    23012303
    23022304        $pages = apply_filters('get_pages', $pages, $r);
    23032305