Update to comments the side_menu function
authorSteve Sutton <steve@gaslightmedia.com>
Thu, 9 Jul 2015 13:10:06 +0000 (09:10 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Thu, 9 Jul 2015 13:10:06 +0000 (09:10 -0400)
functions.php

index 71e06c1..e7d90c3 100644 (file)
@@ -187,18 +187,21 @@ function glm_get_header() {
 //    echo '</div>';
 //    echo '</div>';
 
+
+/**
+ * glm_side_menu
+ *
+ * Return the Wordpress Menu for location top-bar.
+ * Will return the sub menu for the page based on the lowest level of menu.
+ * So if the page has no sub menu items it will output its siblings and the
+ * parent page as the title. If it has child menu items then it will display
+ * them and itself as the tile.
+ *
+ * @access public
+ * @return void
+ */
 function glm_side_menu() {
     global $post;
-    //echo '<pre>'.print_r($post, true).'</pre>';
-    $parents = get_post_ancestors($post->ID);
-    $id = (count($parents) > 1) ? $parents[0]: $post->ID;
-    $parent = get_page( $id );
-    if ($id == 0) {
-        $ID = $post->ID;
-    } else {
-        $ID = $parent->ID;
-    }
-    //echo '<pre>'.print_r($ID, true).'</pre>';
     if (($locations = get_nav_menu_locations()) && isset($locations['top-bar'])) {
         $menu = wp_get_nav_menu_object($locations['top-bar']);
         $menu_items = wp_get_nav_menu_items($menu->term_id);