Make WordPress Core


Ignore:
Timestamp:
06/20/2020 11:20:25 AM (5 years ago)
Author:
SergeyBiryukov
Message:

Docs: Synchronize and correct the documentation for wp_nav_menu() arguments in bundled themes.

See #49572.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentynineteen/inc/icon-functions.php

    r48101 r48103  
    3232 * Display SVG icons in social links menu.
    3333 *
    34  * @param  string  $item_output The menu item output.
    35  * @param  WP_Post $item        Menu item object.
    36  * @param  int     $depth       Depth of the menu.
    37  * @param  object  $args        wp_nav_menu() arguments.
     34 * @param string   $item_output The menu item's starting HTML output.
     35 * @param WP_Post  $item        Menu item data object.
     36 * @param int      $depth       Depth of the menu. Used for padding.
     37 * @param stdClass $args        An object of wp_nav_menu() arguments.
    3838 * @return string The menu item output with social icon.
    3939 */
     
    5555 * Add a dropdown icon to top-level menu items.
    5656 *
    57  * @param string $output Nav menu item start element.
    58  * @param object $item   Nav menu item.
    59  * @param int    $depth  Depth.
    60  * @param object $args   Nav menu args.
     57 * @param string   $item_output The menu item's starting HTML output.
     58 * @param WP_Post  $item        Menu item data object.
     59 * @param int      $depth       Depth of the menu. Used for padding.
     60 * @param stdClass $args        An object of wp_nav_menu() arguments.
    6161 * @return string Nav menu item start element.
    62  * Add a dropdown icon to top-level menu items
    6362 */
    64 function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) {
     63function twentynineteen_add_dropdown_icons( $item_output, $item, $depth, $args ) {
    6564
    6665    // Only add class to 'top level' items on the 'primary' menu.
    6766    if ( ! isset( $args->theme_location ) || 'menu-1' !== $args->theme_location ) {
    68         return $output;
     67        return $item_output;
    6968    }
    7069
     
    7877
    7978        // Replace opening <a> with <button>.
    80         $output = preg_replace(
     79        $item_output = preg_replace(
    8180            '/<a\s.*?>/',
    8281            $link,
    83             $output,
     82            $item_output,
    8483            1 // Limit.
    8584        );
    8685
    8786        // Replace closing </a> with </button>.
    88         $output = preg_replace(
     87        $item_output = preg_replace(
    8988            '#</a>#i',
    9089            '</button>',
    91             $output,
     90            $item_output,
    9291            1 // Limit.
    9392        );
     
    9897        $icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 );
    9998
    100         $output .= sprintf(
     99        $item_output .= sprintf(
    101100            '<button class="submenu-expand" tabindex="-1">%s</button>',
    102101            $icon
     
    104103    }
    105104
    106     return $output;
     105    return $item_output;
    107106}
    108107add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 );
Note: See TracChangeset for help on using the changeset viewer.