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

get_header(); ?>

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

  <?php if( get_theme_mod( 'vw_dark_slider_hide_show', true) == 1 || get_theme_mod( 'vw_dark_resp_slider_hide_show', true) == 1) { ?>
    <section id="slider"> 
      <?php if(get_theme_mod('vw_dark_slider_type', 'Default slider') == 'Default slider' ){ ?>       
      <div id="carouselExampleInterval" class="carousel carousel-fade" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'vw_dark_slider_speed',4000)) ?>">
        <?php $vw_dark_pages = array();
          for ( $count = 1; $count <= 3; $count++ ) {
            $mod = intval( get_theme_mod( 'vw_dark_slider_page' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $vw_dark_pages[] = $mod;
            }
          }
          if( !empty($vw_dark_pages) ) :
            $args = array(
              'post_type' => 'page',
              'post__in' => $vw_dark_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">
                  <?php if( get_theme_mod('vw_dark_slider_small_title') != '' ){ ?>
                    <strong class="small-title"><?php echo esc_html(get_theme_mod('vw_dark_slider_small_title'));?></strong>
                  <?php }?>
                  <?php if( get_theme_mod('vw_dark_slider_title_hide_show',true) == 1
                  ){ ?>
                    <h1 class="wow rollIn 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>
                  <?php } ?>
                  <div class="slider-btn wow lightSpeedIn delay-1000" data-wow-duration="2s"> 
                    <a href="<?php echo esc_url(get_permalink()); ?>"><?php echo esc_html('SEE MORE','vw-dark');?><span class="screen-reader-text"><?php echo esc_html(__('SEE MORE','vw-dark'));?></span></a>
                  </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('vw_dark_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('vw_dark_slider_prev_icon','fas fa-angle-left')); ?>"></i>
          <span class="screen-reader-text"><?php echo esc_html(__('Previous','vw-dark')); ?></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('vw_dark_slider_next_icon','fas fa-angle-right')); ?>"></i>
          <span class="screen-reader-text"><?php echo esc_html(__('Next','vw-dark')); ?></span>
          </button>
        <?php }?>
      </div> 
      <div class="social-icons">
        <?php if(get_theme_mod('vw_dark_facebook_url') != ''){?>
          <a href="<?php echo esc_url(get_theme_mod('vw_dark_facebook_url')) ?>" target="_blank"><i class="fab fa-facebook-f"></i><span class="screen-reader-text"><?php echo esc_html('Facebook', 'vw-dark'); ?></span></a>
        <?php }?>
        <?php if(get_theme_mod('vw_dark_twitter_url') != ''){?>
          <a href="<?php echo esc_url(get_theme_mod('vw_dark_twitter_url')) ?>" target="_blank"><i class="fab fa-twitter"></i><span class="screen-reader-text"><?php echo esc_html('Twitter', 'vw-dark'); ?></span></a>
        <?php }?>
        <?php if(get_theme_mod('vw_dark_pinterest_url') != ''){?>
          <a href="<?php echo esc_url(get_theme_mod('vw_dark_pinterest_url')) ?>" target="_blank"><i class="fab fa-pinterest-p"></i><span class="screen-reader-text"><?php echo esc_html('Pinterest', 'vw-dark'); ?></span></a>
        <?php }?>
        <?php if(get_theme_mod('vw_dark_youtube_url') != ''){?>
          <a href="<?php echo esc_url(get_theme_mod('vw_dark_youtube_url')) ?>" target="_blank"><i class="fab fa-youtube"></i><span class="screen-reader-text"><?php echo esc_html('Youtube', 'vw-dark'); ?></span></a>
        <?php }?>
      </div>
      <?php } else if(get_theme_mod('vw_dark_slider_type', 'Advance slider') == 'Advance slider'){?>
        <?php echo do_shortcode(get_theme_mod('vw_dark_advance_slider_shortcode')); ?>
      <?php } ?>
    </section>
  <?php }?>

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

  <?php if(get_theme_mod('vw_dark_section_title') != '' || get_theme_mod('vw_dark_section_small_title') != '' || get_theme_mod('vw_dark_service_category') != '') {?>
    <section id="about-section" class="py-5 wow bounceInDown delay-1000" data-wow-duration="3s">
      <div class="container">
        <?php
        $vw_dark_about_post =  get_theme_mod('vw_dark_about_post');
        if($vw_dark_about_post){
          $args = array( 'p' => esc_html($vw_dark_about_post ,'vw-dark'),
          'post_type' => 'post',  
        );
          $query = new WP_Query( $args );
          if ( $query->have_posts() ) :
            $count = 0;
            while ( $query->have_posts() ) : $query->the_post(); ?>
              <div class="row">
                <?php if (has_post_thumbnail()){?>
                  <div class="col-lg-6 col-md-12 align-self-center">
                    <?php the_post_thumbnail(); ?>
                  </div>
                <?php }?>
                <div class="<?php if (has_post_thumbnail()){?> col-lg-6 col-md-12<?php } else {?> col-lg-12 col-md-12 <?php }?> align-self-center">
                  <?php if( get_theme_mod('vw_dark_section_small_title') != '' ){ ?>
                    <strong class="small-title"><?php echo esc_html(get_theme_mod('vw_dark_section_small_title'));?></strong>
                  <?php }?>
                  <h2><?php the_title(); ?></h2>
                  <p><?php $vw_dark_excerpt = get_the_excerpt(); echo esc_html( vw_dark_string_limit_words( $vw_dark_excerpt, 30)); ?></p>
                  <div class="seemore-btn">
                    <a href="<?php the_permalink(); ?>"><?php echo esc_html('SEE MORE', 'vw-dark'); ?><span class="screen-reader-text"><?php echo esc_html('SEE MORE', 'vw-dark'); ?></span></a>
                  </div>
                  <div class="experience-box mt-5">
                    <div class="row">
                      <div class="col-lg-3 col-md-4 align-self-center pe-md-0">
                        <?php if(get_theme_mod('vw_dark_experience_years') != ''){ ?>
                          <span><?php echo esc_html(get_theme_mod('vw_dark_experience_years')); ?></span>
                        <?php }?>
                      </div>
                      <div class="col-lg-9 col-md-8 align-self-center">
                        <?php if(get_theme_mod('vw_dark_experience_text') != ''){ ?>
                          <p class="mb-md-0"><?php echo esc_html(get_theme_mod('vw_dark_experience_text')); ?></p>
                        <?php }?>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            <?php endwhile; 
            wp_reset_postdata();?>
          <?php else : ?>
            <div class="no-postfound"></div>
          <?php endif;
        }?>
      </div>
    </section>
  <?php }?>

  <?php do_action( 'vw_dark_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(); ?>