wc_format_hex

Format string as hex.

Description

(string) wc_format_hex( (string) $hex ); 

Returns (string)

Parameters (1)

0. $hex (string)
The hex.

Usage

  1. if ( !function_exists( 'wc_format_hex' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The hex. 
  5. $hex = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_format_hex($hex); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_format_hex( $hex ) { 
  2.  
  3. $hex = trim( str_replace( '#', '', $hex ) ); 
  4.  
  5. if ( strlen( $hex ) == 3 ) { 
  6. $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; 
  7.  
  8. return $hex ? '#' . $hex : null;