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

?>
<!-- banner section -->
<main id="maincontent" role="main">

  <?php do_action( 'manufacturing_plant_above_slider' ); ?>
  
  <?php if (get_theme_mod('manufacturing_plant_hide_show_slider_section', true)) { ?>
  <?php 
    $manufacturing_plant_number = get_theme_mod('manufacturing_plant_slide_number');
    if($manufacturing_plant_number != ''){
  ?>
    <section class="slider-section wow fadeInRightBig position-relative" data-wow-delay=".25s">
      <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 ($manufacturing_plant_i = 1; $manufacturing_plant_i <= $manufacturing_plant_number; $manufacturing_plant_i++) { ?>
              <div class="carousel-item <?php echo esc_attr($manufacturing_plant_i) == 1 ? 'active' : ''; ?>">
                <?php if (get_theme_mod('manufacturing_plant_slider_bg_img' . $manufacturing_plant_i) != "") { ?>
                  <div class="slider-img position-relative">
                    <img class="slider-carousel-img" src="<?php echo esc_url(get_theme_mod('manufacturing_plant_slider_bg_img' . $manufacturing_plant_i)); ?>" alt="<?php echo esc_attr( sprintf( __( 'Slide %d', 'manufacturing-plant' ), $manufacturing_plant_i ) ); ?>">
                    <div class="slider-overlay"></div>
                  </div>
                <?php } ?>
                <div class="carousel-caption">
                  <div class="container">
                    <div class="inner_carousel text-start">
                      <?php if (get_theme_mod('manufacturing_plant_slider_small_title' . $manufacturing_plant_i) != '') { ?>
                        <p class="slider-small-title"><?php echo esc_html(get_theme_mod('manufacturing_plant_slider_small_title' . $manufacturing_plant_i)); ?></p>
                      <?php } ?>
                      <?php if (get_theme_mod('manufacturing_plant_slider_title' . $manufacturing_plant_i) != '') { ?>
                        <h1 class="slider-title text-capitalize"><?php echo esc_html(get_theme_mod('manufacturing_plant_slider_title' . $manufacturing_plant_i)); ?></h1>
                      <?php } ?>
                      <?php if (get_theme_mod('manufacturing_plant_slider_text' . $manufacturing_plant_i) != '') { ?>
                        <p class="slider-text mt-3"><?php echo esc_html(get_theme_mod('manufacturing_plant_slider_text' . $manufacturing_plant_i)); ?></p>
                      <?php } ?>
                    </div>
                    <!-- Navigation Controls -->
                    <?php if( get_theme_mod( 'manufacturing_plant_display_slider_icons', true) == true ) { ?>
                      <div class="slider-arrows">
                        <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('manufacturing_plant_slider_previous_icon','fa-solid fa-angle-left')); ?>" ></i></span>
                          <span class="screen-reader-text"><?php esc_html_e( 'Previous','manufacturing-plant' );?></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('manufacturing_plant_slider_next_icon','fa-solid fa-angle-right')); ?>" ></i></span>
                          <span class="screen-reader-text"><?php esc_html_e( 'Next','manufacturing-plant' );?></span>
                        </a>  
                      </div>
                    <?php }?>
                  </div>
                </div>
              </div>
            <?php } ?>
          </div>
        </div>
      </div>
    </section>
  <?php }}?>

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

  <!-- Industry Section -->
  <?php if (get_theme_mod('manufacturing_plant_indusrties_section_hide_show', true)){ ?>
    <section id="indusrties-section" class="wow fadeInLeftBig" data-wow-delay=".25s">
      <div class="container">
        <div class="industry-sec-content">
          <div class="row">
            <div class="col-xxl-4 col-xl-5 col-lg-5 col-md-6 col-12 section-left-content align-self-center ps-0">
              <?php if(get_theme_mod('manufacturing_plant_indusrties_section_left_text') != '') {?>
                <p class="left-text mb-0 text-capitalize"><?php echo esc_html(get_theme_mod('manufacturing_plant_indusrties_section_left_text')) ?></p>
              <?php }?>
              <?php if(get_theme_mod('manufacturing_plant_indusrties_section_title') != '') {?>
                <h2 class="section-title text-capitalize mb-0"><?php echo esc_html(get_theme_mod('manufacturing_plant_indusrties_section_title')) ?></h2>
              <?php }?>
            </div>
            <div class="col-xxl-4 col-xl-2 col-lg-2 col-md-1 col-12"></div>
            <div class="col-xxl-4 col-xl-5 col-lg-5 col-md-5 col-12 section-right-content align-self-center pe-0">
              <?php if(get_theme_mod('manufacturing_plant_indusrties_section_right_text') != '') {?>
                <p class="right-text mb-0"><?php echo esc_html(get_theme_mod('manufacturing_plant_indusrties_section_right_text')) ?></p>
              <?php }?>
            </div>
          </div>
        </div>
        <div class="row">
          <?php
            $manufacturing_plant_catdata=  get_theme_mod('manufacturing_plant_discovery_category');
            if($manufacturing_plant_catdata){
            $manufacturing_plant_page_query = new WP_Query(array(
              'category_name' => esc_html($manufacturing_plant_catdata, 'manufacturing-plant'),
              'posts_per_page' => 4
            ));  
          ?>         
          <?php while( $manufacturing_plant_page_query->have_posts() ) : $manufacturing_plant_page_query->the_post(); ?>
            <div class="col-xl-3 col-lg-3 col-md-6 col-sm-12 p-0 category-main">
              <div class="cat-box position-relative">
                <div class="post-img position-relative">
                  <?php if(has_post_thumbnail()){ ?>
                    <?php the_post_thumbnail(); ?>
                  <?php } else {?>
                    <img src="<?php echo esc_url(get_template_directory_uri()) ?>/assets/images/post-image.png" alt="<?php echo esc_attr('Post Image', 'manufacturing-plant'); ?>">
                  <?php }?>
                  <div class="image-overlay position-absolute"></div>
                </div>
                <div class="cat-btn">
                  <a href="<?php the_permalink(); ?>"><i class="fa-solid fa-chevron-right"></i></a>
                </div>
                <div class="articles text-center">
                  <h3 class="cat-title text-capitalize mb-0"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></h3>
                </div>
              </div>
            </div>
          <?php endwhile;
            wp_reset_postdata();
          }?>
        </div>
      </div>
    </section>
  <?php }?>
  <?php do_action( 'manufacturing_plant_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(); ?> 