<?php
$bosa_media_marketing_categoryproductoneID = get_theme_mod( 'bosa_media_marketing_product_image_one', '' );
$bosa_media_marketing_categoryproductone = get_theme_mod( 'bosa_media_marketing_product_category_one', '' );

$bosa_media_marketing_categoryproducttwoID = get_theme_mod( 'bosa_media_marketing_product_image_two', '' );
$bosa_media_marketing_categoryproducttwo = get_theme_mod( 'bosa_media_marketing_product_category_two', '' );

$bosa_media_marketing_categoryproductthreeID = get_theme_mod( 'bosa_media_marketing_product_image_three', '' );
$bosa_media_marketing_categoryproductthree = get_theme_mod( 'bosa_media_marketing_product_category_three', '' );

$bosa_media_marketing_categoryproductfourID = get_theme_mod( 'bosa_media_marketing_product_image_four', '' );
$bosa_media_marketing_categoryproductfour = get_theme_mod( 'bosa_media_marketing_product_category_four', '' );

$bosa_media_marketing_categoryproductfiveID = get_theme_mod( 'bosa_media_marketing_product_image_five', '' );
$bosa_media_marketing_categoryproductfive = get_theme_mod( 'bosa_media_marketing_product_category_five', '' );

$bosa_media_marketing_categoryproductsixID = get_theme_mod( 'bosa_media_marketing_product_image_six', '' );
$bosa_media_marketing_categoryproductsix = get_theme_mod( 'bosa_media_marketing_product_category_six', '' );

$bosa_media_marketing_categoryproductsevenID = get_theme_mod( 'bosa_media_marketing_product_image_seven', '' );
$bosa_media_marketing_categoryproductseven = get_theme_mod( 'bosa_media_marketing_product_category_seven', '' );

$bosa_media_marketing_categoryproducteightID = get_theme_mod( 'bosa_media_marketing_product_image_eight', '' );
$bosa_media_marketing_categoryproducteight = get_theme_mod( 'bosa_media_marketing_product_category_eight', '' );

$bosa_media_marketing_categoryproductnineID = get_theme_mod( 'bosa_media_marketing_product_image_nine', '' );
$bosa_media_marketing_categoryproductnine = get_theme_mod( 'bosa_media_marketing_product_category_nine', '' );


