Automattic\WooCommerce\Blocks\BlockTypes\AddToCartWithOptions
VariationSelectorAttributeOptions::get_normalized_attributes
Get the normalized version of the attributes.
Метод класса: VariationSelectorAttributeOptions{}
Хуков нет.
Возвращает
Строку. The HTML element's attributes.
Использование
$result = VariationSelectorAttributeOptions::get_normalized_attributes( $attributes, $default_attributes );
- $attributes(массив) (обязательный)
- The element's attributes.
- $default_attributes(массив)
- The element's default attributes.
По умолчанию: array()
Код VariationSelectorAttributeOptions::get_normalized_attributes() VariationSelectorAttributeOptions::get normalized attributes WC 10.3.6
public static function get_normalized_attributes( $attributes, $default_attributes = array() ) {
$normalized_attributes = array();
$merged_attributes = array_merge( $default_attributes, $attributes );
foreach ( $merged_attributes as $key => $value ) {
if ( is_null( $value ) ) {
continue;
}
if ( is_array( $value ) || is_object( $value ) ) {
$value = wp_json_encode(
$value,
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP
);
}
$normalized_attributes[] = sprintf( '%s="%s"', esc_attr( $key ), esc_attr( $value ) );
}
return implode( ' ', $normalized_attributes );
}