Ensures that any hex color is properly hashed.
Otherwise, returns value untouched.
This method should only be necessary if using sanitize_hex_color_no_hash() .
$colorstringrequired
function maybe_hash_hex_color( $color ) {
$unhashed = sanitize_hex_color_no_hash( $color );
if ( $unhashed ) {
return '#' . $unhashed;
}
return $color;
}
| Version | Description |
|---|---|
| 3.4.0 | Introduced. |
© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/maybe_hash_hex_color