function buatp_directory_search_text($text)
{
    global $bp;
    if (!bp_is_buatp_component()) {
        return $text;
    }
    return 'Search ' . $bp->current_action . '...';
}
function buatp_template()
{
    if (!bp_is_buatp_component()) {
        return;
    }
    global $bp;
    $buatp_general_settings = get_option('buatp_basic_setting', true);
    $slug = $bp->current_action;
    $types = buatp_get_all_types(buatp_get_field_id_by_name($buatp_general_settings['buatp_type_field_selection']));
    $found = 0;
    foreach ($types as $type) {
        $type_slug = $buatp_general_settings['buatp_slug_selection_for_' . $type['id']];
        if ($slug == $type_slug) {
            $found = 1;
            $bp->buatp->directory_id = $type['id'];
        }
    }
    return $found;
}
function buatp_directory_setup()
{
    $buatp_general_settings = get_option('buatp_basic_setting', true);
    global $bp;
    if (bp_is_buatp_component() && !$bp->current_action) {
        if ($buatp_general_settings['buatp_default_type_selection']) {
            bp_core_redirect(buatp_get_type_directory_url($buatp_general_settings['buatp_default_type_selection']));
        } else {
            bp_core_redirect(site_url());
        }
    } else {
        if (bp_is_buatp_component() && $bp->current_action) {
            if ($bp->buatp->directory_id) {
                do_action('buatp_directory_setup');
                bp_core_load_template(apply_filters('buatp_directory_template', 'members/members-loop'));
            } else {
                bp_core_redirect(site_url());
            }
        }
    }
}
function buatp_current_page_type()
{
    global $bp;
    if (!bp_is_buatp_component() || !$bp->current_action) {
        return;
    }
    $type_id = $bp->buatp->directory_id;
    return buatp_get_field_name_by_id($type_id);
}