MailPoet\EmailEditor\Engine

Theme_Controller::get_variables_values_map()publicWC 1.0

Returns the map of CSS variables and their values from the theme.

Method of the class: Theme_Controller{}

No Hooks.

Return

Array.

Usage

$Theme_Controller = new Theme_Controller();
$Theme_Controller->get_variables_values_map(): array;

Theme_Controller::get_variables_values_map() code WC 9.8.1

public function get_variables_values_map(): array {
	$variables_css = $this->get_theme()->get_stylesheet( array( 'variables' ) );
	$map           = array();
	// Regular expression to match CSS variable definitions.
	$pattern = '/--(.*?):\s*(.*?);/';

	if ( preg_match_all( $pattern, $variables_css, $matches, PREG_SET_ORDER ) ) {
		foreach ( $matches as $match ) {
			// '--' . $match[1] is the variable name, $match[2] is the variable value.
			$map[ '--' . $match[1] ] = $match[2];
		}
	}

	return $map;
}