wc_format_hex()
Format string as hex.
No Hooks.
Return
String|null
.
Usage
wc_format_hex( $hex );
- $hex(string) (required)
- HEX color.
wc_format_hex() wc format hex code WC 9.6.1
function wc_format_hex( $hex ) { $hex = trim( str_replace( '#', '', $hex ?? '' ) ); if ( strlen( $hex ) === 3 ) { $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; } return $hex ? '#' . $hex : null; }