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
This commit is contained in:
Sergey Biryukov 2020-06-20 11:20:25 +00:00
parent 806c94fe0a
commit 7179459b79
4 changed files with 44 additions and 45 deletions

View File

@ -491,10 +491,10 @@ add_action( 'wp_enqueue_scripts', 'twentyfifteen_post_nav_background' );
* *
* @since Twenty Fifteen 1.0 * @since Twenty Fifteen 1.0
* *
* @param string $item_output The menu item output. * @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item object. * @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. * @param int $depth Depth of the menu. Used for padding.
* @param array $args wp_nav_menu() arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @return string Menu item with possible description. * @return string Menu item with possible description.
*/ */
function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) { function twentyfifteen_nav_description( $item_output, $item, $depth, $args ) {

View File

@ -31,10 +31,10 @@ function twentynineteen_get_social_link_svg( $uri, $size = 24 ) {
/** /**
* Display SVG icons in social links menu. * Display SVG icons in social links menu.
* *
* @param string $item_output The menu item output. * @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item object. * @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. * @param int $depth Depth of the menu. Used for padding.
* @param object $args wp_nav_menu() arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @return string The menu item output with social icon. * @return string The menu item output with social icon.
*/ */
function twentynineteen_nav_menu_social_icons( $item_output, $item, $depth, $args ) { 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. * Add a dropdown icon to top-level menu items.
* *
* @param string $output Nav menu item start element. * @param string $item_output The menu item's starting HTML output.
* @param object $item Nav menu item. * @param WP_Post $item Menu item data object.
* @param int $depth Depth. * @param int $depth Depth of the menu. Used for padding.
* @param object $args Nav menu args. * @param stdClass $args An object of wp_nav_menu() arguments.
* @return string Nav menu item start element. * @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. // Only add class to 'top level' items on the 'primary' menu.
if ( ! isset( $args->theme_location ) || 'menu-1' !== $args->theme_location ) { 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 ) ) { 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 <a> with <button>. // Replace opening <a> with <button>.
$output = preg_replace( $item_output = preg_replace(
'/<a\s.*?>/', '/<a\s.*?>/',
$link, $link,
$output, $item_output,
1 // Limit. 1 // Limit.
); );
// Replace closing </a> with </button>. // Replace closing </a> with </button>.
$output = preg_replace( $item_output = preg_replace(
'#</a>#i', '#</a>#i',
'</button>', '</button>',
$output, $item_output,
1 // Limit. 1 // Limit.
); );
@ -97,12 +96,12 @@ function twentynineteen_add_dropdown_icons( $output, $item, $depth, $args ) {
// Add SVG icon to parent items. // Add SVG icon to parent items.
$icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 ); $icon = twentynineteen_get_icon_svg( 'keyboard_arrow_down', 24 );
$output .= sprintf( $item_output .= sprintf(
'<button class="submenu-expand" tabindex="-1">%s</button>', '<button class="submenu-expand" tabindex="-1">%s</button>',
$icon $icon
); );
} }
return $output; return $item_output;
} }
add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 ); add_filter( 'walker_nav_menu_start_el', 'twentynineteen_add_dropdown_icons', 10, 4 );

View File

@ -117,10 +117,10 @@ function twentyseventeen_get_svg( $args = array() ) {
/** /**
* Display SVG icons in social links menu. * Display SVG icons in social links menu.
* *
* @param string $item_output The menu item output. * @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item object. * @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. * @param int $depth Depth of the menu. Used for padding.
* @param object $args wp_nav_menu() arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @return string The menu item output with social icon. * @return string The menu item output with social icon.
*/ */
function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $args ) { function twentyseventeen_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
@ -145,7 +145,7 @@ add_filter( 'walker_nav_menu_start_el', 'twentyseventeen_nav_menu_social_icons',
* *
* @param string $title The menu item's title. * @param string $title The menu item's title.
* @param WP_Post $item The current menu item. * @param WP_Post $item The current menu item.
* @param object $args An array of wp_nav_menu() arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @param int $depth Depth of menu item. Used for padding. * @param int $depth Depth of menu item. Used for padding.
* @return string The menu item's title with dropdown icon. * @return string The menu item's title with dropdown icon.
*/ */

View File

@ -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. * 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. * 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[] $css_class An array of CSS classes to be applied to each list item.
* @param string $item Comment. * @param WP_Post $page Page data object.
* @param int $depth Depth of the current comment. * @param int $depth Depth of page, used for padding.
* @param array $args An array of arguments. * @param array $args An array of arguments.
* @param string $current_page Whether or not the item is the current item. * @param int $current_page ID of the current page.
* @return array $css_class CSS Class names. * @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. // Only apply to wp_list_pages() calls with match_menu_classes set to true.
$match_menu_classes = isset( $args['match_menu_classes'] ); $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. * Adds a Sub Nav Toggle to the Expanded Menu and Mobile Menu.
* *
* @param stdClass $args An array of arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @param string $item Menu item. * @param WP_Post $item Menu item data object.
* @param int $depth Depth of the current menu item. * @param int $depth Depth of menu item. Used for padding.
* @return stdClass $args An object of wp_nav_menu() arguments. * @return stdClass An object of wp_nav_menu() arguments.
*/ */
function twentytwenty_add_sub_toggles_to_main_menu( $args, $item, $depth ) { 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. * Displays SVG icons in social links menu.
* *
* @param string $item_output The menu item output. * @param string $item_output The menu item's starting HTML output.
* @param WP_Post $item Menu item object. * @param WP_Post $item Menu item data object.
* @param int $depth Depth of the menu. * @param int $depth Depth of the menu. Used for padding.
* @param array $args wp_nav_menu() arguments. * @param stdClass $args An object of wp_nav_menu() arguments.
* @return string $item_output The menu item output with social icon. * @return string The menu item output with social icon.
*/ */
function twentytwenty_nav_menu_social_icons( $item_output, $item, $depth, $args ) { function twentytwenty_nav_menu_social_icons( $item_output, $item, $depth, $args ) {
// Change SVG icon inside social links menu if there is supported URL. // Change SVG icon inside social links menu if there is supported URL.