From b90e8014f1cecb8bee54d0a920f80c91c04bfc43 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 4 Mar 2016 12:16:17 -0500 Subject: [PATCH] Updating the side menu for this site Fixing some places where errors are being generated when WP debug is on --- lib/navigation.php | 113 +++++++++++++++++++-------------------------- 1 file changed, 48 insertions(+), 65 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index a162c63..7b7e4de 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -164,28 +164,11 @@ function glm_get_menu_options() return $menu_options; } -//function glm_side_menu() { -// global $post; -// $parents = get_post_ancestors($post->ID); -// $id = ($parents) ? $parents[count($parents)-1]: $post->ID; -// $parent = get_page( $id ); -// if ($id == 0) { -// $ID = $post->ID; -// } else { -// $ID = $parent->ID; -// } -// echo '

'.get_the_title($ID).'

'; -// echo ''."\n"; -//} function glm_side_menu($mobile = false) { - global $post; - + global $post; // do not use appearance menu for the following page ID's or their ancestors - if( !is_page(array(3200, 3201,3202,3203)) && !is_tree(3200) && !is_tree(3201) && !is_tree(3202) && !is_tree(3203)){ - - $sideMenu = $allMenu = $pageMenuId = array(); + if( !is_page(array(3200, 3201,3202,3203)) && !is_tree(3200) && !is_tree(3201) && !is_tree(3202) && !is_tree(3203)) { + $sideMenu = $allMenu = $pageMenuId = array(); if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) { $menu = wp_get_nav_menu_object($locations['top-bar']); } @@ -212,69 +195,69 @@ function glm_side_menu($mobile = false) { } // does the current page (in the menu) have sub menu items? if (isset($sideMenu[$thisPageMenuId]) && !empty($sideMenu[$thisPageMenuId])) { - $pageHead = $allMenu[$thisPageMenuId]; + $pageHead = (isset($allMenu[$thisPageMenuId])) ? $allMenu[$thisPageMenuId] : (object) array('url' => '', 'target' => '', 'title' => ''); // get the subs for $thisPageMenuId $subs = $sideMenu[$thisPageMenuId]; // If the first element is title [Tabs] then this is a uber menu // custom item and we need to get the subs under that menu item // instead ($sideMenu[$subs[0]->ID]) -// if ($subs[0]->title == '[Tabs]') { -// $subs = $sideMenu[$subs[0]->ID]; -// } + // if ($subs[0]->title == '[Tabs]') { + // $subs = $sideMenu[$subs[0]->ID]; + // } } else if ($thisPageMenuParent) { $pageHead = $allMenu[$thisPageMenuParent]; // get the subs for $thisPageMenuParent $subs = $sideMenu[$thisPageMenuParent]; } else { - $pageHead = $allMenu[0]; + $pageHead = (isset($allMenu[0])) ? $allMenu[0] : (object) array('url' => '', 'target' => '', 'title' => ''); // get Main level $subs = $sideMenu[0]; } - - if ($mobile) { - echo '