Example #1
0
/**
 * Register Styles
 *
 * Checks the styles option and hooks the required filter.
 *
 * @since 1.0
 * @return void
 */
function give_register_styles()
{
    if (give_get_option('disable_css', false)) {
        return;
    }
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $file = 'give' . $suffix . '.css';
    $templates_dir = give_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 . 'give.css';
    $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file;
    $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'give.css';
    $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()) . $file;
    // Look in the child theme directory first, followed by the parent theme, followed by the Give 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 give.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 . 'give.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 . 'give.css';
        } else {
            $url = trailingslashit(get_template_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
        $url = trailingslashit(give_get_templates_url()) . $file;
    }
    wp_register_style('give-styles', $url, array(), GIVE_VERSION, 'all');
    wp_enqueue_style('give-styles');
}
Example #2
0
/**
 * Get the stylesheet URI.
 *
 * @since 1.6
 * @return mixed|void
 */
function give_get_stylesheet_uri()
{
    // Use minified libraries if SCRIPT_DEBUG is turned off
    $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
    $file = 'give' . $suffix . '.css';
    $templates_dir = give_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 . 'give.css';
    $parent_theme_style_sheet = trailingslashit(get_template_directory()) . $templates_dir . $file;
    $parent_theme_style_sheet_2 = trailingslashit(get_template_directory()) . $templates_dir . 'give.css';
    $give_plugin_style_sheet = trailingslashit(give_get_templates_dir()) . $file;
    $uri = false;
    // Look in the child theme directory first, followed by the parent theme, followed by the Give 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 give.css to their theme
    if (file_exists($child_theme_style_sheet) || !empty($suffix) && ($nonmin = file_exists($child_theme_style_sheet_2))) {
        if (!empty($nonmin)) {
            $uri = trailingslashit(get_stylesheet_directory_uri()) . $templates_dir . 'give.css';
        } else {
            $uri = 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)) {
            $uri = trailingslashit(get_template_directory_uri()) . $templates_dir . 'give.css';
        } else {
            $uri = trailingslashit(get_template_directory_uri()) . $templates_dir . $file;
        }
    } elseif (file_exists($give_plugin_style_sheet) || file_exists($give_plugin_style_sheet)) {
        $uri = trailingslashit(give_get_templates_url()) . $file;
    }
    return apply_filters('give_get_stylesheet_uri', $uri);
}