Esempio n. 1
0
/**
 * Attempt to load a custom Achievements functions file, similar to a theme's functions.php file.
 *
 * @global string $pagenow
 * @since Achievements (3.0)
 */
function dpa_load_theme_functions()
{
    global $pagenow;
    // If Achievements is being deactivated, do not load any more files
    if (dpa_is_deactivation()) {
        return;
    }
    if (!defined('WP_INSTALLING') || !empty($pagenow) && 'wp-activate.php' !== $pagenow) {
        dpa_locate_template('achievements-functions.php', true);
        if (class_exists('DPA_Default')) {
            achievements()->theme_functions = new DPA_Default();
        }
    }
}
/**
 * Retrieve 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 templates theme with
 * the use of {@link dpa_locate_template()}. Allows for more generic template
 * locations without the use of the other get_*_template() functions.
 *
 * @param string $type Filename without extension.
 * @param array $templates An optional list of template candidates
 * @return string Full path to file.
 * @since Achievements (3.0)
 */
function dpa_get_query_template($type, $templates = array())
{
    // Only allow a-z0-9 characters in file names
    $type = preg_replace('|[^a-z0-9-]+|', '', $type);
    if (empty($templates)) {
        $templates = array("{$type}.php");
    }
    /**
     * Filter possible templates, try to match one, and set any Achievements theme
     * compat properties so they can be cross-checked later.
     */
    $templates = apply_filters("dpa_get_{$type}_template", $templates);
    $templates = dpa_set_theme_compat_templates($templates);
    $template = dpa_locate_template($templates);
    $template = dpa_set_theme_compat_template($template);
    return apply_filters("dpa_{$type}_template", $template);
}