<?php
$bosa_app_hub_page_one 	= get_theme_mod( 'bosa_app_hub_services_page_one', '' );
$bosa_app_hub_page_two 	= get_theme_mod( 'bosa_app_hub_services_page_two', '' );
$bosa_app_hub_page_three = get_theme_mod( 'bosa_app_hub_services_page_three', '' );
$bosa_app_hub_page_four  = get_theme_mod( 'bosa_app_hub_services_page_four', '' );
$bosa_app_hub_page_five  = get_theme_mod( 'bosa_app_hub_services_page_five', '');
$bosa_app_hub_page_six  = get_theme_mod( 'bosa_app_hub_services_page_six', '');

$bosa_app_hub_page_array = array();
$bosa_app_hub_has_page = false;
$bosa_app_hub_has_array = false;

if( !empty( $bosa_app_hub_page_one ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_one'] = array(
		'ID' => $bosa_app_hub_page_one,
	);
}
if( !empty( $bosa_app_hub_page_two ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_two'] = array(
		'ID' => $bosa_app_hub_page_two,
	);
}
if( !empty( $bosa_app_hub_page_three ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_three'] = array(
		'ID' => $bosa_app_hub_page_three,
	);
}
if( !empty( $bosa_app_hub_page_four ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_four'] = array(
		'ID' => $bosa_app_hub_page_four,
	);
}
if( !empty( $bosa_app_hub_page_five ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_five'] = array(
		'ID' => $bosa_app_hub_page_five,
	);
}
if( !empty( $bosa_app_hub_page_six ) ){
	$bosa_app_hub_has_page = true;
	$bosa_app_hub_has_array = true;
	$bosa_app_hub_page_array['page_six'] = array(
		'ID' => $bosa_app_hub_page_six,
	);
}

if( !get_theme_mod( 'bosa_app_hub_disable_services_section', true ) && $bosa_app_hub_has_page ){ ?>
	<section class="section-services-area">
		<?php
		if ( $bosa_app_hub_has_array ){ ?>
			<div class="row justify-content-center">
				<?php foreach( $bosa_app_hub_page_array as $bosa_app_hub_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_app_hub_each_page[ 'ID' ], 'bosa-app-hub-420-380' ); ?>
							</figure>
							<div class="entry-content">
								<h4 class="entry-title">
									<a href="<?php echo esc_url( get_permalink( $bosa_app_hub_each_page[ 'ID' ] ) ); ?>">
										<?php echo esc_html( get_the_title( $bosa_app_hub_each_page[ 'ID' ] ) ); ?>
									</a>
								</h4>
								<div class="entry-text">
									<?php 
									$bosa_app_hub_excerpt = get_the_excerpt( $bosa_app_hub_each_page[ 'ID' ] );
									$bosa_app_hub_result  = wp_trim_words( $bosa_app_hub_excerpt, 15, '' );
									echo esc_html( $bosa_app_hub_result );
									?>
								</div>
								<a href="<?php echo esc_url( get_permalink( $bosa_app_hub_each_page[ 'ID' ] ) ); ?>" class="event-page-link">
									<?php echo esc_html__('Learn More...', 'bosa-app-hub');?>
								</a>
							</div>
						</article>
					</div>
				<?php } ?>
			</div>
		<?php } ?>
	</section>	
<?php }