milohuang / reverie

Reverie is a versatile HTML5 responsive WordPress framework based on ZURB's Foundation.
http://theakiba.com/reverie/
MIT License
916 stars 196 forks source link

nav_menu_css_class filter #79

Closed Vinsanity closed 11 years ago

Vinsanity commented 12 years ago

add_filter('nav_menu_css_class' , function ($classes, $item){ if($item->current == 1){ //Notice you can change the conditional from is_single() and $item->title $classes[] = "active"; } return $classes; } , 10 , 2);

This function was giving me some trouble today. I was not able to activate or preview this theme unless I commented this out in the functions.php file. Any ideas? Can the function be written in place of the param looking for a function name or does nav_menu_objects only support that?

milohuang commented 12 years ago

Change it to the below and see if it works. We are using the recommended WP API (http://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_css_class).

function reverie_active_nav_class( $classes, $item )
{
    if($item->current == 1)
    {
        $classes[] = 'active';
    }
    return $classes;
}
add_filter( 'nav_menu_css_class', 'reverie_active_nav_class', 10, 2 );
Vinsanity commented 12 years ago

Yes changing it to the standard API for this filter worked. Thanks!

But my original question was in regards the function itself being written into the callback parameter of the add_filter() function. I know that the recommended API allows for an anonymous function to be passed in for the callback but the nav_menu_css_class filter reference API does not show this as an example.

I'm wondering if there is an issue with that filter specifically (more of a question for WP staff I guess)?

Could also just be a quirk in this instance of my WP install (most likely, this is the issue). Too many variables...

Anyway, great framework, thanks for distributing it!