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

get_header(); ?>

<main id="skip-content">
  <section id="top-section">
     <?php if(get_theme_mod('digi_restaurant_banner_setting') != ''){ ?>
    <div class="container-fluid p-0">
      <div class="row m-0">
        <div class="col-lg-4 col-md-4 col-sm-4 pl-md-0">
          <?php if(get_theme_mod('digi_restaurant_image_two') != ''){ ?>
            <img src="<?php echo esc_url(get_theme_mod('digi_restaurant_image_one')); ?>"/>
          <?php }?>
          <?php if(get_theme_mod('digi_restaurant_image_two') != ''){ ?>
            <img src="<?php echo esc_url(get_theme_mod('digi_restaurant_image_two')); ?>"/>
          <?php }?>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4">
          <div class="top-inner">
            <?php if(get_theme_mod('digi_restaurant_top_section_heading') != ''){ ?>
              <h2><?php echo esc_html(get_theme_mod('digi_restaurant_top_section_heading')); ?></h2>
            <?php }?>
            <?php if(get_theme_mod('digi_restaurant_top_section_content') != ''){ ?>
              <p><?php echo esc_html(get_theme_mod('digi_restaurant_top_section_content')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('digi_restaurant_top_section_url') != '' || get_theme_mod('digi_restaurant_top_section_text') != ''){ ?>
              <div class="top-inner-btn my-4"><a href="<?php echo esc_url(get_theme_mod('digi_restaurant_top_section_url')); ?>"><?php echo esc_html(get_theme_mod('digi_restaurant_top_section_text')); ?></a></div>
            <?php }?>
          </div>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 pr-md-0">
          <?php if(get_theme_mod('digi_restaurant_image_three') != ''){ ?>
            <img src="<?php echo esc_url(get_theme_mod('digi_restaurant_image_three')); ?>"/>
          <?php }?>
          <?php if(get_theme_mod('digi_restaurant_image_four') != ''){ ?>
            <img src="<?php echo esc_url(get_theme_mod('digi_restaurant_image_four')); ?>"/>
          <?php }?>
        </div>
      </div>
    </div>
    <?php }?>
  </section>

 <?php if(get_theme_mod('digi_restaurant_welcome_setting') != ''){ ?>
  <section id="welcome-section" class="py-5">
    <div class="container">
      <div class="row">
        <?php $digi_restaurant_welcome_page = array();
          $digi_restaurant_welcome_keys = array(
            'digi_restaurant_welcome_page',
            'digi_restaurant_welcome_page1',
            'digi_restaurant_welcome_page2',
            'digi_restaurant_welcome_page3',
          );

          foreach ( $digi_restaurant_welcome_keys as $digi_restaurant_welcome_key ) {
            $digi_restaurant_mod = intval( get_theme_mod( $digi_restaurant_welcome_key ) );
            if ( $digi_restaurant_mod > 0 ) {
              $digi_restaurant_welcome_page[] = $digi_restaurant_mod;
              break;
            }
          }

          if( !empty($digi_restaurant_welcome_page) ) :
            $digi_restaurant_args = array(
              'post_type' => 'page',
              'post__in' => $digi_restaurant_welcome_page,
              'orderby' => 'post__in'
            );
            $digi_restaurant_query = new WP_Query( $digi_restaurant_args );
            if ( $digi_restaurant_query->have_posts() ) :
        ?>
        <?php  while ( $digi_restaurant_query->have_posts() ) : $digi_restaurant_query->the_post(); ?>
          <div class="col-lg-6 col-md-6 col-sm-6 align-self-center position-relative">
            <div class="welcome-box text-center">
              <h2><?php echo esc_html(get_theme_mod('digi_restaurant_welcome_section_heading')); ?></h2>
              <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
              <p><?php the_excerpt(); ?></p>
            </div>
          </div>
          <div class="col-lg-6 col-md-6 col-sm-6 align-self-center">
            <img src="<?php the_post_thumbnail_url('full'); ?>"/>
          </div>
        <?php endwhile;
        wp_reset_postdata();?>
        <?php else : ?>
          <div class="no-postfound"></div>
        <?php endif;
        endif;?>
      </div>
    </div>
  </section>
<?php }?>
</main>

<?php get_footer(); ?>
