Skip to content

Commit

Permalink
fix: menu corrected parent id (#1097)
Browse files Browse the repository at this point in the history
* fix: menu corrected parent id

* chore: remove whitespace lint
  • Loading branch information
NiclasNorin authored Oct 31, 2024
1 parent ba73206 commit d4977a9
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ public function getMenu(): array
return $menu;
}

$mappedParentIdToPageId = [];

foreach ($menu['items'] as &$menuItem) {
$menuItem['active'] = null;
$menuItem['ancestor'] = null;
$menuItem['children'] = null;
$menuItem['id'] = $menuItem['page_id'] ? (int) $menuItem['page_id'] : ($menuItem['id'] ?? null);
if ($menuItem['page_id']) {
$mappedParentIdToPageId[$menuItem['id']] = $menuItem['page_id'];
}

$menuItem['active'] = null;
$menuItem['children'] = null;
$menuItem['id'] = $menuItem['page_id'] ? (int) $menuItem['page_id'] : ($menuItem['id'] ?? null);
$menuItem['post_parent'] = isset($mappedParentIdToPageId[$menuItem['post_parent']]) ? $mappedParentIdToPageId[$menuItem['post_parent']] : $menuItem['post_parent'];
}

return $menu;
Expand Down

0 comments on commit d4977a9

Please sign in to comment.