From: Ian Weller Date: Wed, 29 Jul 2015 17:35:35 +0000 (-0400) Subject: nav work X-Git-Tag: v1.0.0^2~275 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=3aba0cebe8aa626604d70a379c524ead1b2eb8d1;p=WP-Themes%2Fmountpleasantwow.git nav work --- diff --git a/functions.php b/functions.php index 8edc962..30033b5 100644 --- a/functions.php +++ b/functions.php @@ -40,6 +40,89 @@ function glm_get_menu_options() return $menu_options; } +register_nav_menus(array( + 'top-bar' => 'Site Navigation', + //'mobile-off-canvas' => 'Mobile', + 'footer' => 'Footer' +)); + +if ( ! function_exists( 'mountpleasantcvb_top_bar' ) ) { + function westerncvb_top_bar() { + 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' => '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' => 3, // limit the depth of the nav + 'fallback_cb' => false, // fallback function (see below) + 'walker' => new Mountpleasantcvb_Top_Bar_Walker() + )); + } +} +if ( ! class_exists( 'Mountpleasantcvb_Top_Bar_Walker' ) ) : +class Mountpleasantcvb_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 > 3 ) ? '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; +if ( ! function_exists( 'mountpleasantcvb_footer' ) ) { + function westerncvb_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) + )); + } +} + /** * glm_page_menu * diff --git a/header.php b/header.php index 9bf46ab..9a61a7e 100644 --- a/header.php +++ b/header.php @@ -30,7 +30,7 @@