WordPress функция перевода HEX в RGB/A цвет
if ( ! function_exists( 'hex_to_rgb' ) ) { | |
function hex_to_rgb( $hex_color, $normal = false, $opacity = 1 ) { | |
$hex_int = hexdec( sanitize_hex_color($hex_color) ); | |
$rgb = array( 'red' => 0xFF & ( $hex_int >> 0x10 ), 'green' => 0xFF & ( $hex_int >> 0x8 ), 'blue' => 0xFF & $hex_int ); | |
if($normal) { | |
$opacity_value = is_numeric($opacity) ? $opacity : 1; | |
$rgb = 'rgba('. implode(',', array_values($rgb)) .','. $opacity_value .')'; | |
} | |
return $rgb; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment