Advertisement
Guest User

walker

a guest
Jun 26th, 2012
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.89 KB | None | 0 0
  1. class lavalamp_walker extends Walker_Nav_Menu
  2. {
  3.       function start_el(&$output, $item, $depth, $args)
  4.       {
  5.            global $wp_query;
  6.            $indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
  7.  
  8.            $class_names = $value = '';
  9.  
  10.            $classes = empty( $item->classes ) ? array() : (array) $item->classes;
  11.  
  12.            $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item ) );
  13.  
  14.            if (this.is_home()){ $class_names = ' class="current"';}
  15.            else { $class_names = ' class="'. esc_attr( $class_names ) . '"'; }
  16.            $output .= $indent . '<li id="menu-item-'. $item->ID . '"' . $value . $class_names .'>';
  17.  
  18.            $attributes  = ! empty( $item->attr_title ) ? ' title="'  . esc_attr( $item->attr_title ) .'"' : '';
  19.            $attributes .= ! empty( $item->target )     ? ' target="' . esc_attr( $item->target     ) .'"' : '';
  20.            $attributes .= ! empty( $item->xfn )        ? ' rel="'    . esc_attr( $item->xfn        ) .'"' : '';
  21.            $attributes .= ! empty( $item->url )        ? ' href="'   . esc_attr( $item->url        ) .'"' : '';
  22.  
  23.            $prepend = '<strong>';
  24.            $append = '</strong>';
  25.            $description  = ! empty( $item->description ) ? '<span>'.esc_attr( $item->description ).'</span>' : '';
  26.  
  27.            if($depth != 0)
  28.            {
  29.                      $description = $append = $prepend = "";
  30.            }
  31.  
  32.             $item_output = $args->before;
  33.             $item_output .= '<a'. $attributes .'>';
  34.             $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
  35.             $item_output .= $description.$args->link_after;
  36.             $item_output .= '</a>';
  37.             $item_output .= $args->after;
  38.  
  39.             $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  40.             }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement