<?php
$bosa_bakery_blogcodeoneID 		= get_theme_mod( 'bosa_bakery_blog_code_one','');
$bosa_bakery_blogcodetwoID 		= get_theme_mod( 'bosa_bakery_blog_code_two','');       
$bosa_bakery_blogcodethreeID 	= get_theme_mod( 'bosa_bakery_blog_code_three','');
$bosa_bakery_blogcodefourID 	= get_theme_mod( 'bosa_bakery_blog_code_four','');

$bosa_bakery_codes_array = array();
$bosa_bakery_has_codes = false;
if( !empty( $bosa_bakery_blogcodeoneID ) ){
	$bosa_bakery_blog_code_one  = wp_get_attachment_image_src( $bosa_bakery_blogcodeoneID,'bosa-bakery-420-300');
 	if ( is_array(  $bosa_bakery_blog_code_one ) ){
 		$bosa_bakery_has_codes = true;
   	 	$bosa_bakery_blog_codes_one = $bosa_bakery_blog_code_one[0];
   	 	$bosa_bakery_codes_array['image_one'] = array(
			'ID' => $bosa_bakery_blog_codes_one,
		);	
  	}
}
if( !empty( $bosa_bakery_blogcodetwoID ) ){
	$bosa_bakery_blog_code_two = wp_get_attachment_image_src( $bosa_bakery_blogcodetwoID,'bosa-bakery-420-300');
	if ( is_array(  $bosa_bakery_blog_code_two ) ){
		$bosa_bakery_has_codes = true;	
        $bosa_bakery_blog_codes_two = $bosa_bakery_blog_code_two[0];
        $bosa_bakery_codes_array['image_two'] = array(
			'ID' => $bosa_bakery_blog_codes_two,
		);	
  	}
}
if( !empty( $bosa_bakery_blogcodethreeID ) ){	
	$bosa_bakery_blog_code_three = wp_get_attachment_image_src( $bosa_bakery_blogcodethreeID,'bosa-bakery-420-300');
	if ( is_array(  $bosa_bakery_blog_code_three ) ){
		$bosa_bakery_has_codes = true;
      	$bosa_bakery_blog_codes_three = $bosa_bakery_blog_code_three[0];
      	$bosa_bakery_codes_array['image_three'] = array(
			'ID' => $bosa_bakery_blog_codes_three,
		);	
  	}
}
if( !empty( $bosa_bakery_blogcodefourID ) ){	
	$bosa_bakery_blog_code_four = wp_get_attachment_image_src( $bosa_bakery_blogcodefourID,'bosa-bakery-420-300');
	if ( is_array(  $bosa_bakery_blog_code_four ) ){
		$bosa_bakery_has_codes = true;
      	$bosa_bakery_blog_codes_four = $bosa_bakery_blog_code_four[0];
      	$bosa_bakery_codes_array['image_four'] = array(
			'ID' => $bosa_bakery_blog_codes_four,
		);	
  	}
}

if( !get_theme_mod( 'bosa_bakery_disable_redemption_codes_section', true ) && $bosa_bakery_has_codes ){ ?>
	<section class="section-redemption-code-area">
		<div class="content-wrap">
			<div class="row">
				<?php foreach( $bosa_bakery_codes_array as $bosa_bakery_each_codes ){ ?>
					<div class="col-md-3 col-sm-6">
						<article class="code-content-wrap">
							<figure class= "featured-image">
								<img src="<?php echo esc_url( $bosa_bakery_each_codes['ID'] ); ?>">
							</figure>
						</article>
					</div>
				<?php } ?>
			</div>	
		</div>
	</section>
<?php } 