<?php

/**
 * Template Name: Custom Home Page
 */

get_header();

?>
<main id="maincontent" role="main">
  <?php do_action( 'ac_repairing_services_before_slider' ); ?>
    <?php if( get_theme_mod( 'ac_repairing_services_slider_hide_show', true) == 1 || get_theme_mod( 'ac_repairing_services_resp_slider_hide_show1', true) == 1) { ?>
      <section id="slider">
        <div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'ac_repairing_services_slider_speed',4000)) ?>">
          <div class="row m-0 position-relative">
            <div class="col-lg-11 col-md-11 px-0">
              <?php $ac_repairing_services_pages = array();
                for ( $count = 1; $count <= 3; $count++ ) {
                  $mod = intval( get_theme_mod( 'ac_repairing_services_slider_page' . $count ));
                  if ( 'page-none-selected' != $mod ) {
                    $ac_repairing_services_pages[] = $mod;
                  }
                }
                if( !empty($ac_repairing_services_pages) ) :
                  $args = array(
                    'post_type' => 'page',
                    'post__in' => $ac_repairing_services_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_template_directory_uri()); ?>/inc/block-patterns/images/slider.png" alt="" />
                    <?php } ?>
                    <div class="carousel-caption">
                      <div class="inner_carousel">
                        <h1 class="wow slideInRight 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>
                        <p class="wow slideInRight delay-1000" data-wow-duration="2s"><?php $ac_repairing_services_excerpt = get_the_excerpt(); echo esc_html( ac_repairing_services_string_limit_words( $ac_repairing_services_excerpt, esc_attr(get_theme_mod('ac_repairing_services_slider_excerpt_number','30')))); ?></p>
                        <?php
                          $ac_repairing_services_button_text = get_theme_mod('ac_repairing_services_slider_button_text', 'View All Services');
                          $ac_repairing_services_button_link = get_theme_mod('ac_repairing_services_slider_btn_link', '');
                          if (empty($ac_repairing_services_button_link)) {
                            $ac_repairing_services_button_link = get_permalink();
                          }
                          if ($ac_repairing_services_button_text || !empty($ac_repairing_services_button_link)) { ?>
                            <div class="slider-btn my-4 wow slideInRight delay-1000" data-wow-duration="2s">
                              <?php if( get_theme_mod('ac_repairing_services_slider_button_text','View All Services') != ''){ ?>
                                <a href="<?php echo esc_url($ac_repairing_services_button_link); ?>" class="button redmor">
                                <?php echo esc_html($ac_repairing_services_button_text); ?>
                                 <i class="fas fa-long-arrow-alt-right ms-2"></i><span class="screen-reader-text"><?php echo esc_html($ac_repairing_services_button_text); ?></span>
                                </a>
                              <?php } ?>
                            </div>
                        <?php } ?>
                      </div>
                    </div>
                  </div>
                <?php $i++; endwhile;
                wp_reset_postdata();?>
              </div>
              <div class="video-btn">
                <a id="openBtn">
                 <i class="<?php echo esc_attr(get_theme_mod('ac_repairing_services_video_button_icon','fas fa-play')); ?>"></i>
                </a>
                <p class="video-text align-self-center mb-0 ms-3"><?php echo esc_html( get_theme_mod('ac_repairing_services_video_button_text','Our Video') ); ?></p>
                  <div class="overlay" id="videoOverlay">
                    <div class="popup">
                      <span class="close-btn"><i class="fas fa-times"></i></span>
                      <iframe width="100%" height="100%" src="<?php echo esc_url(get_theme_mod('ac_repairing_services_video_button_url'));?>" frameborder="0" allowfullscreen></iframe>
                    </div>
                </div>
              </div>
              <?php else : ?>
                <div class="no-postfound"></div>
              <?php endif;
              endif;?>
            </div>
            <div class="media-box-style">
              <div class="social-bx">
                <?php if (is_active_sidebar('slider-social')) : ?>
                  <?php dynamic_sidebar('slider-social'); ?> 
                <?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://pinterest.com" target="_blank"><i class="fab fa-pinterest"></i></a></li>                    
                        </ul>
                    </div>
                <?php endif; ?>   
              </div>
            </div>
          </div>
          <div class="contact-section position-relative">
            <div class="container">
              <div class="row">
                <div class="col-xl-3 col-lg-3 col-md-3 align-self-center">
                  <?php if( get_theme_mod( 'ac_repairing_services_phone_text') != ''| get_theme_mod( 'ac_repairing_services_phone_number') != ''){ ?>
                    <div class="styling-box1">
                      <div class="row m-0 styling-box2">
                        <div class="col-lg-2 col-md-2 col-2 align-self-center phone-media">
                          <i class="<?php echo esc_attr(get_theme_mod('ac_repairing_services_phone_icon','fa-solid fa-headset')); ?>"></i>
                        </div>
                        <div class="col-lg-10 col-md-10 col-10 phone-sections">
                          <h3><?php echo esc_html(get_theme_mod('ac_repairing_services_phone_text',''));?></h3>
                          <p><a href="tel:<?php echo esc_attr( get_theme_mod('ac_repairing_services_phone_number','') ); ?>"><?php echo esc_html(get_theme_mod('ac_repairing_services_phone_number',''));?></a></p>
                        </div>
                      </div>
                    </div>
                  <?php }?>
                </div>
                <div class="col-xl-4 col-lg-4 col-md-3 align-self-center">
                  <?php if( get_theme_mod( 'ac_repairing_services_email_text') != ''| get_theme_mod( 'ac_repairing_services_email_address') != ''){ ?>
                    <div class="styling-box1">
                      <div class="row m-0 styling-box2">
                        <div class="col-lg-2 col-md-2 col-2 align-self-center styling-box2-mail">
                          <i class="<?php echo esc_attr(get_theme_mod('ac_repairing_services_email_address_icon','fa-solid fa-envelope-open-text')); ?>"></i>
                        </div>
                        <div class="col-lg-10 col-md-10 col-10 phone-sections1">
                          <h3><?php echo esc_html(get_theme_mod('ac_repairing_services_email_text',''));?></h3>
                          <p><a href="mailto:<?php echo esc_attr(get_theme_mod('ac_repairing_services_email_address',''));?>"><?php echo esc_html(get_theme_mod('ac_repairing_services_email_address',''));?></a></p>
                        </div>
                      </div>
                    </div>
                  <?php }?>
                </div>
                <div class="col-xl-4 col-lg-4 col-md-5 align-self-center">
                  <?php if( get_theme_mod( 'ac_repairing_services_opening_time') != ''| get_theme_mod( 'ac_repairing_services_opening_time_text') != ''){ ?>
                    <div class="styling-box">
                      <div class="row m-0">
                        <div class="col-lg-2 col-md-2 col-2 align-self-center">
                         <i class="<?php echo esc_attr(get_theme_mod('ac_repairing_services_timing_icon','fas fa-clock')); ?>"></i>
                        </div>
                        <div class="col-lg-10 col-md-10 col-10 phone-sections1">
                          <h3><?php echo esc_html(get_theme_mod('ac_repairing_services_opening_time_text',''));?></h3>
                          <p><?php echo esc_html(get_theme_mod('ac_repairing_services_opening_time',''));?></p>
                        </div>
                      </div>
                    </div>
                  <?php }?>
                </div>
              </div>
            </div>
            <div class="slider-arrow-section">
                <a class="carousel-control-next" data-bs-target="#carouselExampleCaptions" data-bs-slide="next" role="button">
                  <span class="carousel-control-next-icon" aria-hidden="true"><i class="fa-solid fa-arrow-right"></i></span>
                  <span class="screen-reader-text"><?php esc_html_e( 'Next','ac-repairing-services' );?></span>
                </a>
                <a class="carousel-control-prev" data-bs-target="#carouselExampleCaptions" data-bs-slide="prev" role="button">
                  <span class="carousel-control-prev-icon" aria-hidden="true"><i class="fa-solid fa-arrow-left"></i></span>
                  <span class="screen-reader-text"><?php esc_html_e( 'Previous','ac-repairing-services' );?></span>
                </a>
                
              </div>
          </div>
        </div>
      </section>
    <?php }?>
