rest_parse_hex_color( string $color )

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


Parameters Parameters

$color

(string) (Required) 3 or 6 digit hex color (with #).


Top ↑

Return Return

(string|false)


Top ↑

Source Source

File: wp-includes/rest-api.php

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

	return $color;
}


Top ↑

Changelog Changelog

Changelog
Version Description
5.4.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.