WordPress at Your Fingertips
function is not described

WP_Theme_JSON::compute_style_properties() private WP 5.8.0

Given a styles array, it extracts the style properties and adds them to the $declarations array following the format:

array( 'name' => 'property_name', 'value' => 'property_value,

)

{} It's a method of the class: WP_Theme_JSON{}

No Hooks.

Return

Array. Returns the modified $declarations.

Usage

$result = WP_Theme_JSON::compute_style_properties( $styles );
$styles(array) (required)
Styles to process.

Changelog

Since 5.8.0 Introduced.

Code of WP_Theme_JSON::compute_style_properties() WP 5.8.2

private static function compute_style_properties( $styles ) {
	$declarations = array();
	if ( empty( $styles ) ) {
		return $declarations;
	}

	$properties = array();
	foreach ( self::PROPERTIES_METADATA as $name => $metadata ) {
		/*
		 * Some properties can be shorthand properties, meaning that
		 * they contain multiple values instead of a single one.
		 * An example of this is the padding property.
		 */
		if ( self::has_properties( $metadata ) ) {
			foreach ( $metadata['properties'] as $property ) {
				$properties[] = array(
					'name'  => $name . '-' . $property,
					'value' => array_merge( $metadata['value'], array( $property ) ),
				);
			}
		} else {
			$properties[] = array(
				'name'  => $name,
				'value' => $metadata['value'],
			);
		}
	}

	foreach ( $properties as $prop ) {
		$value = self::get_property_value( $styles, $prop['value'] );
		if ( empty( $value ) ) {
			continue;
		}

		$declarations[] = array(
			'name'  => $prop['name'],
			'value' => $value,
		);
	}

	return $declarations;
}