<?php
$bosa_event_organizer_past_event_one_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_one', '' );
$bosa_event_organizer_past_event_one = get_theme_mod( 'bosa_event_organizer_event_list_one', '' );

$bosa_event_organizer_past_event_two_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_two', '' );
$bosa_event_organizer_past_event_two = get_theme_mod( 'bosa_event_organizer_event_list_two', '' );

$bosa_event_organizer_past_event_three_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_three', '' );
$bosa_event_organizer_past_event_three = get_theme_mod( 'bosa_event_organizer_event_list_three', '' );

$bosa_event_organizer_past_event_four_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_four', '' );
$bosa_event_organizer_past_event_four = get_theme_mod( 'bosa_event_organizer_event_list_four', '' );

$bosa_event_organizer_past_event_five_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_five', '' );
$bosa_event_organizer_past_event_five = get_theme_mod( 'bosa_event_organizer_event_list_five', '' );

$bosa_event_organizer_past_event_six_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_six', '' );
$bosa_event_organizer_past_event_six = get_theme_mod( 'bosa_event_organizer_event_list_six', '' );

$bosa_event_organizer_past_event_seven_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_seven', '' );
$bosa_event_organizer_past_event_seven = get_theme_mod( 'bosa_event_organizer_event_list_seven', '' );

$bosa_event_organizer_past_event_eight_ID = get_theme_mod( 'bosa_event_organizer_blog_event_image_eight', '' );
$bosa_event_organizer_past_event_eight = get_theme_mod( 'bosa_event_organizer_event_list_eight', '' );