$bosa_media_marketing_category_product_one_array = array();
$bosa_media_marketing_category_product_two_array = array();
$bosa_media_marketing_category_product_three_array = array();
$bosa_media_marketing_has_product_one = false;
$bosa_media_marketing_has_product_two = false;
$bosa_media_marketing_has_product_three = false;
if( !empty( $bosa_media_marketing_categoryproductoneID ) || !empty( $bosa_media_marketing_categoryproductone ) ){
	$bosa_media_marketing_category_product_one = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductoneID ,'bosa-media-marketing-1370-550');
 	if ( is_array( $bosa_media_marketing_category_product_one ) ){
 		$bosa_media_marketing_has_product_one = true;
   	 	$bosa_media_marketing_category_products_one = $bosa_media_marketing_category_product_one[0];
   	 	$bosa_media_marketing_category_product_one_array['image_one'] ['ID'] = $bosa_media_marketing_category_products_one;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductone ) ){
 		$bosa_media_marketing_has_product_one = true;
   	 	$bosa_media_marketing_category_product_one_array['image_one']['category'] = $bosa_media_marketing_categoryproductone;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproducttwoID ) || !empty( $bosa_media_marketing_categoryproducttwo ) ){
	$bosa_media_marketing_category_product_two = wp_get_attachment_image_src( $bosa_media_marketing_categoryproducttwoID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_two ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_products_two = $bosa_media_marketing_category_product_two[0];
   	 	$bosa_media_marketing_category_product_two_array['image_two'] ['ID'] = $bosa_media_marketing_category_products_two;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproducttwo ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_product_two_array['image_two']['category'] = $bosa_media_marketing_categoryproducttwo;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductthreeID ) || !empty( $bosa_media_marketing_categoryproductthree ) ){
	$bosa_media_marketing_category_product_three = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductthreeID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_three ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_products_three = $bosa_media_marketing_category_product_three[0];
   	 	$bosa_media_marketing_category_product_two_array['image_three'] ['ID'] = $bosa_media_marketing_category_products_three;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductthree ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_product_two_array['image_three']['category'] = $bosa_media_marketing_categoryproductthree;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductfourID ) || !empty( $bosa_media_marketing_categoryproductfour ) ){
	$bosa_media_marketing_category_product_four = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductfourID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_four ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_products_four = $bosa_media_marketing_category_product_four[0];
   	 	$bosa_media_marketing_category_product_two_array['image_four'] ['ID'] = $bosa_media_marketing_category_products_four;	 	
  	}
  	if ( !empty($bosa_media_marketing_categoryproductfour) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_product_two_array['image_four']['category'] = $bosa_media_marketing_categoryproductfour;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductfiveID ) || !empty( $bosa_media_marketing_categoryproductfive ) ){
	$bosa_media_marketing_category_product_five = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductfiveID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_five ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_products_five = $bosa_media_marketing_category_product_five[0];
   	 	$bosa_media_marketing_category_product_two_array['image_five'] ['ID'] = $bosa_media_marketing_category_products_five;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductfive ) ){
 		$bosa_media_marketing_has_product_two = true;
   	 	$bosa_media_marketing_category_product_two_array['image_five']['category'] = $bosa_media_marketing_categoryproductfive;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductsixID ) || !empty( $bosa_media_marketing_categoryproductsix ) ){
	$bosa_media_marketing_category_product_six = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductsixID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_six ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_products_six = $bosa_media_marketing_category_product_six[0];
   	 	$bosa_media_marketing_category_product_three_array['image_six'] ['ID'] = $bosa_media_marketing_category_products_six;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductsix ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_product_three_array['image_six']['category'] = $bosa_media_marketing_categoryproductsix;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductsevenID ) || !empty( $bosa_media_marketing_categoryproductseven ) ){
	$bosa_media_marketing_category_product_seven = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductsevenID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_seven ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_products_seven = $bosa_media_marketing_category_product_seven[0];
   	 	$bosa_media_marketing_category_product_three_array['image_seven'] ['ID'] = $bosa_media_marketing_category_products_seven;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductseven ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_product_three_array['image_seven']['category'] = $bosa_media_marketing_categoryproductseven;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproducteightID ) || !empty( $bosa_media_marketing_categoryproducteight ) ){
	$bosa_media_marketing_category_product_eight = wp_get_attachment_image_src( $bosa_media_marketing_categoryproducteightID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_eight ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_products_eight = $bosa_media_marketing_category_product_eight[0];
   	 	$bosa_media_marketing_category_product_three_array['image_eight'] ['ID'] = $bosa_media_marketing_category_products_eight;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproducteight ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_product_three_array['image_eight']['category'] = $bosa_media_marketing_categoryproducteight;	
  	}
}
if( !empty( $bosa_media_marketing_categoryproductnineID ) || !empty( $bosa_media_marketing_categoryproductnine ) ){
	$bosa_media_marketing_category_product_nine = wp_get_attachment_image_src( $bosa_media_marketing_categoryproductnineID ,'bosa-media-marketing-420-300');
 	if ( is_array( $bosa_media_marketing_category_product_nine ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_products_nine = $bosa_media_marketing_category_product_nine[0];
   	 	$bosa_media_marketing_category_product_three_array['image_nine'] ['ID'] = $bosa_media_marketing_category_products_nine;	 	
  	}
  	if ( !empty( $bosa_media_marketing_categoryproductnine ) ){
 		$bosa_media_marketing_has_product_three = true;
   	 	$bosa_media_marketing_category_product_three_array['image_nine']['category'] = $bosa_media_marketing_categoryproductnine;	
  	}
}

$bosa_media_marketing_product_cat = bosa_media_marketing_get_product_categories();

if( !get_theme_mod( 'bosa_media_marketing_disable_product_category_section', true ) && ( $bosa_media_marketing_has_product_one || $bosa_media_marketing_has_product_two || $bosa_media_marketing_has_product_three || get_theme_mod( 'bosa_media_marketing_product_category_title_one' ) || get_theme_mod( 'bosa_media_marketing_product_category_title_two' ) || get_theme_mod( 'bosa_media_marketing_product_category_title_three' ) ) ){ ?>
	<section class="section-product-category-area">
		<div class="row">
			<?php if( $bosa_media_marketing_has_product_one || get_theme_mod( 'bosa_media_marketing_product_category_title_one' ) ){ ?>
				<div class="col-md-12 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_media_marketing_product_category_title_one' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_media_marketing_product_category_title_one' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_media_marketing_category_product_one_array as $bosa_media_marketing_each_categoryproductone ){ ?>
									<div class="col-sm-12">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_media_marketing_each_categoryproductone['ID'] ) && !empty( $bosa_media_marketing_each_categoryproductone['ID'] ) ){
												$bosa_media_marketing_cat_url = '';
												if( isset( $bosa_media_marketing_each_categoryproductone['category'] ) && !empty( $bosa_media_marketing_each_categoryproductone['category'] ) ) {
													$bosa_media_marketing_cat_url = $bosa_media_marketing_each_categoryproductone['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_media_marketing_each_categoryproductone['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_media_marketing_each_categoryproductone['category'] ) && !empty( $bosa_media_marketing_each_categoryproductone['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_each_categoryproductone ['category'] ) ); ?>">
														<?php echo esc_html($bosa_media_marketing_product_cat[$bosa_media_marketing_each_categoryproductone['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_media_marketing_has_product_two || get_theme_mod( 'bosa_media_marketing_product_category_title_two' ) ){ ?>
				<div class="col-md-6 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_media_marketing_product_category_title_two' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_media_marketing_product_category_title_two' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row flex-row-container">
								<?php foreach( $bosa_media_marketing_category_product_two_array as $bosa_media_marketing_each_categoryproducttwo ){ ?>
									<div class="col-sm-6 px-lg-2 flex-col-container">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_media_marketing_each_categoryproducttwo['ID'] ) && !empty( $bosa_media_marketing_each_categoryproducttwo['ID'] ) ){
												$bosa_media_marketing_cat_url = '';
												if( isset( $bosa_media_marketing_each_categoryproducttwo['category'] ) && !empty( $bosa_media_marketing_each_categoryproducttwo['category'] ) ) {
													$bosa_media_marketing_cat_url = $bosa_media_marketing_each_categoryproducttwo['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_media_marketing_each_categoryproducttwo['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_media_marketing_each_categoryproducttwo['category'] ) && !empty( $bosa_media_marketing_each_categoryproducttwo['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_each_categoryproducttwo ['category'] ) ); ?>">
														<?php echo esc_html($bosa_media_marketing_product_cat[$bosa_media_marketing_each_categoryproducttwo['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_media_marketing_has_product_three || get_theme_mod( 'bosa_media_marketing_product_category_title_three' ) ){ ?>
				<div class="col-md-6 col-lg-4">
					<div class="category-wraper">
						<?php if( get_theme_mod( 'bosa_media_marketing_product_category_title_three' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_media_marketing_product_category_title_three' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row flex-row-container">
								<?php foreach( $bosa_media_marketing_category_product_three_array as $bosa_media_marketing_each_categoryproductthree ){ ?>
									<div class="col-sm-6 px-lg-2 flex-col-container">
										<article class="category-content-wrap">
											<?php 
											if ( isset( $bosa_media_marketing_each_categoryproductthree['ID'] ) && !empty( $bosa_media_marketing_each_categoryproductthree['ID'] ) ){
												$bosa_media_marketing_cat_url = '';
												if( isset( $bosa_media_marketing_each_categoryproductthree['category'] ) && !empty( $bosa_media_marketing_each_categoryproductthree['category'] ) ) {
													$bosa_media_marketing_cat_url = $bosa_media_marketing_each_categoryproductthree['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_media_marketing_each_categoryproductthree['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_media_marketing_each_categoryproductthree['category'] ) && !empty( $bosa_media_marketing_each_categoryproductthree['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_media_marketing_each_categoryproductthree ['category'] ) ); ?>">
														<?php echo esc_html($bosa_media_marketing_product_cat[$bosa_media_marketing_each_categoryproductthree['category'] ] ); ?>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</section>
<?php } ?>

