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

get_header(); ?>

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

  <?php if( get_theme_mod( 'halloween_party_slider_hide_show', true) == 1 || get_theme_mod( 'halloween_party_resp_slider_hide_show', true) == 1) { ?>
    <section id="slider">   
     <?php if(get_theme_mod('halloween_party_slider_type', 'Default slider') == 'Default slider' ){ ?>     
      <div id="carouselExampleInterval" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'halloween_party_slider_speed',4000)) ?>">
        <?php $halloween_party_pages = array();
          for ( $count = 1; $count <= 3; $count++ ) {
            $mod = intval( get_theme_mod( 'halloween_party_slider_page' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $halloween_party_pages[] = $mod;
            }
          }
          if( !empty($halloween_party_pages) ) :
            $args = array(
              'post_type' => 'page',
              'post__in' => $halloween_party_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/banner.png" alt="" />
              <?php } ?>
              <div class="carousel-caption">
                <div class="inner_carousel">
                  <div class="small-slider-text">
                    <?php if( get_theme_mod('halloween_party_slidersmall_section_title') != ''){ ?>
                      <p><?php echo esc_html(get_theme_mod('halloween_party_slidersmall_section_title','')); ?></p>
                    <?php }?>
                  </div>
                  <h1 class="wow slideInRight 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>
                  <p class="wow slideInRight delay-1000" data-wow-duration="2s"><?php $halloween_party_excerpt = get_the_excerpt(); echo esc_html( halloween_party_string_limit_words( $halloween_party_excerpt, esc_attr(get_theme_mod('halloween_party_slider_excerpt_number','20')))); ?></p> 
                  <?php
                    $halloween_party_button_text = get_theme_mod('halloween_party_slider_button_text','READ MORE');
                    $halloween_party_button_link = get_theme_mod('halloween_party_top_button_url', '');
                    if (empty($halloween_party_button_link)) {
                      $halloween_party_button_link = get_permalink();
                    }
                    if ($halloween_party_button_text || !empty($halloween_party_button_link)) { ?>
                      <div class="more-btn mt-3 mt-md-4 wow slideInRight delay-1000" data-wow-duration="2s">
                        <?php if( get_theme_mod('halloween_party_slider_button_text','READ MORE') != ''){ ?>
                          <a href="<?php echo esc_url($halloween_party_button_link); ?>" class="button redmor">
                          <?php echo esc_html($halloween_party_button_text); ?>
                            <span class="screen-reader-text"><?php echo esc_html($halloween_party_button_text); ?></span>
                          </a>
                        <?php } ?>
                      </div>
                  <?php }?>
                </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('halloween_party_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('halloween_party_slider_prev_icon','fas fa-angle-left')); ?>"></i>
          <span class="screen-reader-text"><?php echo esc_html(__('Previous','halloween-party')); ?></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('halloween_party_slider_next_icon','fas fa-angle-right')); ?>"></i>
          <span class="screen-reader-text"><?php echo esc_html(__('Next','halloween-party')); ?></span>
          </button>
        <?php } ?>
      </div> 
       <?php } else if(get_theme_mod('halloween_party_slider_type', 'Advance slider') == 'Advance slider'){?>
          <?php echo do_shortcode(get_theme_mod('halloween_party_advance_slider_shortcode')); ?>
        <?php } ?>
    </section>
  <?php }?>

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

  <?php if( get_theme_mod( 'halloween_party_events_small_title') != '' || get_theme_mod( 'halloween_party_events_heading') != '' || get_theme_mod( 'halloween_party_events_category') != '') { ?>
    <section id="events-section" class="pt-5 px-2 wow bounceInDown delay-1000" data-wow-duration="3s">
      <div class="container">
        <div class="events-head text-center mb-5">
          <?php if( get_theme_mod('halloween_party_events_small_title') != '' ){ ?>
            <strong class="d-block mb-1"><?php echo esc_html(get_theme_mod('halloween_party_events_small_title',''));?></strong>
          <?php }?>
          <?php if( get_theme_mod('halloween_party_events_heading') != '' ){ ?>
            <h2 class="heading-text"><?php echo esc_html(get_theme_mod('halloween_party_events_heading',''));?></h2>
          <?php }?>
        </div>
        <div class="row">
          <div class="tab-main col-lg-3 col-md-12">
            <ul class="nav tab-nav">
              <?php 
              for ($n=1; $n < 4; $n++) { 
                $halloween_party_postData1 =  get_theme_mod('halloween_party_tab_pages'.$n);
                if($halloween_party_postData1){
                  $args = array( 
                    'p' => esc_html($halloween_party_postData1 ,'halloween-party'),
                    'post_type' => 'post'
                  );
                  $new = new WP_Query($args); ?>
                  <?php $j=1;
                  while ( $new->have_posts() ){
                    $new->the_post();  ?>
                    <li  class="outside nav-item">
                      <a class="pointer nav-link" href="#blog_tab<?php echo esc_attr($n);?>" role="tab" data-toggle="tab" onclick="halloween_party_tab_open(event, '#blog_tab<?php echo esc_attr($n);?>')">
                        <?php the_post_thumbnail(); ?>
                        <h3 ><?php the_title(); ?></h3><span class="screen-reader-text"><?php the_title(); ?></span>
                      </a>
                    </li>
                  <?php $j++;}
                wp_reset_query(); }?>
              <?php } ?>
            </ul>
          </div>
          <div class="tab-content blog_content col-lg-9 col-md-12">
            <?php 
            for ($count=1; $count < 4; $count++) { 
              $halloween_party_postData1 =  get_theme_mod('halloween_party_tab_pages'.$count);
              if($halloween_party_postData1){
                $args = array( 
                  'p' => esc_html($halloween_party_postData1 ,'halloween-party'),
                  'post_type' => 'post'
                );
                $new = new WP_Query($args); 
                ?>
                <?php $i=1; while ( $new->have_posts() ){
                  $new->the_post();  ?>
                  <div role="tabpanel" class="tm_tab tab-pane" id="blog_tab<?php echo esc_attr($count);?>">
                    <div class="events-box">
                      <?php the_post_thumbnail(); ?>
                      <div class="inner-events-box">
                        <img class="inner-events-box-img" src="<?php echo esc_url(get_template_directory_uri()); ?>/inc/block-patterns/images/eye.png" alt="" />
                        <h3 class="my-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h3>
                        <p class="pt-2 pt-md-2 pt-lg-3"><?php $halloween_party_excerpt = get_the_excerpt(); echo esc_html( halloween_party_string_limit_words( $halloween_party_excerpt, 20)); ?></p>
                        <div class="invite-btn mt-md-3 mt-2">
                          <a href="<?php the_permalink(); ?>"><?php echo esc_html('CONFIRM YOUR INVITE','halloween-party');?><span class="screen-reader-text"><?php echo esc_html('CONFIRM YOUR INVITE','halloween-party');?></span></a>
                        </div>
                      </div>
                    </div>
                  </div>
                <?php $i++; }
               wp_reset_query(); }?>
            <?php }?>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

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

  <div id="content-vw" class="entry-content 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(); ?>