Update off canvas menu
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Nov 2015 20:20:04 +0000 (15:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 10 Nov 2015 20:20:04 +0000 (15:20 -0500)
Use menu walker from mountpleasant

functions.php
parts/off-canvas-menu.php

index 6c31ae8..ee5d363 100644 (file)
@@ -262,7 +262,64 @@ function glm_offcanvas_menu()
         'menu_class' => 'left-off-canvas-list'
     ));
 }
+/**
+ * Mobile off-canvas
+ */
+if ( ! function_exists( 'glm_theme_mobile_off_canvas' ) ) {
+    function glm_theme_mobile_off_canvas() {
+        echo '<div class="left-off-canvas-list"><ul>';
+        echo '<li class="page_item"><a href="' . get_bloginfo('url') . '">Home</a></li>';
+            wp_nav_menu(array(
+            'container' => false,                           // remove nav container
+            'container_class' => '',                        // class of container
+            'menu' => '',                                   // menu name
+            'menu_class' => 'off-canvas-list',              // adding custom nav class
+            'theme_location' => 'top-bar',        // where it's located in the theme
+            'before' => '',                                 // before each link <a>
+            'after' => '',                                  // after each link </a>
+            'link_before' => '',                            // before each link text
+            'link_after' => '',                             // after each link text
+            'depth' => 5,                                   // limit the depth of the nav
+            'fallback_cb' => false,                         // fallback function (see below)
+            'items_wrap' => '%3$s',
+            'walker' => new Glm_Theme_Off_Canvas_Walker()
+        ));
+        echo '</ul></div>';
+    }
+}
+if ( ! class_exists( 'Glm_Theme_Off_Canvas_Walker' ) ) :
+class Glm_Theme_Off_Canvas_Walker extends Walker_Nav_Menu {
+    function display_element( $element, &$children_elements, $max_depth, $depth = 0, $args, &$output ) {
+        $element->has_children = ! empty( $children_elements[ $element->ID ] );
+        $element->classes[] = ( $element->current || $element->current_item_ancestor ) ? 'active' : '';
+        $element->classes[] = ( $element->has_children && 1 !== $max_depth ) ? 'page_item_has_children' : '';
+        $element->classes[] = 'page_item';
 
+        parent::display_element( $element, $children_elements, $max_depth, $depth, $args, $output );
+    }
+
+    function start_el( &$output, $object, $depth = 0, $args = array(), $current_object_id = 0 ) {
+        $item_html = '';
+        parent::start_el( $item_html, $object, $depth, $args );
+
+        $classes = empty( $object->classes ) ? array() : (array) $object->classes;
+
+        if ( in_array( 'label', $classes ) ) {
+            $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '<label>$1</label>', $item_html );
+        }
+
+        $output .= $item_html;
+    }
+
+    function start_lvl( &$output, $depth = 0, $args = array() ) {
+        $output .= "\n<ul class=\"children\">\n";
+    }
+
+    function end_lvl(&$output, $depth = 0, $args = array()){
+        $output .= '</ul>';
+    }
+}
+endif;
 add_theme_support('post-thumbnails');
 set_post_thumbnail_size(120, 100, true);
 /**
index ef96b80..975dbcd 100644 (file)
@@ -1,5 +1,5 @@
 <aside class="left-off-canvas-menu hide-for-large-up">
-    <?php glm_offcanvas_menu(); ?>
+    <?php glm_theme_mobile_off_canvas(); ?>
     <?php get_template_part('parts/client-info-offcanvas');?>
     <ul class="offcavas-social-list">
         <li><a class="tweet" href="https://twitter.com/bigpowderhorn/ "></a></li>
@@ -33,7 +33,7 @@
             <div class="small-6 guest columns">
                 <!--<input id="offGuests" type="text" placeholder="Guests" > -->
                 <select id= "offGuests" class="weblink-occupancy weblink-textbox" name="Occupancy" >
-                                                  <option value="1" selected>1</option>   
+                                                  <option value="1" selected>1</option>
                                                   <option value="2">2</option>
                                                   <option value="3">3</option>
                                                   <option value="4">4</option>
@@ -52,8 +52,8 @@
                                                   <option value="17">17</option>
                                                   <option value="18">18</option>
                                                   <option value="19">19</option>
-                                             </select> 
-                                
+                                             </select>
+
                 <img class="icon-people" src="<?php echo get_template_directory_uri(); ?>/assets/people-icon.jpg">
             </div>
             <div class="small-6 columns">
@@ -70,4 +70,4 @@
         <li><a target="_blank" class="insta" href="https://instagram.com/explore/locations/389549733/ "></a></li>
         <li><a target="_blank" class="google" href="https://plus.google.com/+BigPowderhornLodgingAssociationBessemer/posts/ "></a></li>
     </ul>
-</aside>
\ No newline at end of file
+</aside>