Make WordPress Core

Ticket #13979: wp-page-menu-id-arg.diff

File wp-page-menu-id-arg.diff, 1.8 KB (added by iandstewart, 14 years ago)
  • post-template.php

     
    809809 * <ul>
    810810 * <li><strong>sort_column</strong> - How to sort the list of pages. Defaults
    811811 * to page title. Use column for posts table.</li>
    812  * <li><strong>menu_class</strong> - Class to use for the div ID which contains
     812 * <li><strong>menu_class</strong> - Class to use for the div Class which contains
    813813 * the page list. Defaults to 'menu'.</li>
     814 * <li><strong>menu_id</strong> - Class to use for the div ID which contains
     815 * the page list. Defaults to ''.</li>
    814816 * <li><strong>echo</strong> - Whether to echo list or return it. Defaults to
    815817 * echo.</li>
    816818 * <li><strong>link_before</strong> - Text before show_home argument text.</li>
     
    825827 * @param array|string $args
    826828 */
    827829function wp_page_menu( $args = array() ) {
    828         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
     830        $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'menu_id' => '', 'echo' => true, 'link_before' => '', 'link_after' => '');
    829831        $args = wp_parse_args( $args, $defaults );
    830832        $args = apply_filters( 'wp_page_menu_args', $args );
    831833
     
    860862
    861863        if ( $menu )
    862864                $menu = '<ul>' . $menu . '</ul>';
    863 
    864         $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
     865       
     866        $menu_id = '';
     867        if ( $args['menu_id'] != '' )
     868                $menu_id = ' id="'. esc_attr($args['menu_id']) .'"';
     869               
     870        $menu = '<div'. $menu_id .' class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
    865871        $menu = apply_filters( 'wp_page_menu', $menu, $args );
    866872        if ( $args['echo'] )
    867873                echo $menu;