<?php
$bosa_business_agency_page_one 		= get_theme_mod( 'bosa_business_agency_blog_occasion_page_one', '' );
$bosa_business_agency_page_two 		= get_theme_mod( 'bosa_business_agency_blog_occasion_page_two', '' );
$bosa_business_agency_page_three 	= get_theme_mod( 'bosa_business_agency_blog_occasion_page_three', '' );
$bosa_business_agency_page_four  	= get_theme_mod( 'bosa_business_agency_blog_occasion_page_four', '' );

$bosa_business_agency_page_array = array();
$bosa_business_agency_has_page = false;
$bosa_business_agency_has_array = false;
$bosa_business_agency_has_occasion_text = false;

if ( !empty( get_theme_mod( 'bosa_business_agency_occasion_title', '' ) ) || !empty( get_theme_mod( 'bosa_business_agency_occasion_info_one', '' ) ) ) {
	$bosa_garden_care_has_occasion_text = true;
}

if( !empty( $bosa_business_agency_page_one ) ){
	$bosa_business_agency_has_page = true;
	$bosa_business_agency_has_array = true;
	$bosa_business_agency_page_array['page_one'] = array(
		'ID' => $bosa_business_agency_page_one,
	);
}
if( !empty( $bosa_business_agency_page_two ) ){
	$bosa_business_agency_has_page = true;
	$bosa_business_agency_has_array = true;
	$bosa_business_agency_page_array['page_two'] = array(
		'ID' => $bosa_business_agency_page_two,
	);
}
if( !empty( $bosa_business_agency_page_three ) ){
	$bosa_business_agency_has_page = true;
	$bosa_business_agency_has_array = true;
	$bosa_business_agency_page_array['page_three'] = array(
		'ID' => $bosa_business_agency_page_three,
	);
}
if( !empty( $bosa_business_agency_page_four ) ){
	$bosa_business_agency_has_page = true;
	$bosa_business_agency_has_array = true;
	$bosa_business_agency_page_array['page_four'] = array(
		'ID' => $bosa_business_agency_page_four,
	);
}

if( !get_theme_mod( 'bosa_business_agency_disable_occasions_section', true ) && $bosa_business_agency_has_page ){ ?>
	<section class="section-occasions-area">
		<?php if( !empty( $bosa_garden_care_has_occasion_text ) ){ ?>
			<div class="section-title-wrap text-center col-md-8 offset-md-2">
				<h2 class="section-title">
					<?php echo esc_html( get_theme_mod( 'bosa_business_agency_occasion_title', '' ) ); ?>
				</h2>
				<p>
					<?php echo esc_html( get_theme_mod('bosa_business_agency_occasion_info_one') ); ?>
				</p>
			</div>
		<?php }
		if ( $bosa_business_agency_has_array ){ ?>
			<div class="row justify-content-center">
				<?php foreach( $bosa_business_agency_page_array as $bosa_business_agency_each_page ){ ?>
					<div class="col-md-6 px-lg-4">
						<div class="event-wrapper">
							<article class="event-iconbox">
								<figure class="featured-image">
									<?php echo get_the_post_thumbnail( $bosa_business_agency_each_page[ 'ID' ], 'bosa-business-agency-420-300' ); ?>
								</figure>
								<div class="entry-content">
									<h3 class="entry-title">
										<a href="<?php echo esc_url( get_permalink( $bosa_business_agency_each_page[ 'ID' ] ) ); ?>">
											<?php echo esc_html( get_the_title( $bosa_business_agency_each_page[ 'ID' ] ) ); ?>
										</a>
									</h3>
									<div class="entry-text">
										<?php 
										$bosa_business_agency_excerpt = get_the_excerpt( $bosa_business_agency_each_page[ 'ID' ] );
										$bosa_business_agency_result  = wp_trim_words( $bosa_business_agency_excerpt, 10, '' );
										echo esc_html( $bosa_business_agency_result );
										?>
									</div>
									<a href="<?php echo esc_url( get_permalink( $bosa_business_agency_each_page[ 'ID' ] ) ); ?>" class="event-page-link">
										Learn More...
									</a>
								</div>
							</article>
						</div>
					</div>
				<?php } ?>
			</div>
		<?php } ?>
	</section>	
<?php } 