Skip to content

Commit

Permalink
Rewrite assign_menu_location().
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Jun 8, 2016
1 parent 0e65fa9 commit 2365f7e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,10 @@ function register_my_menu() {

function assign_menu_location() {
$locations = get_nav_menu_locations();
if(!empty($locations)) {
foreach($locations as $locationId => $menuValue) {
switch($locationId) {
case 'primary':
$menu = get_term_by('slug', 'main-menu', 'nav_menu');
break;
}
if(isset($menu)) {
$locations[$locationId] = $menu->term_id;
}
if(empty($locations) || $locations['primary'] == 0) {
$menu = get_term_by('slug', 'main-menu', 'nav_menu');
if(isset($menu)) {
$locations['primary'] = $menu->term_id;
}
set_theme_mod('nav_menu_locations', $locations);
}
Expand Down

1 comment on commit 2365f7e

@delucis
Copy link
Member Author

@delucis delucis commented on 2365f7e Jun 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closes #5.

Please sign in to comment.