WordPress.org

Make WordPress Core

Changeset 34330


Ignore:
Timestamp:
09/19/2015 06:06:49 PM (5 years ago)
Author:
wonderboymusic
Message:

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.

File:
1 edited

Legend:

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

    r34307 r34330  
    11881188 *
    11891189 * @since 2.7.0
    1190  * @since 4.4.0 Added `container`, `before`, `after`, and `walker` arguments.
     1190 * @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments.
    11911191 *
    11921192 * @param array|string $args {
     
    11951195 *     @type string          $sort_column How to short the list of pages. Accepts post column names.
    11961196 *                                        Default 'menu_order, post_title'.
     1197 *     @type string          $menu_id     ID for the div containing the page list. Default is empty string.
    11971198 *     @type string          $menu_class  Class to use for the element containing the page list. Default 'menu'.
    11981199 *     @type string          $container   Element to use for the element containing the page list. Default 'div'.
     
    12121213    $defaults = array(
    12131214        'sort_column' => 'menu_order, post_title',
     1215        'menu_id'     => '',
    12141216        'menu_class'  => 'menu',
    12151217        'container'   => 'div',
     
    12681270    }
    12691271    $container = sanitize_text_field( $args['container'] );
    1270     $menu = "<{$container} class=\"" . esc_attr( $args['menu_class'] ) . '">' . $menu . "</{$container}>\n";
     1272    $attrs = '';
     1273    if ( ! empty( $args['menu_id'] ) ) {
     1274        $attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"';
     1275    }
     1276
     1277    if ( ! empty( $args['menu_class'] ) ) {
     1278        $attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
     1279    }
     1280
     1281    $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
    12711282
    12721283    /**
Note: See TracChangeset for help on using the changeset viewer.