Example
Nav menu walker – allows adding eg. css classes to (all) menu items.
// copyied from /wp-core/wp-includes/nav-menu-template.php > line 76 (wp 3.1.1) - start_el() function
$class_names = join( ' ', apply_filters( 'nav_menu_css_class', array_filter( $classes ), $item, $args ) );
Now let’s check the $var:
function wpse15319_check_nav_menu_classes( $classes )
{
// You can take any of the $vars from the core function above: $classes, $item, $args
echo '<pre>';
// nice list:
print_r( $classes );
// or check of what type the $var is
var_dump( $classes );
echo '</pre>';
return $classes;
}
add_filter( 'nav_menu_css_class', 'wpse15319_check_nav_menu_classes', 10 );
Modify – Applied example
function wpse15319_add_nav_menu_classes( $classes )
{
$classes[] = '';
$classes[] .= 'my added css classes';
return $classes;
}
add_filter( 'nav_menu_css_class', 'wpse15319_add_nav_menu_classes', 10 );