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
if ( !function_exists( 'maybe_hash_hex_color' ) ) { require_once ABSPATH . WPINC . '/formatting.php'; } // The color. $color = ''; // NOTICE! Understand what this does before running. $result = maybe_hash_hex_color($color);
Defined (1)
The function is defined in the following location(s).
- /wp-includes/formatting.php
- function maybe_hash_hex_color( $color ) {
- if ( $unhashed = sanitize_hex_color_no_hash( $color ) ) {
- return '#' . $unhashed;
- }
- return $color;
- }