I came across this thread trying to solve the same problem - this is what I've come up with. I don't know how well this performs, since it'll be called for every single menu item, but it seems menus are set up as taxonomies inside WordPress, and so you can use has_term()
to determine if the item is in a particular menu, and get_nav_menu_locations()
to pull back the list of which menus are in which theme location.
Modifying your code:
add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2);
function special_nav_class($classes, $item){
$menu_locations = get_nav_menu_locations();
if ( has_term($menu_locations['primary-menu'], 'nav_menu', $item) ) {
$classes[] = 'btn';
}
return $classes;
}