W3cubDocs

/WordPress

WP_Duotone::colord_parse( string $input ): array|null

Tries to convert an incoming string into RGBA values.

Description

Direct port of colord’s parse function simplified for our use case. This version only supports string parsing and only returns RGBA values.

Parameters

$inputstringrequired
The string to parse.

Return

array|null An array of RGBA values or null if the string is invalid.

Source

private static function colord_parse( $input ) {
	$result = self::colord_parse_hex( $input );

	if ( ! $result ) {
		$result = self::colord_parse_rgba_string( $input );
	}

	if ( ! $result ) {
		$result = self::colord_parse_hsla_string( $input );
	}

	return $result;
}

Changelog

Version Description
6.3.0 Introduced.

© 2003–2024 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_duotone/colord_parse