Make WordPress Core


Ignore:
Timestamp:
12/16/2022 02:38:10 AM (2 years ago)
Author:
peterwilsoncc
Message:

Menus: Prevent infinite loop in menus.

This modifies how the menu-item-has-children class is removed from bottom level menu items. Instead of removing the class within wp_nav_menu() a filter is applied to the nav_menu_css_class hook to remove the class as required.

Introduces wp_nav_menu_remove_menu_item_has_children_class() for removing the class.

Reverts source code changes in [54478,54801], the tests are retained.

Props davidbinda, SergeyBiryukov, mhkuu, JeffPaul, jmdodd, priethor, desrosj, hellofromTonya, azaozz, peterwilsoncc.
Fixes #56926.
See #28620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r54687 r54999  
    618618// Nav menu.
    619619add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
     620add_filter( 'nav_menu_css_class', 'wp_nav_menu_remove_menu_item_has_children_class', 10, 4 );
    620621
    621622// Widgets.
Note: See TracChangeset for help on using the changeset viewer.