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

get_header(); 

$pest_control_services_banner_backgroud_image = get_theme_mod('pest_control_services_banner_background_image');
?>

<main id="skip-content">
  <section id="top-slider" >
    <?php $pest_control_services_slide_pages = array();
      for ( $pest_control_services_count = 1; $pest_control_services_count <= 3; $pest_control_services_count++ ) {
        $pest_control_services_mod = intval( get_theme_mod( 'pest_control_services_top_slider_page' . $pest_control_services_count ));
        if ( 'page-none-selected' != $pest_control_services_mod ) {
          $pest_control_services_slide_pages[] = $pest_control_services_mod;
        }
      }
      if( !empty($pest_control_services_slide_pages) ) :
        $pest_control_services_args = array(
          'post_type' => 'page',
          'post__in' => $pest_control_services_slide_pages,
          'orderby' => 'post__in'
        );
        $pest_control_services_query = new WP_Query( $pest_control_services_args );
        if ( $pest_control_services_query->have_posts() ) :
          $i = 1;
    ?>
    <div class="owl-carousel" role="listbox">
      <?php  while ( $pest_control_services_query->have_posts() ) : $pest_control_services_query->the_post(); ?>
        <div class="slide-box">
          <div class="slider-image">
            <?php if(has_post_thumbnail()){
              the_post_thumbnail();
              } else{?>
              <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/image/slider.png" alt="" />
            <?php } ?>
          </div>
          <div class="slider-inner-box">
            <h2 class="m-0"><?php the_title(); ?></h2>
            <p class="content mb-5"><?php echo esc_html( wp_trim_words( get_the_content(),20 )); ?></p>
            <div class="slide-btn ">
              <a href="<?php the_permalink(); ?>"><i class="fas fa-arrow-right me-2"></i><?php esc_html_e('Know More','pest-control-services'); ?></a>
            </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('pest_control_services_facebook_url') != '' || get_theme_mod('pest_control_services_twitter_url') != '' || get_theme_mod('pest_control_services_twitter_url') != '' ||get_theme_mod('pest_control_services_intagram_url') != '' || get_theme_mod('pest_control_services_linkedin_url') != '' || get_theme_mod('pest_control_services_pintrest_url') != '' ){ ?>
      <div class="social-icon">
        <?php if(get_theme_mod('pest_control_services_facebook_url') != ''){ ?>
            <a href="<?php echo esc_url(get_theme_mod('pest_control_services_facebook_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('pest_control_services_facebook_icon') ); ?>"></i></a>
        <?php }?>
        <?php if(get_theme_mod('pest_control_services_twitter_url') != ''){ ?>
            <a href="<?php echo esc_url(get_theme_mod('pest_control_services_twitter_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('pest_control_services_twitter_icon') ); ?>"></i></a>
        <?php }?>
        <?php if(get_theme_mod('pest_control_services_intagram_url') != ''){ ?>
            <a href="<?php echo esc_url(get_theme_mod('pest_control_services_intagram_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('pest_control_services_intagram_icon') ); ?>"></i></a>
        <?php }?>
        <?php if(get_theme_mod('pest_control_services_linkedin_url') != ''){ ?>
            <a href="<?php echo esc_url(get_theme_mod('pest_control_services_linkedin_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('pest_control_services_linkedin_icon') ); ?>"></i></a>
        <?php }?>
        <?php if(get_theme_mod('pest_control_services_pintrest_url') != ''){ ?>
            <a href="<?php echo esc_url(get_theme_mod('pest_control_services_pintrest_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('pest_control_services_pintrest_icon') ); ?>"></i></a>
        <?php }?>
      </div>
    <?php }?>
  </section>
  <section class="featured py-5">
    <div class="container">
      <div class="heading-main">
        <?php if(get_theme_mod('pest_control_services_about_us_main_heading') != ''){ ?>
          <h3 class="image-heading mb-2"><?php echo esc_html(get_theme_mod('pest_control_services_about_us_main_heading')); ?></h3>
        <?php }?>
        <?php if(get_theme_mod('pest_control_services_about_us_main_content') != ''){ ?>
          <p class="main-heading mb-4"><?php echo esc_html(get_theme_mod('pest_control_services_about_us_main_content')); ?></p>
        <?php }?>
      </div>
      <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-12 col-12 about-image align-self-center">
          <?php if(get_theme_mod('pest_control_services_about_us_left_image') != ''){ ?>
            <img src="<?php echo esc_url( get_theme_mod( 'pest_control_services_about_us_left_image' )); ?>">
          <?php }?>
          <?php if(get_theme_mod('pest_control_services_about_us_left_image_content') != ''){ ?>
            <div class="img-content">
              <p class="img-text m-0"><?php echo esc_html(get_theme_mod('pest_control_services_about_us_left_image_content')); ?></p>
            </div>
          <?php }?>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
            <div class="about-text-box">
              <?php if(get_theme_mod('pest_control_services_about_us_image_heading') != ''){ ?>
                <h3 class="image-heading mb-2"><?php echo esc_html(get_theme_mod('pest_control_services_about_us_image_heading')); ?></h3>
              <?php }?>
              <?php if(get_theme_mod('pest_control_services_about_us_content') != ''){ ?>
                <p class="main-heading mb-4"><?php echo esc_html(get_theme_mod('pest_control_services_about_us_content')); ?></p>
              <?php }?>
              <div class="row">
                <?php for ($i=1; $i <=4 ; $i++) {  ?>
                  <?php if(get_theme_mod('pest_control_services_about_us_list_heading'.$i) != ''){ ?>
                    <div class="mb-3">
                      <h5 class="tick-box"><i class="far fa-check-circle me-2"></i></i><?php echo esc_html(get_theme_mod('pest_control_services_about_us_list_heading'.$i)); ?></h5>
                    </div>
                  <?php } ?>
                <?php }  ?>
              </div>
              <div class="abt-btns mt-4">
                <?php if(get_theme_mod('pest_control_services_about_us_button_url') != '' || get_theme_mod('pest_control_services_about_us_button_text') != ''){ ?>
                  <span class="about-btn">
                    <a href="<?php echo esc_url(get_theme_mod('pest_control_services_about_us_button_url')); ?>"><i class="fas fa-arrow-right me-2"></i><?php echo esc_html(get_theme_mod('pest_control_services_about_us_button_text')); ?></a>
                  </span>
                <?php } ?>

                <?php if(get_theme_mod('pest_control_services_about_us_video_button_url') != ''){ ?>
                  <span class="about-video-btn ">
                    <!-- Button to open the modal -->
                    <a id="openModalButton" data-modal-src="<?php echo esc_url(get_theme_mod('pest_control_services_about_us_video_button_url')); ?>"><i class="far fa-play-circle"></i>
                    </i><?php esc_html_e('Play The Video','pest-control-services') ?></a>
                    <!-- The modal -->
                    <div id="myModal" class="modal">
                      <!-- Modal content -->
                      <div class="modal-content">
                        <span id="closeModalButton" class="close">&times;</span>
                        <?php if( get_theme_mod('pest_control_services_about_us_video_button_url') != ''){ ?>
                        <embed id="videoPlayer" height="369" src="<?php echo esc_url(get_theme_mod('pest_control_services_about_us_video_button_url')); ?>"  allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></embed>
                        <?php }else{ ?>
                          <h3><?php esc_html_e('Add Video Url In Customizer To Display Video Here','pest-control-services'); ?></h3>
                        <?php } ?>
                      </div>
                    </div> 
                  </span>
                <?php } ?>
              </div>
            </div>
        </div>       
      </div>
    </div>
  </section>
  <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(); ?>