Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.57 KB | None | 0 0
  1. /* custom walker */
  2.  
  3.  
  4. class dropdown_menu_walker extends Walker_Nav_Menu {
  5.     function start_lvl( &$output, $depth = 0, $args = array() ) {
  6.             $indent = str_repeat("\t", $depth);
  7.             $output .= "\n$indent<div class=\"dropdown-holder\"><div class=\"dropdown-menu\"><ul class=\"children\">\n";
  8.     }
  9.  
  10.     function end_lvl( &$output, $depth = 0, $args = array() ) {
  11.             $indent = str_repeat("\t", $depth);
  12.             $output .= "$indent</ul></div></div>\n";
  13.     }
  14.  
  15.   function start_el(&$output, $item, $depth, $args)
  16.   {
  17.        global $wp_query;
  18.        $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  19.        $class_names = $value = '';
  20.        $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  21.        $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  22.        $class_names = ' class="'. esc_attr( $class_names ) . '"';
  23.         $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .' count="' . $counter.'">';
  24.         $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
  25.         $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
  26.         $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
  27.         $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
  28.         $attributes .= ! empty( $item->classes )    ? ' class=""' : '';
  29.        
  30.        
  31.    
  32.         // thumbnail image output
  33.         $item_output = ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '<a' . $attributes . ' class="thumb-link">' : '';
  34.         $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 );     
  35.         $item_output .= ( isset( $args->thumbnail_link ) && $args->thumbnail_link ) ? '</a>' : '';
  36.        
  37.         $item_output .= '<a'. $attributes .'>';
  38.         $item_output .= apply_filters( 'the_title', $item->title, $item->ID );
  39.         $item_output .= '</a>';
  40.         // menu description output based on depth
  41.         $item_output .= ( $args->desc_depth >= $depth ) ? '<span class="description">' . $item->description . '</span>' : '';
  42.        
  43.        
  44.         $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );      
  45.   }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement