Automattic\WooCommerce\Blocks\BlockTypes

CouponCode::is_css_color_valueprivateWC 1.0

Check if a string is a valid CSS color value (hex, rgb, or hsl).

Method of the class: CouponCode{}

No Hooks.

Returns

true|false.

Usage

// private - for code of main (parent) class only
$result = $this->is_css_color_value( $value ): bool;
$value(string) (required)
Value to check.

CouponCode::is_css_color_value() code WC 10.8.1

private function is_css_color_value( string $value ): bool {
	return str_starts_with( $value, '#' )
		|| str_starts_with( $value, 'rgb' )
		|| str_starts_with( $value, 'hsl' );
}