<?php
$bosa_driving_school_page_one 	= get_theme_mod( 'bosa_driving_school_services_page_one', '' );
$bosa_driving_school_page_two 	= get_theme_mod( 'bosa_driving_school_services_page_two', '' );
$bosa_driving_school_page_three = get_theme_mod( 'bosa_driving_school_services_page_three', '' );
$bosa_driving_school_page_four  = get_theme_mod( 'bosa_driving_school_services_page_four', '' );
$bosa_driving_school_page_five  = get_theme_mod( 'bosa_driving_school_services_page_five', '');
$bosa_driving_school_page_six  	= get_theme_mod( 'bosa_driving_school_services_page_six', '');

$bosa_driving_school_page_array = array();
$bosa_driving_school_has_page = false;
$bosa_driving_school_has_array = false;

if( !empty( $bosa_driving_school_page_one ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_one'] = array(
		'ID' => $bosa_driving_school_page_one,
	);
}
if( !empty( $bosa_driving_school_page_two ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_two'] = array(
		'ID' => $bosa_driving_school_page_two,
	);
}
if( !empty( $bosa_driving_school_page_three ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_three'] = array(
		'ID' => $bosa_driving_school_page_three,
	);
}
if( !empty( $bosa_driving_school_page_four ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_four'] = array(
		'ID' => $bosa_driving_school_page_four,
	);
}
if( !empty( $bosa_driving_school_page_five ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_five'] = array(
		'ID' => $bosa_driving_school_page_five,
	);
}
if( !empty( $bosa_driving_school_page_six ) ){
	$bosa_driving_school_has_page = true;
	$bosa_driving_school_has_array = true;
	$bosa_driving_school_page_array['page_six'] = array(
		'ID' => $bosa_driving_school_page_six,
	);
}

if( !get_theme_mod( 'bosa_driving_school_disable_services_section', true ) && $bosa_driving_school_has_page ){ ?>
	<section class="section-services-area">
		<?php
		if ( $bosa_driving_school_has_array ){ ?>
			<div class="row justify-content-center">
				<?php foreach( $bosa_driving_school_page_array as $bosa_driving_school_each_page ){ ?>
					<div class="col-md-6 px-lg-4">
						<article class="event-iconbox">
							<figure class="featured-image">
								<?php echo get_the_post_thumbnail( $bosa_driving_school_each_page[ 'ID' ], 'bosa-driving-school-420-380' ); ?>
							</figure>
							<div class="entry-content">
								<h4 class="entry-title">
									<a href="<?php echo esc_url( get_permalink( $bosa_driving_school_each_page[ 'ID' ] ) ); ?>">
										<?php echo esc_html( get_the_title( $bosa_driving_school_each_page[ 'ID' ] ) ); ?>
									</a>
								</h4>
								<div class="entry-text">
									<?php 
									$bosa_driving_school_excerpt = get_the_excerpt( $bosa_driving_school_each_page[ 'ID' ] );
									$bosa_driving_school_result  = wp_trim_words( $bosa_driving_school_excerpt, 15, '' );
									echo esc_html( $bosa_driving_school_result );
									?>
								</div>
								<a href="<?php echo esc_url( get_permalink( $bosa_driving_school_each_page[ 'ID' ] ) ); ?>" class="event-page-link">
									<?php echo esc_html__('Learn More...', 'bosa-driving-school');?>
								</a>
							</div>
						</article>
					</div>
				<?php } ?>
			</div>
		<?php } ?>
	</section>	
<?php }