Example #1
0
/**
 * Register Styles
 *
 * Checks the styles option and hooks the required filter.
 *
 * @since	1.0
 * @return	void
 */
function kbs_register_styles()
{
    if (kbs_get_option('disable_styles', false)) {
        return;
    }
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '';
    //'.min';
    $file = 'kbs' . $suffix . '.css';
    $templates_dir = kbs_get_theme_template_dir_name();
    $child_theme_style_sheet = trailingslashit(get_stylesheet_directory()) . $templates_dir . $file;
    $child_theme_style_sheet_2 = trailingslashit(get_stylesheet_directory()) . $templates_dir . 'kbs.css';
    $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file;
    $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'kbs.css';
    $kbs_plugin_style_sheet = trailingslashit(kbs_get_templates_dir()) . $file;
    // Look in the child theme directory first, followed by the parent theme, followed by the KBS core templates directory
    // Also look for the min version first, followed by non minified version, even if SCRIPT_DEBUG is not enabled.
    // This allows users to copy just kbs.css to their theme
    if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'kbs.css';
        } else {
            $url = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($parent_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($parent_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . 'kbs.css';
        } else {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($kbs_plugin_style_sheet) || file_exists($kbs_plugin_style_sheet)) {
        $url = trailingslashit(kbs_get_templates_url()) . $file;
    }
    wp_register_style('kbs-font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css', array(), KBS_VERSION, 'all');
    wp_enqueue_style('kbs-font-awesome');
    wp_register_style('kbs-styles', $url, array(), KBS_VERSION, 'all');
    wp_enqueue_style('kbs-styles');
}
/**
 * Returns a list of paths to check for template locations
 *
 * @since	0.1
 * @return mixed|void
 */
function kbs_get_theme_template_paths()
{
    $template_dir = kbs_get_theme_template_dir_name();
    $file_paths = array(1 => trailingslashit(get_stylesheet_directory()) . $template_dir, 10 => trailingslashit(get_template_directory()) . $template_dir, 100 => kbs_get_templates_dir());
    $file_paths = apply_filters('kbs_template_paths', $file_paths);
    // sort the file paths based on priority
    ksort($file_paths, SORT_NUMERIC);
    return array_map('trailingslashit', $file_paths);
}