WordPress.org

Make WordPress Core

Ticket #13998: 13998_wp_page_menu_incosistence_2.patch

File 13998_wp_page_menu_incosistence_2.patch, 2.0 KB (added by Sanjo, 5 years ago)

Added documentation

  • wp-includes/post-template.php

     
    840840 * <ul> 
    841841 * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults 
    842842 * to page title. Use column for posts table.</li> 
    843  * <li><strong>menu_class</strong> - Class to use for the div ID which contains 
    844  * the page list. Defaults to 'menu'.</li> 
     843 * <li><strong>container_class</strong> - Class that is applied to the container. 
     844 * <li><strong>menu_class</strong> - Class that is applied to the ul element which 
     845 * forms the menu. Defaults to 'menu'.</li> 
    845846 * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to 
    846847 * echo.</li> 
    847848 * <li><strong>link_before</strong> - Text before show_home argument text.</li> 
     
    856857 * @param array|string $args 
    857858 */ 
    858859function wp_page_menu( $args = array() ) { 
    859         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
     860        $defaults = array('sort_column' => 'menu_order, post_title', 'container_class' => '', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => ''); 
    860861        $args = wp_parse_args( $args, $defaults ); 
    861862        $args = apply_filters( 'wp_page_menu_args', $args ); 
    862863 
     
    889890        $list_args['title_li'] = ''; 
    890891        $menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) ); 
    891892 
    892         if ( $menu ) 
    893                 $menu = '<ul>' . $menu . '</ul>'; 
     893        $class = $args['menu_class'] ? ' class="'. $args['menu_class'] .'"' : ''; 
     894        $menu = '<ul' . $class . '>' . $menu . '</ul>'; 
    894895 
    895         $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n"; 
     896        $class = $args['container_class'] ? ' class="' . esc_attr( $args['container_class'] ) . '"' : ''; 
     897        $menu = '<div' . $class . '>' . $menu . "</div>\n"; 
    896898        $menu = apply_filters( 'wp_page_menu', $menu, $args ); 
    897899        if ( $args['echo'] ) 
    898900                echo $menu;