<?php
/**
 * Template Name: Custom Home Page
 */
get_header();

?>
<!-- slider section -->
<main id="maincontent" role="main">
  <?php do_action( 'vw_locksmith_above_slider' ); ?>
  
  <?php if (get_theme_mod('vw_locksmith_hide_show_slider_section', false)) { ?>
  <?php 
    $vw_locksmith_number = get_theme_mod('vw_locksmith_slide_number');
    if($vw_locksmith_number != ''){
  ?>
    <section class="slider-section position-relative">
      <div id="slider" class="mw-100 m-auto p-0">
        <div id="carouselExampleIndicators" class="carousel slide carousel-fade" data-bs-ride="carousel">
          <!-- Slider Items -->
          <div class="carousel-inner" role="listbox">
            <?php for ($vw_locksmith_i = 1; $vw_locksmith_i <= $vw_locksmith_number; $vw_locksmith_i++) { ?>
              <div class="carousel-item <?php echo esc_attr($vw_locksmith_i) == 1 ? 'active' : ''; ?>">
                <?php if (get_theme_mod('vw_locksmith_slider_bg_img' . $vw_locksmith_i) != "") { ?>
                  <div class="slider-bg position-relative d-flex">
                    <div class="slider-left-bg"></div>
                    <img class="slider-carousel-img" src="<?php echo esc_url(get_theme_mod('vw_locksmith_slider_bg_img' . $vw_locksmith_i)); ?>" alt="<?php echo esc_attr( sprintf( __( 'Slide %d', 'vw-locksmith' ), $vw_locksmith_i ) ); ?>">
                    <div class="banner-social-box position-absolute">
                      <?php if ( is_active_sidebar( 'social-widget-sidemenu' ) ) : ?>                
                        <?php dynamic_sidebar('social-widget-sidemenu'); ?>
                      <?php else : ?>
                        <div class="custom-social-icons">
                          <ul class="social-icons">
                            <a href="https://facebook.com" target="_blank"><i class="fa-brands fa-facebook-f"></i></a>
                            <a href="https://twitter.com" target="_blank"><i class="fa-brands fa-twitter"></i></a>
                            <a href="https://instagram.com" target="_blank"><i class="fa-brands fa-instagram"></i></a>
                            <a href="https://linkedin.com" target="_blank"><i class="fa-brands fa-linkedin-in"></i></a>
                            <a href="https://youtube.com" target="_blank"><i class="fa-brands fa-youtube"></i></a>
                          </ul>
                        </div>
                      <?php endif; ?>
                    </div>
                  </div>
                <?php } ?>
                <div class="carousel-caption">
                  <div class="inner_carousel text-lg-start text-md-start text-center px-4 py-5">
                    <?php if (get_theme_mod('vw_locksmith_slider_small_title' . $vw_locksmith_i) != '') { ?>
                      <p class="slider-small-title text-capitalize wow fadeInDown" data-wow-delay=".25s"><?php echo esc_html(get_theme_mod('vw_locksmith_slider_small_title' . $vw_locksmith_i)); ?></p>
                    <?php } ?>
                    <?php if (get_theme_mod('vw_locksmith_slider_title' . $vw_locksmith_i) != '') { ?>
                      <h1 class="slider-title text-capitalize wow fadeInDown" data-wow-delay=".30s"><?php echo esc_html(get_theme_mod('vw_locksmith_slider_title' . $vw_locksmith_i)); ?></h1>
                    <?php } ?>
                    <?php if (get_theme_mod('vw_locksmith_slider_text' . $vw_locksmith_i) != '') { ?>
                      <p class="slider-text mt-2 mb-4 wow fadeInDown" data-wow-delay=".40s"><?php echo esc_html(get_theme_mod('vw_locksmith_slider_text' . $vw_locksmith_i)); ?></p>
                    <?php } ?>
                    
                      <div class ="slider-btn d-flex gap-3 align-items-center wow fadeInDown" data-wow-delay=".45s">
                        <?php if ( get_theme_mod('vw_locksmith_slider_button_label' . $vw_locksmith_i) != '' || get_theme_mod('vw_locksmith_slider_button_url' . $vw_locksmith_i) != '') {?>
                          <a href="<?php echo esc_url(get_theme_mod('vw_locksmith_slider_button_url' . $vw_locksmith_i));?>" class="text-uppercase button1"><?php echo esc_html(get_theme_mod('vw_locksmith_slider_button_label' . $vw_locksmith_i));?>
                          </a>
                        <?php }?>
                        <?php if ( get_theme_mod('vw_locksmith_slider_next_button_label' . $vw_locksmith_i) != '' || get_theme_mod('vw_locksmith_slider_next_button_url' . $vw_locksmith_i) != '') {?>
                          <a href="<?php echo esc_url(get_theme_mod('vw_locksmith_slider_next_button_url' . $vw_locksmith_i));?>" class="text-uppercase button2"><?php echo esc_html(get_theme_mod('vw_locksmith_slider_next_button_label' . $vw_locksmith_i));?>
                          </a>
                        <?php }?>
                      </div>
                  </div>
                  <!-- Navigation Controls -->
                  <div class="slider-arrows position-relative mt-5">
                    <a class="carousel-control-prev" data-bs-target="#carouselExampleIndicators" data-bs-slide="prev" role="button">
                      <span class="carousel-control-prev-icon w-auto h-auto" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('vw_locksmith_slider_previous_icon','fa-solid fa-angle-left')); ?>" ></i></span>
                      <span class="screen-reader-text"><?php esc_html_e( 'Previous','vw-locksmith' );?></span>
                    </a>
                    <a class="carousel-control-next" data-bs-target="#carouselExampleIndicators" data-bs-slide="next" role="button">
                      <span class="carousel-control-next-icon w-auto h-auto" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('vw_locksmith_slider_next_icon','fa-solid fa-angle-right')); ?>" ></i></span>
                      <span class="screen-reader-text"><?php esc_html_e( 'Next','vw-locksmith' );?></span>
                    </a>  
                  </div>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
      </div>
    </section>
  <?php }}?>

  <!-- Product Section -->
  <?php if (get_theme_mod('vw_locksmith_products_section_hide_show', false)){ ?>
    <section id="products-section" class="my-5">
      <div class="container">
        <div class="products-sec-content mb-5 text-center wow fadeInDown">
          <div class="row">
            <div class="col-lg-6 col-md-6 col-12 align-self-center text-lg-start text-md-start text-center products-sec-title">
              <?php if(get_theme_mod('vw_locksmith_products_section_title') != '') {?>
                <i class="<?php echo esc_attr(get_theme_mod('vw_locksmith_products_section_title_icon','fa-solid fa-door-closed')); ?> me-2"></i><h2 class="section-title text-uppercase d-inline"><?php echo esc_html(get_theme_mod('vw_locksmith_products_section_title')) ?></h2>
              <?php }?>
            </div>
            <div class="col-lg-6 col-md-6 col-12 align-self-center text-lg-end text-md-end text-center">
              <?php if ( get_theme_mod('vw_locksmith_product_sec_button_label') != '' || get_theme_mod('vw_locksmith_product_sec_button_url') != '') {?>
                <div class ="product-sec-btn mt-lg-0 mt-md-0 mt-3">
                  <a href="<?php echo esc_url(get_theme_mod('vw_locksmith_product_sec_button_url'));?>" class="text-capitalize"><?php echo esc_html(get_theme_mod('vw_locksmith_product_sec_button_label'));?>
                  </a>
                </div>
              <?php }?>
            </div>
          </div>
        </div>
        <div class="row">
          <?php if ( class_exists( 'WooCommerce' ) ) {
            $vw_locksmith_selected_category = get_theme_mod('vw_locksmith_best_product_category', '');
            if (!empty($vw_locksmith_selected_category)) {
              $vw_locksmith_args = array( 
                'post_type'      => 'product',
                'product_cat'    => $vw_locksmith_selected_category,
                'order'          => 'ASC',
                'hide_empty'     => 0,
                'posts_per_page' => 4,
              );
              $vw_locksmith_loop = new WP_Query($vw_locksmith_args);
              while ($vw_locksmith_loop->have_posts()) : $vw_locksmith_loop->the_post(); global $product; ?>
                <div class="col-xl-3 col-lg-3 col-md-6 col-sm-6 col-12 mb-3">
                  <div class="product-box p-3 wow zoomIn">
                    <div class="product-box-img p-4 text-center">
                      <?php if ( has_post_thumbnail( $vw_locksmith_loop->post->ID ) ) {
                        echo get_the_post_thumbnail( $vw_locksmith_loop->post->ID, 'shop_catalog' );
                      } else {
                        echo '<img src="'.esc_url(woocommerce_placeholder_img_src()).'" />';
                      } ?>
                    </div>
                    <div class="product-box-content text-start mt-4">
                      <h3 class="product-title text-uppercase mb-3"><a href="<?php echo esc_url( get_permalink( $vw_locksmith_loop->post->ID ) ); ?>"><?php the_title(); ?></a></h3>
                      <p class="product-price mb-0">
                        <?php echo wc_price( $product->get_regular_price() ); ?>
                      </p>
                    </div>
                  </div>
                </div>
              <?php endwhile;
              wp_reset_postdata();
          }} ?>
        </div>
      </div>
    </section>
  <?php }?>
  <?php do_action( 'vw_locksmith_after_service' ); ?>

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

<?php get_footer(); ?> 