<?php
$bosa_app_hub_promotion_oneID = get_theme_mod( 'bosa_app_hub_blog_promotion_one','');
$bosa_app_hub_promotion_DiscountoneLabel = get_theme_mod( 'bosa_app_hub_promotion_label_one', '');
$bosa_app_hub_promotion_twoID = get_theme_mod( 'bosa_app_hub_blog_promotion_two','');
$bosa_app_hub_promotion_DiscounttwoLabel = get_theme_mod( 'bosa_app_hub_promotion_label_two', '');
$bosa_app_hub_promotion_threeID = get_theme_mod( 'bosa_app_hub_blog_promotion_three','');
$bosa_app_hub_promotion_DiscountthreeLabel = get_theme_mod( 'bosa_app_hub_promotion_label_three', '');

$bosa_app_hub_promotion_Advert_array = array();
$bosa_app_hub_promotion_has_Advert = false;
$bosa_app_hub_promotion_has_label = false;


if( !empty( $bosa_app_hub_promotion_oneID  ) || !empty( $bosa_app_hub_promotion_DiscountoneLabel ) ){
	$bosa_app_hub_promotion_blog_advertisement_one = wp_get_attachment_image_src( $bosa_app_hub_promotion_oneID,'bosa-app-hub-590-310');
	if ( is_array(  $bosa_app_hub_promotion_blog_advertisement_one ) ){
		$bosa_app_hub_promotion_has_Advert = true;
		$bosa_app_hub_promotion_has_label = true;	
        $bosa_app_hub_promotion_blog_advertisements_one = $bosa_app_hub_promotion_blog_advertisement_one[0];
        $bosa_app_hub_promotion_Advert_array['image_one'] = array(
			'ID' => $bosa_app_hub_promotion_blog_advertisements_one,
			'discount_label' => $bosa_app_hub_promotion_DiscountoneLabel,
		);	
  	}
}

if( !empty( $bosa_app_hub_promotion_twoID  ) || !empty( $bosa_app_hub_promotion_DiscounttwoLabel ) ){
	$bosa_app_hub_promotion_blog_advertisement_two = wp_get_attachment_image_src( $bosa_app_hub_promotion_twoID,'bosa-app-hub-590-310');
	if ( is_array(  $bosa_app_hub_promotion_blog_advertisement_two ) ){
		$bosa_app_hub_promotion_has_Advert = true;
		$bosa_app_hub_promotion_has_label = true;	
        $bosa_app_hub_promotion_blog_advertisements_two = $bosa_app_hub_promotion_blog_advertisement_two[0];
        $bosa_app_hub_promotion_Advert_array['image_two'] = array(
			'ID' => $bosa_app_hub_promotion_blog_advertisements_two,
			'discount_label' => $bosa_app_hub_promotion_DiscounttwoLabel,
		);	
  	}
}
if( !empty( $bosa_app_hub_promotion_threeID ) || !empty( $bosa_app_hub_promotion_DiscountthreeLabel )){	
	$bosa_app_hub_promotion_blog_advertisement_three = wp_get_attachment_image_src( $bosa_app_hub_promotion_threeID,'bosa-app-hub-590-310');
	if ( is_array(  $bosa_app_hub_promotion_blog_advertisement_three ) ){
		$bosa_app_hub_promotion_has_Advert = true;
		$bosa_app_hub_promotion_has_label = true;
      	$bosa_app_hub_promotion_blog_advertisements_three = $bosa_app_hub_promotion_blog_advertisement_three[0];
      	$bosa_app_hub_promotion_Advert_array['image_three'] = array(
			'ID' => $bosa_app_hub_promotion_blog_advertisements_three,
			'discount_label' => $bosa_app_hub_promotion_DiscountthreeLabel,
		);	
  	}
}

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