<?php
$bosa_startup_business_promotion_oneID = get_theme_mod( 'bosa_startup_business_blog_promotion_one','');
$bosa_startup_business_promotion_DiscountoneLabel = get_theme_mod( 'bosa_startup_business_promotion_label_one', '');
$bosa_startup_business_promotion_twoID = get_theme_mod( 'bosa_startup_business_blog_promotion_two','');
$bosa_startup_business_promotion_DiscounttwoLabel = get_theme_mod( 'bosa_startup_business_promotion_label_two', '');
$bosa_startup_business_promotion_threeID = get_theme_mod( 'bosa_startup_business_blog_promotion_three','');
$bosa_startup_business_promotion_DiscountthreeLabel = get_theme_mod( 'bosa_startup_business_promotion_label_three', '');

$bosa_startup_business_promotion_Advert_array = array();
$bosa_startup_business_promotion_has_Advert = false;
$bosa_startup_business_promotion_has_label = false;


if( !empty( $bosa_startup_business_promotion_oneID  ) || !empty( $bosa_startup_business_promotion_DiscountoneLabel ) ){
	$bosa_startup_business_promotion_blog_advertisement_one = wp_get_attachment_image_src( $bosa_startup_business_promotion_oneID,'bosa-startup-business-590-310');
	if ( is_array(  $bosa_startup_business_promotion_blog_advertisement_one ) ){
		$bosa_startup_business_promotion_has_Advert = true;
		$bosa_startup_business_promotion_has_label = true;	
        $bosa_startup_business_promotion_blog_advertisements_one = $bosa_startup_business_promotion_blog_advertisement_one[0];
        $bosa_startup_business_promotion_Advert_array['image_one'] = array(
			'ID' => $bosa_startup_business_promotion_blog_advertisements_one,
			'discount_label' => $bosa_startup_business_promotion_DiscountoneLabel,
		);	
  	}
}

if( !empty( $bosa_startup_business_promotion_twoID  ) || !empty( $bosa_startup_business_promotion_DiscounttwoLabel ) ){
	$bosa_startup_business_promotion_blog_advertisement_two = wp_get_attachment_image_src( $bosa_startup_business_promotion_twoID,'bosa-startup-business-590-310');
	if ( is_array(  $bosa_startup_business_promotion_blog_advertisement_two ) ){
		$bosa_startup_business_promotion_has_Advert = true;
		$bosa_startup_business_promotion_has_label = true;	
        $bosa_startup_business_promotion_blog_advertisements_two = $bosa_startup_business_promotion_blog_advertisement_two[0];
        $bosa_startup_business_promotion_Advert_array['image_two'] = array(
			'ID' => $bosa_startup_business_promotion_blog_advertisements_two,
			'discount_label' => $bosa_startup_business_promotion_DiscounttwoLabel,
		);	
  	}
}
if( !empty( $bosa_startup_business_promotion_threeID ) || !empty( $bosa_startup_business_promotion_DiscountthreeLabel )){	
	$bosa_startup_business_promotion_blog_advertisement_three = wp_get_attachment_image_src( $bosa_startup_business_promotion_threeID,'bosa-startup-business-590-310');
	if ( is_array(  $bosa_startup_business_promotion_blog_advertisement_three ) ){
		$bosa_startup_business_promotion_has_Advert = true;
		$bosa_startup_business_promotion_has_label = true;
      	$bosa_startup_business_promotion_blog_advertisements_three = $bosa_startup_business_promotion_blog_advertisement_three[0];
      	$bosa_startup_business_promotion_Advert_array['image_three'] = array(
			'ID' => $bosa_startup_business_promotion_blog_advertisements_three,
			'discount_label' => $bosa_startup_business_promotion_DiscountthreeLabel,
		);	
  	}
}

if( !get_theme_mod( 'bosa_startup_business_disable_promotions_section', true ) && $bosa_startup_business_promotion_has_Advert && $bosa_startup_business_promotion_has_label ){ ?>
	<section class="section-promotion-area">
		<div class="content-wrap">
			<div class="row justify-content-center">
				<?php foreach( $bosa_startup_business_promotion_Advert_array as $bosa_startup_business_promotion_each_Advert ){ ?>
					<div class="col-sm-6 col-md-4">
						<article class="promotion-content-wrap">
							<figure class= "featured-image">
								<?php
									if( !empty( $bosa_startup_business_promotion_each_Advert['discount_label'] ) ) { ?>
										<span class="overlay-txt">
											<?php
												echo esc_html( $bosa_startup_business_promotion_each_Advert['discount_label'] );
											?>
										</span>
									<?php } ?>
								<img src="<?php echo esc_url( $bosa_startup_business_promotion_each_Advert['ID'] ); ?>">
							</figure>
						</article>
					</div>
				<?php } ?>
			</div>	
		</div>
	</section>
<?php } 