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

					} elseif (
						isset( $preset_metadata['value_func'] ) &&
						is_callable( $preset_metadata['value_func'] )
					) {
						$value = call_user_func( $preset_metadata['value_func'], $preset );
					}

					$preset_is_valid = true;
					foreach ( $preset_metadata['properties'] as $property ) {
						if ( ! static::is_safe_css_declaration( $property, $value ) ) {
							$preset_is_valid = false;
							break;
						}
					}

					if ( $preset_is_valid ) {
						$escaped_preset[] = $preset;
					}
				}
			}

			if ( ! empty( $escaped_preset ) ) {
				_wp_array_set( $output, $path_with_origin, $escaped_preset );
			}
		}
	}

	// Ensure indirect properties not included in any `PRESETS_METADATA` value are allowed.
	static::remove_indirect_properties( $input, $output );

	return $output;
}

/**
 * Processes a style node and returns the same node
 * without the insecure styles.
 *

Changelog

VersionDescription
6.3.0Introduced.

User Contributed Notes

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