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

<main id="content">
  <?php if( get_option('business_consulting_lite_hide_show', false) !== 'off'){ ?>
    <section id="slider">
      <div id="carouselExampleAutoplaying" class="carousel slide" data-bs-ride="carousel">
        <?php $business_consulting_lite_slider_count = get_theme_mod('business_consulting_lite_slider_count'); ?>
              <?php
                for ( $i = 1; $i <= $business_consulting_lite_slider_count; $i++ ) {
            $business_consulting_lite_mod =  get_theme_mod( 'business_consulting_lite_post_setting' . $i );
            if ( 'page-none-selected' != $business_consulting_lite_mod ) {
              $business_consulting_lite_slide_post[] = $business_consulting_lite_mod;
            }
          }
           if( !empty($business_consulting_lite_slide_post) ) :
          $business_consulting_lite_args = array(
            'post_type' =>array('post'),
            'post__in' => $business_consulting_lite_slide_post,
            'ignore_sticky_posts'  => true, // Exclude sticky posts by default
          );

          // Check if specific posts are selected
          if (empty($business_consulting_lite_slide_post) && is_sticky()) {
              $business_consulting_lite_args['post__in'] = get_option('sticky_posts');
          }

          $business_consulting_lite_query = new WP_Query( $business_consulting_lite_args );
          if ( $business_consulting_lite_query->have_posts() ) :
            $i = 1;
        ?>
        <div class="carousel-inner" role="listbox">
          <?php  while ( $business_consulting_lite_query->have_posts() ) : $business_consulting_lite_query->the_post(); ?>
          <div <?php if($i == 1){echo 'class="carousel-item active"';} else{ echo 'class="carousel-item"';}?>>
            <?php if(has_post_thumbnail()){ ?>
              <img src="<?php the_post_thumbnail_url('full'); ?>"/>
            <?php }else{?>
              <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/slider.jpg" alt="" />
            <?php } ?>
            <div class="carousel-caption slider-inner">
              <h2 class="slider-title"><?php the_title();?></h2>
              <?php if( get_option('business_consulting_lite_slider_excerpt_show_hide',false) != 'off'){ ?>
                <p class="slider-excerpt mb-0"><?php echo wp_trim_words(get_the_content(), get_theme_mod('business_consulting_lite_slider_excerpt_count',20) );?></p>
              <?php } ?>
              <div class="home-btn  my-4">
                <a class="py-md-3 px-md-4 py-2 px-3" href="<?php the_permalink(); ?>"><?php echo esc_html(get_theme_mod('business_consulting_lite_slider_read_more',__('READ MORE','business-consulting-lite'))); ?><i class="fas fa-chevron-right ms-3"></i></a>
              </div>
            </div>
          </div>
          <?php $i++; endwhile;
          wp_reset_postdata();?>
        </div>
        <?php else : ?>
        <div class="no-postfound"></div>
          <?php endif;
        endif;?>
          <a class="carousel-control-prev" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"><i class="fas fa-long-arrow-alt-left"></i></span>
          </a>
          <a class="carousel-control-next" type="button" data-bs-target="#carouselExampleAutoplaying" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"><i class="fas fa-long-arrow-alt-right"></i></span>
          </a>
      </div>
      <div class="clearfix"></div>
    </section>
  <?php }?>

  <?php if( get_option('business_consulting_lite_skill_enable', false) !== 'off'){ ?>
    <section id="skill" class="py-5 text-center">
      <div class="container">
        <?php if( get_theme_mod('business_consulting_lite_skill_title') != '' ){ ?>
          <h3 class="mb-4"><?php echo esc_html(get_theme_mod('business_consulting_lite_skill_title','')); ?></h3>
        <?php }?>
        <?php if( get_theme_mod('business_consulting_lite_skill_btn_text') != ''){ ?>
          <p><?php echo esc_html(get_theme_mod('business_consulting_lite_skill_btn_text','')); ?></p>
        <?php }?>
        <div class="row pt-5">
          <?php $business_consulting_lite_skill = get_theme_mod('business_consulting_lite_skill_increament');
          for ($i=1; $i <= $business_consulting_lite_skill; $i++) { ?>
            <div class="col-lg-3 col-md-3 col-sm-6">
              <div class="skill-box mb-5 text-center">
                <div class="skill-icon">
                  <?php if( get_theme_mod('business_consulting_lite_skill_box_icon'.$i) != '' ){ ?>
                    <i class="<?php echo esc_html(get_theme_mod('business_consulting_lite_skill_box_icon'.$i)); ?> wow rotateIn"></i>
                  <?php }?>
                </div>
                <?php if( get_theme_mod('business_consulting_lite_skill_box_number'.$i) != '' ){ ?>
                  <h4 class="mt-3"><?php echo esc_html(get_theme_mod('business_consulting_lite_skill_box_number'.$i)); ?></h4>
                <?php }?>
                <?php if( get_theme_mod('business_consulting_lite_skill_box_title'.$i) != '' ){ ?>
                  <p><?php echo esc_html(get_theme_mod('business_consulting_lite_skill_box_title'.$i)); ?></p>
                <?php }?>
              </div>
            </div>
          <?php } ?>
        </div>
      </div>
    </section>
  <?php }?>
  <section id="custom-page-content" <?php if ( have_posts() && trim( get_the_content() ) !== '' ) echo 'class="pt-3"'; ?>>
    <div class="container">
      <?php while ( have_posts() ) : the_post(); ?>
        <?php the_content(); ?>
      <?php endwhile; ?>
    </div>
  </section>
</main>

<?php get_footer(); ?>
