6339functionsanitize_hex_color($color){6340if(''===$color){6341return'';6342}63436344// 3 or 6 hex digits, or the empty string.6345if(preg_match('|^#([A-Fa-f0-9]{3}){1,2}$|',$color)){6346return$color;6347}6348returnnull;6349}
History
Introduced in 3.4.0. One change between 6.7.7 and 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
7.1.0
Return type changed from string|void to string|null.verified against source
3.4.0
Introduced.from the docblock
About this page
Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.