<?php do_action( 'ac_repairing_services_after_slider' ); ?>

<!-- Our Services Section -->
  <?php if( get_theme_mod('ac_repairing_services_show_hide_claases_number',true) != ''){ ?>
    <section id="about-sec" class=" pt-5">
      <div class="container">
        <div class="about-setting text-center">
          <?php if(get_theme_mod('ac_repairing_services_feature_courses_tagline_title') != '') {?>
            <h3 class="mb-4"><?php echo esc_html(get_theme_mod('ac_repairing_services_feature_courses_tagline_title')) ?></h3>
          <?php }?>
          <?php if(get_theme_mod('ac_repairing_services_section_title1') != ''){ ?>
            <p class="services-para mb-4"><?php echo esc_html(get_theme_mod('ac_repairing_services_section_title1')) ?></p>
          <?php }?>
        </div>
          <div class="owl-carousel">
              <?php
                $ac_repairing_services_featured_post = get_theme_mod('ac_repairing_services_claases_number');
              for ($ac_repairing_services_i=1; $ac_repairing_services_i <= $ac_repairing_services_featured_post; $ac_repairing_services_i++) { 
                $ac_repairing_services_postData=  get_theme_mod('ac_repairing_services_services_category'.$ac_repairing_services_i);
                if($ac_repairing_services_postData){ ?>
                  <div class="feature-box">
                    <?php 
                      $args = array( 
                        'p' => esc_html($ac_repairing_services_postData ,'ac-repairing-services'),
                        'posts_per_page' => 1,
                        'post_type' => 'post'
                      );
                      $query = new WP_Query( $args );
                      if ( $query->have_posts() ) :
                        while ( $query->have_posts() ) : $query->the_post(); ?>
                          <div>
                          <div class="box">
                              <?php if(has_post_thumbnail()){
                                the_post_thumbnail();
                              } else{?>
                                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/inc/block-patterns/images/service-3.png" alt="" />
                              <?php } ?>
                              <div class="box-content">
                                  <i class="<?php echo esc_attr(get_theme_mod('ac_repairing_services_single_icon'.$ac_repairing_services_i,'fa-solid fa-fan')); ?>"></i>
                                  <h4 class="mt-2 "><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h4>
                                  <p class=""><?php $ac_repairing_services_excerpt = get_the_excerpt(); echo esc_html( ac_repairing_services_string_limit_words( $ac_repairing_services_excerpt, esc_attr(get_theme_mod('ac_repairing_services_slider_excerpt_number_post','25')))); ?> <?php echo esc_html(get_theme_mod('ac_repairing_services_blog_excerpt_suffix1',''));?>
                                  </p>
                              </div>
                          </div>
                        </div>
                        <?php endwhile;
                          wp_reset_postdata();
                      endif; ?> 
                    </div>
                <?php }
              } ?>   
          </div>
      </div>
    </section>
  <?php }?>
<?php do_action( 'ac_repairing_services_after_service' ); ?>

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

<?php get_footer(); ?>