'Cormorant Garamond', 'variant'=>'regular' ) ); $site_title_fonts = blossom_pin_get_fonts( $site_title_font['font-family'], $site_title_font['variant'] ); $primary_color = get_theme_mod( 'primary_color', '#ff91a4' ); $rgb = blossom_pin_hex2rgb( blossom_pin_sanitize_hex_color( $primary_color ) ); echo ""; } endif; add_action( 'wp_head', 'blossom_pin_dynamic_css', 99 ); /** * Function for sanitizing Hex color */ function blossom_pin_sanitize_hex_color( $color ){ if ( '' === $color ) return ''; // 3 or 6 hex digits, or the empty string. if ( preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) return $color; } /** * convert hex to rgb * @link http://bavotasan.com/2011/convert-hex-color-to-rgb-using-php/ */ function blossom_pin_hex2rgb($hex) { $hex = str_replace("#", "", $hex); if(strlen($hex) == 3) { $r = hexdec(substr($hex,0,1).substr($hex,0,1)); $g = hexdec(substr($hex,1,1).substr($hex,1,1)); $b = hexdec(substr($hex,2,1).substr($hex,2,1)); } else { $r = hexdec(substr($hex,0,2)); $g = hexdec(substr($hex,2,2)); $b = hexdec(substr($hex,4,2)); } $rgb = array($r, $g, $b); //return implode(",", $rgb); // returns the rgb values separated by commas return $rgb; // returns an array with the rgb values }