Uses
Uses | Description |
---|---|
wp-includes/formatting.php: sanitize_hex_color() | Sanitizes a hex color. |
Sanitizes a hex color without a hash. Use sanitize_hex_color() when possible.
Saving hex colors without a hash puts the burden of adding the hash on the UI, which makes it difficult to use or upgrade to other color types such as rgba, hsl, rgb, and HTML color names.
Returns either ”, a 3 or 6 digit hex color (without a #), or null.
(string) (Required)
(string|null)
File: wp-includes/formatting.php
function sanitize_hex_color_no_hash( $color ) { $color = ltrim( $color, '#' ); if ( '' === $color ) { return ''; } return sanitize_hex_color( '#' . $color ) ? $color : null; }
Version | Description |
---|---|
3.4.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/sanitize_hex_color_no_hash