WP_Theme_JSON::convert_variables_to_value( array $styles, array $values ): array

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Replaces CSS variables with their values in place.

Parameters

$stylesarrayrequired
CSS declarations to convert.
$valuesarrayrequired
key => value pairs to use for replacement.

Return

array

Source

			 * support features use the same custom selector.
			 */
			if ( isset( $declarations[ $feature_selector ] ) ) {
				foreach ( $new_declarations as $new_declaration ) {
					$declarations[ $feature_selector ][] = $new_declaration;
				}
			} else {
				$declarations[ $feature_selector ] = $new_declarations;
			}

			/*
			 * Remove the feature from the block's node now its styles
			 * will be included under its own selector not the block's.
			 */
			unset( $node[ $feature ] );
		}
	}

	return $declarations;
}

/**
 * Replaces CSS variables with their values in place.
 *
 * @since 6.3.0
 * @param array $styles CSS declarations to convert.
 * @param array $values key => value pairs to use for replacement.
 * @return array
 */
private static function convert_variables_to_value( $styles, $values ) {
	foreach ( $styles as $key => $style ) {
		if ( is_array( $style ) ) {
			$styles[ $key ] = self::convert_variables_to_value( $style, $values );
			continue;
		}

		if ( 0 <= strpos( $style, 'var(' ) ) {

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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