<?php
/**
 * Featured Groups Shortcode View
 *
 * @package Northmill_Webshop_Theme
 */

defined( 'ABSPATH' ) || exit;

/**
 * View parameters.
 *
 * @var array $params
 */

?>
<div class="mf-light-featured-groups">
	<h2 class="has-text-align-center"><?php echo esc_html( $params['title'] ); ?></h2>
	<div style="height:10px" aria-hidden="true" class="wp-block-spacer"></div>
	<div class="mf-light-featured-groups__row">
		<?php
		foreach ( $params['terms'] as $group_term ) {
			$term_id    = $group_term->term_id;
			$group_term = get_term( $term_id, 'product_cat' );
			$thumbnail  = get_term_meta( $term_id, 'thumbnail_id', true );
			?>
			<div class="mf-light-featured-groups__col">
				<?php
				echo $thumbnail
					? wp_get_attachment_image(
						$thumbnail,
						array( 1500, 800 ),
						false,
						array(
							'class'           => 'mf-light-featured-groups__image-background',
							'loading'         => 'lazy',
							'data-object-fit' => 'cover',
						)
					)
					: wc_placeholder_img(
						array( 1500, 800 ),
						array(
							'class'           => 'mf-light-featured-groups__image-background',
							'loading'         => 'lazy',
							'data-object-fit' => 'cover',
						)
					)
				?>
				<div class="mf-light-featured-groups__inner-container">
					<a href="<?php echo esc_attr( get_term_link( $group_term ) ); ?>" class="mf-light-featured-groups__link"><span class="mf-light-featured-groups__link__inner"><?php echo esc_html( $group_term->name ); ?></span></a>
				</div>
			</div>
			<?php
		}
		?>
	</div>
</div>
