Skip to content

Commit

Permalink
Merge 781b8b8 into c96b9f8
Browse files Browse the repository at this point in the history
  • Loading branch information
mcaskill committed Feb 13, 2023
2 parents c96b9f8 + 781b8b8 commit 6254b64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ protected function __construct(?WP_term $term, array $args)
}

// Set theme location if available
$this->theme_location = array_flip(get_nav_menu_locations())[$term->term_id] ?? null;
$locations = array_flip(array_filter(get_nav_menu_locations(), fn ($location) => is_string($location) || is_int($location)));
$this->theme_location = $locations[$term->term_id] ?? null;
if ($this->theme_location) {
$this->args->theme_location = $this->theme_location;
}
Expand Down
4 changes: 4 additions & 0 deletions tests/test-timber-menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -924,12 +924,16 @@ public function testGetCurrentTopLevelItem()
$this->assertEquals($parent->link(), $top->link());
}

/**
* @issue https://github.com/timber/timber/issues/2576
*/
public function testThemeLocationProperty()
{
$term = self::_createTestMenu();
$menu_id = $term['term_id'];

$this->registerNavMenus([
'primary' => null,
'secondary' => $menu_id,
]);

Expand Down

0 comments on commit 6254b64

Please sign in to comment.