Add custom link to sidebar under Visit & Explore page
authorLaury GvR <laury@gaslightmedia.com>
Fri, 17 Aug 2018 19:25:50 +0000 (15:25 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Fri, 17 Aug 2018 19:25:50 +0000 (15:25 -0400)
functions.php
header.php
js/app.js
js/custom/pageSetup.js
sidebar.php
style.css

index a43f756..a25a220 100644 (file)
@@ -185,7 +185,7 @@ function glm_site_scripts()
     wp_enqueue_script('jquery');
     wp_enqueue_script(
         'glm_foundation',
-        get_template_directory_uri() . '/js/app.js?v=1.2.45',
+        get_template_directory_uri() . '/js/app.js?v=1.2.46',
         'jquery',
         '1.0',
         true
@@ -197,7 +197,7 @@ function glm_site_scripts()
     );
     wp_enqueue_script(
         'glm_foundation',
-        get_template_directory_uri() . '/js/app.js?v=1.2.45',
+        get_template_directory_uri() . '/js/app.js?v=1.2.46',
             'jquery',
             '1.0',
             true
@@ -271,6 +271,26 @@ function custom_upload_mimes ( $existing_mimes=array() )
 //}
 //add_action('admin_init', 'redirect_user_on_role');
 
+/*
+ * 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;
+        }
+        $anc = get_post_ancestors( $post->ID );
+        foreach ( $anc as $ancestor ) {
+            if( is_page() && $ancestor == $pid ) {
+                return true;
+            }
+        }
+        return false;
+    }
+}
+
 add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 20;' ), 20 );
 
 add_filter( 'woocommerce_output_related_products_args', 'woo_related_products_limit' );
index 40b62ed..6f9b41e 100644 (file)
@@ -4,7 +4,7 @@
     <meta charset="utf-8" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <title><?php wp_title(); ?></title>
-    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/app.css?v=1.2.44">
+    <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/css/app.css?v=1.2.46">
       <link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico">
     <link href='//fonts.googleapis.com/css?family=Balthazar' rel='stylesheet' type='text/css'>
        <?php wp_head();?>
index e021796..1333156 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -18,10 +18,7 @@ $(document).ready(function () {
         $(this).siblings('ul').toggleClass('open');
     });
 
-    var childTarget = $('#page-header .top-bar .top-bar-section > ul:nth-of-type(1) > li:nth-of-type(1) > ul:nth-of-type(1) > li:nth-of-type(7)');
-    childTarget.before( $( '<li class="no-dropdown nav-item customlink"><a href="http://gilmorecarmuseum.pastperfectonline.com/" target="_blank">Search Our Collection</a></li>' ) );
-
-    //console.log(dropdownTarget);
-
-    //<li class="no-dropdown nav-item"><a href="https://www.gilmorecarmuseum.org/visit-explore-2/must-sees/">Customy Link</a></li>
+    let childTarget = $('#page-header .top-bar .top-bar-section > ul:nth-of-type(1) > li:nth-of-type(1) > ul:nth-of-type(1) > li:nth-of-type(7)');
+    let customLink = $( '<li class="no-dropdown nav-item customlink"><a href="http://gilmorecarmuseum.pastperfectonline.com/" target="_blank">Search Our Collection</a></li>' );
+    childTarget.before( customLink );
 });
index c242d21..3dba5f8 100644 (file)
@@ -9,10 +9,7 @@ $(document).ready(function () {
         $(this).siblings('ul').toggleClass('open');
     });
 
-    var childTarget = $('#page-header .top-bar .top-bar-section > ul:nth-of-type(1) > li:nth-of-type(1) > ul:nth-of-type(1) > li:nth-of-type(7)');
-    childTarget.before( $( '<li class="no-dropdown nav-item customlink"><a href="http://gilmorecarmuseum.pastperfectonline.com/" target="_blank">Search Our Collection</a></li>' ) );
-
-    //console.log(dropdownTarget);
-
-    //<li class="no-dropdown nav-item"><a href="https://www.gilmorecarmuseum.org/visit-explore-2/must-sees/">Customy Link</a></li>
+    let childTarget = $('#page-header .top-bar .top-bar-section > ul:nth-of-type(1) > li:nth-of-type(1) > ul:nth-of-type(1) > li:nth-of-type(7)');
+    let customLink = $( '<li class="no-dropdown nav-item customlink"><a href="http://gilmorecarmuseum.pastperfectonline.com/" target="_blank">Search Our Collection</a></li>' );
+    childTarget.before( customLink );
 });
index 3581d77..23fdb36 100644 (file)
                 if (!is_page('sponsors')) {
                     echo '<a class="tab" href="' . esc_url(get_permalink(49)).'"><h3>Sponsors</h3></a>';
                 }?>
-            </div>
\ No newline at end of file
+            </div>
+
+
+
+<?php if (is_in_tree(526)) { ?>
+    <script>
+        let sidebarTarget = $('ul.sidebar > li:nth-of-type(4)');
+        let customSidebarLink = $( '<li class="page_item customlink"><a href="http://gilmorecarmuseum.pastperfectonline.com/" target="_blank">Search Our Collection</a></li>' );
+        sidebarTarget.before( customSidebarLink );
+    </script>
+<?php } ?>
\ No newline at end of file
index c0d09ba..686c9c0 100644 (file)
--- a/style.css
+++ b/style.css
@@ -3,5 +3,5 @@ Theme Name: Gilmore Car Museum
 Author: Gaslight Media
 Author URI: http://www.gaslightmedia.com
 Description: A theme created for Gilmore Car Museum.
-Version: 1.2.45
+Version: 1.2.46
 */