diff --git a/kit/css/search.css b/kit/css/search.css index ea9f620..7b99a92 100644 --- a/kit/css/search.css +++ b/kit/css/search.css @@ -141,5 +141,4 @@ h2.screen-reader-text { .tx-indexedsearch-redMarkup { font-weight: 400; - background-color: rgba(0, 153, 130, 0.1); } diff --git a/kit/functions.php b/kit/functions.php index 788f4bd..5893f05 100644 --- a/kit/functions.php +++ b/kit/functions.php @@ -217,118 +217,157 @@ add_action( 'customize_register', 'theme_customize_register' ); # Apply custom CSS settings +function hex2rgba($color, $opacity = false) { + + $default = 'rgb(0,0,0)'; + + //Return default if no color provided + if(empty($color)) + return $default; + + //Sanitize $color if "#" is provided + if ($color[0] == '#' ) { + $color = substr( $color, 1 ); + } + + //Check if color has 6 or 3 characters and get values + if (strlen($color) == 6) { + $hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] ); + } elseif ( strlen( $color ) == 3 ) { + $hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] ); + } else { + return $default; + } + + //Convert hexadec to rgb + $rgb = array_map('hexdec', $hex); + + //Check if opacity is set(rgba or rgb) + if($opacity){ + if(abs($opacity) > 1) + $opacity = 1.0; + $output = 'rgba('.implode(",",$rgb).','.$opacity.')'; + } else { + $output = 'rgb('.implode(",",$rgb).')'; + } + + //Return rgb(a) color string + return $output; +} + function kit_customize_css() { + $theme_color = get_theme_mod('theme_color', '#009982'); ?>