evolve_Walker_Nav_Menu

Evolve_Walker_Nav_Menu.

Defined (1)

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

/library/functions/basic-functions.php  
  1. class evolve_Walker_Nav_Menu extends Walker_Nav_Menu { 
  2. /** 
  3. * @see Walker::start_lvl() 
  4. * @since 3.0.0 
  5. * @param string $output Passed by reference. Used to append additional content. 
  6. * @param int $depth Depth of page. Used for padding. 
  7. */ 
  8.  
  9. /** 
  10. * @see Walker::start_el() 
  11. * @since 3.0.0 
  12. * @param string $output Passed by reference. Used to append additional content. 
  13. * @param object $item Menu item data object. 
  14. * @param int $depth Depth of menu item. Used for padding. 
  15. * @param int $current_page Menu item ID. 
  16. * @param object $args 
  17. */ 
  18. public function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { 
  19. $indent = ( $depth ) ? str_repeat("\t", $depth) : ''; 
  20.  
  21. /** 
  22. * Dividers, Headers or Disabled 
  23. * ============================= 
  24. * Determine whether the item is a Divider, Header, Disabled or regular 
  25. * menu item. To prevent errors we use the strcasecmp() function to so a 
  26. * comparison that is not case sensitive. The strcasecmp() function returns 
  27. * a 0 if the strings are equal. 
  28. */ 
  29. $class_names = $value = ''; 
  30.  
  31. $classes = empty($item->classes) ? array() : (array) $item->classes; 
  32. $classes[] = 'menu-item-' . $item->ID; 
  33.  
  34. $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item, $args)); 
  35.  
  36. if ($args->has_children) { 
  37. $class_names .= ' dropdown'; 
  38.  
  39. if (in_array('current-menu-item', $classes)) { 
  40. $class_names .= ' active'; 
  41.  
  42. $class_names = $class_names ? ' class="' . esc_attr($class_names) . '"' : ''; 
  43.  
  44. $id = apply_filters('nav_menu_item_id', 'menu-item-' . $item->ID, $item, $args); 
  45. $id = $id ? ' id="' . esc_attr($id) . '"' : ''; 
  46.  
  47. $output .= $indent . '<li' . $id . $value . $class_names . '>'; 
  48.  
  49. /** 
  50. * PolyLang Broken Flag Images - Fix 
  51. * ================================= 
  52. * @by jerry 
  53. * @since 3.2.0 
  54. * @todo find better solution 
  55. */ 
  56. $item->title_2 = $item->title; // Let's take flag image 
  57. if (class_exists('Polylang')) { 
  58. if (preg_match('/<img src=/', $item->title)) { 
  59. $item->title = strip_tags($item->title); // Let's remove flag image 
  60.  
  61. $atts = array(); 
  62. $atts['title'] = !empty($item->title) ? $item->title : ''; 
  63. $atts['target'] = !empty($item->target) ? $item->target : ''; 
  64. $atts['rel'] = !empty($item->xfn) ? $item->xfn : ''; 
  65. $atts['href'] = !empty($item->url) ? $item->url : ''; 
  66.  
  67.  
  68. $atts = apply_filters('nav_menu_link_attributes', $atts, $item, $args); 
  69.  
  70. $attributes = ''; 
  71. foreach ($atts as $attr => $value) { 
  72. if (!empty($value)) { 
  73. $value = ( 'href' === $attr ) ? esc_url($value) : esc_attr($value); 
  74. $attributes .= ' ' . $attr . '="' . $value . '"'; 
  75.  
  76. $item_output = $args->before; 
  77.  
  78. /** 
  79. * Glyphicons 
  80. * =========== 
  81. * Since the the menu item is NOT a Divider or Header we check the see 
  82. * if there is a value in the attr_title property. If the attr_title 
  83. * property is NOT null we apply it as the class name for the glyphicon. 
  84. */ 
  85. if (evolve_get_option('evl_main_menu_hover_effect', 'rollover') == 'disable') { 
  86. $item_output .= '<a' . $attributes . '>'; 
  87. } else { 
  88. $item_output .= '<a' . $attributes . '><span data-hover="' . $item->title . '">'; 
  89.  
  90. $item_output .= $args->link_before . apply_filters('the_title', $item->title_2, $item->ID) . $args->link_after; 
  91. $item_output .= ( $args->has_children && 0 === $depth ) ? ' <span class="arrow"></span>' : ''; 
  92. if (evolve_get_option('evl_main_menu_hover_effect', 'rollover') == 'disable') { 
  93. $item_output .= '</a>'; 
  94. } else { 
  95. $item_output .= '</span></a>'; 
  96. $item_output .= $args->after; 
  97.  
  98. $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args); 
  99.  
  100. /** 
  101. * Traverse elements to create list from elements. 
  102. * Display one element if the element doesn't have any children otherwise,  
  103. * display the element and its children. Will only traverse up to the max 
  104. * depth and no ignore elements under that depth. 
  105. * This method shouldn't be called directly, use the walk() method instead. 
  106. * @see Walker::start_el() 
  107. * @since 2.5.0 
  108. * @param object $element Data object 
  109. * @param array $children_elements List of elements to continue traversing. 
  110. * @param int $max_depth Max depth to traverse. 
  111. * @param int $depth Depth of current element. 
  112. * @param array $args 
  113. * @param string $output Passed by reference. Used to append additional content. 
  114. * @return null Null on failure with no changes to parameters. 
  115. */ 
  116. public function display_element($element, &$children_elements, $max_depth, $depth, $args, &$output) { 
  117. if (!$element) { 
  118. return; 
  119.  
  120. $id_field = $this->db_fields['id']; 
  121.  
  122. // Display this element. 
  123. if (is_object($args[0])) { 
  124. $args[0]->has_children = !empty($children_elements[$element->$id_field]); 
  125.  
  126. parent::display_element($element, $children_elements, $max_depth, $depth, $args, $output); 
  127.