/**
 * Possibly intercept the template being loaded.
 *
 * Listens to the 'template_include' filter and waits for any BuddyPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise.
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since 1.7.0
 *
 * @param string $template
 *
 * @return string The path to the template file that is being used.
 */
function bp_template_include_theme_supports($template = '')
{
    /**
     * Filters whether or not to override the template being loaded in parent/child themes.
     *
     * @since 1.7.0
     *
     * @param bool   $value    Whether or not there is a file override. Default false.
     * @param string $template The path to the template file that is being used.
     */
    $new_template = apply_filters('bp_get_root_template', false, $template);
    // A BuddyPress template file was located, so override the WordPress
    // template and use it to switch off BuddyPress's theme compatibility.
    if (!empty($new_template)) {
        $template = bp_set_template_included($new_template);
    }
    /**
     * Filters the final template being loaded in parent/child themes.
     *
     * @since 1.7.0
     *
     * @param string $template The path to the template file that is being used.
     */
    return apply_filters('bp_template_include_theme_supports', $template);
}
/**
 * Possibly intercept the template being loaded.
 *
 * Listens to the 'template_include' filter and waits for any BuddyPress specific
 * template condition to be met. If one is met and the template file exists,
 * it will be used; otherwise
 *
 * Note that the _edit() checks are ahead of their counterparts, to prevent them
 * from being stomped on accident.
 *
 * @since BuddyPress (1.7.0)
 *
 * @param string $template
 * @return string The path to the template file that is being used.
 */
function bp_template_include_theme_supports($template = '')
{
    // Look for root BuddyPress template files in parent/child themes
    $new_template = apply_filters('bp_get_root_template', false, $template);
    // A BuddyPress template file was located, so override the WordPress
    // template and use it to switch off BuddyPress's theme compatibility.
    if (!empty($new_template)) {
        $template = bp_set_template_included($new_template);
    }
    return apply_filters('bp_template_include_theme_supports', $template);
}