WP_Style_Engine::get_url_or_value_css_declaration()protected staticWP 6.4.0

Style value parser that constructs a CSS definition array comprising a single CSS property and value. If the provided value is an array containing a url property, the function will return a CSS definition array with a single property and value, with url escaped and injected into a CSS url() function, e.g., array( 'background-image' => "url( '...' )" ).

Метод класса: WP_Style_Engine{}

Хуков нет.

Возвращает

Строку[]. An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).

Использование

$result = WP_Style_Engine::get_url_or_value_css_declaration( $style_value, $style_definition );
$style_value(массив) (обязательный)
A single raw style value from $block_styles array.
$style_definition(массив) (обязательный)
A single style definition from BLOCK_STYLE_DEFINITIONS_METADATA.

Список изменений

С версии 6.4.0 Введена.

Код WP_Style_Engine::get_url_or_value_css_declaration() WP 6.7.1

protected static function get_url_or_value_css_declaration( $style_value, $style_definition ) {
	if ( empty( $style_value ) ) {
		return array();
	}

	$css_declarations = array();

	if ( isset( $style_definition['property_keys']['default'] ) ) {
		$value = null;

		if ( ! empty( $style_value['url'] ) ) {
			$value = "url('" . $style_value['url'] . "')";
		} elseif ( is_string( $style_value ) ) {
			$value = $style_value;
		}

		if ( null !== $value ) {
			$css_declarations[ $style_definition['property_keys']['default'] ] = $value;
		}
	}

	return $css_declarations;
}