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

<main id="maincontent" role="main">
  <?php do_action('multipurpose_lawyer_above_slider_section'); ?>
  
  <?php if( get_theme_mod( 'multipurpose_lawyer_slider_hide_show', false ) != '' || get_theme_mod( 'multipurpose_lawyer_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_lawyer_slider_speed',3000)); ?>"> 
        <?php $multipurpose_lawyer_content_pages = array();
          for ( $count = 1; $count <= 4; $count++ ) {
            $mod = intval( get_theme_mod( 'multipurpose_lawyer_slidersettings_page' . $count ));
            if ( 'page-none-selected' != $mod ) {
              $multipurpose_lawyer_content_pages[] = $mod;
            }
          }
          if( !empty($multipurpose_lawyer_content_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $multipurpose_lawyer_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 bounceInDown" data-wow-delay="0.3s" data-wow-duration="1.4s"';} else{ echo 'class="carousel-item"';}?>>
            <a href="<?php the_permalink(); ?>"><?php if(has_post_thumbnail()){
                  the_post_thumbnail();
              } else{?>
                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/block-patterns/images/banner.png" alt="" />
              <?php } ?><span class="screen-reader-text"><?php the_title(); ?></span></a>
            <?php if ( get_theme_mod('multipurpose_lawyer_slider_title',true) != '' || get_theme_mod('multipurpose_lawyer_slider_content',true) != '' || get_theme_mod('multipurpose_lawyer_slider_button',true) != '' ) {?>
              <div class="carousel-caption d-none d-md-block p-5">
                <div class="inner_carousel wow zoomIn">
                  <?php if ( get_theme_mod('multipurpose_lawyer_slider_title',true) != '' ) {?>
                    <h1><?php the_title(); ?></h1> 
                  <?php }?>
                  <?php if ( get_theme_mod('multipurpose_lawyer_slider_content',true) != '' ) {?>
                    <p><?php $multipurpose_lawyer_excerpt = get_the_excerpt(); echo esc_html( multipurpose_lawyer_string_limit_words( $multipurpose_lawyer_excerpt, esc_attr(get_theme_mod('multipurpose_lawyer_slider_excerpt','25')))); ?></p>
                  <?php }?>
                  <?php if(get_theme_mod('multipurpose_lawyer_slider_button',true) != '' || get_theme_mod('multipurpose_lawyer_slider_button_responsive',true) != ''|| get_theme_mod('multipurpose_lawyer_slider_button_link') != '') {?>
                    <?php if ( get_theme_mod('multipurpose_lawyer_slider_button_label','READ MORE') != '' ) {?>
                      <div class ="read-more mt-4">
                        <a href="<?php echo esc_url(get_theme_mod('multipurpose_lawyer_slider_button_link')!= '') ? esc_url(get_theme_mod('multipurpose_lawyer_slider_button_link')) : esc_url(get_permalink()); ?>"><?php echo esc_html( get_theme_mod('multipurpose_lawyer_slider_button_label',__('READ MORE','multipurpose-lawyer')) ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('multipurpose_lawyer_slider_button_label',__('READ MORE','multipurpose-lawyer')) ); ?></span></a>
                      </div>  
                    <?php }?>  
                  <?php }?>                   
                </div>
              </div>
            <?php }?>
          </div>
          <?php $i++; endwhile; 
          wp_reset_postdata();?>
        </div>
        <?php else : ?>
          <div class="no-postfound"></div>
        <?php endif;
        endif;?>
        <?php if(get_theme_mod('multipurpose_lawyer_slider_arrow_hide_show', true)){?>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('multipurpose_lawyer_slider_prev_icon','fas fa-angle-left')); ?>"></i></span>
            <span class="screen-reader-text"><?php esc_html_e('Previous','multipurpose-lawyer'); ?></span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('multipurpose_lawyer_slider_next_icon','fas fa-angle-right')); ?>"></i></span>
            <span class="screen-reader-text"><?php esc_html_e('Next','multipurpose-lawyer'); ?></span>
          </a>
        <?php } ?>  
      </div>  
      <div class="clearfix"></div>
    </section> 
  <?php }?>

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

  <?php if( get_theme_mod('multipurpose_lawyer_practice_setting') != ''){ ?>
    <section id="practice" class="py-md-0 py-3 text-md-start text-center">
      <div class="container">
        <div class="row">
          <div class="col-lg-9 col-md-9">
            <?php
            $multipurpose_lawyer_postData1 =  get_theme_mod('multipurpose_lawyer_practice_setting');
            if($multipurpose_lawyer_postData1){
              $args = array( 'name' => esc_html($multipurpose_lawyer_postData1 ,'multipurpose-lawyer'));
              $query = new WP_Query( $args );
              if ( $query->have_posts() ) :
                while ( $query->have_posts() ) : $query->the_post(); ?>
                  <div class="row">
                    <div class="col-lg-3 col-md-3">
                      <div class="abt-image">
                        <?php the_post_thumbnail(); ?>
                      </div>
                    </div>
                    <div class="col-lg-9 col-md-9 practice-text my-lg-4 m-0 p-3">
                      <span class="head mb-lg-0 mb-3"><?php the_title(); ?></span>
                      <?php if ( get_theme_mod('multipurpose_lawyer_practice_button_text','OUR PRACTICE') != '' ) {?>                        
                        <span><a class="practice-btn" href="<?php the_permalink(); ?>"><?php esc_html_e( get_theme_mod('multipurpose_lawyer_practice_button_text',__('OUR PRACTICE','multipurpose-lawyer')) ); ?><span class="screen-reader-text"><?php esc_html_e(get_theme_mod('multipurpose_lawyer_practice_button_text',__('OUR PRACTICE','multipurpose-lawyer')) ); ?></span></a></span>
                      <?php }?>  
                    </div> 
                  </div>         
                <?php endwhile; 
                wp_reset_postdata();?>
              <?php else : ?>
                <div class="no-postfound"></div>
              <?php endif; 
            }?>
          </div>
          <div class="col-lg-3 col-md-3">
            <div class="call my-4">
              <?php if ( get_theme_mod('multipurpose_lawyer_phone_text','') != "" || get_theme_mod('multipurpose_lawyer_phone_no','') != "" ) {?>
                <p class="heading mb-0 text-center"><?php echo esc_html( get_theme_mod('multipurpose_lawyer_phone_text','')); ?></p>
                <a href="tel:<?php echo esc_attr( get_theme_mod('multipurpose_lawyer_email','')); ?>"><p class="mb-0 text-center"><?php echo esc_html( get_theme_mod('multipurpose_lawyer_phone_no','')); ?></p><span class="screen-reader-text"><?php esc_html_e('Phone Number','multipurpose-lawyer'); ?></span></a>
              <?php }?>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

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

  <?php if( get_theme_mod('multipurpose_lawyer_about_setting') != ''){ ?>
    <?php /*--About Us--*/?>
    <section id="about" class="py-5 wow bounceIn" data-wow-delay="0.3s" data-wow-duration="1.4s">
      <div class="container">
        <div class="row">
          <?php
            $multipurpose_lawyer_postData1 =  get_theme_mod('multipurpose_lawyer_about_setting');
            if($multipurpose_lawyer_postData1){
              $args = array( 'name' => esc_html($multipurpose_lawyer_postData1 ,'multipurpose-lawyer'));
            $query = new WP_Query( $args );
            if ( $query->have_posts() ) :
              while ( $query->have_posts() ) : $query->the_post(); ?>
                <div class="col-lg-4 col-md-4">
                  <div class="abt-image">
                    <?php the_post_thumbnail(); ?>
                  </div>
                </div>
                <div class="col-lg-8 col-md-8">
                  <h2><?php the_title(); ?></h2>
                  <p class="m-0"><?php the_excerpt(); ?></p>
                  <div class ="read-more mt-4">
                    <a href="<?php the_permalink(); ?>"><?php esc_html_e('READ MORE','multipurpose-lawyer'); ?><span class="screen-reader-text"><?php esc_html_e('READ MORE','multipurpose-lawyer'); ?></span></a>
                  </div>
                </div>          
              <?php endwhile; 
              wp_reset_postdata();?>
            <?php else : ?>
              <div class="no-postfound"></div>
            <?php
          endif; }?>
        </div>
      </div>
    </section>
  <?php }?>

  <?php do_action('multipurpose_lawyer_after_about_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(); ?>