WP_Duotone::get_slug_from_attribute( string $duotone_attr ): string

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Takes the inline CSS duotone variable from a block and return the slug.

Description

Handles styles slugs like: var:preset|duotone|blue-orange var(–wp–preset–duotone–blue-orange)

Parameters

$duotone_attrstringrequired
The duotone attribute from a block.

Return

string The slug of the duotone preset or an empty string if no slug is found.

Source

private static function get_slug_from_attribute( $duotone_attr ) {
	// Uses Branch Reset Groups `(?|…)` to return one capture group.
	preg_match( '/(?|var:preset\|duotone\|(\S+)|var\(--wp--preset--duotone--(\S+)\))/', $duotone_attr, $matches );

	return ! empty( $matches[1] ) ? $matches[1] : '';
}

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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