Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* custom walker */
- class dropdown_menu_walker extends Walker_Nav_Menu {
- function start_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
- $output .= "\n$indent<div class=\"dropdown-holder\"><div class=\"dropdown-menu\"><ul class=\"children\">\n";
- }
- function end_lvl( &$output, $depth = 0, $args = array() ) {
- $indent = str_repeat("\t", $depth);
- $output .= "$indent</ul></div></div>\n";
- }
- function start_el(&$output, $item, $depth, $args)
- {
- global $wp_query;
- $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
- $class_names = $value = '';
- $classes = empty( $item->classes ) ? array() : (array) $item->classes;
- $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
- $class_names = ' class="'. esc_attr( $class_names ) . '"';
- $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .' count="' . $counter.'">';
- $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
- $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
- $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
- $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
- $attributes .= ! empty( $item->classes ) ? ' class=""' : '';
- // thumbnail image output
- $item_output = ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '<a' . $attributes . ' class="thumb-link">' : '';
- $item_output .= apply_filters( 'menu_item_thumbnail' , ( isset( $args->thumbnail ) && $args->thumbnail ) ? get_the_post_thumbnail( $item->object_id , ( isset( $args->thumbnail_size ) ) ? $args->thumbnail_size : 'sidebar-image-size' , $attr ) : '' , $item , $args , $depth );
- $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '</a>' : '';
- $item_output .= '<a'. $attributes .'>';
- $item_output .= apply_filters( 'the_title', $item->title, $item->ID );
- $item_output .= '</a>';
- // menu description output based on depth
- $item_output .= ( $args->desc_depth >= $depth ) ? '<span class="description">' . $item->description . '</span>' : '';
- $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement