Bootstrap_Nav_Walker

Bootstrap custom meny settings for downdrop support.

Defined (1)

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

/functions.php  
  1. class Bootstrap_Nav_Walker extends Walker_Nav_Menu { 
  2. function check_current($val) { 
  3. return preg_match('/(current-)/', $val); 
  4.  
  5. function start_el(&$output, $item, $depth, $args) { 
  6. global $wp_query; 
  7. $indent = ($depth) ? str_repeat("\t", $depth) : ''; 
  8.  
  9. $slug = sanitize_title($item->title); 
  10. $id = apply_filters('nav_menu_item_id', 'menu-' . $slug, $item, $args); 
  11. $id = strlen($id) ? '' . esc_attr( $id ) . '' : ''; 
  12.  
  13. $class_names = $value = ''; 
  14. $classes = empty($item->classes) ? array() : (array) $item->classes; 
  15.  
  16. $classes = array_filter($classes, array(&$this, 'check_current')); 
  17.  
  18. $class_names = join(' ', apply_filters('nav_menu_css_class', array_filter($classes), $item)); 
  19. $class_names = $class_names ? ' class="' . $id . ' ' . esc_attr($class_names) . '"' : ' class="' . $id . '"'; 
  20.  
  21. $output .= $indent . '<li' . $class_names . '>'; 
  22.  
  23. $attributes = ! empty($item->attr_title) ? ' title="' . esc_attr($item->attr_title) .'"' : ''; 
  24. $attributes .= ! empty($item->target) ? ' target="' . esc_attr($item->target ) .'"' : ''; 
  25. $attributes .= ! empty($item->xfn) ? ' rel="' . esc_attr($item->xfn ) .'"' : ''; 
  26. $attributes .= ! empty($item->url) ? ' href="' . esc_attr($item->url ) .'"' : ''; 
  27.  
  28. $item_output = $args->before; 
  29. $item_output .= '<a'. $attributes .'>'; 
  30. $item_output .= $args->link_before . apply_filters('the_title', $item->title, $item->ID) . $args->link_after; 
  31. $item_output .= '</a>'; 
  32. $item_output .= $args->after; 
  33.  
  34. $output .= apply_filters('walker_nav_menu_start_el', $item_output, $item, $depth, $args);