Advertisement
Guest User

Untitled

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