WordPress.org

Make WordPress Core

Ticket #12945: 12945.diff

File 12945.diff, 2.1 KB (added by technosailor, 4 years ago)

This should be considered for 3.1, not 3.0, as it modifies the get_pages() function and adds a new include_full argument where, if true, returns an array of postdata and if false returns an array of IDs

  • wp-includes/post-template.php

     
    821821 * @param array|string $args 
    822822 */ 
    823823function wp_page_menu( $args = array() ) { 
    824         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
     824        $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '', 'exclude' => implode( ',', get_pages('include_full') => false ) ); 
    825825        $args = wp_parse_args( $args, $defaults ); 
    826826        $args = apply_filters( 'wp_page_menu_args', $args ); 
    827827 
  • wp-includes/post.php

     
    29502950                'meta_key' => '', 'meta_value' => '', 
    29512951                'authors' => '', 'parent' => -1, 'exclude_tree' => '', 
    29522952                'number' => '', 'offset' => 0, 
    2953                 'post_type' => 'page', 'post_status' => 'publish', 
     2953                'post_type' => 'page', 'post_status' => 'publish', 'include_full' => true 
    29542954        ); 
    29552955 
    29562956        $r = wp_parse_args( $args, $defaults ); 
     
    30613061 
    30623062        $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status ); 
    30633063 
    3064         $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 
     3064        if( $include_full ) 
     3065                $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 
     3066        else 
     3067                $query = "SELECT ID FROM $wpdb->posts $join WHERE ($where_post_type) $where "; 
    30653068        $query .= $author_query; 
    30663069        $query .= " ORDER BY " . $sort_column . " " . $sort_order ; 
    30673070 
    30683071        if ( !empty($number) ) 
    30693072                $query .= ' LIMIT ' . $offset . ',' . $number; 
    30703073 
    3071         $pages = $wpdb->get_results($query); 
    3072  
     3074        if( $include_full ) 
     3075                $pages = $wpdb->get_results( $query ); 
     3076        else 
     3077                $pages = $wpdb->get_col( $query ); 
     3078                 
    30733079        if ( empty($pages) ) { 
    30743080                $pages = apply_filters('get_pages', array(), $r); 
    30753081                return $pages;