wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



wp_normalize_state_preset_vars › WordPress Function

Seit7.1.0
Veraltetn/v
wp_normalize_state_preset_vars ( $value )
Parameter:
  • (mixed) $value Style value to normalize.
    Erforderlich: Ja
Gibt zurück:
  • (mixed) Normalized style value.
Definiert in:
Codex:

Converts internal preset references to CSS custom property references.

State styles are emitted as CSS rules and cannot rely on preset classnames. Converting var:preset|color|contrast to var(--wp--preset--color--contrast) ensures preset values are emitted as declarations by the style engine.


Quellcode

function wp_normalize_state_preset_vars( $value ) {
	if ( is_array( $value ) ) {
		foreach ( $value as $key => $nested_value ) {
			$value[ $key ] = wp_normalize_state_preset_vars( $nested_value );
		}
		return $value;
	}

	if ( ! is_string( $value ) || ! str_starts_with( $value, 'var:preset|' ) ) {
		return $value;
	}

	$unwrapped_name = str_replace( '|', '--', substr( $value, strlen( 'var:' ) ) );
	return "var(--wp--$unwrapped_name)";
}