wpseek.com
A WordPress-centric search engine for devs and theme authors



rest_parse_hex_color › WordPress Function

Since5.4.0
Deprecatedn/a
rest_parse_hex_color ( $color )
Parameters:
  • (string) $color 3 or 6 digit hex color (with #).
    Required: Yes
Returns:
  • (string|false)
Defined at:
Codex:

Parses a 3 or 6 digit hex color (with #).



Source

function rest_parse_hex_color( $color ) {
	$regex = '|^#([A-Fa-f0-9]{3}){1,2}$|';
	if ( ! preg_match( $regex, $color, $matches ) ) {
		return false;
	}

	return $color;
}