WP_Style_Engine::get_slug_from_preset_value()protected staticWP 6.1.0

Util: Extracts the slug in kebab case from a preset string, e.g. heavenly-blue from var:preset|color|heavenlyBlue.

Метод класса: WP_Style_Engine{}

Хуков нет.

Возвращает

Строку. The slug, or empty string if not found.

Использование

$result = WP_Style_Engine::get_slug_from_preset_value( $style_value, $property_key );
$style_value(строка) (обязательный)
A single CSS preset value.
$property_key(строка) (обязательный)
The CSS property that is the second element of the preset string. Used for matching.

Список изменений

С версии 6.1.0 Введена.

Код WP_Style_Engine::get_slug_from_preset_value() WP 6.5.2

protected static function get_slug_from_preset_value( $style_value, $property_key ) {
	if ( is_string( $style_value ) && is_string( $property_key )
		&& str_contains( $style_value, "var:preset|{$property_key}|" )
	) {
		$index_to_splice = strrpos( $style_value, '|' ) + 1;
		return _wp_to_kebab_case( substr( $style_value, $index_to_splice ) );
	}
	return '';
}