WP_Classic_To_Block_Menu_Converter::group_by_parent_idprivate staticWP 6.3.0

Returns an array of menu items grouped by the id of the parent menu item.

Method of the class: WP_Classic_To_Block_Menu_Converter{}

No Hooks.

Returns

Array.

Usage

$result = WP_Classic_To_Block_Menu_Converter::group_by_parent_id( $menu_items );
$menu_items(array) (required)
An array of menu items.

Changelog

Since 6.3.0 Introduced.

WP_Classic_To_Block_Menu_Converter::group_by_parent_id() code WP 6.8.1

private static function group_by_parent_id( $menu_items ) {
	$menu_items_by_parent_id = array();

	foreach ( $menu_items as $menu_item ) {
		$menu_items_by_parent_id[ $menu_item->menu_item_parent ][] = $menu_item;
	}

	return $menu_items_by_parent_id;
}