WordPress.org

Make WordPress Core

Ticket #20289: nav-menu-template.diff

File nav-menu-template.diff, 1.4 KB (added by dannydehaan, 8 years ago)
  • wp-includes/post-template.php

    diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
    index eac548b0b0635481eb0803569b2df900b4f7216f..495aa9125e61e06b1bb3620fe0e21ce8b6ac0fb3 100644
    a b function wp_list_pages($args = '') { 
    882882 * @param array|string $args
    883883 */
    884884function wp_page_menu( $args = array() ) {
    885         $defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
     885        $defaults = array('sort_column' => 'menu_order, post_title', 'container' => 'div', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
    886886        $args = wp_parse_args( $args, $defaults );
    887887        $args = apply_filters( 'wp_page_menu_args', $args );
    888888
    function wp_page_menu( $args = array() ) { 
    918918        if ( $menu )
    919919                $menu = '<ul>' . $menu . '</ul>';
    920920
    921         $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
     921        $allowed_tags = apply_filters( 'wp_nav_menu_container_allowedtags', array( 'div', 'nav' ) );
     922        $container = ( in_array( $args[ 'container' ], $allowed_tags ) ? $args[ 'container' ] : 'div' );
     923       
     924        $menu = '<'. $container .' class="' . esc_attr($args['menu_class']) . '">' . $menu . "</". $container .">\n";
    922925        $menu = apply_filters( 'wp_page_menu', $menu, $args );
    923926        if ( $args['echo'] )
    924927                echo $menu;