<?php
/* Template Name: Active Filters shortcode */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

?>
<?php if ( ! empty( $args_request ) ) : ?>
<div class="prodigy-filter__main prodigy-filter__main-active prodigy-custom-template active-filter-js">
	<div class="prodigy-filter__main-title-wrap position-relative">
		<p class="prodigy-filter__title prodigy-active-filter__title"><?php echo esc_html( $heading_active_filter, 'prodigy-commerce' ); ?></p>
		<span class="prodigy-main-badge__md">
			<button class="prodigy-main-badge prodigy-main-badge--btn clear-params-js" aria-label="<?php esc_html_e( 'Clear all active filters', 'prodigy-commerce' ); ?>"
					type="button"><?php esc_html_e( 'Clear All', 'prodigy-commerce' ); ?></button>
		</span>
	</div>
	<?php endif; ?>
	<div class="prodigy-filter__badges" role="list" aria-label="<?php esc_attr_e( 'Active filters', 'prodigy-commerce' ); ?>">
		<?php foreach ( $args_request ?? array() as $attribute => $value ) : ?>
			<?php foreach ( $value as $key => $values ) : ?>
				<?php foreach ( $values as $attr ) : ?>
					<span class="prodigy-main-badge" data-attribute-id="<?php echo esc_attr( $key ); ?>"
							role="listitem"
							data-attribute-name="<?php echo esc_attr( $attr['name'] ); ?>"
							data-attribute-slug="<?php echo esc_attr( $attr['slug'] ); ?>">
								<span class="prodigy-main-badge__text">
								<?php if ( ! empty( $is_show_active_filter_name ) ) : ?>
									<span class="prodigy-main-badge__inner-wrap">
										<span class="prodigy-main-badge__attr"><?php echo esc_attr( $key === 'Price' ? $key . ':' : $attribute . ':' ); ?></span>
										<span class="prodigy-main-badge__val"><?php echo esc_attr( $attr['name'] ); ?></span>
									</span>
								<?php else : ?>
									<span class="prodigy-main-badge__val"><?php echo esc_attr( $attr['name'] ); ?></span>
								<?php endif; ?>
									<button class="prodigy-main-badge__close icon icon-close filter-close-js"
										<?php /* translators: %s: filter attribute name */ ?>
										aria-label="<?php echo esc_attr( sprintf( __( 'Remove filter %s', 'prodigy-commerce' ), $attr['name'] ) ); ?>"
										data-filter-nonce="<?php echo esc_attr( $filter_nonce ); ?>"
										type="button">
											<?php /* translators: %s: filter attribute name */ ?>
											<span class="prodigy-visually-hidden"><?php echo esc_html( sprintf( __( 'Remove filter %s', 'prodigy-commerce' ), $attr['name'] ) ); ?></span>
									</button>
								</span>
								<span class="prodigy-main-badge__divider" aria-hidden="true"></span>
							</span>
				<?php endforeach; ?>
			<?php endforeach; ?>
		<?php endforeach; ?>
	</div>

	<?php if ( ! empty( $args_request ) ) : ?>
</div>
<?php endif; ?>
