WP_Theme_JSON::convert_custom_propertiesprivate staticWP 6.3.0

This is used to convert the internal representation of variables to the CSS representation. For example, var:preset|color|vivid-green-cyan becomes var(--wp--preset--color--vivid-green-cyan).

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

Хуков нет.

Возвращает

Строку. The converted variable.

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

$result = WP_Theme_JSON::convert_custom_properties( $value );
$value(строка) (обязательный)
The variable such as var:preset|color|vivid-green-cyan to convert.

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

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

Код WP_Theme_JSON::convert_custom_properties() WP 7.0

private static function convert_custom_properties( $value ) {
	$prefix     = 'var:';
	$prefix_len = strlen( $prefix );
	$token_in   = '|';
	$token_out  = '--';
	if ( str_starts_with( $value, $prefix ) ) {
		$unwrapped_name = str_replace(
			$token_in,
			$token_out,
			substr( $value, $prefix_len )
		);
		$value          = "var(--wp--$unwrapped_name)";
	}

	return $value;
}