<?php
$bosa_resort_services_title 	= get_theme_mod( 'bosa_resort_services_title', '' );
$bosa_resort_services_content 	= get_theme_mod( 'bosa_resort_services_content', '' );
$bosa_resort_service_one 		= get_theme_mod( 'bosa_resort_services_one', '' );
$bosa_resort_service_two 		= get_theme_mod( 'bosa_resort_services_two', '' );
$bosa_resort_service_three 		= get_theme_mod( 'bosa_resort_services_three', '' );
$bosa_resort_service_four  		= get_theme_mod( 'bosa_resort_services_four', '' );
$bosa_resort_service_five  		= get_theme_mod( 'bosa_resort_services_five', '');
$bosa_resort_service_six  		= get_theme_mod( 'bosa_resort_services_six', '');

$bosa_resort_service_array = array();
$bosa_resort_has_array = false;
$bosa_resort_has_service = false;
$bosa_resort_has_service_content = false;

if( !empty( $bosa_resort_services_title ) || !empty( $bosa_resort_services_content ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_service_content = true;
}
if( !empty( $bosa_resort_service_one ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_one'] = array(
		'ID' => $bosa_resort_service_one,
	);
}
if( !empty( $bosa_resort_service_two ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_two'] = array(
		'ID' => $bosa_resort_service_two,
	);
}
if( !empty( $bosa_resort_service_three ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_three'] = array(
		'ID' => $bosa_resort_service_three,
	);
}
if( !empty( $bosa_resort_service_four ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_four'] = array(
		'ID' => $bosa_resort_service_four,
	);
}
if( !empty( $bosa_resort_service_five ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_five'] = array(
		'ID' => $bosa_resort_service_five,
	);
}
if( !empty( $bosa_resort_service_six ) ){
	$bosa_resort_has_service = true;
	$bosa_resort_has_array = true;
	$bosa_resort_service_array['service_six'] = array(
		'ID' => $bosa_resort_service_six,
	);
}

if( !get_theme_mod( 'bosa_resort_disable_services_section', true ) && $bosa_resort_has_service ){ ?>
	<section class="section-service-area">
		<?php if( $bosa_resort_has_service_content ){ ?>
			<div class="section-title-wrap text-center col-lg-8 offset-lg-2 col-md-6 offset-md-3">
				<h2 class="sections-title">
					<?php echo esc_html( $bosa_resort_services_title ) ; ?>
				</h2>
				<p>
					<?php echo esc_html( wp_trim_words( $bosa_resort_services_content, 25, '' ) );?>	
				</p>
			</div>
		<?php }
		if ( $bosa_resort_has_array ){ ?>
			<div class="row">
				<?php foreach( $bosa_resort_service_array as $bosa_resort_each_service ){ ?>
					<div class="col-lg-6">
						<article class="services-content-wrap text-center">
							<figure class="featured-image">
								<?php echo get_the_post_thumbnail( $bosa_resort_each_service[ 'ID' ], 'bosa-resort-420-300' ); ?>
							</figure>
							
							<div class="entry-content">
									<h3 class="entry-title">
										<a href="<?php echo esc_url( get_permalink( $bosa_resort_each_service[ 'ID' ] ) ); ?>">
											<?php echo esc_html( get_the_title( $bosa_resort_each_service[ 'ID' ] ) ); ?>
										</a>
									</h3>
								<div class="entry-text">
									<?php 
									$excerpt = get_the_excerpt( $bosa_resort_each_service[ 'ID' ] );
									$result  = wp_trim_words( $excerpt, 10, '' );
									echo esc_html( $result );
									?>
									this heading
								</div>
								<div class="button-container">
									<a href="<?php echo esc_url( get_permalink( $bosa_resort_each_service[ 'ID' ] ) ); ?>" class="button-text">
										<?php echo esc_html__( 'Continue reading', 'bosa-resort' ); ?>
										<i class="fas fa-arrow-right"></i>
									</a>
								</div>
							</div>
						</article>

					</div>
				<?php } ?>
			</div>
		<?php } ?>
	</section>	
<?php }