Make WordPress Core

Ticket #8298: 8298.2.diff

File 8298.2.diff, 1.6 KB (added by wojtek.szkutnik, 14 years ago)
  • wp-includes/post-template.php

     
    825825 * @param array|string $args
    826826 */
    827827function wp_page_menu( $args = array() ) {
    828         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
     828        $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'include' => '', 'exclude' => '', 'echo' => true, 'link_before' => '', 'link_after' => '');
    829829        $args = wp_parse_args( $args, $defaults );
    830830        $args = apply_filters( 'wp_page_menu_args', $args );
    831831
     
    843843                if ( is_front_page() && !is_paged() )
    844844                        $class = 'class="current_page_item"';
    845845                $menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
     846               
     847                // Because include overrides subpages, we need to reverse engineer the include as exclude
     848                $include = is_array( $args['include'] ) ? $args['include'] : (array) $args['include'];
     849                $exclude = is_array( $args['exclude'] ) ? $args['exclude'] : (array) $args['exclude'];
     850                $pages = get_pages();
     851                foreach( $pages as $page ) {
     852                        if( !in_array( $page->ID, $include ) )
     853                                $exclude[] = $page->ID;
     854                }
     855                $list_args['exclude'] = implode( ',', $exclude );
     856               
    846857                // If the front page is a page, add it to the exclude list
    847858                if (get_option('show_on_front') == 'page') {
    848859                        if ( !empty( $list_args['exclude'] ) ) {