weblizar_nav_walker

Nav-menu-walker.php.

Defined (1)

The class is defined in the following location(s).

/core/menu/weblizar_nav_walker.php  
  1. class weblizar_nav_walker extends Walker_Nav_Menu {  
  2. function start_lvl( &$output, $depth = 0, $args = array() ) { 
  3. $indent = str_repeat("\t", $depth); 
  4. $output .= "\n$indent<ul class=\"dropdown-menu\">\n"; 
  5. function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { 
  6. $indent = ( $depth ) ? str_repeat( "\t", $depth ) : ''; 
  7.  
  8. $class_names = $value = ''; 
  9.  
  10. $classes = empty( $item->classes ) ? array() : (array) $item->classes; 
  11. $classes[] = 'menu-item-' . $item->ID; 
  12. if ($args->has_children && $depth > 0) { 
  13. $classes[] = 'dropdown-submenu'; 
  14. } else if($args->has_children && $depth === 0) { 
  15. $classes[] = 'dropdown'; 
  16. $class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) ); 
  17. $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : ''; 
  18.  
  19. $id = apply_filters( 'nav_menu_item_id', 'menu-item-'. $item->ID, $item, $args ); 
  20. $id = $id ? ' id="' . esc_attr( $id ) . '"' : ''; 
  21.  
  22. $output .= $indent . '<li' . $id . $value . $class_names .'>'; 
  23.  
  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 .= ($args->has_children) ? ' data-toggle="dropdown" data-target="#" class="dropdown-toggle"' : ''; 
  29.  
  30. $item_output = $args->before; 
  31. $item_output .= '<a'. $attributes .'>'; 
  32. $item_output .= $args->link_before . apply_filters( 'the_title', $item->title, $item->ID ) . $args->link_after; 
  33. $item_output .= ($args->has_children) ? '<i class="fa fa-angle-down"></i></a>' : '</a>'; 
  34. $item_output .= $args->after; 
  35.  
  36. $output .= apply_filters( 'walker_nav_menu_start_el', $item_output, $item, $depth, $args ); 
  37. function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { 
  38.  
  39. if ( !$element ) 
  40. return; 
  41.  
  42. $id_field = $this->db_fields['id']; 
  43.  
  44. //display this element 
  45. if ( is_array( $args[0] ) ) 
  46. $args[0]['has_children'] = ! empty( $children_elements[$element->$id_field] ); 
  47. else if ( is_object( $args[0] ) )  
  48. $args[0]->has_children = ! empty( $children_elements[$element->$id_field] );  
  49. $cb_args = array_merge( array(&$output, $element, $depth), $args); 
  50. call_user_func_array(array($this, 'start_el'), $cb_args); 
  51.  
  52. $id = $element->$id_field; 
  53.  
  54. // descend only when the depth is right and there are childrens for this element 
  55. if ( ($max_depth == 0 || $max_depth > $depth+1 ) && isset( $children_elements[$id]) ) { 
  56.  
  57. foreach( $children_elements[ $id ] as $child ) { 
  58.  
  59. if ( !isset($newlevel) ) { 
  60. $newlevel = true; 
  61. //start the child delimiter 
  62. $cb_args = array_merge( array(&$output, $depth), $args); 
  63. call_user_func_array(array($this, 'start_lvl'), $cb_args); 
  64. $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); 
  65. unset( $children_elements[ $id ] ); 
  66.  
  67. if ( isset($newlevel) && $newlevel ) { 
  68. //end the child delimiter 
  69. $cb_args = array_merge( array(&$output, $depth), $args); 
  70. call_user_func_array(array($this, 'end_lvl'), $cb_args); 
  71.  
  72. //end this element 
  73. $cb_args = array_merge( array(&$output, $element, $depth), $args); 
  74. call_user_func_array(array($this, 'end_el'), $cb_args);