From c53fd02e4315822fd225415c72333994136337a7 Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 7 Jan 2016 09:49:28 -0500 Subject: [PATCH] testing side menu nav --- lib/navigation.php | 176 ++++++++++++++++++++++----------------------- 1 file changed, 88 insertions(+), 88 deletions(-) diff --git a/lib/navigation.php b/lib/navigation.php index 68f75ec..8f85012 100644 --- a/lib/navigation.php +++ b/lib/navigation.php @@ -171,97 +171,97 @@ 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) { +//function glm_side_menu() { // global $post; -// $sideMenu = $allMenu = $pageMenuId = array(); -// -// if (($locations = get_nav_menu_locations()) && isset($locations['top-bar-2'])) { -// $menu = wp_get_nav_menu_object($locations['top-bar-2']); -// $menu_items = wp_get_nav_menu_items($menu->term_id); -// foreach ((array) $menu_items as $key => $menu_item) { -// $sideMenu[$menu_item->menu_item_parent][] = $menu_item; -// $allMenu[$menu_item->ID] = $menu_item; -// if ($menu_item->object_id == $post->ID) { -// $pageMenuId[] = $menu_item; -// } -// } -// if (count($pageMenuId) > 1) { -// $thisPageMenuId = (isset($pageMenuId[1])) ? $pageMenuId[1]->ID : 0; -// $thisPageMenuParent = (isset($pageMenuId[1])) ? $pageMenuId[1]->menu_item_parent : 0; -// foreach ($pageMenuId as $men) { -// if (isset($sideMenu[$men->ID]) && !empty($sideMenu[$men->ID])) { -// $thisPageMenuId = $men->ID; -// $thisPageMenuParent = $men->menu_item_parent; -// } -// } -// } else { -// $thisPageMenuId = (isset($pageMenuId[0])) ? $pageMenuId[0]->ID : 0; -// $thisPageMenuParent = (isset($pageMenuId[0])) ? $pageMenuId[0]->menu_item_parent : 0; -// } -// // does the current page (in the menu) have sub menu items? -// if (isset($sideMenu[$thisPageMenuId]) && !empty($sideMenu[$thisPageMenuId])) { -// $pageHead = $allMenu[$thisPageMenuId]; -// // 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]) -// +// $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; + $sideMenu = $allMenu = $pageMenuId = array(); + + if (($locations = get_nav_menu_locations()) && isset($locations['top-bar-1'])) { + $menu = wp_get_nav_menu_object($locations['top-bar-1']); + $menu_items = wp_get_nav_menu_items($menu->term_id); + foreach ((array) $menu_items as $key => $menu_item) { + $sideMenu[$menu_item->menu_item_parent][] = $menu_item; + $allMenu[$menu_item->ID] = $menu_item; + if ($menu_item->object_id == $post->ID) { + $pageMenuId[] = $menu_item; + } + } + if (count($pageMenuId) > 1) { + $thisPageMenuId = (isset($pageMenuId[1])) ? $pageMenuId[1]->ID : 0; + $thisPageMenuParent = (isset($pageMenuId[1])) ? $pageMenuId[1]->menu_item_parent : 0; + foreach ($pageMenuId as $men) { + if (isset($sideMenu[$men->ID]) && !empty($sideMenu[$men->ID])) { + $thisPageMenuId = $men->ID; + $thisPageMenuParent = $men->menu_item_parent; + } + } + } else { + $thisPageMenuId = (isset($pageMenuId[0])) ? $pageMenuId[0]->ID : 0; + $thisPageMenuParent = (isset($pageMenuId[0])) ? $pageMenuId[0]->menu_item_parent : 0; + } + // does the current page (in the menu) have sub menu items? + if (isset($sideMenu[$thisPageMenuId]) && !empty($sideMenu[$thisPageMenuId])) { + $pageHead = $allMenu[$thisPageMenuId]; + // 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]; // } -// } else if ($thisPageMenuParent) { -// $pageHead = $allMenu[$thisPageMenuParent]; -// // get the subs for $thisPageMenuParent -// $subs = $sideMenu[$thisPageMenuParent]; -// } else { -// $pageHead = $allMenu[0]; -// // get Main level -// $subs = $sideMenu[0]; -// } -// } -// if ($mobile) { -// echo '