<?php
$bosa_handyman_services_promotion_oneID = get_theme_mod( 'bosa_handyman_services_blog_promotion_one','');
$bosa_handyman_services_promotion_DiscountoneLabel = get_theme_mod( 'bosa_handyman_services_promotion_label_one', '');
$bosa_handyman_services_promotion_twoID = get_theme_mod( 'bosa_handyman_services_blog_promotion_two','');
$bosa_handyman_services_promotion_DiscounttwoLabel = get_theme_mod( 'bosa_handyman_services_promotion_label_two', '');
$bosa_handyman_services_promotion_threeID = get_theme_mod( 'bosa_handyman_services_blog_promotion_three','');
$bosa_handyman_services_promotion_DiscountthreeLabel = get_theme_mod( 'bosa_handyman_services_promotion_label_three', '');

$bosa_handyman_services_promotion_Advert_array = array();
$bosa_handyman_services_promotion_has_Advert = false;
$bosa_handyman_services_promotion_has_label = false;


if( !empty( $bosa_handyman_services_promotion_oneID  ) || !empty( $bosa_handyman_services_promotion_DiscountoneLabel ) ){
	$bosa_handyman_services_promotion_blog_advertisement_one = wp_get_attachment_image_src( $bosa_handyman_services_promotion_oneID,'bosa-handyman_services-590-310');
	if ( is_array(  $bosa_handyman_services_promotion_blog_advertisement_one ) ){
		$bosa_handyman_services_promotion_has_Advert = true;
		$bosa_handyman_services_promotion_has_label = true;	
        $bosa_handyman_services_promotion_blog_advertisements_one = $bosa_handyman_services_promotion_blog_advertisement_one[0];
        $bosa_handyman_services_promotion_Advert_array['image_one'] = array(
			'ID' => $bosa_handyman_services_promotion_blog_advertisements_one,
			'discount_label' => $bosa_handyman_services_promotion_DiscountoneLabel,
		);	
  	}
}

if( !empty( $bosa_handyman_services_promotion_twoID  ) || !empty( $bosa_handyman_services_promotion_DiscounttwoLabel ) ){
	$bosa_handyman_services_promotion_blog_advertisement_two = wp_get_attachment_image_src( $bosa_handyman_services_promotion_twoID,'bosa-handyman_services-590-310');
	if ( is_array(  $bosa_handyman_services_promotion_blog_advertisement_two ) ){
		$bosa_handyman_services_promotion_has_Advert = true;
		$bosa_handyman_services_promotion_has_label = true;	
        $bosa_handyman_services_promotion_blog_advertisements_two = $bosa_handyman_services_promotion_blog_advertisement_two[0];
        $bosa_handyman_services_promotion_Advert_array['image_two'] = array(
			'ID' => $bosa_handyman_services_promotion_blog_advertisements_two,
			'discount_label' => $bosa_handyman_services_promotion_DiscounttwoLabel,
		);	
  	}
}
if( !empty( $bosa_handyman_services_promotion_threeID ) || !empty( $bosa_handyman_services_promotion_DiscountthreeLabel )){	
	$bosa_handyman_services_promotion_blog_advertisement_three = wp_get_attachment_image_src( $bosa_handyman_services_promotion_threeID,'bosa-handyman_services-590-310');
	if ( is_array(  $bosa_handyman_services_promotion_blog_advertisement_three ) ){
		$bosa_handyman_services_promotion_has_Advert = true;
		$bosa_handyman_services_promotion_has_label = true;
      	$bosa_handyman_services_promotion_blog_advertisements_three = $bosa_handyman_services_promotion_blog_advertisement_three[0];
      	$bosa_handyman_services_promotion_Advert_array['image_three'] = array(
			'ID' => $bosa_handyman_services_promotion_blog_advertisements_three,
			'discount_label' => $bosa_handyman_services_promotion_DiscountthreeLabel,
		);	
  	}
}

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