From 7179459b79a38aef8d7308732c9294f14dc0e378 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 20 Jun 2020 11:20:25 +0000 Subject: [PATCH] Docs: Synchronize and correct the documentation for `wp_nav_menu()` arguments in bundled themes. See #49572. git-svn-id: https://develop.svn.wordpress.org/trunk@48103 602fd350-edb4-49c9-b593-d223f7449a82 --- .../themes/twentyfifteen/functions.php | 8 ++--- .../twentynineteen/inc/icon-functions.php | 33 +++++++++---------- .../twentyseventeen/inc/icon-functions.php | 16 ++++----- .../themes/twentytwenty/inc/template-tags.php | 32 +++++++++--------- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/src/wp-content/themes/twentyfifteen/functions.php b/src/wp-content/themes/twentyfifteen/functions.php index 206cf0b88d..7535caf850 100644 --- a/src/wp-content/themes/twentyfifteen/functions.php +++ b/src/wp-content/themes/twentyfifteen/functions.php @@ -491,10 +491,10 @@ add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' ); * * @since Twenty Fifteen 1.0 * - * @param string $item_output The menu item output. - * @param WP_Post $item Menu item object. - * @param int $depth Depth of the menu. - * @param array $args wp_nav_menu() arguments. + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of the menu. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. * @return string Menu item with possible description. */ function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { diff --git a/src/wp-content/themes/twentynineteen/inc/icon-functions.php b/src/wp-content/themes/twentynineteen/inc/icon-functions.php index b69513a319..76dba55094 100644 --- a/src/wp-content/themes/twentynineteen/inc/icon-functions.php +++ b/src/wp-content/themes/twentynineteen/inc/icon-functions.php @@ -31,10 +31,10 @@ function twentynineteen_get_social_link_svg( $uri, $size = 24 ) { /** * Display SVG icons in social links menu. * - * @param string $item_output The menu item output. - * @param WP_Post $item Menu item object. - * @param int $depth Depth of the menu. - * @param object $args wp_nav_menu() arguments. + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of the menu. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. * @return string The menu item output with social icon. */ function twentynineteen_nav_menu_social_icons( $item_output, $item, $depth, $args ) { @@ -54,18 +54,17 @@ add_filter( 'walker_nav_menu_start_el', 'twentynineteen_nav_menu_social_icons', /** * Add a dropdown icon to top-level menu items. * - * @param string $output Nav menu item start element. - * @param object $item Nav menu item. - * @param int $depth Depth. - * @param object $args Nav menu args. + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of the menu. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. * @return string Nav menu item start element. - * Add a dropdown icon to top-level menu items */ -function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) { +function twentynineteen_add_dropdown_icons( $item_output, $item, $depth, $args ) { // Only add class to 'top level' items on the 'primary' menu. if ( ! isset( $args->theme_location ) || 'menu-1' !== $args->theme_location ) { - return $output; + return $item_output; } if ( in_array( 'mobile-parent-nav-menu-item', $item->classes, true ) && isset( $item->original_id ) ) { @@ -77,18 +76,18 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) { ); // Replace opening with . - $output = preg_replace( + $item_output = preg_replace( '##i', '', - $output, + $item_output, 1 // Limit. ); @@ -97,12 +96,12 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) { // Add SVG icon to parent items. $icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 ); - $output .= sprintf( + $item_output .= sprintf( '', $icon ); } - return $output; + return $item_output; } add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 ); diff --git a/src/wp-content/themes/twentyseventeen/inc/icon-functions.php b/src/wp-content/themes/twentyseventeen/inc/icon-functions.php index 79dcbf03be..4a0964ca61 100644 --- a/src/wp-content/themes/twentyseventeen/inc/icon-functions.php +++ b/src/wp-content/themes/twentyseventeen/inc/icon-functions.php @@ -117,10 +117,10 @@ function twentyseventeen_get_svg( $args = array() ) { /** * Display SVG icons in social links menu. * - * @param string $item_output The menu item output. - * @param WP_Post $item Menu item object. - * @param int $depth Depth of the menu. - * @param object $args wp_nav_menu() arguments. + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of the menu. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. * @return string The menu item output with social icon. */ function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $args ) { @@ -143,10 +143,10 @@ add_filter( 'walker_nav_menu_start_el', 'twentyseventeen_nav_menu_social_icons', /** * Add dropdown icon if menu item has children. * - * @param string $title The menu item's title. - * @param WP_Post $item The current menu item. - * @param object $args An array of wp_nav_menu() arguments. - * @param int $depth Depth of menu item. Used for padding. + * @param string $title The menu item's title. + * @param WP_Post $item The current menu item. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param int $depth Depth of menu item. Used for padding. * @return string The menu item's title with dropdown icon. */ function twentyseventeen_dropdown_icon_to_menu_link( $title, $item, $args, $depth ) { diff --git a/src/wp-content/themes/twentytwenty/inc/template-tags.php b/src/wp-content/themes/twentytwenty/inc/template-tags.php index 759b86695a..a543a36895 100644 --- a/src/wp-content/themes/twentytwenty/inc/template-tags.php +++ b/src/wp-content/themes/twentytwenty/inc/template-tags.php @@ -499,14 +499,14 @@ function twentytwenty_get_post_meta( $post_id = null, $location = 'single-top' ) * Filter the class applied to wp_list_pages() items with children to match the menu class, to simplify. * styling of sub levels in the fallback. Only applied if the match_menu_classes argument is set. * - * @param array $css_class CSS Class names. - * @param string $item Comment. - * @param int $depth Depth of the current comment. - * @param array $args An array of arguments. - * @param string $current_page Whether or not the item is the current item. - * @return array $css_class CSS Class names. + * @param string[] $css_class An array of CSS classes to be applied to each list item. + * @param WP_Post $page Page data object. + * @param int $depth Depth of page, used for padding. + * @param array $args An array of arguments. + * @param int $current_page ID of the current page. + * @return array CSS class names. */ -function twentytwenty_filter_wp_list_pages_item_classes( $css_class, $item, $depth, $args, $current_page ) { +function twentytwenty_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page ) { // Only apply to wp_list_pages() calls with match_menu_classes set to true. $match_menu_classes = isset( $args['match_menu_classes'] ); @@ -534,10 +534,10 @@ add_filter( 'page_css_class', 'twentytwenty_filter_wp_list_pages_item_classes', /** * Adds a Sub Nav Toggle to the Expanded Menu and Mobile Menu. * - * @param stdClass $args An array of arguments. - * @param string $item Menu item. - * @param int $depth Depth of the current menu item. - * @return stdClass $args An object of wp_nav_menu() arguments. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of menu item. Used for padding. + * @return stdClass An object of wp_nav_menu() arguments. */ function twentytwenty_add_sub_toggles_to_main_menu( $args, $item, $depth ) { @@ -580,11 +580,11 @@ add_filter( 'nav_menu_item_args', 'twentytwenty_add_sub_toggles_to_main_menu', 1 /** * Displays SVG icons in social links menu. * - * @param string $item_output The menu item output. - * @param WP_Post $item Menu item object. - * @param int $depth Depth of the menu. - * @param array $args wp_nav_menu() arguments. - * @return string $item_output The menu item output with social icon. + * @param string $item_output The menu item's starting HTML output. + * @param WP_Post $item Menu item data object. + * @param int $depth Depth of the menu. Used for padding. + * @param stdClass $args An object of wp_nav_menu() arguments. + * @return string The menu item output with social icon. */ function twentytwenty_nav_menu_social_icons( $item_output, $item, $depth, $args ) { // Change SVG icon inside social links menu if there is supported URL.