I'm trying to track down why menu switching by language in the polylang filter is not working correctly.
I'm looking at the function nav_menu_locations which is added as a filter as such:
add_filter('theme_mod_nav_menu_locations', array($this, 'nav_menu_locations'), 20);
and then defined subsequently as:
public function nav_menu_locations($menus) {
...
return $menus;
}
I inserted statements to echo $menus at the start and just before the altered value is returned, and can confirm that the function is being called.
But the curious thing is that searching the entire plug-in code–and then the entire WordPress core–I can find no matching apply_filters for theme_mod_nav_menu_locations, and no direct calls to the function either as far as I can tell. So I can't see where the $menus parameter is being generated.
I thought I understood how filter hooks work, and yet can't see how the function nav_menu_locations is being run, although it clearly is.
It might not help me solve the problems with my menu switching, but I'd at least like to clarify how the filter is being triggered.