<?php 
/**
 * Featured Products Template
 */
?>
<div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
	<div class="section-content">
		<div class="pls-featured-products-wrap">
			<div class="pls-featured-products-content">
				<div class="pls-featured-products-heading">
					<h3 class="pls-section-heading"><?php echo wp_kses_post( $title ); ?></h3>
					<div class="pls-section-tagline"><?php echo esc_html( $title_tagline ); ?></div>
				</div>
				<div class="pls-featured-products-list">
					<?php
					global $post, $product;
					$global_post    = $post;
					$global_product = $product;
					$i = 0;
					$active_tab = 1;
					while ( $query->have_posts() ) {
						$i++;
						$query->the_post();
						$image_output	= '';
						$product_id 	= $query->post->ID;
						$product 		= wc_get_product( $product_id );
						$active_class		= '';
						if ( $i == $active_tab ){
							$active_class = ' active';
						}
						if( $product ){
							echo '<div class="pls-featured-product-title'.esc_attr( $active_class ).'" data-index="'.esc_attr($i).'">';
								echo $product->get_title();
								echo '<div class="link-arrow">';
									echo '<span>'.esc_html__( 'More', 'modave-core' ).'</span>';
								echo '</div>';
							echo '</div>';
						}
					} ?>
				</div>
				<?php if( $show_view_more_button ){ ?>
					<div class="pls-featured-products-view-all-btn">			
						<div class="view-all-btn">
							<a <?php echo implode( ' ', $view_all_btn ); ?> ><?php echo esc_html( $view_more_button_text ); ?></a>
						</div>			
					</div>
				<?php } ?>
			</div>
			<div class="pls-featured-products-items">
				<?php
				$i = 0;
				while ( $query->have_posts() ) {
					$i++;
					$active_class	= '';
					if ( $i == $active_tab ){
						$active_class = 'active';
					}
					$query->the_post();
					$image_output	= '';
					$product_id 	= $query->post->ID;
					$product 		= wc_get_product( $product_id );
					$post      		= get_post( $product_id );
					if( $product ){ ?>
						<div class="pls-featured-product product pls-featured-product-<?php echo esc_attr($i).' '.esc_attr( $active_class ); ?>" data-index="<?php echo esc_attr($i); ?>">
							<div class="pls-featured-product-image">
								<div class="pls-product-labels">
									<?php pls_wc_product_widget_sale_label(); ?>
								</div>
								<a href="<?php echo esc_url( $product->get_permalink() ); ?>">
									<?php echo pls_get_post_thumbnail( 'woocommerce_single' ); // PHPCS:Ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
								</a>
							</div>
							<div class="pls-featured-product-info">
								<div class="pls-featured-product-title-price">
									<a class="product-title" href="<?php echo esc_url( $product->get_permalink() ); ?>">
										<?php echo wp_kses_post( $product->get_name() ); ?>
									</a>
									<span class="price">
										<?php echo wp_kses_post( $product->get_price_html() ); // PHPCS:Ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
									</span>
								</div>
								<div class="pls-featured-product-button">
									<?php pls_wc_product_loop_quick_view_button('button'); ?>
								</div>
							</div>
						</div>
					<?php
					}
				} ?>
			</div>
			<?php
			wp_reset_postdata();
			pls_reset_loop();
			$post    = $global_post;
			$product = $global_product; 
			?>
		</div>
	</div>
</div>