Skip to content

Instantly share code, notes, and snippets.

@viruthagiri
Created February 3, 2012 22:49
Show Gist options
  • Save viruthagiri/1733478 to your computer and use it in GitHub Desktop.
Save viruthagiri/1733478 to your computer and use it in GitHub Desktop.
<?php
class My_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl(&$output, $depth) {
$indent = str_repeat("\t", $depth);
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
}
function start_el( &$output, $item, $depth, $args ) {
if ( $args->has_children ) {
// ...
}
}
}
add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1);
add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1);
function my_css_attributes_filter($var) {
if(is_array($var)){
$varci= array_intersect($var, array('current-menu-item'));
$cmeni = array('current-menu-item');
$selava = array('active');
$selavaend = array();
$selavaend = str_replace($cmeni, $selava, $varci);
}
else{
$selavaend= '';
}
return $selavaend;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment