Working on custom menu
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Jun 2015 20:59:09 +0000 (16:59 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Jun 2015 20:59:09 +0000 (16:59 -0400)
footer.php
functions.php
lib/menu-walker.php [new file with mode: 0644]
lib/navigation.php [new file with mode: 0644]
parts/frontpage-sidebar-dropdown.php
parts/off-canvas-menu.php
parts/search.php
parts/slide-show.php
parts/top-bar.php

index 9854adc..aaeb034 100644 (file)
@@ -20,8 +20,8 @@
                             </div>
 -->
                         </footer>
-                </div><!--End of shadow-->
                     </main><!--End of main-->
+                </div><!--End of shadow-->
                 <div id="copyright" class="small-12 text-center row columns">
                     <span>&copy; <?php echo date('Y');?> Emmet County Government</span>
                     <span class="bullet"> &#8226; </span>
                 </div>
         <a class="exit-off-canvas"></a>
         </div><!--End of inner-wrap-->
-      </div><!--End of off-canvas-->  
-  </body>
+      </div><!--End of off-canvas-->
     <div id="modal-placeholder">
         <?php $modal_link = do_shortcode('[ninja_forms_modal_form id=5 text_link="eNews Signup"]'); // Must stay above wp_footer() as it adds actions to it ?>
     </div>
   <?php wp_footer();?>
     <script>$(document).foundation({   equalizer : {     // Specify if Equalizer should make elements equal height once they become stacked.     equalize_on_stack: true   } });</script>
-</html>
\ No newline at end of file
+  </body>
+</html>
index be6fff7..40464cd 100644 (file)
@@ -24,6 +24,9 @@ if (!function_exists('glm_quicksite_widget_init')) {
 
 }
 
+require_once('lib/menu-walker.php');
+require_once('lib/navigation.php');
+
 /**
  * get_menu_options
  *
@@ -182,7 +185,7 @@ function glm_side_menu() {
     } else {
         $ID = $parent->ID;
     }
-    echo '<h1>'.get_the_title($ID).'</h1>';    
+    echo '<h1>'.get_the_title($ID).'</h1>';
     echo '<ul class="sidebar"><!-- begin -->'."\n";
     echo wp_list_pages( 'child_of='.$ID.'&title_li=&depth=1&echo=0');
     echo '</ul><!-- end -->'."\n";
diff --git a/lib/menu-walker.php b/lib/menu-walker.php
new file mode 100644 (file)
index 0000000..ea3e2be
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Customize the output of menus for Foundation top bar
+ */
+if ( ! class_exists( 'Emmetcounty_Top_Bar_Walker' ) ) :
+class Emmetcounty_Top_Bar_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 ) ? 'has-dropdown' : '';
+               $element->classes[] = ( $element->post_parent == 0 && $element->menu_order > 2 ) ? 'drop-right' : 'drop-left';
+               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 );
+
+               // Insert style to display page's thumbnail
+               $item_style = '';
+               if ($depth == 0 && has_post_thumbnail((int)$object->object_id)) {
+                       $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id((int)$object->object_id));
+                       $item_style .= "<style>#menu-item-".$object->ID." > .dropdown:before { background-image: url('".$thumbnail[0]."');</style>";
+               }
+               //$output .= ( 0 == $depth ) ? '<li class="divider"></li>' : '';
+               $classes = empty( $object->classes ) ? array() : (array) $object->classes;
+               if ( in_array( 'label', $classes ) ) {
+                       //$output .= '<li class="divider"></li>';
+                       $item_html = preg_replace( '/<a[^>]*>(.*)<\/a>/iU', '<label>$1</label>', $item_html );
+               }
+               if ( in_array( 'divider', $classes ) ) {
+                       $item_html = preg_replace( '/<a[^>]*>( .* )<\/a>/iU', '', $item_html );
+               }
+               if ($item_style)
+                       $output .= $item_style;
+               $output .= $item_html;
+       }
+
+       function start_lvl( &$output, $depth = 0, $args = array() ) {
+               $output .= "\n<ul class=\"sub-menu dropdown\">\n";
+       }
+
+}
+endif;
+?>
diff --git a/lib/navigation.php b/lib/navigation.php
new file mode 100644 (file)
index 0000000..46a54b3
--- /dev/null
@@ -0,0 +1,90 @@
+<?php
+
+register_nav_menus(array(
+  'top-bar' => 'Site Navigation',
+  //'mobile-off-canvas' => 'Mobile',
+  //'footer' => 'Footer'
+));
+
+/**
+ * Right top bar
+ */
+if ( ! function_exists( 'emmetcounty_top_bar' ) ) {
+  function emmetcounty_top_bar() {
+      wp_nav_menu(array(
+          'container' => false,                           // remove nav container
+          'container_class' => '',                        // class of container
+          'menu' => '',                                   // menu name
+          'menu_class' => 'top-bar-menu right',           // 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)
+          'walker' => new Emmetcounty_Top_Bar_Walker()
+      ));
+  }
+}
+
+/**
+ * Mobile off-canvas
+ */
+if ( ! function_exists( 'emmetcounty_mobile_off_canvas' ) ) {
+  function emmetcounty_mobile_off_canvas() {
+      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)
+          'walker' => new Emmetcounty_Offcanvas_Walker()
+      ));
+  }
+}
+
+/**
+ * Footer
+ */
+if ( ! function_exists( 'emmetcounty_footer' ) ) {
+  function emmetcounty_footer() {
+      wp_nav_menu(array(
+          'container' => false,                           // remove nav container
+          'container_class' => '',                        // class of container
+          'menu' => '',                                   // menu name
+          'menu_class' => '',                             // adding custom nav class
+          'theme_location' => 'footer',                   // 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' => 1,                                   // limit the depth of the nav
+          'fallback_cb' => false,                         // fallback function (see below)
+          //'walker' => new munisingcvb_Offcanvas_Walker()
+      ));
+  }
+}
+
+/**
+ * Add support for buttons in the top-bar menu:
+ * 1) In WordPress admin, go to Apperance -> Menus.
+ * 2) Click 'Screen Options' from the top panel and enable 'CSS CLasses' and 'Link Relationship (XFN)'
+ * 3) On your menu item, type 'has-form' in the CSS-classes field. Type 'button' in the XFN field
+ * 4) Save Menu. Your menu item will now appear as a button in your top-menu
+*/
+if ( ! function_exists( 'munisingcvb_add_menuclass' ) ) {
+  function munisingcvb_add_menuclass($ulclass) {
+      $find = array('/<a rel="button"/', '/<a title=".*?" rel="button"/');
+      $replace = array('<a rel="button" class="button"', '<a rel="button" class="button"');
+
+      return preg_replace( $find, $replace, $ulclass, 1 );
+  }
+  add_filter( 'wp_nav_menu','munisingcvb_add_menuclass' );
+}
index cfd38b1..c8a96e8 100644 (file)
@@ -3,9 +3,9 @@
 // Nav Menu Dropdown Class
 include_once( 'nav-menu-dropdown.php' );
 
