Advertisement
Kyleiwaniec

walker class extend

Mar 16th, 2011
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. class My_Walker_Nav_Menu 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 ) ) );
  13. $class_names = ' class="'. esc_attr( $class_names ) . '"';
  14.  
  15. $output .= $indent . '<li ' . $class_names .'>';
  16.  
  17. $attributes = ! empty( $item->attr_title ) ? ' title="' . esc_attr( $item->attr_title ) .'"' : '';
  18. $attributes .= ! empty( $item->target ) ? ' target="' . esc_attr( $item->target ) .'"' : '';
  19. $attributes .= ! empty( $item->xfn ) ? ' rel="' . esc_attr( $item->xfn ) .'"' : '';
  20. $attributes .= ! empty( $item->url ) ? ' href="' . esc_attr( $item->url ) .'"' : '';
  21.  
  22.  
  23. $item_output = $args->before;
  24. $item_output .= '<a'. $attributes .'>';
  25. $item_output .= $args->link_before .$prepend.apply_filters( 'the_title', $item->title, $item->ID ).$append;
  26. $item_output .= $description.$args->link_after;
  27. $item_output .= '</a>';
  28. $item_output .= $args->after;
  29.  
  30. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args );
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement