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

get_header(); ?>

<main id="skip-content">
  <?php if (get_theme_mod('eauto_repair_banner_section_setting', false) != '') { ?>
    <section id="top-banner">
      <div class="banner-box">
        <div class="container">
          <div class="row">
            <div class="col-lg-6 col-md-6 align-self-center">
              <div class="banner-inner-box">
                <?php if(get_theme_mod('eauto_repair_banner_sub_heading') != ''){ ?>
                  <h6 class=""><?php echo esc_html(get_theme_mod('eauto_repair_banner_sub_heading')); ?></h6>
                <?php }?>
                <?php if(get_theme_mod('eauto_repair_banner_heading') != ''){ ?>
                  <h2 class=""><?php echo esc_html(get_theme_mod('eauto_repair_banner_heading')); ?></h2>
                <?php }?>
                <?php if(get_theme_mod('eauto_repair_banner_content') != ''){ ?>
                  <p class=""><?php echo esc_html(get_theme_mod('eauto_repair_banner_content')); ?></p>
                <?php }?>
                <div class="slide-btn mt-lg-4 mt-4">
                  <?php if(get_theme_mod('eauto_repair_banner_button_text1') != '' || get_theme_mod('eauto_repair_banner_button_url1') != ''){ ?>
                    <a href="<?php echo esc_url(get_theme_mod('eauto_repair_banner_button_url1')); ?>" class="banner-btn1 me-3"><?php echo esc_html(get_theme_mod('eauto_repair_banner_button_text1')); ?></a>
                  <?php }?>
                  <?php if(get_theme_mod('eauto_repair_banner_button_text2') != '' || get_theme_mod('eauto_repair_banner_button_url2') != ''){ ?>
                    <a href="<?php echo esc_url(get_theme_mod('eauto_repair_banner_button_url2')); ?>" class="banner-btn2"><?php echo esc_html(get_theme_mod('eauto_repair_banner_button_text2')); ?></a>
                  <?php }?>
                </div>
              </div>
            </div>
            <div class="col-lg-6 col-md-6 px-0">
              <div class="slider-image text-center">
                <div class="banner-inner">
                  <?php if(get_theme_mod('eauto_repair_banner_image') != ''){ ?>
                    <img src="<?php echo esc_url(get_theme_mod('eauto_repair_banner_image')); ?>" class="banner-img" alt="" />
                  <?php } else{?>
                    <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/banner-img.png" class="banner-img" alt="" />
                  <?php } ?>
                </div>
                <?php if(get_theme_mod('eauto_repair_banner_emergency_text','24/7 Emergency') != '') {?>
                  <div class="emer-text">
                    <p><?php echo esc_html(get_theme_mod('eauto_repair_banner_emergency_text', __('24/7 Emergency','eauto-repair'))); ?></p>
                  </div>
                <?php }?>
              </div>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

  <?php if (get_theme_mod('eauto_repair_service_section_setting', false) != '') { ?>
    <section id="service-section" class="py-5">
      <div class="container">
        <div class="service-head mb-3 py-3 text-center">
          <?php if(get_theme_mod('eauto_repair_service_sub_heading') != ''){ ?>
            <h6 class=""><?php echo esc_html(get_theme_mod('eauto_repair_service_sub_heading')); ?></h6>
          <?php }?>
          <?php if(get_theme_mod('eauto_repair_service_heading') != ''){ ?>
            <h3 class="main-heading mb-4"><?php echo esc_html(get_theme_mod('eauto_repair_service_heading')); ?></h3>
          <?php }?>
        </div>
        <div class="row">
          <?php
            $eauto_repair_service_category = get_theme_mod('eauto_repair_service_category','');
            if($eauto_repair_service_category){
              $eauto_repair_page_query5 = new WP_Query(array( 'category_name' => esc_html($eauto_repair_service_category,'eauto-repair'), 'posts_per_page' => esc_attr(get_theme_mod('eauto_repair_service_number',3))));
              $i=1;
              while( $eauto_repair_page_query5->have_posts() ) : $eauto_repair_page_query5->the_post(); ?>
                <div class="col-lg-4 col-md-4">
                  <div class="service-box">
                    <?php if(get_theme_mod('eauto_repair_service_icon'.$i) != ''){ ?>
                      <div class="service-icon">
                        <i class="<?php echo esc_html(get_theme_mod('eauto_repair_service_icon'.$i)); ?>"></i>
                      </div>
                    <?php }?>
                    <div class="service-img">
                      <?php if(has_post_thumbnail()) {
                        the_post_thumbnail();
                      } else{?>
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/service1.png" class="banner-img" alt="" />
                      <?php } ?>
                    </div>
                    <div class="service-content">
                      <h4><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), 8, '...'); ?></a></h4>
                    </div>
                  </div>
                </div>
              <?php $i++; endwhile;
            wp_reset_postdata();
          } ?>
        </div>
        <?php if(get_theme_mod('eauto_repair_service_btn_text') != '' || get_theme_mod('eauto_repair_service_btn_url') != ''){?>
          <div class="service-btn text-center mt-4">
            <a href="<?php echo esc_url(get_theme_mod('eauto_repair_service_btn_url')); ?>"><?php echo esc_html(get_theme_mod('eauto_repair_service_btn_text')); ?></a>
          </div>
        <?php }?>
      </div>
    </section>
  <?php }?>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>