<?php
$bosa_online_marketing_services_title = get_theme_mod( 'bosa_online_marketing_services_title', '' );
$bosa_online_marketing_services_content 	= get_theme_mod( 'bosa_online_marketing_services_content', '' );
$bosa_online_marketing_service_one 	= get_theme_mod( 'bosa_online_marketing_services_one', '' );
$bosa_online_marketing_service_two 	= get_theme_mod( 'bosa_online_marketing_services_two', '' );
$bosa_online_marketing_service_three = get_theme_mod( 'bosa_online_marketing_services_three', '' );
$bosa_online_marketing_service_four  = get_theme_mod( 'bosa_online_marketing_services_four', '' );
$bosa_online_marketing_service_five  = get_theme_mod( 'bosa_online_marketing_services_five', '');
$bosa_online_marketing_service_six  = get_theme_mod( 'bosa_online_marketing_services_six', '');

$bosa_online_marketing_service_array = array();
$bosa_online_marketing_has_array = false;
$bosa_online_marketing_has_service = false;
$bosa_online_marketing_has_service_content = false;

if( !empty( $bosa_online_marketing_services_title ) || !empty( $bosa_online_marketing_services_content ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_service_content = true;
}
if( !empty( $bosa_online_marketing_service_one ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_one'] = array(
		'ID' => $bosa_online_marketing_service_one,
	);
}
if( !empty( $bosa_online_marketing_service_two ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_two'] = array(
		'ID' => $bosa_online_marketing_service_two,
	);
}
if( !empty( $bosa_online_marketing_service_three ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_three'] = array(
		'ID' => $bosa_online_marketing_service_three,
	);
}
if( !empty( $bosa_online_marketing_service_four ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_four'] = array(
		'ID' => $bosa_online_marketing_service_four,
	);
}
if( !empty( $bosa_online_marketing_service_five ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_five'] = array(
		'ID' => $bosa_online_marketing_service_five,
	);
}
if( !empty( $bosa_online_marketing_service_six ) ){
	$bosa_online_marketing_has_service = true;
	$bosa_online_marketing_has_array = true;
	$bosa_online_marketing_service_array['service_six'] = array(
		'ID' => $bosa_online_marketing_service_six,
	);
}

if( !get_theme_mod( 'bosa_online_marketing_disable_services_section', true ) && $bosa_online_marketing_has_service ){ ?>
	<section class="section-service-area">
		<?php if( $bosa_online_marketing_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_online_marketing_services_title ) ; ?>
				</h2>
				<p>
					<?php echo esc_html( wp_trim_words( $bosa_online_marketing_services_content, 25, '' ) );?>	
				</p>
			</div>
		<?php }
		if ( $bosa_online_marketing_has_array ){ ?>
			<div class="row">
				<?php foreach( $bosa_online_marketing_service_array as $bosa_online_marketing_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_online_marketing_each_service[ 'ID' ], 'bosa-online-marketing-420-300' ); ?>
							</figure>
							
							<div class="entry-content">
									<h3 class="entry-title">
										<a href="<?php echo esc_url( get_permalink( $bosa_online_marketing_each_service[ 'ID' ] ) ); ?>">
											<?php echo esc_html( get_the_title( $bosa_online_marketing_each_service[ 'ID' ] ) ); ?>
										</a>
									</h3>
								<div class="entry-text">
									<?php 
									$excerpt = get_the_excerpt( $bosa_online_marketing_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_online_marketing_each_service[ 'ID' ] ) ); ?>" class="button-text">
										<?php echo esc_html__( 'Continue reading', 'bosa-online-marketing' ); ?>
										<i class="fas fa-arrow-right"></i>
									</a>
								</div>
							</div>
						</article>

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