<?php
/**
 * Template Name: Custom home page
 */
get_header(); ?>

<main id="maincontent" role="main">
  <?php do_action('multipurpose_photography_above_slider_section'); ?>
  <?php if( get_theme_mod( 'multipurpose_photography_slider_hide_show', false ) != '' || get_theme_mod( 'multipurpose_photography_slider_responsive', false ) != '' ) {?>
    <section id="slider">
      <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod('multipurpose_photography_slider_speed',3000)); ?>"> 
        <?php $multipurpose_photography_content_pages = array();
          for ( $count = 1; $count <= 4; $count++ ) {
            $mod = intval( get_theme_mod( 'multipurpose_photography_slidersettings_page' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $multipurpose_photography_content_pages[] = $mod;
            }
          }
          if( !empty($multipurpose_photography_content_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $multipurpose_photography_content_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 wow zoomIn" data-wow-delay="0.3s" data-wow-duration="1.4s"';} else{ echo 'class="carousel-item"';}?>>
            <?php if(has_post_thumbnail()){
                  the_post_thumbnail();
              } else{?>
              <img src="<?php echo esc_url(get_template_directory_uri()); ?>/block-pattern/images/banner.png" alt="" />
            <?php } ?>
            <div class="carousel-caption">
              <div class="inner_carousel text-center">
                <?php if ( get_theme_mod('multipurpose_photography_slider_title',true) != '' ) {?>
                  <h1><?php the_title(); ?></h1> 
                <?php }?>
                <?php if ( get_theme_mod('multipurpose_photography_slider_content',true) != '' ) {?>
                  <p><?php $multipurpose_photography_excerpt = get_the_excerpt(); echo esc_html( multipurpose_photography_string_limit_words( $multipurpose_photography_excerpt, esc_attr(get_theme_mod('multipurpose_photography_slider_excerpt','25')))); ?></p>
                <?php }?>
                <?php if(get_theme_mod('multipurpose_photography_slider_button',true) != '' || get_theme_mod('multipurpose_photography_slider_button_responsive',true) != ''|| get_theme_mod('multipurpose_photography_slider_button_link') != '') {?>
                  <?php if ( get_theme_mod('multipurpose_photography_slider_button_label','READ MORE') != '' ) {?>
                    <div class ="read-more mt-md-4 mt-0">
                      <a href="<?php echo esc_url(get_theme_mod('multipurpose_photography_slider_button_link')!= '') ? esc_url(get_theme_mod('multipurpose_photography_slider_button_link')) : esc_url(get_permalink()); ?>"><?php echo esc_html( get_theme_mod('multipurpose_photography_slider_button_label',__('READ MORE','multipurpose-photography')) ); ?><i class="fas fa-caret-right ps-2"></i><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('multipurpose_photography_slider_button_label',__('READ MORE','multipurpose-photography')) ); ?></span></a>
                    </div>  
                  <?php }?>   
                <?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('multipurpose_photography_slider_arrow_hide_show', true)){?>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
            <span class="carousel-control-prev-icon py-1 px-3" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('multipurpose_photography_slider_prev_icon','fas fa-caret-left')); ?>"></i></span>
            <span class="screen-reader-text"><?php esc_html_e('Previous','multipurpose-photography'); ?></span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
            <span class="carousel-control-next-icon py-1 px-3" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('multipurpose_photography_slider_next_icon','fas fa-caret-right')); ?>"></i></span>
            <span class="screen-reader-text"><?php esc_html_e('Next','multipurpose-photography'); ?></span>
          </a>
        <?php } ?>   
      </div>
      <div class="clearfix"></div>
    </section> 
  <?php }?>

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

  <div class="header-nav">
    <div id="header" class="<?php if( get_theme_mod( 'multipurpose_photography_sticky_header') != '') { ?> sticky-header"<?php } else { ?>close-sticky <?php } ?>">
      <div class="container">
        <div class="row">
          <div class="<?php if(get_theme_mod('multipurpose_photography_show_search',true)) { ?>col-lg-11 col-md-11 col-10" <?php } else { ?>col-lg-12 col-md-12 <?php } ?>">
            <?php if (has_nav_menu('primary')){ ?>
              <div id="sidelong-menu" class="nav side-nav">
                <nav id="primary-site-navigation" class="nav-menu" role="navigation" aria-label="<?php esc_attr_e( 'Top Menu', 'multipurpose-photography' ); ?>">
                  <?php 
                    wp_nav_menu( array( 
                      'theme_location' => 'primary',
                      'container_class' => 'main-menu-navigation clearfix' ,
                      'menu_class' => 'clearfix',
                      'items_wrap' => '<ul id="%1$s" class="%2$s mobile_nav">%3$s</ul>',
                      'fallback_cb' => 'wp_page_menu',
                    ) ); 
                  ?>
                </nav>
              </div>
            <?php }?>
          </div>
          <?php if(get_theme_mod('multipurpose_photography_show_search',true) ){ ?>
            <div class="search-box col-lg-1 col-md-1 col-2 ps-0 my-1 position-relative align-self-center">
              <div class="wrap p-3"><?php get_search_form(); ?></div>
            </div>
          <?php }?>
        </div>
      </div>
    </div> 
  </div>
  <?php if( get_theme_mod( 'multipurpose_photography_service_section_hide_show', false )) {?>
    <?php if( get_theme_mod('multipurpose_photography_services_title') != '' || get_theme_mod('multipurpose_photography_services_category') != ''){ ?>
      <section id="services" class="py-5 text-center wow fadeInUp" data-wow-delay="0.3s" data-wow-duration="1.4s">
        <div class="container">
          <?php if( get_theme_mod('multipurpose_photography_services_title') != ''){ ?>
            <h2 class="btn--corners mb-2"><span class="p-4"><?php echo esc_html(get_theme_mod('multipurpose_photography_services_title','')); ?></span></h2>
          <?php }?>
          <div class="row">
            <?php 
            $multipurpose_photography_catData=  get_theme_mod('multipurpose_photography_services_category');
            if($multipurpose_photography_catData){
              $page_query = new WP_Query(array( 'category_name' => esc_html( $multipurpose_photography_catData ,'multipurpose-photography')));?>
              <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                <div class="col-lg-3 col-md-3">
                  <div class="service-content my-4">
                    <h3 class="pt-0 pb-1 px-4 text-center"><a href="<?php echo esc_url( get_permalink() );?>" class="py-2"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h3>
                    <?php the_post_thumbnail(); ?>
                  </div>
                </div>
              <?php endwhile;
              wp_reset_postdata();
            } ?>
          </div>
        </div>
      </section>
    <?php }?>
  <?php }?>
  <?php do_action('multipurpose_photography_after_service_section'); ?>

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

<?php get_footer(); ?>