<?php
$bosa_preschool_campaignone = get_theme_mod('bosa_preschool_campaign_one','');
$bosa_preschool_campaignoneID = get_theme_mod('bosa_preschool_campaign_image_one','');

$bosa_preschool_campaigntwo = get_theme_mod('bosa_preschool_campaign_two','');
$bosa_preschool_campaigntwoID = get_theme_mod('bosa_preschool_campaign_image_two','');

$bosa_preschool_campaignthree = get_theme_mod('bosa_preschool_campaign_three','');
$bosa_preschool_campaignthreeID = get_theme_mod('bosa_preschool_campaign_image_three','');

$bosa_preschool_campaignfour = get_theme_mod('bosa_preschool_campaign_four','');
$bosa_preschool_campaignfourID = get_theme_mod('bosa_preschool_campaign_image_four','');

$bosa_preschool_campaignfive = get_theme_mod('bosa_preschool_campaign_five','');
$bosa_preschool_campaignfiveID = get_theme_mod('bosa_preschool_campaign_image_five','');

$bosa_preschool_campaignsix = get_theme_mod('bosa_preschool_campaign_six','');
$bosa_preschool_campaignsixID = get_theme_mod('bosa_preschool_campaign_image_six','');


$bosa_preschool_campaign_array = array();
$bosa_preschool_has_campaign = false;
if( !empty( $bosa_preschool_campaignoneID ) || !empty($bosa_preschool_campaignone) ){
	$bosa_preschool_campaign_one  = wp_get_attachment_image_src( $bosa_preschool_campaignoneID,'bosa-preschool-590-310' );
 	if ( is_array(  $bosa_preschool_campaign_one ) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_one = $bosa_preschool_campaign_one[0];
   	 	$bosa_preschool_campaign_array['image_one']['ID'] = $bosa_preschool_campaign_one;
  	}
  	if ( !empty($bosa_preschool_campaignone) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_one']['category'] =  $bosa_preschool_campaignone;	
  	}
}
if( !empty( $bosa_preschool_campaigntwoID ) || !empty($bosa_preschool_campaigntwo) ){
	$bosa_preschool_campaign_two = wp_get_attachment_image_src( $bosa_preschool_campaigntwoID,'bosa-preschool-590-310' );
	if ( is_array(  $bosa_preschool_campaign_two ) ){
		$bosa_preschool_has_campaign = true;	
        $bosa_preschool_campaign_two = $bosa_preschool_campaign_two[0];
        $bosa_preschool_campaign_array['image_two']['ID'] = $bosa_preschool_campaign_two;	
  	}
  	if ( !empty($bosa_preschool_campaigntwo) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_two']['category'] =  $bosa_preschool_campaigntwo;	
  	}
}
if( !empty( $bosa_preschool_campaignthreeID ) || !empty($bosa_preschool_campaignthree) ){
	$bosa_preschool_campaign_three = wp_get_attachment_image_src( $bosa_preschool_campaignthreeID,'bosa-preschool-590-310' );
	if ( is_array(  $bosa_preschool_campaign_three ) ){
		$bosa_preschool_has_campaign = true;	
        $bosa_preschool_campaign_three = $bosa_preschool_campaign_three[0];
        $bosa_preschool_campaign_array['image_three']['ID'] = $bosa_preschool_campaign_three;		
  	}
  	if ( !empty($bosa_preschool_campaignthree) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_three']['category'] =  $bosa_preschool_campaignthree;	
  	}
}

if( !empty( $bosa_preschool_campaignfourID ) || !empty($bosa_preschool_campaignfour) ){	
	$bosa_preschool_campaign_four = wp_get_attachment_image_src( $bosa_preschool_campaignfourID,'bosa-preschool-590-310' );
	if ( is_array(  $bosa_preschool_campaign_four ) ){
		$bosa_preschool_has_campaign = true;
      	$bosa_preschool_campaign_four = $bosa_preschool_campaign_four[0];
      	$bosa_preschool_campaign_array['image_four']['ID'] = $bosa_preschool_campaign_four;		
  	}
  	if ( !empty($bosa_preschool_campaignfour) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_four']['category'] =  $bosa_preschool_campaignfour;	
  	}
}

if( !empty( $bosa_preschool_campaignfiveID ) || !empty($bosa_preschool_campaignfive) ){	
	$bosa_preschool_campaign_five = wp_get_attachment_image_src( $bosa_preschool_campaignfiveID,'bosa-preschool-590-310' );
	if ( is_array(  $bosa_preschool_campaign_five ) ){
		$bosa_preschool_has_campaign = true;
      	$bosa_preschool_campaign_five = $bosa_preschool_campaign_five[0];
      	$bosa_preschool_campaign_array['image_five']['ID'] = $bosa_preschool_campaign_five;	
  	}
  	if ( !empty($bosa_preschool_campaignfive) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_five']['category'] =  $bosa_preschool_campaignfive;	
  	}
}

if( !empty( $bosa_preschool_campaignsixID ) || !empty($bosa_preschool_campaignsix) ){	
	$bosa_preschool_campaign_six = wp_get_attachment_image_src( $bosa_preschool_campaignsixID,'bosa-preschool-590-310' );
	if ( is_array(  $bosa_preschool_campaign_six ) ){
		$bosa_preschool_has_campaign = true;
      	$bosa_preschool_campaign_six = $bosa_preschool_campaign_six[0];
      	$bosa_preschool_campaign_array['image_six']['ID'] = $bosa_preschool_campaign_six;	
  	}
  	if ( !empty($bosa_preschool_campaignfive) ){
 		$bosa_preschool_has_campaign = true;
   	 	$bosa_preschool_campaign_array['image_six']['category'] =  $bosa_preschool_campaignfive;	
  	}
}

if( !get_theme_mod( 'bosa_preschool_disable_campaign_section', true ) && $bosa_preschool_has_campaign ){ ?>
	<section class="section-campaign-area">
		<div class="content-wrap">
			<?php foreach( $bosa_preschool_campaign_array as $bosa_preschool_each_campaign ){ ?>
				<article class="campaign-content-wrap">
					<?php if ( isset( $bosa_preschool_each_campaign['ID'] ) && !empty( $bosa_preschool_each_campaign['ID'] ) ){ ?>
						<figure class= "featured-image">
							<img src="<?php echo esc_url( $bosa_preschool_each_campaign['ID'] ); ?>">
						</figure>
					<?php } ?>
					<?php if ( isset( $bosa_preschool_each_campaign['category'] ) && !empty( $bosa_preschool_each_campaign['category'] ) ){ ?>
						<h5 class="entry-title">
							<a href="<?php echo esc_url( get_category_link( $bosa_preschool_each_campaign ['category'] ) ); ?>">
								<?php echo esc_html(get_cat_name( $bosa_preschool_each_campaign ['category'] ) ); ?>
							</a>	
						</h5>
					<?php } ?>
				</article>
			<?php } ?>
		</div>
	</section>
<?php } 
