<?php
/**
 * Template Name: Custom Home Page
 */

get_header(); ?>

<main id="maincontent" role="main">
  <?php do_action( 'vw_restaurant_lite_above_slider' ); ?>

  <?php if( get_theme_mod( 'vw_restaurant_lite_slider_hide_show', true) ==1 || get_theme_mod( 'vw_restaurant_lite_resp_slider_hide_show', true) ==1) { ?>

    <div class="box-slider">
      <div class="row m-0">
        <div class="p-0 align-self-center <?php if(get_theme_mod('diner_restaurant_social_media')) { ?>col-lg-11 col-md-11" <?php } else { ?>col-lg-11 col-md-11" <?php } ?>">
          <section class="slider">
            <?php if(get_theme_mod('vw_restaurant_lite_slider_type', 'Default slider') == 'Default slider' ){ ?>
            <div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'vw_restaurant_lite_slider_speed',4000)) ?>">
              <?php $vw_restaurant_lite_slider_pages = array();
                for ( $count = 1; $count <= 3; $count++ ) {
                  $mod = intval( get_theme_mod( 'vw_restaurant_lite_slider_page' . $count ));
                  if ( 'page-none-selected' != $mod ) {
                    $vw_restaurant_lite_slider_pages[] = $mod;
                  }
                }
                if( !empty($vw_restaurant_lite_slider_pages) ) :
                  $args = array(
                    'post_type' => 'page',
                    'post__in' => $vw_restaurant_lite_slider_pages,
                    'orderby' => 'post__in'
                  );
                  $query = new WP_Query( $args );
                  if ( $query->have_posts() ) :
                    $i = 1;
              ?>     
              <div class="carousel-inner" role="listbox">
                <?php  while ( $query->have_posts() ) : $query->the_post(); ?>
                  <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail();
                    } else{?>
                      <img src="<?php echo esc_url(get_theme_file_uri()); ?>/inc/block-patterns/images/Slider.png" alt="" />
                    <?php } ?>
                    <div class="carousel-caption">
                      <div class="inner_carousel">
                        <?php if( get_theme_mod('diner_restaurant_slider_small_title') != '' ){ ?>
                          <div class="mb-1 wow bounceInUp" data-wow-duration="2s">
                            <span class="slider-badge mb-1"><?php echo esc_html(get_theme_mod('diner_restaurant_slider_small_title',''));?></span>
                          </div>
                        <?php }?>
                        <?php if( get_theme_mod('vw_restaurant_lite_slider_title_hide_show',true) ==1){ ?>
                          <h1 class="wow lightSpeedIn delay-1000" data-wow-duration="2s"><a href="<?php echo esc_url( get_permalink() ); ?>" title="<?php echo the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
                        <?php } ?>
                        <?php if( get_theme_mod('vw_restaurant_lite_slider_content_hide_show',true) ==1){ ?>
                          <p class="wow lightSpeedIn delay-1000" data-wow-duration="2s"><?php $excerpt = get_the_excerpt(); echo esc_html( vw_restaurant_lite_string_limit_words( $excerpt, esc_attr(get_theme_mod('vw_restaurant_lite_slider_excerpt_number','30')))); ?></p>
                        <?php } ?>
                        <?php if( get_theme_mod('vw_restaurant_lite_slider_button_hide_show',true) ==1){ ?>
                          <?php if( get_theme_mod('vw_restaurant_lite_slider_button_text','READ MORE') !=''|| get_theme_mod('vw_restaurant_lite_slider_button_link') != ''){ ?>
                            <div class="more-btn mt-4 wow lightSpeedIn delay-1000" data-wow-duration="2s">  
                              <a class="button" href="<?php echo esc_url(get_theme_mod('vw_restaurant_lite_slider_button_link','')); ?>"><?php echo esc_html(get_theme_mod('vw_restaurant_lite_slider_button_text',__('READ MORE','diner-restaurant')));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('vw_restaurant_lite_slider_button_text',__('READ MORE','diner-restaurant')));?></span></a>
                            </div>
                          <?php } ?>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                <?php $i++; endwhile; 
                wp_reset_postdata();?>
              </div>
              <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
              <?php if(get_theme_mod('vw_restaurant_lite_slider_arrow_hide_show', true)){?>
                <a class="carousel-control-prev" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev" role="button">
                  <span class="carousel-control-prev-icon w-auto h-auto" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('vw_restaurant_lite_slider_prev_icon','fas fa-chevron-left')); ?>"></i></span>
                  <span class="screen-reader-text"><?php esc_html_e( 'Previous','diner-restaurant' );?></span>
                </a>
                <a class="carousel-control-next" data-bs-target="#carouselExampleCaptions" data-bs-slide="next" role="button">
                  <span class="carousel-control-next-icon w-auto h-auto" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('vw_restaurant_lite_slider_next_icon','fas fa-chevron-right')); ?>"></i></span>
                  <span class="screen-reader-text"><?php esc_html_e( 'Next','diner-restaurant' );?></span>
                </a>
              <?php }?>
            </div>  
            <div class="clearfix"></div>
            <div class="contact-box">
                <div class="row m-0">
                  <div class="col-lg-4 col-md-4 align-self-center">
                    <?php if( get_theme_mod( 'diner_restaurant_phone_text') !='') { ?>
                    <div class="row m-0">
                      <div class="col-lg-3 col-md-3 col-2 align-self-center">
                        <i class="<?php echo esc_attr(get_theme_mod('diner_restaurant_phone_icon','fa fa-phone')); ?>"></i>
                      </div>
                      <div class="col-lg-9 col-md-9 col-10 mt-2 align-self-center">
                        <h2 class="mb-1"><?php echo esc_html(get_theme_mod('diner_restaurant_phone_text',''));?></h2>
                        <p><a href="tel:<?php echo esc_attr(get_theme_mod('diner_restaurant_phone_number',''));?>"><?php echo esc_html(get_theme_mod('diner_restaurant_phone_number',''));?></a></p>
                      </div>
                    </div>
                    <?php } ?>
                  </div>

                  <div class="col-lg-4 col-md-4 align-self-center">
                    <?php if( get_theme_mod( 'diner_restaurant_email_text')!='') { ?>
                    <div class="row m-0">
                      <div class="col-lg-3 col-md-3 col-2 align-self-center">
                        <i class="<?php echo esc_attr(get_theme_mod('diner_restaurant_email_icon','fa fa-envelope')); ?>"></i>
                      </div>
                      <div class="col-lg-9 col-md-9 col-10 mt-2 align-self-center">
                        <h2 class="mb-1"><?php echo esc_html(get_theme_mod('diner_restaurant_email_text',''));?></h2>
                        <p><a href="mailto:<?php echo esc_attr(get_theme_mod('diner_restaurant_email_address',''));?>"><?php echo esc_html(get_theme_mod('diner_restaurant_email_address',''));?></a></p>
                      </div>
                    </div>
                    <?php } ?>
                  </div>
                  <div class="col-lg-4 col-md-4 align-self-center">
                    <?php if( get_theme_mod( 'diner_restaurant_location_text') !='') { ?>
                    <div class="row m-0">
                      <div class="col-lg-3 col-md-3 col-2 align-self-center">
                        <i class="<?php echo esc_attr(get_theme_mod('diner_restaurant_location_icon','fas fa-paper-plane')); ?>"></i>
                      </div>
                      <div class="col-lg-9 col-md-9 col-10 mt-2 align-self-center">
                        <h2 class="mb-1"><?php echo esc_html(get_theme_mod('diner_restaurant_location_text',''));?></h2>
                        <p><?php echo esc_html(get_theme_mod('diner_restaurant_location',''));?></p>
                      </div>
                    </div>
                    <?php } ?>
                  </div>
                </div>
            </div>
              <?php } else if(get_theme_mod('vw_restaurant_lite_slider_type', 'Advance slider') == 'Advance slider'){?>
                <?php echo do_shortcode(get_theme_mod('vw_restaurant_lite_advance_slider_shortcode')); ?>
              <?php } ?>
          </section>
        </div> 

        <?php if( get_theme_mod( 'diner_restaurant_social_media', true) !='') { ?>
          <div class="col-lg-1 col-md-1 text-center social-media position-relative">
            <?php if (is_active_sidebar('social-icon')) : ?>
              <?php dynamic_sidebar( 'social-icon' ); ?>
            <?php else : ?>
            <!-- Default Social Icons Widgets -->
              <div class="widget">
                  <ul class="custom-social-icons" >
                    <li><a href="https://facebook.com" target="_blank"><i class="fab fa-facebook"></i></a></li> 
                    <li><a href="https://twitter.com" target="_blank"><i class="fab fa-twitter"></i></a></li> 
                    <li><a href="https://instagram.com" target="_blank"><i class="fab fa-instagram"></i></a></li> 
                    <li><a href="https://linkedin.com" target="_blank"><i class="fab fa-linkedin"></i></a></li> 
                    <li><a href="https://pinterest.com" target="_blank"><i class="fab fa-pinterest"></i></a></li> 
                    <li><a href="https://youtube.com" target="_blank"><i class="fab fa-youtube"></i></a></li>                     
                  </ul>
              </div>
            <?php endif; ?>  
          </div>
        <?php }?>
      </div>
    </div>

  <?php } ?>
    
  <?php do_action( 'vw_restaurant_lite_below_slider' ); ?>

  <?php /** second section **/ ?>
  <?php if( get_theme_mod('vw_restaurant_lite_belive_post_setting') != ''){ ?>
    <section id="we_belive" class="wow zoomInDown delay-1000" data-wow-duration="2s"> 
      <div class="container">
        <?php
        $vw_restaurant_lite_postData1=  get_theme_mod('vw_restaurant_lite_belive_post_setting');
          if($vw_restaurant_lite_postData1){
          $args = array( 'p' => esc_html($vw_restaurant_lite_postData1 ,'vw-restaurant-lite'),
           'post_type'=> 'post' ,
          );
        $query = new WP_Query( $args );
        if ( $query->have_posts() ) :
          while ( $query->have_posts() ) : $query->the_post(); ?>
          <div class="row">
            <?php if(has_post_thumbnail()){ 
              $thumb_col = 'col-md-5 col-sm-12';
              $desc_col = 'col-md-7 col-sm-12';
              }else{
                $desc_col = 'col-md-12';
            } ?>
            <div class="<?php echo esc_attr($thumb_col); ?>">
              <?php the_post_thumbnail('full'); ?>
            </div>
            <div class="<?php echo esc_attr($desc_col); ?>">
              <h2><q><?php the_title(); ?></q></h2>
              <p><?php $vw_restaurant_lite_excerpt = get_the_excerpt(); echo esc_html( vw_restaurant_lite_string_limit_words( $vw_restaurant_lite_excerpt,25 ) ); ?></p>
              <div class="clearfix"></div>
              <?php if( get_theme_mod('vw_restaurant_lite_about_button_text','ABOUT US') != ''){ ?>
                <div><a class="button hvr-sweep-to-right"  href="<?php echo esc_url(get_permalink()); ?>"><?php echo esc_html(get_theme_mod('vw_restaurant_lite_about_button_text',__('ABOUT US','vw-restaurant-lite')));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('vw_restaurant_lite_about_button_text',__('ABOUT US','vw-restaurant-lite')));?></span></a>
                </div>
              <?php } ?>
            </div>
          </div>
          <?php endwhile; 
          wp_reset_postdata();?>
          <?php else : ?>
             <div class="no-postfound"></div>
           <?php
          endif; } ?>
          <div class="clearfix"></div>
      </div> 
    </section>
  <?php }?>

  <?php do_action( 'vw_restaurant_lite_below_we_belive_section' ); ?>

  <section id="popular-menu" class="py-5 text-center wow bounceInUp delay-1000" data-wow-duration="2s">
    <div class="container">
      <?php if( get_theme_mod('diner_restaurant_popular_menu_title') !='' ){ ?>
        <h3 class="mb-3 htext text-center"><?php echo esc_html(get_theme_mod('diner_restaurant_popular_menu_title',''));?></h3>
      <?php }?>

      <div class="tab my-3">
        <?php
          $featured_post = get_theme_mod('diner_restaurant_popular_menu_tab_number', '');
          for ( $j = 1; $j <= $featured_post; $j++ ){ ?>
          <button class="tablinks me-3" onclick="diner_restaurant_project_tab(event, '<?php $main_id = get_theme_mod('diner_restaurant_services_text'.$j); $tab_id = str_replace(' ', '-', $main_id); echo $tab_id; ?> ')">
          <?php echo esc_html(get_theme_mod('diner_restaurant_services_text'.$j)); ?></button>
        <?php }?>
      </div>

      <?php for ( $j = 1; $j <= $featured_post; $j++ ){ ?>
        <div id="<?php $main_id = get_theme_mod('diner_restaurant_services_text'.$j); $tab_id = str_replace(' ', '-', $main_id); echo $tab_id; ?>"  class="tabcontent mt-3">
          <div class="row">
            <?php if ( class_exists( 'WooCommerce' ) ) {
              $args = array( 
                'post_type' => 'product',
                'product_cat' => get_theme_mod('diner_restaurant_popular_menu_category'.$j),
                'order' => 'ASC'
              );
              $loop = new WP_Query( $args );
              while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
                <div class="col-lg-4 col-md-6 col-12 mb-lg-5">
                  <div class="product-box mb-4">
                    <div class="row">
                      <div class="col-lg-4 col-md-4 col-4">
                        <div class="product-image">
                          <?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.esc_url(woocommerce_placeholder_img_src()).'" />'; ?>
                        </div>
                      </div>
                      <div class="col-lg-8 col-md-8 col-8">
                        <div class="product-content text-start">
                          <h4 class="mb-lg-1"><a href="<?php echo esc_url(get_permalink( $loop->post->ID )); ?>"><?php the_title(); ?></a></h4>
                          <p class="product-text mb-3"><?php $excerpt = get_the_excerpt(); echo esc_html( vw_restaurant_lite_string_limit_words( $excerpt, 8)); ?></p>
                          <p class="text-end <?php echo esc_attr( apply_filters( 'woocommerce_product_price_class', 'price' ) ); ?>"><?php echo $product->get_price_html(); ?></p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              <?php endwhile; wp_reset_query(); ?>
            <?php } ?>
          </div>
        </div>
      <?php }?>
    </div>
  </section>

  <div class="container content-vw entry-content">
    <?php while ( have_posts() ) : the_post(); ?>
      <?php the_content(); ?>
    <?php endwhile; // end of the loop. ?>
  </div>
</main>

<?php get_footer(); ?>