From 3ed914175ae89fc47cedceb8a5cd14a29ba46a27 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 18 Sep 2015 06:07:24 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@34280 git-svn-id: http://core.svn.wordpress.org/trunk@34244 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 5 ++++- wp-includes/version.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index b296464836..d4797cf978 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -1195,6 +1195,7 @@ function wp_list_pages( $args = '' ) { * @type string $sort_column How to short the list of pages. Accepts post column names. * Default 'menu_order, post_title'. * @type string $menu_class Class to use for the div ID containing the page list. Default 'menu'. + * @type string $menu_tag Element to use for the element containing the page list. Default 'div'. * @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). * Default true. * @type int|bool|string $show_home Whether to display the link to the home page. Can just enter the text @@ -1211,6 +1212,7 @@ function wp_page_menu( $args = array() ) { $defaults = array( 'sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', + 'menu_tag' => 'div', 'echo' => true, 'show_home' => false, 'link_before' => '', @@ -1264,7 +1266,8 @@ function wp_page_menu( $args = array() ) { if ( $menu ) { $menu = $args['before'] . $menu . $args['after']; } - $menu = '
' . $menu . "
\n"; + $tag = sanitize_text_field( $args['menu_tag'] ); + $menu = "<{$args['menu_tag']} class=\"" . esc_attr( $args['menu_class'] ) . '">' . $menu . "\n"; /** * Filter the HTML output of a page-based menu. diff --git a/wp-includes/version.php b/wp-includes/version.php index e7d3d051c6..d34bfaad52 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.4-alpha-34278'; +$wp_version = '4.4-alpha-34280'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.