WordPress.org

Make WordPress Core

Changeset 34280


Ignore:
Timestamp:
09/18/2015 06:06:17 AM (6 years ago)
Author:
wonderboymusic
Message:

Add an argument to wp_page_menu(), 'menu_tag', which defaults to div but can be overridden to allow HTML5 tags like nav.

Props paulwilde, stebbiv, wonderboymusic.
Fixes #10968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post-template.php

    r34243 r34280  
    11961196 *                                        Default 'menu_order, post_title'.
    11971197 *     @type string          $menu_class  Class to use for the div ID containing the page list. Default 'menu'.
     1198 *     @type string          $menu_tag    Element to use for the element containing the page list. Default 'div'.
    11981199 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
    11991200 *                                        Default true.
     
    12121213        'sort_column' => 'menu_order, post_title',
    12131214        'menu_class'  => 'menu',
     1215        'menu_tag'    => 'div',
    12141216        'echo'        => true,
    12151217        'show_home'   => false,
     
    12651267        $menu = $args['before'] . $menu . $args['after'];
    12661268    }
    1267     $menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
     1269    $tag = sanitize_text_field( $args['menu_tag'] );
     1270    $menu = "<{$args['menu_tag']} class=\"" . esc_attr( $args['menu_class'] ) . '">' . $menu . "</{$args['menu_tag']}>\n";
    12681271
    12691272    /**
Note: See TracChangeset for help on using the changeset viewer.