コード例 #1
0
ファイル: language.php プロジェクト: wpsitecare/carelib
/**
 * Returns the child theme domain path. No slash.
 *
 * @since  1.0.0
 * @access protected
 * @return string
 */
function _carelib_get_child_domain_path()
{
    if (file_exists(carelib_get_child_dir('languages'))) {
        return 'languages';
    }
    $path = carelib_get_theme()->get('DomainPath');
    return $path ? trim($path, '/') : 'languages';
}
コード例 #2
0
/**
 * Gets the stylesheet files within the parent or child theme and checks if
 * they have the 'Style Name' header. If any files are found, they are
 * returned in an array.
 *
 * @since  1.0.0
 * @access public
 * @return array
 */
function carelib_get_post_styles($post_type = 'post')
{
    static $styles = array();
    if (!empty($styles[$post_type])) {
        return $styles[$post_type];
    }
    $styles[$post_type] = array();
    $files = carelib_get_parent()->get_files('css', 2);
    if (is_child_theme()) {
        $files = array_merge($files, carelib_get_theme()->get_files('css', 2));
    }
    foreach ($files as $file => $path) {
        $headers = get_file_data($path, array('Style Name' => 'Style Name', "{$post_type} Style" => "{$post_type} Style"));
        if (!empty($headers['Style Name'])) {
            $styles[$post_type][$file] = $headers['Style Name'];
        } elseif (!empty($headers["{$post_type} Style"])) {
            $styles[$post_type][$file] = $headers["{$post_type} Style"];
        }
    }
    return $styles[$post_type] = array_flip($styles[$post_type]);
}
コード例 #3
0
/**
 * Returns a link to the child theme URI.
 *
 * @since  1.0.0
 * @access public
 * @return string
 */
function carelib_get_child_theme_link()
{
    if (!is_child_theme()) {
        return '';
    }
    $theme = carelib_get_theme();
    $allowed = array('abbr' => array('title' => true), 'acronym' => array('title' => true), 'code' => true, 'em' => true, 'strong' => true);
    // Note: URI is escaped via `WP_Theme::markup_header()`.
    return sprintf('<a class="child-link" href="%s">%s</a>', $theme->display('ThemeURI'), wp_kses($theme->display('Name'), $allowed));
}
コード例 #4
0
ファイル: theme.php プロジェクト: wpsitecare/carelib
/**
 * Return the fallback version by getting it from the WP_Theme object.
 *
 * @since  1.0.0
 * @access public
 * @return string The current theme's version number.
 */
function carelib_get_fallback_version()
{
    return carelib_get_theme()->get('Version');
}
コード例 #5
0
ファイル: dashboard.php プロジェクト: wpsitecare/carelib
/**
 * Add the WordPress Theme Dashboard to the main WordPress dashboard menu.
 *
 * @since   1.0.0
 * @access  public
 * @return  void
 */
function carelib_dashboard_menu()
{
    $theme = carelib_get_theme();
    add_theme_page($theme['Name'], $theme['Name'], 'edit_theme_options', "{$GLOBALS['carelib_prefix']}-dashboard", 'carelib_dashboard_page');
}
コード例 #6
0
/**
 * Get an array of available custom templates with a specific header.
 *
 * Ideally, this function would be used to grab custom singular post templates.
 * It is a recreation of the WordPress page templates function because it
 * doesn't allow for other types of templates.
 *
 * @since  1.0.0
 * @access public
 * @param  string $post_type      The name of the post type to get templates for.
 * @return array  $post_templates The array of templates.
 */
function carelib_get_post_templates($post_type = 'post')
{
    static $templates;
    if (!empty($templates) && isset($templates[$post_type])) {
        return $templates[$post_type];
    }
    $post_templates = array();
    // Get the theme PHP files one level deep.
    $files = carelib_get_parent()->get_files('php', 1);
    // If a child theme is active, get its files and merge with the parent theme files.
    if (is_child_theme()) {
        $files = array_merge($files, carelib_get_theme()->get_files('php', 1));
    }
    foreach ($files as $file => $path) {
        // Get file data based on the post type singular name.
        $headers = get_file_data($path, array("{$post_type} Template" => "{$post_type} Template"));
        if (!empty($headers["{$post_type} Template"])) {
            $post_templates[$file] = $headers["{$post_type} Template"];
        }
    }
    return $templates[$post_type] = array_flip($post_templates);
}