The nav_menu_css_class
filter is located in the start_el
function of WP’s walker class. As you can see in the source, there is no conditional execution here, so once the walker is called, the filter must be applied.
This bring us to wp_nav_menu
, which calls the walker (through some intermediate calls) on the line where it says: $items .= walk_nav_menu_tree( $sorted_menu_items, $args->depth, $args );
. So, if anything prevents the filter to be called, it must happen before this line. Actually there are three possibilities:
-
First you see a filter called
wp_nav_menu_args
. If this is used it could be adding a custom walker that does not call the filter. -
Secondly there is the
pre_wp_nav_menu
filter. If this is used, the rest of the function is short circuited and never reaches the walker. -
Finally, if there are no items in your menu and no fallback is defined the walker will also be skipped. If there is a fallback (possibly added with
wp_nav_menu_args
) this will produce the output in stead of the walker.