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

get_header(); ?>

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

  <?php if( get_theme_mod( 'web_designer_slider_hide_show', true) == 1 || get_theme_mod( 'web_designer_resp_slider_hide_show', true) == 1) { ?>
    <?php if(get_theme_mod('web_designer_slider_type', 'Default slider') == 'Default slider' ){ ?> 
      <section id="slider" class="py-5">       
        <div id="carouselExampleInterval" class="carousel carousel-fade" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'web_designer_slider_speed',4000)) ?>">
          <?php $web_designer_pages = array();
            for ( $count = 1; $count <= 3; $count++ ) {
              $mod = intval( get_theme_mod( 'web_designer_slider_page' . $count ));
              if ( 'page-none-selected' != $mod ) {
                $web_designer_pages[] = $mod;
              }
            }
            if( !empty($web_designer_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $web_designer_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"';}?>>
                <div class="container">
                  <div class="row">
                    <div class="col-lg-5 col-md-5">
                      <?php if(has_post_thumbnail()){
                        the_post_thumbnail();
                      } else{?>
                        <img src="<?php echo esc_url(get_template_directory_uri()); ?>/inc/block-patterns/images/banner-circle.png" alt="" />
                      <?php } ?>
                    </div>
                    <div class="col-lg-7 col-md-7">
                      <div class="carousel-caption">
                        <div class="inner_carousel">
                          <?php if( get_theme_mod('web_designer_slider_title_hide_show',true) == 1){ ?>
                            <h1><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('web_designer_slider_content_hide_show',true) == 1){ ?>
                              <p class="slider-text"><?php $web_designer_excerpt = get_the_excerpt(); echo esc_html( web_designer_string_limit_words( $web_designer_excerpt, esc_attr(get_theme_mod('web_designer_slider_excerpt_number','20')))); ?></p>
                            <?php } ?>
                          <div class="counter-section">
                            <div class="row">
                              <?php for ( $count = 1; $count <= 3; $count++ ) {?>
                                <div class="col-lg-4 col-md-4 pe-md-0">
                                  <div class="counter-box">
                                    <p class="counter-no"><?php echo esc_html(get_theme_mod('web_designer_counter_no'.$count)); ?></p>
                                    <p class="counter-text"><?php echo esc_html(get_theme_mod('web_designer_counter_text'.$count)); ?></p>
                                  </div>
                                </div>
                              <?php }?>
                            </div>
                          </div>
                          <?php if( get_theme_mod('web_designer_slider_button_text','Get In Touch') != ''){ ?>
                             <div class="read-btn wow bounceInDown delay-1000" data-wow-duration="2s">
                              <a href="<?php echo esc_url(get_theme_mod('web_designer_top_button_url',false));?>"><?php echo esc_html(get_theme_mod('web_designer_slider_button_text',__('Get In Touch','web-designer')));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('web_designer_slider_button_text',__('Get In Touch','web-designer')));?></span></a><i class="<?php echo esc_attr(get_theme_mod('web_designer_slider_button_icon','fas fa-angle-right')); ?>"></i>
                            </div>
                          <?php } ?>
                        </div>
                      </div>
                    </div>
                  </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('web_designer_slider_arrow_hide_show', true)){?>
            <button class="carousel-control-prev" type="button" data-bs-target="#carouselExampleInterval" id="prev" data-bs-slide="prev">
            <i class="<?php echo esc_attr(get_theme_mod('web_designer_slider_prev_icon','fas fa-angle-left')); ?>"></i>
            <span class="screen-reader-text"><?php echo esc_html(__('Previous','web-designer')); ?></span>
            </button>
            <button class="carousel-control-next" type="button" data-bs-target="#carouselExampleInterval" data-bs-slide="next" id="next">
            <i class="<?php echo esc_attr(get_theme_mod('web_designer_slider_next_icon','fas fa-angle-right')); ?>"></i>
            <span class="screen-reader-text"><?php echo esc_html(__('Next','web-designer')); ?></span>
            </button>
          <?php }?>
        </div> 
      </section>
    <?php } else if(get_theme_mod('web_designer_slider_type', 'Advance slider') == 'Advance slider'){?>
      <?php echo do_shortcode(get_theme_mod('web_designer_advance_slider_shortcode')); ?>
    <?php } ?>
  <?php }?>

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

  <?php if(get_theme_mod('web_designer_section_title') != '' || get_theme_mod('web_designer_section_small_title') != '' || get_theme_mod('web_designer_service_category') != '') {?>
    <section id="service-section" class="py-5 wow slideInRight delay-1000" data-wow-duration="2s">
      <div class="container">
        <div class="row">
          <div class="col-lg-3 col-md-4">
            <div class="service-head">
              <?php if( get_theme_mod('web_designer_section_small_title') != '' ){ ?>
                <strong class="small-title"><?php echo esc_html(get_theme_mod('web_designer_section_small_title'));?></strong>
              <?php }?>
              <?php if( get_theme_mod('web_designer_section_title') != '' ){ ?>
                <h2><?php echo esc_html(get_theme_mod('web_designer_section_title'));?></h2>
              <?php }?>
            </div>
          </div>
          <div class="col-lg-9 col-md-8">
            <div class="owl-carousel">
              <?php
              $web_designer_catData = get_theme_mod('web_designer_service_category');
              if($web_designer_catData){
                $page_query = new WP_Query(array( 'category_name' => esc_html( $web_designer_catData ,'web-designer')));
                while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                  <div class="service-box text-center wow zoomIn" data-wow-duration="2s">
                    <div class="bx-image"><?php the_post_thumbnail(); ?></div>
                    <div class="service-content">
                      <h3><a href="<?php the_permalink(); ?>"><?php the_title();?></a></h3>
                      <p class="mb-0"><?php $web_designer_excerpt = get_the_excerpt(); echo esc_html( web_designer_string_limit_words( $web_designer_excerpt, 10)); ?></p>
                    </div>
                  </div>
                <?php endwhile;
                wp_reset_postdata();
              } ?>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

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

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

<?php get_footer(); ?>