From: Steve Sutton Date: Tue, 16 Jun 2015 20:59:09 +0000 (-0400) Subject: Working on custom menu X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ac018a0782c1cf7cc99aac2646913e1c7f93e4ac;p=WP-Themes%2Fglmthemes%2Fcrawfordcounty-theme.git Working on custom menu --- diff --git a/footer.php b/footer.php index 9854adc..aaeb034 100644 --- a/footer.php +++ b/footer.php @@ -20,8 +20,8 @@ --> - + - - + - \ No newline at end of file + + diff --git a/functions.php b/functions.php index be6fff7..40464cd 100644 --- a/functions.php +++ b/functions.php @@ -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 '

'.get_the_title($ID).'

'; + echo '

'.get_the_title($ID).'

'; echo ''."\n"; diff --git a/lib/menu-walker.php b/lib/menu-walker.php new file mode 100644 index 0000000..ea3e2be --- /dev/null +++ b/lib/menu-walker.php @@ -0,0 +1,46 @@ +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 .= ""; + } + //$output .= ( 0 == $depth ) ? '
  • ' : ''; + $classes = empty( $object->classes ) ? array() : (array) $object->classes; + if ( in_array( 'label', $classes ) ) { + //$output .= '
  • '; + $item_html = preg_replace( '/]*>(.*)<\/a>/iU', '', $item_html ); + } + if ( in_array( 'divider', $classes ) ) { + $item_html = preg_replace( '/]*>( .* )<\/a>/iU', '', $item_html ); + } + if ($item_style) + $output .= $item_style; + $output .= $item_html; + } + + function start_lvl( &$output, $depth = 0, $args = array() ) { + $output .= "\n
      \n"; + } + +} +endif; +?> diff --git a/lib/navigation.php b/lib/navigation.php new file mode 100644 index 0000000..46a54b3 --- /dev/null +++ b/lib/navigation.php @@ -0,0 +1,90 @@ + '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 + 'after' => '', // after each link + '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 + 'after' => '', // after each link + '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 + 'after' => '', // after each link + '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('/ 'mobile', - 'menu' => 'frontpage-sidebar', - 'walker' => new Walker_Nav_Menu_Dropdown(), - 'items_wrap' => '
      ', -) ); +//wp_nav_menu( array( + //// 'theme_location' => 'mobile', + //'menu' => 'frontpage-sidebar', + //'walker' => new Walker_Nav_Menu_Dropdown(), + //'items_wrap' => '
      ', +//) ); diff --git a/parts/off-canvas-menu.php b/parts/off-canvas-menu.php index 79c0b38..5bcb7a2 100644 --- a/parts/off-canvas-menu.php +++ b/parts/off-canvas-menu.php @@ -15,9 +15,9 @@
    --> -
      +
      • Emmet County, Michigan
      • -
      • 200 Division Street
      • +
      • 200 Division Street
      • Petoskey, MI 49770
      • 231-348-1702
      • Contact Us
      • diff --git a/parts/search.php b/parts/search.php index 29b5919..3e1e06a 100644 --- a/parts/search.php +++ b/parts/search.php @@ -1,5 +1,5 @@ \ No newline at end of file + + + + diff --git a/parts/slide-show.php b/parts/slide-show.php index a70b381..333ed97 100644 --- a/parts/slide-show.php +++ b/parts/slide-show.php @@ -1,6 +1,7 @@ '; echo do_shortcode("[metaslider id=50]"); + echo do_shortcode("[metaslider id=1163]"); echo ''; } ?> diff --git a/parts/top-bar.php b/parts/top-bar.php index 8e2bfb3..aa57210 100644 --- a/parts/top-bar.php +++ b/parts/top-bar.php @@ -1,6 +1,6 @@