$bosa_event_organizer_event_list_one_array = array();
$bosa_event_organizer_event_list_two_array = array();
$bosa_event_organizer_has_list_one = false;
$bosa_event_organizer_has_list_two = false;
if( !empty( $bosa_event_organizer_past_event_one_ID ) || !empty( $bosa_event_organizer_past_event_one ) ){
	$bosa_event_organizer_event_list_one = wp_get_attachment_image_src( $bosa_event_organizer_past_event_one_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_one ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_lists_one = $bosa_event_organizer_event_list_one[0];
   	 	$bosa_event_organizer_event_list_one_array['image_one'] ['ID'] = $bosa_event_organizer_event_lists_one;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_one ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_list_one_array['image_one']['category'] = $bosa_event_organizer_past_event_one;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_two_ID ) || !empty( $bosa_event_organizer_past_event_two ) ){
	$bosa_event_organizer_event_list_two = wp_get_attachment_image_src( $bosa_event_organizer_past_event_two_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_two ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_lists_two = $bosa_event_organizer_event_list_two[0];
   	 	$bosa_event_organizer_event_list_one_array['image_two'] ['ID'] = $bosa_event_organizer_event_lists_two;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_two ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_list_one_array['image_two']['category'] = $bosa_event_organizer_past_event_two;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_three_ID ) || !empty( $bosa_event_organizer_past_event_three ) ){
	$bosa_event_organizer_event_list_three = wp_get_attachment_image_src( $bosa_event_organizer_past_event_three_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_three ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_lists_three = $bosa_event_organizer_event_list_three[0];
   	 	$bosa_event_organizer_event_list_one_array['image_three'] ['ID'] = $bosa_event_organizer_event_lists_three;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_three ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_list_one_array['image_three']['category'] = $bosa_event_organizer_past_event_three;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_four_ID ) || !empty( $bosa_event_organizer_past_event_four ) ){
	$bosa_event_organizer_event_list_four = wp_get_attachment_image_src( $bosa_event_organizer_past_event_four_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_four ) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_lists_four = $bosa_event_organizer_event_list_four[0];
   	 	$bosa_event_organizer_event_list_one_array['image_four'] ['ID'] = $bosa_event_organizer_event_lists_four;	 	
  	}
  	if ( !empty($bosa_event_organizer_past_event_four) ){
 		$bosa_event_organizer_has_list_one = true;
   	 	$bosa_event_organizer_event_list_one_array['image_four']['category'] = $bosa_event_organizer_past_event_four;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_five_ID ) || !empty( $bosa_event_organizer_past_event_five ) ){
	$bosa_event_organizer_event_list_five = wp_get_attachment_image_src( $bosa_event_organizer_past_event_five_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_five ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_lists_five = $bosa_event_organizer_event_list_five[0];
   	 	$bosa_event_organizer_event_list_two_array['image_five'] ['ID'] = $bosa_event_organizer_event_lists_five;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_five ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_list_two_array['image_five']['category'] = $bosa_event_organizer_past_event_five;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_six_ID ) || !empty( $bosa_event_organizer_past_event_six ) ){
	$bosa_event_organizer_event_list_six = wp_get_attachment_image_src( $bosa_event_organizer_past_event_six_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_six ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_lists_six = $bosa_event_organizer_event_list_six[0];
   	 	$bosa_event_organizer_event_list_two_array['image_six'] ['ID'] = $bosa_event_organizer_event_lists_six;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_six ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_list_two_array['image_six']['category'] = $bosa_event_organizer_past_event_six;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_seven_ID ) || !empty( $bosa_event_organizer_past_event_seven ) ){
	$bosa_event_organizer_event_list_seven = wp_get_attachment_image_src( $bosa_event_organizer_past_event_seven_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_seven ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_lists_seven = $bosa_event_organizer_event_list_seven[0];
   	 	$bosa_event_organizer_event_list_two_array['image_seven'] ['ID'] = $bosa_event_organizer_event_lists_seven;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_seven ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_list_two_array['image_seven']['category'] = $bosa_event_organizer_past_event_seven;	
  	}
}
if( !empty( $bosa_event_organizer_past_event_eight_ID ) || !empty( $bosa_event_organizer_past_event_eight ) ){
	$bosa_event_organizer_event_list_eight = wp_get_attachment_image_src( $bosa_event_organizer_past_event_eight_ID ,'bosa-event-organizer-420-300');
 	if ( is_array( $bosa_event_organizer_event_list_eight ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_lists_eight = $bosa_event_organizer_event_list_eight[0];
   	 	$bosa_event_organizer_event_list_two_array['image_eight'] ['ID'] = $bosa_event_organizer_event_lists_eight;	 	
  	}
  	if ( !empty( $bosa_event_organizer_past_event_eight ) ){
 		$bosa_event_organizer_has_list_two = true;
   	 	$bosa_event_organizer_event_list_two_array['image_eight']['category'] = $bosa_event_organizer_past_event_eight;	
  	}
}

$bosa_event_organizer_event_cat = bosa_event_organizer_get_post_categories();

if( !get_theme_mod( 'bosa_event_organizer_disable_past_events_section', true ) && ( $bosa_event_organizer_has_list_one || $bosa_event_organizer_has_list_two || get_theme_mod( 'bosa_event_organizer_event_list_title_one' ) || get_theme_mod( 'bosa_event_organizer_event_list_title_two' ) ) ){ ?>
	<section class="section-event-segment-area">
		<div class="row">
			<?php if( $bosa_event_organizer_has_list_one || get_theme_mod( 'bosa_event_organizer_event_list_title_one' ) ){ ?>
				<div class="col-lg-6 px-lg-4">
					<div class="category-section">
						<?php if( get_theme_mod( 'bosa_event_organizer_event_list_title_one' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="event-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_event_organizer_event_list_title_one' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_event_organizer_event_list_one_array as $bosa_event_organizer_each_eventlistone ){ ?>
									<div class="col-sm-6">
										<article class="event-segment-content-wrap">
											<?php 
											if ( isset( $bosa_event_organizer_each_eventlistone['ID'] ) && !empty( $bosa_event_organizer_each_eventlistone['ID'] ) ){
												$bosa_event_organizer_cat_url = '';
												if( isset( $bosa_event_organizer_each_eventlistone['category'] ) && !empty( $bosa_event_organizer_each_eventlistone['category'] ) ) {
													$bosa_event_organizer_cat_url = $bosa_event_organizer_each_eventlistone['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_event_organizer_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_event_organizer_each_eventlistone['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_event_organizer_each_eventlistone['category'] ) && !empty( $bosa_event_organizer_each_eventlistone['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_event_organizer_each_eventlistone ['category'] ) ); ?>">
														<?php echo esc_html($bosa_event_organizer_event_cat[$bosa_event_organizer_each_eventlistone['category'] ] ); ?>
														<i class="fas fa-external-link"></i>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php if( $bosa_event_organizer_has_list_two || get_theme_mod( 'bosa_event_organizer_event_list_title_two' ) ){ ?>
				<div class="col-lg-6 px-lg-4">
					<div class="category-section">
						<?php if( get_theme_mod( 'bosa_event_organizer_event_list_title_two' ) ){ ?>
							<div class="section-title-wrap">
								<h2 class="event-section-title">	
									<?php echo esc_html( get_theme_mod( 'bosa_event_organizer_event_list_title_two' ) ); ?>
								</h2>
							</div>
						<?php } ?>
						<div class="content-wrap">
							<div class="row">
								<?php foreach( $bosa_event_organizer_event_list_two_array as $bosa_event_organizer_each_eventlisttwo ){ ?>
									<div class="col-sm-6">
										<article class="event-segment-content-wrap">
											<?php 
											if ( isset( $bosa_event_organizer_each_eventlisttwo['ID'] ) && !empty( $bosa_event_organizer_each_eventlisttwo['ID'] ) ){
												$bosa_event_organizer_cat_url = '';
												if( isset( $bosa_event_organizer_each_eventlisttwo['category'] ) && !empty( $bosa_event_organizer_each_eventlisttwo['category'] ) ) {
													$bosa_event_organizer_cat_url = $bosa_event_organizer_each_eventlisttwo['category'];
												}
											?>
												<figure class= "featured-image">
													<a href="<?php echo esc_url( get_category_link( $bosa_event_organizer_cat_url ) ); ?>">
														<img src="<?php echo esc_url( $bosa_event_organizer_each_eventlisttwo['ID'] ); ?>">
													</a>	
												</figure>
											<?php } ?>
											<?php if ( isset( $bosa_event_organizer_each_eventlisttwo['category'] ) && !empty( $bosa_event_organizer_each_eventlisttwo['category'] ) ){ ?>
												<h5 class="entry-title">
													<a href="<?php echo esc_url( get_category_link( $bosa_event_organizer_each_eventlisttwo ['category'] ) ); ?>">
														<?php echo esc_html($bosa_event_organizer_event_cat[$bosa_event_organizer_each_eventlisttwo['category'] ] ); ?>
														<i class="fas fa-external-link"></i>
													</a>	
												</h5>
											<?php } ?>
										</article>	
									</div>
								<?php } ?>
							</div>
						</div>
					</div>
				</div>
			<?php } ?>
		</div>
	</section>
<?php }

