<?php
$bosa_event_organizer_page_one 	= get_theme_mod( 'bosa_event_organizer_services_page_one', '' );
$bosa_event_organizer_page_two 	= get_theme_mod( 'bosa_event_organizer_services_page_two', '' );
$bosa_event_organizer_page_three	= get_theme_mod( 'bosa_event_organizer_services_page_three', '' );
$bosa_event_organizer_page_four	= get_theme_mod( 'bosa_event_organizer_services_page_four', '' );
$bosa_event_organizer_page_five	= get_theme_mod( 'bosa_event_organizer_services_page_five', '' );
$bosa_event_organizer_page_six	= get_theme_mod( 'bosa_event_organizer_services_page_six', '' );

$bosa_event_organizer_page_array = array();
$bosa_event_organizer_has_page = false;
if( !empty( $bosa_event_organizer_page_one ) ){
	$bosa_event_organizer_has_page = 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_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_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_page_array['page_four'] = array(
		'ID' => $bosa_event_organizer_page_four,
	);
}
if( !empty( $bosa_event_organizer_page_five ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_page_array['page_five'] = array(
		'ID' => $bosa_event_organizer_page_five,
	);
}
if( !empty( $bosa_event_organizer_page_six ) ){
	$bosa_event_organizer_has_page = true;
	$bosa_event_organizer_page_array['page_six'] = array(
		'ID' => $bosa_event_organizer_page_six,
	);
}

if( !get_theme_mod( 'bosa_event_organizer_disable_services_section', true ) && $bosa_event_organizer_has_page ){ ?>
	<section class="section-services-area">
		<div class="row">
			<?php foreach( $bosa_event_organizer_page_array as $bosa_event_organizer_each_page ){ ?>
				<div class="col-md-6 col-lg-4">
					<article class="services-content-wrap">
						<figure class="featured-image">
							<?php echo get_the_post_thumbnail( $bosa_event_organizer_each_page[ 'ID' ], 'bosa-event-organizer-590-310' ); ?>
						</figure>						
						<div class="entry-content text-center">
							<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>
							<p 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, 15, '' );
								echo esc_html( $bosa_event_organizer_result );
								?>
							</p>
							<div class="button-container">
								<a href="<?php echo esc_url( get_permalink( $bosa_event_organizer_each_page[ 'ID' ] ) ); ?>" class="button-text">
									<?php echo esc_html__( 'Continue reading...', 'bosa-event-organizer' ); ?>
									<i class="fas fa-arrow-right"></i>
								</a>
							</div>							
						</div>
					</article>
				</div>
			<?php } ?>
		</div>
	</section>
<?php } 