Add a `'menu_id'` argument to `wp_page_menu()` so that fallback menus have the same attributes as `wp_nav_menu()`.
Props lancewillett, ocean90, wonderboymusic. Fixes #31656. Built from https://develop.svn.wordpress.org/trunk@34330 git-svn-id: http://core.svn.wordpress.org/trunk@34294 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fc8c624a61
commit
e4f350706c
|
@ -1187,13 +1187,14 @@ function wp_list_pages( $args = '' ) {
|
||||||
* arguments.
|
* arguments.
|
||||||
*
|
*
|
||||||
* @since 2.7.0
|
* @since 2.7.0
|
||||||
* @since 4.4.0 Added `container`, `before`, `after`, and `walker` arguments.
|
* @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
|
||||||
*
|
*
|
||||||
* @param array|string $args {
|
* @param array|string $args {
|
||||||
* Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
|
* Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
|
||||||
*
|
*
|
||||||
* @type string $sort_column How to short the list of pages. Accepts post column names.
|
* @type string $sort_column How to short the list of pages. Accepts post column names.
|
||||||
* Default 'menu_order, post_title'.
|
* Default 'menu_order, post_title'.
|
||||||
|
* @type string $menu_id ID for the div containing the page list. Default is empty string.
|
||||||
* @type string $menu_class Class to use for the element containing the page list. Default 'menu'.
|
* @type string $menu_class Class to use for the element containing the page list. Default 'menu'.
|
||||||
* @type string $container Element to use for the element containing the page list. Default 'div'.
|
* @type string $container 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).
|
* @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return).
|
||||||
|
@ -1211,6 +1212,7 @@ function wp_list_pages( $args = '' ) {
|
||||||
function wp_page_menu( $args = array() ) {
|
function wp_page_menu( $args = array() ) {
|
||||||
$defaults = array(
|
$defaults = array(
|
||||||
'sort_column' => 'menu_order, post_title',
|
'sort_column' => 'menu_order, post_title',
|
||||||
|
'menu_id' => '',
|
||||||
'menu_class' => 'menu',
|
'menu_class' => 'menu',
|
||||||
'container' => 'div',
|
'container' => 'div',
|
||||||
'echo' => true,
|
'echo' => true,
|
||||||
|
@ -1267,7 +1269,16 @@ function wp_page_menu( $args = array() ) {
|
||||||
$menu = $args['before'] . $menu . $args['after'];
|
$menu = $args['before'] . $menu . $args['after'];
|
||||||
}
|
}
|
||||||
$container = sanitize_text_field( $args['container'] );
|
$container = sanitize_text_field( $args['container'] );
|
||||||
$menu = "<{$container} class=\"" . esc_attr( $args['menu_class'] ) . '">' . $menu . "</{$container}>\n";
|
$attrs = '';
|
||||||
|
if ( ! empty( $args['menu_id'] ) ) {
|
||||||
|
$attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( ! empty( $args['menu_class'] ) ) {
|
||||||
|
$attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
$menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the HTML output of a page-based menu.
|
* Filter the HTML output of a page-based menu.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.4-alpha-34329';
|
$wp_version = '4.4-alpha-34330';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue