[wp-trac] [WordPress Trac] #52694: Twenty Twenty-One: Primary menu toggle filter adds toggles to third party menu locations

WordPress Trac noreply at wordpress.org
Tue Mar 2 09:02:50 UTC 2021


#52694: Twenty Twenty-One: Primary menu toggle filter adds toggles to third party
menu locations
---------------------------+-----------------------------
 Reporter:  domainsupport  |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 The code in /inc/menu-functions.php ...

 {{{#!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
 <?php
 if (isset($args->theme_location) && $args->theme_location === 'primary') {
 ...
 }
 }}}

 Thank you.

 Oliver

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/52694>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list