Instantly share code, notes, and snippets.
-
Star
0
(0)
You must be signed in to star a gist -
Fork
0
(0)
You must be signed in to fork a gist
-
-
Save vladfil/f71edbc2bb5b0efb533fbd734ae409af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Description_Walker extends Walker_Nav_Menu { | |
| function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { | |
| $classes = empty($item->classes) ? array () : (array) $item->classes; | |
| $class_names = join(' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); | |
| !empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . ' nav-link w-nav-link"'; | |
| $output .= ""; | |
| $attributes = ''; | |
| !empty( $item->attr_title ) and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"'; | |
| !empty( $item->target ) and $attributes .= ' target="' . esc_attr( $item->target ) .'"'; | |
| !empty( $item->xfn ) and $attributes .= ' rel="' . esc_attr( $item->xfn ) .'"'; | |
| !empty( $item->url ) and $attributes .= ' href="' . esc_attr( $item->url ) .'"'; | |
| // var_dump($class_names); | |
| if ( stripos( $class_names, 'menu-item-has-children' ) ) { | |
| if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { | |
| $t = ''; | |
| $n = ''; | |
| } else { | |
| $t = "\t"; | |
| $n = "\n"; | |
| } | |
| $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; | |
| $classes = empty( $item->classes ) ? array() : (array) $item->classes; | |
| $classes[] = 'menu-item-' . $item->ID; | |
| $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); | |
| $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); | |
| $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; | |
| $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); | |
| $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; | |
| // создаем HTML код элемента меню | |
| $class_names = "class='menu-item-has-children dropdown w-dropdown'"; | |
| $output .= $indent . '<div data-delay="250" data-hover="1" ' . $id . $class_names .'>'; | |
| $atts = array(); | |
| $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; | |
| $atts['target'] = ! empty( $item->target ) ? $item->target : ''; | |
| $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; | |
| $atts['href'] = ! empty( $item->url ) ? $item->url : ''; | |
| $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); | |
| $attributes = ''; | |
| foreach ( $atts as $attr => $value ) { | |
| if ( ! empty( $value ) ) { | |
| $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); | |
| $attributes .= ' ' . $attr . '="' . $value . '"'; | |
| } | |
| } | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); | |
| $item_output = $args->before; | |
| $item_output .= '<div class="dropdown-toggle w-dropdown-toggle">'; | |
| $item_output .= '<div class="dropdown-arrow w-icon-dropdown-toggle"></div>'; | |
| $item_output .= '<div class="nav-link-dropdown">'; | |
| $item_output .= $args->link_before . $title . $args->link_after; | |
| $item_output .= '</div>'; | |
| $item_output .= '</div>'; | |
| $item_output .= $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); | |
| /*// $class_names = ''; | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| // echo $item->title; | |
| str_replace('menu-item-has-children', 'menu-item-has-children dropdown w-dropdown', $class_names); | |
| $class_names = "class='menu-item-has-children dropdown w-dropdown'"; | |
| // var_dump($class_names); | |
| // var_dump($class_names); | |
| $item_output = $args->before | |
| . "<div data-delay='250' data-hover='1' $class_names>" | |
| . "<div class='dropdown-toggle w-dropdown-toggle'>" | |
| . "<div class='dropdown-arrow w-icon-dropdown-toggle'></div>" | |
| . "<div class='nav-link-dropdown'>" | |
| . $args->link_before | |
| . $title | |
| . '</div>' | |
| . '</div>' | |
| . '</div>' | |
| . $args->link_after | |
| . $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );*/ | |
| } else { | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| // echo $item->title; | |
| $item_output = $args->before | |
| . "<a $attributes $class_names>" | |
| . $args->link_before | |
| . $title | |
| . '</a>' | |
| . $args->link_after | |
| . $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); | |
| } | |
| } | |
| function start_lvl( &$output, $depth = 0, $args = array() ) { | |
| $indent = str_repeat("\t", $depth); | |
| $output .= "\n$indent<nav class='drop-down-list w-dropdown-list sub-menu'>\n"; | |
| } | |
| function end_lvl( &$output, $depth = 0, $args = array() ) { | |
| $indent = str_repeat("\t", $depth); | |
| $output .= "$indent</nav>\n"; | |
| } | |
| } | |
| // Primary menu | |
| class Description_Walker extends Walker_Nav_Menu { | |
| function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { | |
| $classes = empty($item->classes) ? array () : (array) $item->classes; | |
| $class_names = join(' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) ); | |
| if ( stripos( $class_names, 'menu-item-has-children' ) ) { | |
| !empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . ' dropdown-link nav-link w-dropdown-link"'; | |
| } else { | |
| !empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . ' nav-link w-nav-link"'; | |
| } | |
| //empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . ' nav-link w-nav-link"'; | |
| $output .= ""; | |
| $attributes = ''; | |
| !empty( $item->attr_title ) and $attributes .= ' title="' . esc_attr( $item->attr_title ) .'"'; | |
| !empty( $item->target ) and $attributes .= ' target="' . esc_attr( $item->target ) .'"'; | |
| !empty( $item->xfn ) and $attributes .= ' rel="' . esc_attr( $item->xfn ) .'"'; | |
| !empty( $item->url ) and $attributes .= ' href="' . esc_attr( $item->url ) .'"'; | |
| // var_dump($class_names); | |
| if ( stripos( $class_names, 'menu-item-has-children' ) ) { | |
| !empty ( $class_names ) and $class_names = ' class="'. esc_attr( $class_names ) . ' dropdown-link nav-link w-dropdown-link"'; | |
| if ( isset( $args->item_spacing ) && 'discard' === $args->item_spacing ) { | |
| $t = ''; | |
| $n = ''; | |
| } else { | |
| $t = "\t"; | |
| $n = "\n"; | |
| } | |
| $indent = ( $depth ) ? str_repeat( $t, $depth ) : ''; | |
| $classes = empty( $item->classes ) ? array() : (array) $item->classes; | |
| $classes[] = 'menu-item-' . $item->ID; | |
| $args = apply_filters( 'nav_menu_item_args', $args, $item, $depth ); | |
| $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args, $depth ) ); | |
| $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; | |
| $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args, $depth ); | |
| $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; | |
| // создаем HTML код элемента меню | |
| $class_names = "class='menu-item-has-children dropdown w-dropdown'"; | |
| $output .= $indent . '<div data-delay="250" data-hover="1" ' . $id . $class_names .'>'; | |
| $atts = array(); | |
| $atts['title'] = ! empty( $item->attr_title ) ? $item->attr_title : ''; | |
| $atts['target'] = ! empty( $item->target ) ? $item->target : ''; | |
| $atts['rel'] = ! empty( $item->xfn ) ? $item->xfn : ''; | |
| $atts['href'] = ! empty( $item->url ) ? $item->url : ''; | |
| $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth ); | |
| $attributes = ''; | |
| foreach ( $atts as $attr => $value ) { | |
| if ( ! empty( $value ) ) { | |
| $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); | |
| $attributes .= ' ' . $attr . '="' . $value . '"'; | |
| } | |
| } | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| $title = apply_filters( 'nav_menu_item_title', $title, $item, $args, $depth ); | |
| $item_output = $args->before; | |
| $item_output .= '<div class="dropdown-toggle w-dropdown-toggle">'; | |
| $item_output .= '<div class="dropdown-arrow w-icon-dropdown-toggle"></div>'; | |
| $item_output .= '<div class="nav-link-dropdown">'; | |
| $item_output .= $args->link_before . $title . $args->link_after; | |
| $item_output .= '</div>'; | |
| $item_output .= '</div>'; | |
| $item_output .= $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); | |
| /*// $class_names = ''; | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| // echo $item->title; | |
| str_replace('menu-item-has-children', 'menu-item-has-children dropdown w-dropdown', $class_names); | |
| $class_names = "class='menu-item-has-children dropdown w-dropdown'"; | |
| // var_dump($class_names); | |
| // var_dump($class_names); | |
| $item_output = $args->before | |
| . "<div data-delay='250' data-hover='1' $class_names>" | |
| . "<div class='dropdown-toggle w-dropdown-toggle'>" | |
| . "<div class='dropdown-arrow w-icon-dropdown-toggle'></div>" | |
| . "<div class='nav-link-dropdown'>" | |
| . $args->link_before | |
| . $title | |
| . '</div>' | |
| . '</div>' | |
| . '</div>' | |
| . $args->link_after | |
| . $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );*/ | |
| } else { | |
| $title = apply_filters( 'the_title', $item->title, $item->ID ); | |
| // echo $item->title; | |
| $item_output = $args->before | |
| . "<a $attributes $class_names>" | |
| . $args->link_before | |
| . $title | |
| . '</a>' | |
| . $args->link_after | |
| . $args->after; | |
| $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); | |
| } | |
| } | |
| function start_lvl( &$output, $depth = 0, $args = array() ) { | |
| $indent = str_repeat("\t", $depth); | |
| $output .= "\n$indent<nav class='drop-down-list w-dropdown-list sub-menu'>\n"; | |
| } | |
| function end_lvl( &$output, $depth = 0, $args = array() ) { | |
| $indent = str_repeat("\t", $depth); | |
| $output .= "$indent</nav>\n"; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment