/**
 * Retrieve the path to a template.
 *
 * Used to quickly retrieve the path of a template without including the file
 * extension. It will also check the parent theme and theme-compat theme with
 * the use of {@link bp_locate_template()}. Allows for more generic template
 * locations without the use of the other get_*_template() functions.
 *
 * @since 1.7.0
 *
 * @uses bp_set_theme_compat_templates()
 * @uses bp_locate_template()
 * @uses bp_set_theme_compat_template()
 *
 * @param string $type      Filename without extension.
 * @param array  $templates An optional list of template candidates.
 *
 * @return string Full path to file.
 */
function bp_get_query_template($type, $templates = array())
{
    $type = preg_replace('|[^a-z0-9-]+|', '', $type);
    if (empty($templates)) {
        $templates = array("{$type}.php");
    }
    /**
     * Filters possible file paths to check for for a template.
     *
     * This is a variable filter based on the type passed into
     * bp_get_query_template.
     *
     * @since 1.7.0
     *
     * @param array $templates Array of template files already prepared.
     */
    $templates = apply_filters("bp_get_{$type}_template", $templates);
    // Filter possible templates, try to match one, and set any BuddyPress theme
    // compat properties so they can be cross-checked later.
    $templates = bp_set_theme_compat_templates($templates);
    $template = bp_locate_template($templates);
    $template = bp_set_theme_compat_template($template);
    /**
     * Filters the path to a template file.
     *
     * This is a variable filter based on the type passed into
     * bp_get_query_template.
     *
     * @since 1.7.0
     *
     * @param string $template Path to the most appropriate found template file.
     */
    return apply_filters("bp_{$type}_template", $template);
}
/**
 * Retrieve the path to a template.
 *
 * Used to quickly retrieve the path of a template without including the file
 * extension. It will also check the parent theme and theme-compat theme with
 * the use of {@link bp_locate_template()}. Allows for more generic template
 * locations without the use of the other get_*_template() functions.
 *
 * @since BuddyPress (1.7.0)
 *
 * @uses bp_set_theme_compat_templates()
 * @uses bp_locate_template()
 * @uses bp_set_theme_compat_template()
 *
 * @param string $type Filename without extension.
 * @param array $templates An optional list of template candidates.
 * @return string Full path to file.
 */
function bp_get_query_template($type, $templates = array())
{
    $type = preg_replace('|[^a-z0-9-]+|', '', $type);
    if (empty($templates)) {
        $templates = array("{$type}.php");
    }
    // Filter possible templates, try to match one, and set any BuddyPress theme
    // compat properties so they can be cross-checked later.
    $templates = apply_filters("bp_get_{$type}_template", $templates);
    $templates = bp_set_theme_compat_templates($templates);
    $template = bp_locate_template($templates);
    $template = bp_set_theme_compat_template($template);
    return apply_filters("bp_{$type}_template", $template);
}