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

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

  <?php if( get_theme_mod( 'vw_lawyer_attorney_slider_hide_show', true) == 1 || get_theme_mod( 'vw_lawyer_attorney_resp_slider_hide_show', true) == 1) { ?>
      <section class="slider">
        <?php if(get_theme_mod('vw_lawyer_attorney_slider_type', 'Default slider') == 'Default slider' ){ ?>
        <div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel" data-bs-interval="<?php echo esc_attr(get_theme_mod( 'vw_lawyer_attorney_slider_speed',4000)) ?>"> 
          <?php $vw_lawyer_attorney_slider_pages = array();
            for ( $count = 1; $count <= 4; $count++ ) {
              $mod = intval( get_theme_mod( 'vw_lawyer_attorney_slider_page' . $count ));
              if ( 'page-none-selected' != $mod ) {
                $vw_lawyer_attorney_slider_pages[] = $mod;
              }
            }
            if( !empty($vw_lawyer_attorney_slider_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $vw_lawyer_attorney_slider_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_theme_file_uri()); ?>/inc/block-patterns/images/banner.png" alt="" />
                <?php } ?>
                <div class="carousel-caption">
                  <div class="inner_carousel">
                    <h1 class="wow slideInRight" 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" data-wow-duration="2s"><?php $excerpt = get_the_excerpt(); echo esc_html( vw_lawyer_attorney_string_limit_words( $excerpt, esc_attr(get_theme_mod('vw_lawyer_attorney_slider_excerpt_number','30')))); ?></p>
                      <?php
                        $vw_lawyer_attorney_button_text = get_theme_mod('vw_lawyer_attorney_slider_button_text', 'KNOW MORE');
                        $vw_lawyer_attorney_button_link = get_theme_mod('vw_lawyer_attorney_slider_button_link_text2', '');
                        if (empty($vw_lawyer_attorney_button_link)) {
                          $vw_lawyer_attorney_button_link = get_permalink();
                        }
                        if ($vw_lawyer_attorney_button_text || !empty($vw_lawyer_attorney_button_link)) { ?>
                          <div class="testbutton wow slideInRight" data-wow-duration="2s">
                            <?php if( get_theme_mod('vw_lawyer_attorney_slider_button_text', 'KNOW MORE') != ''){ ?>
                              <a class="hvr-sweep-to-right" href="<?php echo esc_url($vw_lawyer_attorney_button_link); ?>" class="button redmor">
                              <?php echo esc_html($vw_lawyer_attorney_button_text); ?>
                                <span class="screen-reader-text"><?php echo esc_html($vw_lawyer_attorney_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('vw_lawyer_attorney_slider_arrow_hide_show', true)){?>
            <a class="carousel-control-prev" data-bs-target="#carouselExampleCaptions" 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('vw_lawyer_attorney_slider_prev_icon','fas fa-angle-left')); ?>"></i></span>
              <span class="screen-reader-text"><?php esc_html_e( 'Previous','law-advocate' );?></span>
            </a>
            <a class="carousel-control-next" data-bs-target="#carouselExampleCaptions" 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('vw_lawyer_attorney_slider_next_icon','fas fa-angle-right')); ?>"></i></span>
              <span class="screen-reader-text"><?php esc_html_e( 'Next','law-advocate' );?></span>
            </a>
          <?php }?>
        </div>  
        <div class="clearfix"></div>
          <?php } else if(get_theme_mod('vw_lawyer_attorney_slider_type', 'Advance slider') == 'Advance slider'){?>
            <?php echo do_shortcode(get_theme_mod('vw_lawyer_attorney_advance_slider_shortcode')); ?>
          <?php } ?>
      </section> 
  <?php }?>

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

  <?php if(get_theme_mod('vw_lawyer_attorney_about_setting') != '' || get_theme_mod('law_advocate_section_small_title') != '' || get_theme_mod('vw_lawyer_attorney_about_name') != '') {?>
    <section id="about-section" class="p-lg-5 p-4">
      <div class="container">
        <?php
        $vw_lawyer_attorney_postData1 =  get_theme_mod('vw_lawyer_attorney_about_setting');
        if($vw_lawyer_attorney_postData1){
          $args = array( 'p' => esc_html($vw_lawyer_attorney_postData1 ,'law-advocate'),
          'post_type' => 'post'  
          );
          $query = new WP_Query( $args );
          if ( $query->have_posts() ) :
            $count = 0;
            while ( $query->have_posts() ) : $query->the_post(); ?>
              <div class="row">
                <?php if (has_post_thumbnail()){?>
                  <div class="col-lg-5 col-md-5 mb-4 align-self-center">
                    <?php the_post_thumbnail(); ?>
                  </div>
                <?php }?>
                <div class="<?php if (has_post_thumbnail()){?> col-lg-7 col-md-7 <?php } else {?> col-lg-12 col-md-12 <?php }?> align-self-center">
                  <?php if( get_theme_mod('law_advocate_section_small_title') != '' ){ ?>
                    <strong class="small-title"><?php echo esc_html(get_theme_mod('law_advocate_section_small_title'));?></strong>
                  <?php }?>
                  <h2 class="mt-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h2>
                  <p><?php $excerpt = get_the_excerpt(); echo esc_html( vw_lawyer_attorney_string_limit_words( $excerpt, esc_attr(get_theme_mod('vw_lawyer_attorney_about_excerpt_number','30')))); ?></p>

                  <div class="client-section mb-4">
                    <div class="row">
                      <div class="col-lg-2 col-md-3 col-4 align-self-center">
                        <img class="about-image2" src="<?php echo esc_url(get_theme_mod('law_advocate_about_image2'));?>" alt="About Image">
                      </div>
                      <div class="col-lg-8 col-md-8 col-8 align-self-center">
                        <h3 class="mb-0"><?php echo esc_html(get_theme_mod('law_advocate_about_client_name'));?></h3>
                        <p class="designation mb-0"><?php echo esc_html(get_theme_mod('law_advocate_about_client_designation'));?></p>
                      </div>
                    </div>
                  </div>

                  <div class="about-list">
                    <div class="row">
                      <?php for ($i=1; $i <= 4 ; $i++) { ?>
                       <div class="col-lg-6 col-md-6 mb-3 align-self-center">
                         <i class="<?php echo esc_attr(get_theme_mod('law_advocate_about_list_icon'.$i, 'fas fa-check')); ?>"></i> <span class="list mb-4"><?php echo esc_html(get_theme_mod('law_advocate_about_page_list'.$i));?></span>
                       </div>
                      <?php }?>
                    </div>
                  </div>

                  <div class="about-btn mt-4">
                    <a href="<?php the_permalink(); ?>"><?php echo esc_html(get_theme_mod('vw_lawyer_attorney_about_name',__('Free Consultation','law-advocate')));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('vw_lawyer_attorney_about_name',__('Free Consultation','law-advocate')));?></span></a>
                  </div>
                </div>
              </div>
            <?php endwhile; 
            wp_reset_postdata();?>
          <?php else : ?>
            <div class="no-postfound"></div>
          <?php endif;
        }?>
      </div>
    </section>
  <?php }?>

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

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

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