Add Active Classes on User Defined Menu

functions.php

/*////////////////////////////////////////////////
 //
 //	Nav menu active class
 //
 ////////////////////////////////////////////////*/

function mark_menu_item_as_active($classes, $item) {
    if(in_array('menu-item-27', $classes) && (has_term('pre-sale', 'guide_category'))){
        $classes[] = 'active-class';
    }
    if(in_array('menu-item-28', $classes) && (has_term('sales', 'guide_category'))){
        $classes[] = 'active-class';
    }
    if(in_array('menu-item-29', $classes) && (has_term('discovery', 'guide_category'))){
        $classes[] = 'active-class';
    }
    if(in_array('menu-item-30', $classes) && (has_term('dev', 'guide_category'))){
        $classes[] = 'active-class';
    }
    if(in_array('menu-item-31', $classes) && (has_term('post-dev', 'guide_category'))){
        $classes[] = 'active-class';
    }
    return $classes;
}
add_filter('nav_menu_css_class', 'mark_menu_item_as_active', 10, 2);