Automattic\WooCommerce\EmailEditor\Engine\Renderer\ContentRenderer\Preprocessors

Blocks_Width_Preprocessor::resolve_preset_valueprivateWC 1.0

Resolve a CSS value that may contain a preset variable reference.

Block attributes store padding as preset references like "var:preset|spacing|20" which resolve to actual pixel values (e.g. "8px"). This method converts the reference to its resolved value using the variables map passed through styles.

Method of the class: Blocks_Width_Preprocessor{}

No Hooks.

Returns

String. The resolved value (e.g. "8px") or the original value.

Usage

// private - for code of main (parent) class only
$result = $this->resolve_preset_value( $value, $variables_map ): string;
$value(string) (required)
The CSS value, possibly a preset reference.
$variables_map(array) (required)
Map of CSS variable names to resolved values.

Blocks_Width_Preprocessor::resolve_preset_value() code WC 10.7.0

private function resolve_preset_value( string $value, array $variables_map ): string {
	if ( strpos( $value, 'var:preset|' ) !== 0 ) {
		return $value;
	}

	$css_var_name = '--wp--' . str_replace( '|', '--', str_replace( 'var:', '', $value ) );
	return $variables_map[ $css_var_name ] ?? $value;
}