From 0e17fdfb1993c9bc95fc550940d299d58614bada Mon Sep 17 00:00:00 2001 From: Anthony Talarico Date: Thu, 22 Oct 2015 09:37:19 -0400 Subject: [PATCH] Changed functions.php and off-canvas-menu.php to remove extra off canvas items --- functions.php | 59 +++++++++++++++++++++++++++++++++++++++ parts/off-canvas-menu.php | 2 +- 2 files changed, 60 insertions(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 3e98721..91f42f4 100644 --- a/functions.php +++ b/functions.php @@ -109,7 +109,66 @@ class Shipwreck_Top_Bar_Walker extends Walker_Nav_Menu { } endif; +/** + * Mobile off-canvas + */ +if ( ! function_exists( 'shipwreck_mobile_off_canvas' ) ) { + function shipwreck_mobile_off_canvas() { + echo ''; + } +} +if ( ! class_exists( 'Shipwreck_Offcanvas_Walker' ) ) : +class Shipwreck_Offcanvas_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; /** * glm_page_menu * diff --git a/parts/off-canvas-menu.php b/parts/off-canvas-menu.php index 4954056..aa074e1 100644 --- a/parts/off-canvas-menu.php +++ b/parts/off-canvas-menu.php @@ -1,5 +1,5 @@