WordPress.org

Make WordPress Core

Ticket #12945: 12945-4.diff

File 12945-4.diff, 2.0 KB (added by technosailor, 8 years ago)
  • 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( array('fields' => 'id') ) ) );
    825825        $args = wp_parse_args( $args, $defaults );
    826826        $args = apply_filters( 'wp_page_menu_args', $args );
    827827
  • wp-includes/post.php

     
    29512951                'meta_key' => '', 'meta_value' => '',
    29522952                'authors' => '', 'parent' => -1, 'exclude_tree' => '',
    29532953                'number' => '', 'offset' => 0,
    2954                 'post_type' => 'page', 'post_status' => 'publish',
     2954                'post_type' => 'page', 'post_status' => 'publish', 'fields' => 'all'
    29552955        );
    29562956
    29572957        $r = wp_parse_args( $args, $defaults );
     
    30623062
    30633063        $where_post_type = $wpdb->prepare( "post_type = '%s' AND post_status = '%s'", $post_type, $post_status );
    30643064
    3065         $query = "SELECT * FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
     3065        $field = ( $fields == 'all' ) ? '*' : 'ID';
     3066        $query = "SELECT $field FROM $wpdb->posts $join WHERE ($where_post_type) $where ";
     3067       
    30663068        $query .= $author_query;
    30673069        $query .= " ORDER BY " . $sort_column . " " . $sort_order ;
    30683070
    30693071        if ( !empty($number) )
    30703072                $query .= ' LIMIT ' . $offset . ',' . $number;
    30713073
    3072         $pages = $wpdb->get_results($query);
    3073 
     3074        if( $fields == 'all' )
     3075                $pages = $wpdb->get_results( $query );
     3076        else
     3077                $pages = $wpdb->get_col( $query );
     3078               
    30743079        if ( empty($pages) ) {
    30753080                $pages = apply_filters('get_pages', array(), $r);
    30763081                return $pages;