From: Anthony Talarico Date: Fri, 30 Oct 2015 15:35:39 +0000 (-0400) Subject: Added off canvas mobile menu and menu walker X-Git-Tag: v1.0.0^2~74 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=db9d4c553bdcf7701761226168808c5878a76a63;p=WP-Themes%2Fbpla.git Added off canvas mobile menu and menu walker --- diff --git a/functions.php b/functions.php index 7ef15bd..891c1f5 100644 --- a/functions.php +++ b/functions.php @@ -45,7 +45,63 @@ function glm_get_menu_options() } return $menu_options; } +if ( ! function_exists( 'bpla_mobile_off_canvas' ) ) { + function bpla_mobile_off_canvas() { + echo ''; + } +} +if ( ! class_exists( 'Bpla_Offcanvas_Walker' ) ) : +class Bpla_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 *