fixing the is in tree function for the nav menu checking so that it isn't overwritten...
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 11 Oct 2018 17:34:10 +0000 (13:34 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 11 Oct 2018 17:34:10 +0000 (13:34 -0400)
functions.php
sections/header.php

index 8a1ca73..2e8a7f7 100644 (file)
@@ -223,23 +223,40 @@ add_action('thematic_searchloop', 'mytheme_search_loop');
  * This function returns true when the current page is the page given by ID
  *  or a descendent thereof.
  */
-if (!function_exists('is_in_tree')) {
-    function is_in_tree( $pid ) {
-        global $post;
-        if ( is_page( $pid ) ) {
-            return true;
-        }
-        if ($post) {
-            $anc = get_post_ancestors( $post->ID );
-            foreach ( $anc as $ancestor ) {
-                if( is_page() && $ancestor == $pid ) {
-                    return true;
-                }
+function is_in_tree_theme( $pid, $pageID ) {
+    if ( is_page( $pid ) ) {
+        return true;
+    }
+    if ( $pageID ) {
+        $anc = get_post_ancestors( $pageID );
+   
+        foreach ( $anc as $ancestor ) {
+            if( $ancestor == $pid ) {
+                return true;
             }
         }
-        return false;
     }
+    return false;
 }
+// if (!function_exists('is_in_tree')) {
+//     function is_in_tree( $pid, $pageID = false ) {
+        
+//         if ( is_page( $pid ) ) {
+//             return true;
+//         }
+        
+//         if ( $pageID ) {
+            
+//             $anc = get_post_ancestors( $pageID );
+//             foreach ( $anc as $ancestor ) {
+//                 if(  $ancestor == $pid ) {
+//                     return true;
+//                 }
+//             }
+//         }
+//         return false;
+//     }
+// }
 
 // The GLM Simple Messageboard needs this function to display its data
 if ( !function_exists( 'glm_get_simplemessageboard_option' ) ) {
index e43344a..fce8693 100644 (file)
@@ -4,12 +4,19 @@
             <a class="logo-link" href="<?php echo get_bloginfo('url'); ?>"><img class="small-header-logo" src="<?php echo get_template_directory_uri();?>/assets/logo.png" alt=""></a>
         </div>
         
-        
+    
         <nav class="large-12 columns top-bar text-center show-for-large-up opensearchserver.ignore" data-topbar role="navigation" data-options="sticky_on: large">
             <section class="top-bar-section">
             <?php 
-            if(is_in_tree(OWNERS_FRONTPAGE_ID) ): 
-                glm_theme_top_bar('owners');
+            global $post;
+            if( is_home() ){
+                $page_id = get_option( 'page_for_posts' );
+            }else{
+                $page_id = $post->ID;
+            }
+
+            if(is_in_tree_theme(OWNERS_FRONTPAGE_ID, $page_id) ): 
+                glm_theme_top_bar('owners'); 
             else:
                 glm_theme_top_bar('public');
             endif;