WP_Style_Engine::get_slug_from_preset_value( string $style_value, string $property_key ): string

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


Parameters

$style_value string Required
A single CSS preset value.
$property_key string Required
The CSS property that is the second element of the preset string. Used for matching.

Top ↑

Return

string The slug, or empty string if not found.


Top ↑

Source

File: wp-includes/style-engine/class-wp-style-engine.php. View all references

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 '';
}


Top ↑

Changelog

Changelog
Version Description
6.1.0 Introduced.

Top ↑

User Contributed Notes

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