wp-includes/formatting.php:6194Sanitizes a hex color.
$colorstringstring|voidfunction sanitize_hex_color( $color ) { if ( '' === $color ) { return ''; } // 3 or 6 hex digits, or the empty string. if ( preg_match( '|^#([A-Fa-f0-9]{3}){1,2}$|', $color ) ) { return $color; }}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.
string|void to string|null.verified against sourcesrc/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.