<?php
$bosa_garden_care_product_segment_one_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_one', '' );
$bosa_garden_care_product_segment_one = get_theme_mod( 'bosa_garden_care_product_item_one', '' );

$bosa_garden_care_product_segment_two_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_two', '' );
$bosa_garden_care_product_segment_two = get_theme_mod( 'bosa_garden_care_product_item_two', '' );

$bosa_garden_care_product_segment_three_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_three', '' );
$bosa_garden_care_product_segment_three = get_theme_mod( 'bosa_garden_care_product_item_three', '' );

$bosa_garden_care_product_segment_four_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_four', '' );
$bosa_garden_care_product_segment_four = get_theme_mod( 'bosa_garden_care_product_item_four', '' );

$bosa_garden_care_product_segment_five_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_five', '' );
$bosa_garden_care_product_segment_five = get_theme_mod( 'bosa_garden_care_product_item_five', '' );

$bosa_garden_care_product_segment_six_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_six', '' );
$bosa_garden_care_product_segment_six = get_theme_mod( 'bosa_garden_care_product_item_six', '' );

$bosa_garden_care_product_segment_seven_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_seven', '' );
$bosa_garden_care_product_segment_seven = get_theme_mod( 'bosa_garden_care_product_item_seven', '' );

$bosa_garden_care_product_segment_eight_ID = get_theme_mod( 'bosa_garden_care_blog_product_image_eight', '' );
$bosa_garden_care_product_segment_eight = get_theme_mod( 'bosa_garden_care_product_item_eight', '' );

