Opened 2 years ago
Last modified 11 months ago
#52694 new defect (bug)
Twenty Twenty-One: Primary menu toggle filter adds toggles to third party menu locations
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | Bundled Theme | Keywords: | |
Focuses: | Cc: |
Description
The code in /inc/menu-functions.php ...
<?php function twenty_twenty_one_add_sub_menu_toggle( $output, $item, $depth, $args ) { if ( 0 === $depth && in_array( 'menu-item-has-children', $item->classes, true ) ) { // Add toggle button. $output .= '<button class="sub-menu-toggle" aria-expanded="false" onClick="twentytwentyoneExpandSubMenu(this)">'; $output .= '<span class="icon-plus">' . twenty_twenty_one_get_icon_svg( 'ui', 'plus', 18 ) . '</span>'; $output .= '<span class="icon-minus">' . twenty_twenty_one_get_icon_svg( 'ui', 'minus', 18 ) . '</span>'; $output .= '<span class="screen-reader-text">' . esc_html__( 'Open menu', 'twentytwentyone' ) . '</span>'; $output .= '</button>'; } return $output; } add_filter( 'walker_nav_menu_start_el', 'twenty_twenty_one_add_sub_menu_toggle', 10, 4 );
... should be updated so it doesn't affect third party menu locations.
Perhaps by using ...
<?php if (isset($args->theme_location) && $args->theme_location === 'primary') { ... }
Thank you.
Oliver
Change History (5)
This ticket was mentioned in PR #1066 on WordPress/wordpress-develop by mukeshpanchal27.
2 years ago
#2
- Keywords has-patch added
Trac ticket: https://core.trac.wordpress.org/ticket/52694
Note: See
TracTickets for help on using
tickets.
I like the approach of @domainsupport. We can marge theme location condition in if statement like below.