<?php
$bosa_event_organizer_event_destination_title  = get_theme_mod( 'bosa_event_organizer_event_destination_title', '' );
$bosa_event_organizer_page_one 	= get_theme_mod( 'bosa_event_organizer_blog_event_destination_page_one', '' );
$bosa_event_organizer_page_two 	= get_theme_mod( 'bosa_event_organizer_blog_event_destination_page_two', '' );
$bosa_event_organizer_page_three = get_theme_mod( 'bosa_event_organizer_blog_event_destination_page_three', '' );
$bosa_event_organizer_page_four  = get_theme_mod( 'bosa_event_organizer_blog_event_destination_page_four', '' );


$bosa_event_organizer_page_array = array();
$bosa_event_organizer_has_page = false;
$bosa_event_organizer_has_array = false;

if( !empty( $bosa_event_organizer_event_destination_title ) ){
	$bosa_event_organizer_has_page = true;
}

if( !empty( $bosa_event_organizer_page_one ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_has_array = true;
	$bosa_event_organizer_page_array['page_one'] = array(
		'ID' => $bosa_event_organizer_page_one,
	);
}
if( !empty( $bosa_event_organizer_page_two ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_has_array = true;
	$bosa_event_organizer_page_array['page_two'] = array(
		'ID' => $bosa_event_organizer_page_two,
	);
}
if( !empty( $bosa_event_organizer_page_three ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_has_array = true;
	$bosa_event_organizer_page_array['page_three'] = array(
		'ID' => $bosa_event_organizer_page_three,
	);
}
if( !empty( $bosa_event_organizer_page_four ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_has_array = true;
	$bosa_event_organizer_page_array['page_four'] = array(
		'ID' => $bosa_event_organizer_page_four,
	);
}

if( !get_theme_mod( 'bosa_event_organizer_disable_event_destination_section', true ) && $bosa_event_organizer_has_page ){ ?>
	<section class="section-event-destination-area">		
			<div class="section-title-wrap text-center col-lg-6 offset-lg-3 col-md-8 offset-md-2">
				<h2 class="event-section-title">
					<?php echo esc_html( $bosa_event_organizer_event_destination_title ); ?>					
				</h2>
			</div>
		<?php
		if ( $bosa_event_organizer_has_array ){ ?>
			<div class="row justify-content-center">
				<?php foreach( $bosa_event_organizer_page_array as $bosa_event_organizer_each_page ){ ?>
					<div class="col-sm-6">
						<div class="event-wrapper">
							<article class="event-iconbox">
								<figure class="featured-image">
									<?php echo get_the_post_thumbnail( $bosa_event_organizer_each_page[ 'ID' ], 'bosa-event-organizer-1370-550' ); ?>
								</figure>
								<div class="entry-content">
									<h3 class="entry-title">
										<a href="<?php echo esc_url( get_permalink( $bosa_event_organizer_each_page[ 'ID' ] ) ); ?>">
											<?php echo esc_html( get_the_title( $bosa_event_organizer_each_page[ 'ID' ] ) ); ?>
										</a>
									</h3>
									<div class="entry-text">
										<?php 
										$bosa_event_organizer_excerpt = get_the_excerpt( $bosa_event_organizer_each_page[ 'ID' ] );
										$bosa_event_organizer_result  = wp_trim_words( $bosa_event_organizer_excerpt, 10, '' );
										echo esc_html( $bosa_event_organizer_result );
										?>
									</div>
									<a href="<?php echo esc_url( get_permalink( $bosa_event_organizer_each_page[ 'ID' ] ) ); ?>" class="event-page-link">
										<?php echo esc_html__( 'Learn More...', 'bosa-event-organizer' ); ?>
									</a>
								</div>
							</article>
						</div>
					</div>
				<?php } ?>
			</div>
		<?php } ?>
	</section>	
<?php }