Make WordPress Core


Ignore:
Timestamp:
12/14/2022 10:52:11 PM (3 years ago)
Author:
azaozz
Message:

Menus: Reset menu_item_parent to 0 when the parent is set to the item itself.

Props: peterwilsoncc, SergeyBiryukov, azaozz.
Fixes #57169.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/nav-menu-template.php

    r54891 r54973  
    200200    $menu_items_with_children = array();
    201201    foreach ( (array) $menu_items as $menu_item ) {
     202        // Fix invalid `menu_item_parent`. See: https://core.trac.wordpress.org/ticket/56926.
     203        if ( (int) $menu_item->ID === (int) $menu_item->menu_item_parent ) {
     204            $menu_item->menu_item_parent = 0;
     205        }
     206
    202207        $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
    203208        $menu_items_tree[ $menu_item->ID ]           = $menu_item->menu_item_parent;
Note: See TracChangeset for help on using the changeset viewer.