Skip to content

Commit

Permalink
Merge pull request #4 from SandersForPresident/bugfix/handle-empty-fo…
Browse files Browse the repository at this point in the history
…oter-navmenus

Handle unset footer menus
  • Loading branch information
atticoos committed Jul 9, 2015
2 parents 90d75dc + eb89d99 commit 956e255
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

<!-- Social Links -->
<div class="column">
<?php if ($footer->hasLeftNavigation()) : ?>
<h3><?php echo $footer->leftNavigation->title; ?></h3>
<ul>
<?php foreach ($footer->leftNavigation->items as $item) : ?>
Expand All @@ -20,6 +21,7 @@
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<!-- end: Social Links -->

Expand All @@ -39,6 +41,7 @@

<!-- Organization Links -->
<div class="column">
<?php if ($footer->hasRightNavigation()) : ?>
<h3><?php echo $footer->rightNavigation->title; ?></h3>
<ul>
<?php foreach ($footer->rightNavigation->items as $item) : ?>
Expand All @@ -47,6 +50,7 @@
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
<!-- end: Oragnization Links -->

Expand Down
18 changes: 16 additions & 2 deletions lib/models/footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,19 @@ public function __construct() {
$this->prepareRightNavigation();
}

public function hasLeftNavigation() {
return !empty($this->leftNavigation);
}

public function hasRightNavigation() {
return !empty($this->rightNavigation);
}

public function prepareLeftNavigation() {
$menu = wp_get_nav_menu_object($this->navLocations['footer_social']);
if (!array_key_exists(self::LEFT_NAVIGATION_SLUG, $this->navLocations)) {
return;
}
$menu = wp_get_nav_menu_object($this->navLocations[self::LEFT_NAVIGATION_SLUG]);
$menuItems = wp_get_nav_menu_items($menu->term_id);
$this->fillModelAttributes($this->leftNavigation, array(
'title' => $menu->name,
Expand All @@ -25,7 +36,10 @@ public function prepareLeftNavigation() {
}

public function prepareRightNavigation() {
$menu = wp_get_nav_menu_object($this->navLocations['footer_organize']);
if (!array_key_exists(self::RIGHT_NAVIGATION_SLUG, $this->navLocations)) {
return;
}
$menu = wp_get_nav_menu_object($this->navLocations[self::RIGHT_NAVIGATION_SLUG]);
$menuItems = wp_get_nav_menu_items($menu->term_id);
$this->fillModelAttributes($this->rightNavigation, array(
'title' => $menu->name,
Expand Down

0 comments on commit 956e255

Please sign in to comment.