From: Steve Sutton Date: Tue, 10 Nov 2015 20:20:04 +0000 (-0500) Subject: Update off canvas menu X-Git-Tag: v1.0.0^2~21 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=f23a8731fae1ef95e8caf3eaac28a30eba8b87c0;p=WP-Themes%2Fbpla.git Update off canvas menu Use menu walker from mountpleasant --- diff --git a/functions.php b/functions.php index 6c31ae8..ee5d363 100644 --- a/functions.php +++ b/functions.php @@ -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 '
'; + } +} +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>/iU', '', $item_html ); + } + + $output .= $item_html; + } + + function start_lvl( &$output, $depth = 0, $args = array() ) { + $output .= "\n'; + } +} +endif; add_theme_support('post-thumbnails'); set_post_thumbnail_size(120, 100, true); /** diff --git a/parts/off-canvas-menu.php b/parts/off-canvas-menu.php index ef96b80..975dbcd 100644 --- a/parts/off-canvas-menu.php +++ b/parts/off-canvas-menu.php @@ -1,5 +1,5 @@ \ No newline at end of file +