<?php 
/**
 * WCFM Vendors Template
 */
?>
<div id="<?php echo esc_attr($id); ?>" class="<?php echo esc_attr( $class ); ?>">
	<div class="<?php echo esc_attr( $wrapper ); ?>">
		<div class="pls-vendors-list <?php echo esc_attr( $grid_class ); ?>" <?php if( ! empty( $slider_options ) ){ echo 'data-slider_options="'.esc_attr( $slider_options ).'"';  } ?> >
			<?php
			global $WCFM, $WCFMmp;
			foreach ( $vendors as $key => $vendor_id ) {
				$store_user      = wcfmmp_get_store( $vendor_id );
				$store_info      = $store_user->get_shop_info();
				$gravatar        = $store_user->get_avatar();
				$store_name      = isset( $store_info['store_name'] ) ? esc_html( $store_info['store_name'] ) : __( 'N/A', 'anvogue-core' );
				$store_name     = apply_filters( 'wcfmmp_store_title', $store_name , $vendor_id );
				$store_url      = wcfmmp_get_store_url( $vendor_id );
				$store_address  = $store_user->get_address_string(); 
				$store_phone	= isset( $store_info['phone'] ) ? $store_info['phone'] : '';
				$banner         = $store_user->get_list_banner();
				$has_bg_class 	= isset( $banner ) ? "has-vendor-image" : '';
				if( $banner ) {
					$store_banner_url = $banner;
				}else{
					$banner = isset( $WCFMmp->wcfmmp_marketplace_options['store_list_default_banner'] ) ? $WCFMmp->wcfmmp_marketplace_options['store_list_default_banner'] : $WCFMmp->plugin_url . 'assets/images/default_banner.jpg';
					$store_banner_url = apply_filters( 'wcfmmp_list_store_default_bannar', $banner );
				} ?>
				<div class="pls-single-vendor woocommerce<?php echo esc_attr( $column_class ); ?>">
					<div class="pls-vendor-wrapper">
						<div class="pls-vendor-content <?php echo esc_attr($has_bg_class);?>" style="background-image: url( '<?php echo is_array( $store_banner_url ) ? esc_attr( $store_banner_url[0] ) : esc_attr( $store_banner_url ); ?>');">
							<div class="pls-store-data">
								<h2><?php echo esc_html( $store_name ); ?></h2>
								<div class="pls-store-rating">
									<div class="star-rating">
										<?php $store_user->show_star_rating(); ?>
									</div>
								</div>
								
								<?php if ( $store_address || $store_phone ){ ?>
									<ul class="pls-store-info">
										<?php if ( $store_address ){
											$allowed_tags = array(
												'span' => array(
													'class' => array(),
												),
												'br' => array()
											); ?>
											<li class="store-address"><?php echo wp_kses( $store_address, $allowed_tags ); ?></li>
										<?php } ?>
										
										<?php if ( $store_phone ) { ?>
											<li class="store-phone"><?php echo esc_html( $store_phone ); ?></li>
										<?php } ?>
									</ul>
								<?php } ?>
							</div>
						</div>
						<div class="pls-vendor-footer">
							<div class="pls-vendor-avatar">
								<img src="<?php echo esc_url($gravatar); ?>" alt="<?php esc_html_e( 'Logo', 'anvogue-core' ); ?>"/>
							</div>
							<a class="button pls-store-link" href="<?php echo esc_attr( $store_url ); ?>"><?php esc_html_e( 'Visit Store', 'anvogue-core' )?></a>
						</div>
					</div>
				</div>	
			<?php } ?>
		</div>
	</div>
</div>