$bosa_garden_care_product_item_one_array = array();
$bosa_garden_care_product_item_two_array = array();
$bosa_garden_care_has_list_one = false;
$bosa_garden_care_has_list_two = false;
if( !empty( $bosa_garden_care_product_segment_one_ID ) || !empty( $bosa_garden_care_product_segment_one ) ){
	$bosa_garden_care_product_item_one = wp_get_attachment_image_src( $bosa_garden_care_product_segment_one_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_one ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_items_one = $bosa_garden_care_product_item_one[0];
   	 	$bosa_garden_care_product_item_one_array['image_one'] ['ID'] = $bosa_garden_care_product_items_one;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_one ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_item_one_array['image_one']['category'] = $bosa_garden_care_product_segment_one;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_two_ID ) || !empty( $bosa_garden_care_product_segment_two ) ){
	$bosa_garden_care_product_item_two = wp_get_attachment_image_src( $bosa_garden_care_product_segment_two_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_two ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_items_two = $bosa_garden_care_product_item_two[0];
   	 	$bosa_garden_care_product_item_one_array['image_two'] ['ID'] = $bosa_garden_care_product_items_two;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_two ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_item_one_array['image_two']['category'] = $bosa_garden_care_product_segment_two;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_three_ID ) || !empty( $bosa_garden_care_product_segment_three ) ){
	$bosa_garden_care_product_item_three = wp_get_attachment_image_src( $bosa_garden_care_product_segment_three_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_three ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_items_three = $bosa_garden_care_product_item_three[0];
   	 	$bosa_garden_care_product_item_one_array['image_three'] ['ID'] = $bosa_garden_care_product_items_three;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_three ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_item_one_array['image_three']['category'] = $bosa_garden_care_product_segment_three;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_four_ID ) || !empty( $bosa_garden_care_product_segment_four ) ){
	$bosa_garden_care_product_item_four = wp_get_attachment_image_src( $bosa_garden_care_product_segment_four_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_four ) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_items_four = $bosa_garden_care_product_item_four[0];
   	 	$bosa_garden_care_product_item_one_array['image_four'] ['ID'] = $bosa_garden_care_product_items_four;	 	
  	}
  	if ( !empty($bosa_garden_care_product_segment_four) ){
 		$bosa_garden_care_has_list_one = true;
   	 	$bosa_garden_care_product_item_one_array['image_four']['category'] = $bosa_garden_care_product_segment_four;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_five_ID ) || !empty( $bosa_garden_care_product_segment_five ) ){
	$bosa_garden_care_product_item_five = wp_get_attachment_image_src( $bosa_garden_care_product_segment_five_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_five ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_items_five = $bosa_garden_care_product_item_five[0];
   	 	$bosa_garden_care_product_item_two_array['image_five'] ['ID'] = $bosa_garden_care_product_items_five;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_five ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_item_two_array['image_five']['category'] = $bosa_garden_care_product_segment_five;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_six_ID ) || !empty( $bosa_garden_care_product_segment_six ) ){
	$bosa_garden_care_product_item_six = wp_get_attachment_image_src( $bosa_garden_care_product_segment_six_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_six ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_items_six = $bosa_garden_care_product_item_six[0];
   	 	$bosa_garden_care_product_item_two_array['image_six'] ['ID'] = $bosa_garden_care_product_items_six;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_six ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_item_two_array['image_six']['category'] = $bosa_garden_care_product_segment_six;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_seven_ID ) || !empty( $bosa_garden_care_product_segment_seven ) ){
	$bosa_garden_care_product_item_seven = wp_get_attachment_image_src( $bosa_garden_care_product_segment_seven_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_seven ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_items_seven = $bosa_garden_care_product_item_seven[0];
   	 	$bosa_garden_care_product_item_two_array['image_seven'] ['ID'] = $bosa_garden_care_product_items_seven;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_seven ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_item_two_array['image_seven']['category'] = $bosa_garden_care_product_segment_seven;	
  	}
}
if( !empty( $bosa_garden_care_product_segment_eight_ID ) || !empty( $bosa_garden_care_product_segment_eight ) ){
	$bosa_garden_care_product_item_eight = wp_get_attachment_image_src( $bosa_garden_care_product_segment_eight_ID ,'bosa-garden-care-420-300');
 	if ( is_array( $bosa_garden_care_product_item_eight ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_items_eight = $bosa_garden_care_product_item_eight[0];
   	 	$bosa_garden_care_product_item_two_array['image_eight'] ['ID'] = $bosa_garden_care_product_items_eight;	 	
  	}
  	if ( !empty( $bosa_garden_care_product_segment_eight ) ){
 		$bosa_garden_care_has_list_two = true;
   	 	$bosa_garden_care_product_item_two_array['image_eight']['category'] = $bosa_garden_care_product_segment_eight;	
  	}
}

$bosa_garden_care_product_cat = bosa_garden_care_get_post_categories();

if( !get_theme_mod( 'bosa_garden_care_disable_best_product_items_section', true ) && ( $bosa_garden_care_has_list_one || $bosa_garden_care_has_list_two || get_theme_mod( 'bosa_garden_care_product_title_one' ) || get_theme_mod( 'bosa_garden_care_product_title_two' ) ) ){ ?>
	<section class="section-product-segment-area">
		<div class="row">
			<?php if( $bosa_garden_care_has_list_one || get_theme_mod( 'bosa_garden_care_product_title_one' ) ){ ?>
				<div class="col-lg-6 px-lg-4">
					<div class="category-section">
						<?php if( get_theme_mod( 'bosa_garden_care_product_title_one' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_garden_care_product_title_one' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_garden_care_product_item_one_array as $bosa_garden_care_each_productlistone ){ ?>
									<div class="col-sm-6">
										<article class="product-segment-content-wrap">
											<?php 
											if ( isset( $bosa_garden_care_each_productlistone['ID'] ) && !empty( $bosa_garden_care_each_productlistone['ID'] ) ){
												$bosa_garden_care_cat_url = '';
												if( isset( $bosa_garden_care_each_productlistone['category'] ) && !empty( $bosa_garden_care_each_productlistone['category'] ) ) {
													$bosa_garden_care_cat_url = $bosa_garden_care_each_productlistone['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_garden_care_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_garden_care_each_productlistone['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_garden_care_each_productlistone['category'] ) && !empty( $bosa_garden_care_each_productlistone['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_garden_care_each_productlistone ['category'] ) ); ?>">
														<?php echo esc_html($bosa_garden_care_product_cat[$bosa_garden_care_each_productlistone['category'] ] ); ?>
														<i class="fas fa-external-link"></i>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_garden_care_has_list_two || get_theme_mod( 'bosa_garden_care_product_title_two' ) ){ ?>
				<div class="col-lg-6 px-lg-4">
					<div class="category-section">
						<?php if( get_theme_mod( 'bosa_garden_care_product_title_two' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="product-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_garden_care_product_title_two' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_garden_care_product_item_two_array as $bosa_garden_care_each_productlisttwo ){ ?>
									<div class="col-sm-6">
										<article class="product-segment-content-wrap">
											<?php 
											if ( isset( $bosa_garden_care_each_productlisttwo['ID'] ) && !empty( $bosa_garden_care_each_productlisttwo['ID'] ) ){
												$bosa_garden_care_cat_url = '';
												if( isset( $bosa_garden_care_each_productlisttwo['category'] ) && !empty( $bosa_garden_care_each_productlisttwo['category'] ) ) {
													$bosa_garden_care_cat_url = $bosa_garden_care_each_productlisttwo['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_garden_care_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_garden_care_each_productlisttwo['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_garden_care_each_productlisttwo['category'] ) && !empty( $bosa_garden_care_each_productlisttwo['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_garden_care_each_productlisttwo ['category'] ) ); ?>">
														<?php echo esc_html($bosa_garden_care_product_cat[$bosa_garden_care_each_productlisttwo['category'] ] ); ?>
														<i class="fas fa-external-link"></i>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</section>
<?php }

