Skip to content

Instantly share code, notes, and snippets.

@bahia0019
Created September 20, 2018 21:23
Show Gist options
  • Save bahia0019/9a7ee348504c8288105ed9ecfb0f259e to your computer and use it in GitHub Desktop.
Save bahia0019/9a7ee348504c8288105ed9ecfb0f259e to your computer and use it in GitHub Desktop.
Convert Hex string to RGBA
<?php
/**
* Take Accent color, and convert it to RGBA, and add an opacity of .75.
*/
$accent = get_theme_mod( 'site_accent_color' );
$accent_string = ltrim( $accent, '#' );
$arr = str_split( $accent_string, '2' );
foreach ( $arr as $value ) {
$new_value = hexdec( $value ) . ', ';
$rgb .= $new_value;
}
$accent_opacity = 'rgba(' . $rgb . '.75)';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment