WordPress.org

Make WordPress Core

Ticket #13998: 13998_wp_page_menu_incosistence.patch

File 13998_wp_page_menu_incosistence.patch, 1.3 KB (added by Sanjo, 4 years ago)

wp_page_menu() has now a container_class and a menu_class argument that are identical to wp_nav_menu.

  • wp-includes/post-template.php

     
    856856 * @param array|string $args 
    857857 */ 
    858858function wp_page_menu( $args = array() ) { 
    859         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
     859        $defaults = array('sort_column' => 'menu_order, post_title', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
    860860        $args = wp_parse_args( $args, $defaults ); 
    861861        $args = apply_filters( 'wp_page_menu_args', $args ); 
    862862 
     
    889889        $list_args['title_li'] = ''; 
    890890        $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); 
    891891 
    892         if ( $menu ) 
    893                 $menu = '<ul>' . $menu . '</ul>'; 
     892        $class = $args['menu_class'] ? ' class="'. $args['menu_class'] .'"' : ''; 
     893        $menu = '<ul' . $class . '>' . $menu . '</ul>'; 
    894894 
    895         $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; 
     895        $class = $args['container_class'] ? ' class="' . esc_attr( $args['container_class'] ) . '"' : ''; 
     896        $menu = '<div' . $class . '>' . $menu . "</div>\n"; 
    896897        $menu = apply_filters( 'wp_page_menu', $menu, $args ); 
    897898        if ( $args['echo'] ) 
    898899                echo $menu;