Skip to content

Commit

Permalink
fix: handle empty menu
Browse files Browse the repository at this point in the history
if menu exists but is empty we need an empty array rather than null
  • Loading branch information
moussaclarke committed Aug 12, 2024
1 parent e044f50 commit 87b3ac7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Models/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private static function getIndexedWPNavMenuItems(string $type): ?array
}

// If the menu exists, get its items.
$items = wp_get_nav_menu_items($menu->term_id, ['update_post_term_cache' => false]) ?: null;
$items = wp_get_nav_menu_items($menu->term_id, ['update_post_term_cache' => false]) ?: [];

$indexedItems = [];
foreach ($items as $item) {
Expand Down

0 comments on commit 87b3ac7

Please sign in to comment.