Пример #1
0
/**
 * Enqueues front-end custom CSS.
 *
 * @since Fastfood 0.37
 *
 * @see wp_add_inline_style()
 */
function fastfood_dynamic_css()
{
    // gathers the theme mods
    $mods = array('background_color', 'background_repeat', 'background_attachment', 'background_position_x', 'background_position_y', 'background_image', 'background_icons_color');
    $attributes = fastfood_get_background_schemes('0');
    $attributes = $attributes['attributes'];
    foreach ($mods as $attribute_key) {
        $attributes[$attribute_key] = get_theme_mod($attribute_key, $attributes[$attribute_key]);
    }
    $attributes['background_color'] = '#' . str_replace('#', '', $attributes['background_color']);
    // gathers the theme options
    $opts = array('fastfood_colors_link', 'fastfood_colors_link_hover', 'fastfood_colors_link_sel', 'fastfood_body_width', 'fastfood_rsideb_width', 'fastfood_featured_title_size');
    foreach ($opts as $attribute_key) {
        $attributes[$attribute_key] = FastfoodOptions::get_opt($attribute_key);
    }
    $attributes['fastfood_rsideb_width'] = round(absint($attributes['fastfood_rsideb_width']) / absint($attributes['fastfood_body_width']), 5) * 100;
    $attributes['fastfood_content_width'] = 100 - $attributes['fastfood_rsideb_width'];
    $attributes['fastfood_featured_title_size'] = absint($attributes['fastfood_featured_title_size']);
    $dynamic_css = fastfood_get_dynamic_css($attributes);
    wp_add_inline_style('fastfood', $dynamic_css);
}
Пример #2
0
    /**
     * Output an Underscore template for generating custom CSS.
     *
     * The template generates the css dynamically for instant display in the Customizer
     * preview.
     *
     * @since Fastfood 0.37
     */
    function dynamic_css_template()
    {
        $attributes = array('background_color' => '{{ data.background_color }}', 'background_repeat' => '{{ data.background_repeat }}', 'background_attachment' => '{{ data.background_attachment }}', 'background_position_x' => '{{ data.background_position_x }}', 'background_position_y' => '{{ data.background_position_y }}', 'background_image' => '{{ data.background_image }}', 'background_icons_color' => '{{ data.background_icons_color }}', 'fastfood_colors_link' => '{{ data.fastfood_colors_link }}', 'fastfood_colors_link_hover' => '{{ data.fastfood_colors_link_hover }}', 'fastfood_colors_link_sel' => '{{ data.fastfood_colors_link_sel }}', 'fastfood_body_width' => '{{ data.fastfood_body_width }}', 'fastfood_rsideb_width' => '{{ data.fastfood_rsideb_width }}', 'fastfood_content_width' => '{{ data.fastfood_content_width }}', 'fastfood_featured_title_size' => '{{ data.fastfood_featured_title_size }}');
        ?>

		<script type="text/html" id="tmpl-fastfood-dynamic-css">
			<?php 
        echo fastfood_get_dynamic_css($attributes);
        ?>
		</script>

		<?php 
    }