/**
  * Navbar additional CSS
  */
 function navbar_css($styles)
 {
     $font_size = get_theme_mod('font_menus_size', 14);
     $color = get_theme_mod('navbar_bg', '#f8f8f8');
     $opacity = get_theme_mod('navbar_bg_opacity', 100);
     $bg = $color;
     if (100 != $opacity && function_exists('kirki_get_rgba')) {
         $bg = kirki_get_rgba($color, $opacity);
     }
     $styles .= 14 != $font_size ? '.nav-main,.dropdown-menu{font-size:' . $font_size . 'px;}' : '';
     $styles .= '#banner-header{background:' . $bg . ';}';
     return $styles;
 }
 public function test()
 {
     $this->assertEquals(kirki_get_option(), Kirki::get_option());
     $this->assertEquals(kirki_sanitize_hex('#ffffff'), Kirki_Color::sanitize_hex('#ffffff'));
     $this->assertEquals(kirki_get_rgb('#ffffff'), Kirki_Color::get_rgb('#ffffff'));
     $this->assertEquals(kirki_get_rgba('#ffffff'), Kirki_Color::get_rgba('#ffffff'));
     $this->assertEquals(kirki_get_brightness('#ffffff'), Kirki_Color::get_brightness('#ffffff'));
     $font_registry = Kirki_Toolkit::fonts();
     $this->assertEquals(Kirki_Fonts::get_all_fonts(), $font_registry->get_all_fonts());
     $this->assertEquals(Kirki_Fonts::get_font_choices(), $font_registry->get_font_choices());
     $this->assertEquals(Kirki_Fonts::is_google_font('foo'), $font_registry->is_google_font('foo'));
     $this->assertEquals(Kirki_Fonts::get_google_font_uri(array('foo')), $font_registry->get_google_font_uri(array('foo')));
     $this->assertEquals(Kirki_Fonts::get_google_font_subsets(), $font_registry->get_google_font_subsets());
     $this->assertEquals(Kirki_Fonts::choose_google_font_variants('Roboto'), $font_registry->choose_google_font_variants('Roboto'));
     $this->assertEquals(Kirki_Fonts::get_standard_fonts(), $font_registry->get_standard_fonts());
     $this->assertEquals(Kirki_Fonts::get_font_stack('foo'), $font_registry->get_font_stack('foo'));
     $this->assertEquals(Kirki_Fonts::sanitize_font_choice('foo'), $font_registry->sanitize_font_choice('foo'));
     $this->assertEquals(Kirki_Fonts::get_google_fonts(), $font_registry->get_google_fonts());
 }
/**
 * Apply custom backgrounds to our page.
 */
function kirki_background_css()
{
    $controls = apply_filters('kirki/controls', array());
    $config = apply_filters('kirki/config', array());
    if (isset($controls)) {
        foreach ($controls as $control) {
            if ('background' == $control['type']) {
                // Apply custom CSS if we've set the 'output'.
                if (!is_null($control['output'])) {
                    $bg_color = kirki_sanitize_hex(get_theme_mod($control['setting'] . '_color', $control['default']['color']));
                    $bg_image = get_theme_mod($control['setting'] . '_image', $control['default']['image']);
                    $bg_repeat = get_theme_mod($control['setting'] . '_repeat', $control['default']['repeat']);
                    $bg_size = get_theme_mod($control['setting'] . '_size', $control['default']['size']);
                    $bg_attach = get_theme_mod($control['setting'] . '_attach', $control['default']['attach']);
                    $bg_position = get_theme_mod($control['setting'] . '_position', $control['default']['position']);
                    $bg_opacity = get_theme_mod($control['setting'] . '_opacity', $control['default']['opacity']);
                    if (false != $control['default']['opacity']) {
                        $bg_position = get_theme_mod($control['setting'] . '_opacity', $control['default']['opacity']);
                        // If we're using an opacity other than 100, then convert the color to RGBA.
                        if (100 != $bg_opacity) {
                            $bg_color = kirki_get_rgba($bg_color, $bg_opacity);
                        }
                    }
                    // HTML Background
                    $styles = $control['output'] . '{';
                    $styles .= 'background-color:' . $bg_color . ';';
                    if ('' != $bg_image) {
                        $styles .= 'background-image: url("' . $bg_image . '");';
                        $styles .= 'background-repeat: ' . $bg_repeat . ';';
                        $styles .= 'background-size: ' . $bg_size . ';';
                        $styles .= 'background-attachment: ' . $bg_attach . ';';
                        $styles .= 'background-position: ' . str_replace('-', ' ', $bg_position) . ';';
                    }
                    $styles .= '}';
                }
                wp_add_inline_style($config['stylesheet_id'], $styles);
            }
        }
    }
}
Example #4
0
 public function test_kirki_get_rgba()
 {
     $random_color = str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT) . str_pad(dechex(mt_rand(0, 255)), 2, '0', STR_PAD_LEFT);
     $this->assertEquals(kirki_get_rgba($random_color), Kirki_Color::get_rgba($random_color));
 }