WP_Duotone::get_slug_from_attribute()
Takes the inline CSS duotone variable from a block and return the slug.
Handles styles slugs like: var:preset|duotone|blue-orange var(--wp--preset--duotone--blue-orange)
Method of the class: WP_Duotone{}
No Hooks.
Return
String
. The slug of the duotone preset or an empty string if no slug is found.
Usage
$result = WP_Duotone::get_slug_from_attribute( $duotone_attr );
- $duotone_attr(string) (required)
- The duotone attribute from a block.
Changelog
Since 6.3.0 | Introduced. |
WP_Duotone::get_slug_from_attribute() WP Duotone::get slug from attribute code WP 6.7.1
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] : ''; }