_wp_reset_invalid_menu_item_parent()
Prevents menu items from being their own parent.
Resets menu_item_parent to 0 when the parent is set to the item itself. For use before saving _menu_item_menu_item_parent in nav-menus.php.
Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.
No Hooks.
Return
Array
. The menu item data with reset menu_item_parent.
Usage
_wp_reset_invalid_menu_item_parent( $menu_item_data );
- $menu_item_data(array) (required)
- The menu item data array.
Changelog
Since 6.2.0 | Introduced. |
_wp_reset_invalid_menu_item_parent() wp reset invalid menu item parent code WP 6.8
function _wp_reset_invalid_menu_item_parent( $menu_item_data ) { if ( ! is_array( $menu_item_data ) ) { return $menu_item_data; } if ( ! empty( $menu_item_data['ID'] ) && ! empty( $menu_item_data['menu_item_parent'] ) && (int) $menu_item_data['ID'] === (int) $menu_item_data['menu_item_parent'] ) { $menu_item_data['menu_item_parent'] = 0; } return $menu_item_data; }