<?php
$bosa_it_services_topdealone 	= get_theme_mod('bosa_it_services_top_deal_one','');
$bosa_it_services_topdealoneID 	= get_theme_mod('bosa_it_services_top_deals_image_one','');

$bosa_it_services_topdealtwo 	= get_theme_mod('bosa_it_services_top_deal_two','');
$bosa_it_services_topdealtwoID 	= get_theme_mod('bosa_it_services_top_deals_image_two','');

$bosa_it_services_topdealthree 	= get_theme_mod('bosa_it_services_top_deal_three','');
$bosa_it_services_topdealthreeID = get_theme_mod('bosa_it_services_top_deals_image_three','');

$bosa_it_services_topdealfour 	= get_theme_mod('bosa_it_services_top_deal_four','');
$bosa_it_services_topdealfourID 	= get_theme_mod('bosa_it_services_top_deals_image_four','');

$bosa_it_services_topdealfive 	= get_theme_mod('bosa_it_services_top_deal_five','');
$bosa_it_services_topdealfiveID 	= get_theme_mod('bosa_it_services_top_deals_image_five','');


$bosa_it_services_topdeal_array = array();
$bosa_it_services_has_topdeal = false;
if( !empty( $bosa_it_services_topdealoneID ) || !empty($bosa_it_services_topdealone) ){
	$bosa_it_services_top_deal_one  = wp_get_attachment_image_src( $bosa_it_services_topdealoneID,'bosa-it-services-590-310' );
 	if ( is_array(  $bosa_it_services_top_deal_one ) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_top_deals_one = $bosa_it_services_top_deal_one[0];
   	 	$bosa_it_services_topdeal_array['image_one']['ID'] = $bosa_it_services_top_deals_one;
  	}
  	if ( !empty($bosa_it_services_topdealone) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_topdeal_array['image_one']['category'] =  $bosa_it_services_topdealone;	
  	}
}
if( !empty( $bosa_it_services_topdealtwoID ) || !empty($bosa_it_services_topdealtwo) ){
	$bosa_it_services_top_deal_two = wp_get_attachment_image_src( $bosa_it_services_topdealtwoID,'bosa-it-services-590-310' );
	if ( is_array(  $bosa_it_services_top_deal_two ) ){
		$bosa_it_services_has_topdeal = true;	
        $bosa_it_services_top_deals_two = $bosa_it_services_top_deal_two[0];
        $bosa_it_services_topdeal_array['image_two']['ID'] = $bosa_it_services_top_deals_two;	
  	}
  	if ( !empty($bosa_it_services_topdealtwo) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_topdeal_array['image_two']['category'] =  $bosa_it_services_topdealtwo;	
  	}
}
if( !empty( $bosa_it_services_topdealthreeID ) || !empty($bosa_it_services_topdealthree) ){
	$bosa_it_services_top_deal_three = wp_get_attachment_image_src( $bosa_it_services_topdealthreeID,'bosa-it-services-590-310' );
	if ( is_array(  $bosa_it_services_top_deal_three ) ){
		$bosa_it_services_has_topdeal = true;	
        $bosa_it_services_top_deals_three = $bosa_it_services_top_deal_three[0];
        $bosa_it_services_topdeal_array['image_three']['ID'] = $bosa_it_services_top_deals_three;		
  	}
  	if ( !empty($bosa_it_services_topdealthree) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_topdeal_array['image_three']['category'] =  $bosa_it_services_topdealthree;	
  	}
}

if( !empty( $bosa_it_services_topdealfourID ) || !empty($bosa_it_services_topdealfour) ){	
	$bosa_it_services_top_deal_four = wp_get_attachment_image_src( $bosa_it_services_topdealfourID,'bosa-it-services-590-310' );
	if ( is_array(  $bosa_it_services_top_deal_four ) ){
		$bosa_it_services_has_topdeal = true;
      	$bosa_it_services_top_deals_four = $bosa_it_services_top_deal_four[0];
      	$bosa_it_services_topdeal_array['image_four']['ID'] = $bosa_it_services_top_deals_four;		
  	}
  	if ( !empty($bosa_it_services_topdealfour) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_topdeal_array['image_four']['category'] =  $bosa_it_services_topdealfour;	
  	}
}

if( !empty( $bosa_it_services_topdealfiveID ) || !empty($bosa_it_services_topdealfive) ){	
	$bosa_it_services_top_deal_five = wp_get_attachment_image_src( $bosa_it_services_topdealfiveID,'bosa-it-services-590-310' );
	if ( is_array(  $bosa_it_services_top_deal_five ) ){
		$bosa_it_services_has_topdeal = true;
      	$bosa_it_services_top_deals_five = $bosa_it_services_top_deal_five[0];
      	$bosa_it_services_topdeal_array['image_five']['ID'] = $bosa_it_services_top_deals_five;	
  	}
  	if ( !empty($bosa_it_services_topdealfive) ){
 		$bosa_it_services_has_topdeal = true;
   	 	$bosa_it_services_topdeal_array['image_five']['category'] =  $bosa_it_services_topdealfive;	
  	}
}

if( !get_theme_mod( 'bosa_it_services_disable_top_deals_section', true ) && $bosa_it_services_has_topdeal ){ ?>
	<section class="section-top-deal-area">
		<div class="content-wrap">
			<?php foreach( $bosa_it_services_topdeal_array as $bosa_it_services_each_topdeal ){ ?>
				<article class="deal-content-wrap">
					<?php if ( isset( $bosa_it_services_each_topdeal['ID'] ) && !empty( $bosa_it_services_each_topdeal['ID'] ) ){ ?>
						<figure class= "featured-image">
							<img src="<?php echo esc_url( $bosa_it_services_each_topdeal['ID'] ); ?>">
						</figure>
					<?php } ?>
					<?php if ( isset( $bosa_it_services_each_topdeal['category'] ) && !empty( $bosa_it_services_each_topdeal['category'] ) ){ ?>
						<h5 class="entry-title">
							<a href="<?php echo esc_url( get_category_link( $bosa_it_services_each_topdeal ['category'] ) ); ?>">
									<?php echo esc_html(get_cat_name( $bosa_it_services_each_topdeal ['category'] ) ); ?>
								<i class="fas fa-arrow-right right-arrow"></i>
							</a>	
						</h5>
					<?php } ?>
				</article>
			<?php } ?>
		</div>
	</section>
<?php } 
