<?php
/**
 * The main template file.
 *
 * This is the most generic template file in a WordPress theme
 * and one of the two required files for a theme (the other being style.css).
 * It is used to display a page when nothing more specific matches a query.
 * E.g., it puts together the home page when no home.php file exists.
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package bestel
 */
get_header();
$bestel_opt = bestel_options();
?>
	<div class="section-booking">
		<?php get_template_part( 'wp-hotel-booking/search/search-form-page' ); ?>
	</div>
	<div class="section">
		<div class="container">
			<?php if ( $bestel_opt['bestel_offer_title'] ) : ?>
				<div class="title-wrap text-center">
				<?php if ( isset( $bestel_opt['bestel_offer_title'] ) && $bestel_opt['bestel_offer_title'] != '' ) { ?>
						<h1><?php echo esc_html( $bestel_opt['bestel_offer_title'] ); ?></h1>
				<?php } ?>                         
					<div class="h-decor"></div>
				</div>
			<?php endif; ?>
		</div>
	</div>
	<div class="section mt-0">
		<div class="container">
			<?php
			while ( have_posts() ) :
				the_post();
				get_template_part( 'template-parts/content', 'page' );
				if ( comments_open() || get_comments_number() ) :
					comments_template();
				endif;
			endwhile;
			?>
		</div>
	</div>
	<?php
	$orig_post = $post;
	$args      = array(
		'post_type'      => 'our-offers',
		'post__not_in'   => array( $post->ID ),
		'posts_per_page' => 2,
	);


	$args = apply_filters( 'bestel_our_offer_query', $args );
	?>
	<div class="section_top_spacing">
		<div class="container">
			<div class="title-wrap text-center">
				<?php if ( isset( $bestel_opt['bestel_spcial_offer_title'] ) && $bestel_opt['bestel_spcial_offer_title'] != '' ) { ?>
					<h2><?php echo esc_html( $bestel_opt['bestel_spcial_offer_title'] ); ?></h2>
				<?php } ?>                   
				<div class="h-decor"></div>
			</div>
			<?php
			$my_query = new WP_Query( $args );
			if ( $my_query->have_posts() ) :
				?>
				<div class="row special-grid">
				<?php
				while ( $my_query->have_posts() ) {
					$my_query->the_post();
					$discount       = get_post_meta( get_the_ID(), 'framework-discount', true );
					$discount_title = get_post_meta( get_the_ID(), 'framework-discount-title', true );
					$services_list  = get_post_meta( get_the_ID(), 'framework-services-list', true );
					?>

						<div class="col-sm-6">                        
							<div class="special-card-2">
								<div class="special-card-2-photo">
									<a href="<?php the_permalink(); ?>">    <?php the_post_thumbnail( array( 570, 285 ) ); ?>
										<div class="special-card-2-caption">
					<?php echo esc_html( $discount, 'bestel' ); ?>
											<span>
					<?php
										echo wp_kses(
											$discount_title,
											array(
												'a'   => array( 'href' ),
												'div' => array( '' ),
												'p'   => array( '' ),
												'b'   => array( 'class' => true ),
											)
										);
					?>
											</span>
										</div>
									</a>
								</div>
								<div class="special-card-2-info">
									<h3><?php the_title(); ?></h3>
									<div class="row">
										<div class="col-md d-flex flex-column">
					<?php the_excerpt(); ?>
											<a href="<?php the_permalink(); ?>" class="special-card-2-more mt-auto"><i class="icon-information"></i><?php echo wp_kses_post( esc_html__( 'Know more', 'bestel' ) ); ?></a>
										</div>
					<?php if ( isset( $services_list ) && ! empty( $services_list ) ) : ?>
											<div class="col-md ml-auto mt-3 mt-md-0">
						<?php
						echo wp_kses(
							$services_list,
							array(
								'ul'  => array( 'class' => true ),
								'li'  => array( '' ),
								'a'   => array( 'href' ),
								'div' => array( '' ),
								'p'   => array( '' ),
								'i'   => array( 'class' => true ),
							)
						);
						?>
											</div>
					<?php endif; ?>
									</div>
								</div>
							</div>
						</div>

					<?php
				}//end while

				$post = $orig_post;
				wp_reset_postdata();
				?>
				</div>
			<?php endif; ?>
			<?php if ( isset( $bestel_opt['bestel-slug_offer_url'] ) && $bestel_opt['bestel-slug_offer_url'] != '' ) { ?>
				<div class="text-center mt-4">
					<a href="<?php echo esc_url( $bestel_opt['bestel-slug_offer_url'] ); ?>" class="btn btn-primary"><?php echo wp_kses_post( $bestel_opt['bestel-slug_offer_text'] ); ?> </a>
				</div>
			<?php } ?>
		</div>
	</div>
<?php get_footer(); ?>
