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)
Метод класса: WP_Duotone{}
Хуков нет.
Возвращает
Строку
. The slug of the duotone preset or an empty string if no slug is found.
Использование
$result = WP_Duotone::get_slug_from_attribute( $duotone_attr );
- $duotone_attr(строка) (обязательный)
- The duotone attribute from a block.
Список изменений
С версии 6.3.0 | Введена. |
Код WP_Duotone::get_slug_from_attribute() WP Duotone::get slug from attribute WP 6.6.2
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] : ''; }