Add a default attribute to the pattern if exists (https://github.com/woocommerce/woocommerce-blocks/pull/9812)

* Add a default attribute to the pattern if exists

* Use esc_attr instead of esc_html
This commit is contained in:
Alba Rincón 2023-06-15 16:07:47 +02:00 committed by GitHub
parent 1eebcd6750
commit e423c4fde9
1 changed files with 11 additions and 2 deletions

View File

@ -42,8 +42,17 @@
<h3><?php esc_html_e( 'Filter by attribute', 'woo-gutenberg-products-block' ); ?></h3>
<!-- /wp:heading -->
<!-- wp:woocommerce/attribute-filter {"heading":"","lock":{"remove":true}} -->
<div class="wp-block-woocommerce-attribute-filter is-loading" data-attribute-id="0" data-show-counts="true" data-query-type="or" data-heading="" data-heading-level="3"><span aria-hidden="true" class="wc-block-product-attribute-filter__placeholder"></span></div>
<?php
$attribute_id = 0;
$attributes = wc_get_attribute_taxonomies();
if ( ! empty( $attributes ) ) {
$attribute_id = reset( $attributes )->attribute_id;
}
?>
<!-- wp:woocommerce/attribute-filter {"attributeId":<?php echo esc_attr( $attribute_id ); ?>,"heading":"","lock":{"remove":true}} -->
<div class="wp-block-woocommerce-attribute-filter is-loading" data-attribute-id="<?php echo esc_attr( $attribute_id ); ?>" data-show-counts="true" data-query-type="or" data-heading="" data-heading-level="3"><span aria-hidden="true" class="wc-block-product-attribute-filter__placeholder"></span></div>
<!-- /wp:woocommerce/attribute-filter --></div>
<!-- /wp:woocommerce/filter-wrapper -->