<?php 
/**
 * Testimonials Template
 */
 if( 'style-6' != $style ) { ?>
<div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
	<div class="section-content <?php echo $section_class; ?>">	
		<div class="<?php echo $slider_class; ?>" <?php if(!empty( $slider_options ) ){ echo 'data-slider_options="'.esc_attr( $slider_options ).'"';  } ?> >
			<?php foreach( $testimonials_items as $client_data ) {
				$testimonial_args = $client_data;
				$testimonial_args['id'] 			= pls_uniqid( 'pls-testimonial-client-' );
				$testimonial_args['style'] 			= $style;
				$testimonial_args['image'] 			= '';
				$testimonial_args['product_image'] 	= '';
				if( $client_data['rating'] == 'none' ){
					$testimonial_args['rating'] = 0;
				}else{
					$testimonial_args['rating']		= 100 * $client_data['rating'] / 5;
				}
				
				if( ! empty( $client_data['image']['id'] ) ){
					$image_output 		= wp_get_attachment_image( $client_data['image']['id'],  $avatar_img_size, false );
					$testimonial_args['image'] 		= $image_output;
				}elseif( ! empty( $client_data['image']['url'] ) ){
					$testimonial_args['image'] 		= '<img src="'.$client_data['image']['url'].'"/>';
				}
				
				if( ! empty( $client_data['product_image']['id'] ) ){
					$image_output 		= wp_get_attachment_image( $client_data['product_image']['id'],  $product_img_size, false );
					$testimonial_args['product_image'] 		= $image_output;
				}elseif( ! empty( $client_data['product_image']['url'] ) ){
					$testimonial_args['product_image'] 		= '<img src="'.$client_data['product_image']['url'].'"/>';
				}
				$testimonial_args['has_product'] = false;
				if( ! empty( $client_data['product_id'] ) ){ 
				$product 	= wc_get_product( $client_data['product_id']  ); 
					if( !empty( $product ) ) {
						$testimonial_args['has_product'] = true;
						$testimonial_args['product_id'] = $client_data['product_id'];
						$testimonial_args['product_link'] = get_permalink( $client_data['product_id'] );
						$testimonial_args['product_thumbnail'] = $product->get_image( 'thumbnail' );
						$testimonial_args['product_title'] = $product->get_title();
						$testimonial_args['product_price'] = $product->get_price_html();
					}
				}
				pls_core_get_templates( 'elements-widgets/testimonials/'.$style, $testimonial_args );
			} ?>
		</div>
	</div>
</div>
<?php } else { 
	$images = array(); ?>
	<div id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
		<div class="section-content pls-section-slider">
			<div class="pls-content-slider swiper">
				<div class="<?php echo $slider_class; ?>">
					<?php foreach( $testimonials_items as $client_data ) {
						$testimonial_args = $client_data;
						$testimonial_args['id'] 			= pls_uniqid( 'pls-testimonial-client-' );
						$testimonial_args['style'] 			= $style;
						$testimonial_args['image'] 			= '';
						$testimonial_args['product_image'] 	= '';
						if( $client_data['rating'] == 'none' ){
							$testimonial_args['rating'] = 0;
						}else{
							$testimonial_args['rating']		= 100 * $client_data['rating'] / 5;
						}
						
						if( ! empty( $client_data['image']['id'] ) ){
							$image_output 		= wp_get_attachment_image( $client_data['image']['id'],  $avatar_img_size, false );
							$testimonial_args['image'] 		= $image_output;
						}elseif( ! empty( $client_data['image']['url'] ) ){
							$testimonial_args['image'] 		= '<img src="'.$client_data['image']['url'].'"/>';
						}
						$images[] = '<div class="swiper-slide">'.$testimonial_args['image'].'</div>';
						
						if( ! empty( $client_data['product_image']['id'] ) ){
							$image_output 		= wp_get_attachment_image( $client_data['product_image']['id'],  $product_img_size, false );
							$testimonial_args['product_image'] 		= $image_output;
						}elseif( ! empty( $client_data['product_image']['url'] ) ){
							$testimonial_args['product_image'] 		= '<img src="'.$client_data['product_image']['url'].'"/>';
						}					
						pls_core_get_templates( 'elements-widgets/testimonials/'.$style, $testimonial_args );
					} ?>
				</div>
				<div class="pls-slider-navigation">
					<div class="pls-slider-prev"></div>
					<div class="pls-slider-next"></div>
				</div>
			</div>
			<?php if( ! empty( $images ) ){ ?>
				<div class="pls-content-thumb-slider swiper" >
					<div class="swiper-wrapper">
						<?php echo implode( '', $images ); ?>
					</div>
				</div>
			<?php }	?>
		</div>
	</div>
<?php }