예제 #1
0
/**
 * Retrieve the theme file with the highest priority that exists.
 *
 * @since  1.0.0
 * @access public
 * @link   http://core.trac.wordpress.org/ticket/18302
 * @param  array $file_names The files to search for.
 * @return string
 */
function _carelib_locate_theme_file($file_names)
{
    $located = '';
    foreach ((array) $file_names as $file) {
        // If the file exists in the stylesheet (child theme) directory.
        if (is_child_theme() && file_exists(carelib_get_child_dir() . $file)) {
            $located = carelib_get_child_uri() . $file;
            break;
        }
        // If the file exists in the template (parent theme) directory.
        if (file_exists(carelib_get_parent_dir() . $file)) {
            $located = carelib_get_parent_uri() . $file;
            break;
        }
    }
    return $located;
}
예제 #2
0
/**
 * Load the theme, child theme, and library textdomains automatically.
 * No need for theme authors to do this.
 *
 * This also utilizes the `Domain Path` header from `style.css`. It defaults
 * to the `languages` folder.
 *
 * @since  1.0.0
 * @access public
 * @return void
 */
function carelib_load_textdomains()
{
    // Load theme textdomain.
    load_theme_textdomain(_carelib_get_parent_textdomain(), carelib_get_parent_dir(_carelib_get_parent_domain_path()));
    // Load child theme textdomain.
    if (is_child_theme()) {
        load_child_theme_textdomain(_carelib_get_child_textdomain(), carelib_get_child_dir(_carelib_get_child_domain_path()));
    }
}
예제 #3
0
/**
 * Override the default comments template.
 *
 * This filter allows for a "comments-{$post_type}.php" template based on
 * the post type of the current single post view. If this template is not
 * found, it falls back to the default "comments.php" template.
 *
 * @since  1.0.0
 * @access public
 * @param  string $template The comments template file name.
 * @return string $template The theme comments template after all templates have been checked for.
 */
function carelib_comments_template($template)
{
    $templates = array();
    $post_type = get_post_type();
    // Allow for custom templates entered into comments_template( $file ).
    $template = str_replace(carelib_get_parent_dir(), '', $template);
    if ('comments.php' !== $template) {
        $templates[] = $template;
    }
    $templates[] = "template-parts/comments-{$post_type}.php";
    $templates[] = 'template-parts/comments.php';
    $templates[] = 'comments.php';
    // Return the found template.
    return locate_template($templates);
}