maybe_hash_hex_color

Ensures that any hex color is properly hashed.

Description

(string) maybe_hash_hex_color( (string) $color ); 

Otherwise, returns value untouched.

This method should only be necessary if using sanitize_hex_color_no_hash().

Returns (string)

Parameters (1)

0. $color (string)
The color.

Usage

  1. if ( !function_exists( 'maybe_hash_hex_color' ) ) { 
  2. require_once ABSPATH . WPINC . '/formatting.php'; 
  3.  
  4. // The color. 
  5. $color = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = maybe_hash_hex_color($color); 
  9.  

Defined (1)

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

/wp-includes/formatting.php  
  1. function maybe_hash_hex_color( $color ) { 
  2. if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) { 
  3. return '#' . $unhashed; 
  4.  
  5. return $color;