-wp_nav_menu( array(
-       // 'theme_location' => 'mobile',
-       'menu'           => 'frontpage-sidebar',
-       'walker'         => new Walker_Nav_Menu_Dropdown(),
-       'items_wrap'     => '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value"><option value="" selected="selected" disabled="true" selected>-- select a service</option>%3$s</select></form></div>',
-) );
+//wp_nav_menu( array(
+       //// 'theme_location' => 'mobile',
+       //'menu'           => 'frontpage-sidebar',
+       //'walker'         => new Walker_Nav_Menu_Dropdown(),
+       //'items_wrap'     => '<div class="mobile-menu"><form><select onchange="if (this.value) window.location.href=this.value"><option value="" selected="selected" disabled="true" selected>-- select a service</option>%3$s</select></form></div>',
+//) );
index 79c0b38..5bcb7a2 100644 (file)
@@ -15,9 +15,9 @@
         <input type="text" placeholder="Search">
         <a class="magnifying-glass" href="#"> </a>
     </ul>-->
-    <ul class="address" class="show-for-small-down">
+    <ul class="address show-for-small-down">
         <li>Emmet County, Michigan</li>
-        <li>200 Division Street</li> 
+        <li>200 Division Street</li>
         <li>Petoskey, MI 49770</li>
         <li>231-348-1702</li>
         <li><a id="email" href="#">Contact Us</a></li>
index 29b5919..3e1e06a 100644 (file)
@@ -1,5 +1,5 @@
 <form role="search" method="get" id="searchform" action="<?php echo home_url('/'); ?>">
-     <input type="text" placeholder="SEARCH" value="" name="s" id="lar-search">
-     <input class="show-for-large-up" id="search-button" value="" name="searchButton" type="image"></input>
-     <input class="hide-for-large-up" id="search-button" value="Submit" name="searchButton" type="image"></input>
-</form>
\ No newline at end of file
+     <input type="text" placeholder="SEARCH" value="" name="s" id="lar-search" />
+     <input class="show-for-large-up" id="search-button" value="" name="searchButton" type="image" />
+     <input class="hide-for-large-up" id="search-button" value="Submit" name="searchButton" type="image" />
+</form>
index a70b381..333ed97 100644 (file)
@@ -1,6 +1,7 @@
 <?php if (is_front_page()) {
     echo '<div id="slideshow">';
     echo do_shortcode("[metaslider id=50]");
+    echo do_shortcode("[metaslider id=1163]");
     echo '</div>';
 }
 ?>
index 8e2bfb3..aa57210 100644 (file)
@@ -1,6 +1,6 @@
 <nav class="top-bar show-for-large-up" data-topbar role="navigation">
     <section class="top-bar-section">
-        <?php glm_page_menu(); ?>
+        <?php echo emmetcounty_top_bar(); ?>
     </section>
 </nav>
 <nav class="tab-bar show-for-medium-down">