Make WordPress Core

Ticket #31656: 31656.diff

File 31656.diff, 2.0 KB (added by wonderboymusic, 9 years ago)
  • src/wp-includes/post-template.php

     
    11871187 * arguments.
    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 {
    11931193 *     Optional. Arguments to generate a page menu. See wp_list_pages() for additional arguments.
     
    11941194 *
    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'.
    11991200 *     @type bool            $echo        Whether to echo the list or return it. Accepts true (echo) or false (return).
     
    12111212function wp_page_menu( $args = array() ) {
    12121213        $defaults = array(
    12131214                'sort_column' => 'menu_order, post_title',
     1215                'menu_id'     => '',
    12141216                'menu_class'  => 'menu',
    12151217                'container'   => 'div',
    12161218                'echo'        => true,
     
    12671269                $menu = $args['before'] . $menu . $args['after'];
    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        }
    12711276
     1277        if ( ! empty( $args['menu_class'] ) ) {
     1278                $attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"';
     1279        }
     1280
     1281        $menu = "<{$container}{$attrs}>" . $menu . "</{$container}>\n";
     1282
    12721283        /**
    12731284         * Filter the HTML output of a page-based menu.
    12741285         *