Example #1
0
/**
 * Basic top-level template hierarchy. I generally prefer to leave this functionality up to
 * themes.  This is just a foundation to build upon if needed.
 *
 * @since  1.0.0
 * @access public
 * @param  string  $template
 * @return string
 */
function thds_template_include($template)
{
    // Bail if not a theme page.
    if (!thds_is_theme_designer()) {
        return $template;
    }
    $templates = array();
    // Author archive.
    if (thds_is_author()) {
        $templates[] = 'theme-author.php';
        // Subject archive.
    } else {
        if (thds_is_subject()) {
            $templates[] = 'theme-subject.php';
            // Feature archive.
        } else {
            if (thds_is_feature()) {
                $templates[] = 'theme-feature.php';
                // Single theme.
            } else {
                if (thds_is_single_theme()) {
                    $post_template = get_post_meta(get_queried_object_id(), 'template', true);
                    if ('' === $post_template) {
                        $post_template = get_post_meta(get_queried_object_id(), '_wp_theme_template', true);
                    }
                    if ($post_template) {
                        $templates[] = $post_template;
                    }
                    $templates[] = 'theme-single.php';
                }
            }
        }
    }
    // Fallback template for all archive-type pages.
    if (thds_is_archive()) {
        $templates[] = 'theme-archive.php';
    }
    // Fallback template.
    $templates[] = 'theme-designer.php';
    // Check if we have a template.
    $has_template = locate_template(apply_filters('thds_template_hierarchy', $templates));
    // Return the template.
    return $has_template ? $has_template : $template;
}
Example #2
0
/**
 * Conditional tag to check if viewing any Theme Designer plugin page.
 *
 * @since  1.0.0
 * @access public
 * @param  mixed  $term
 * @return bool
 */
function thds_is_theme_designer()
{
    $is_thds = thds_is_theme_archive() || thds_is_single_theme() || thds_is_author() || thds_is_subject() || thds_is_feature();
    return apply_filters('thds_is_theme_designer', $is_thds);
}