<?php
/*
 * Template Name: Home Page
 */
$legal_options = get_option('legal_theme_options');
get_header(); ?>
<!--section start-->
<section class="section-main home-page">
    <div class="theme-banner">
        <div id="myCarousel" class="carousel slide" data-ride="carousel">
            <div class="carousel-inner">
                <?php  $legal_slider_active=0;
                for ($legal_slider = 1; $legal_slider <= 5; $legal_slider++): 

                    $sliderimage_image = get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_image',isset($legal_options['slider-img-'.$legal_slider])?legal_get_image_id($legal_options['slider-img-'.$legal_slider]):'');                    
                    if (!empty($sliderimage_image)) {
                        $sliderimage_image_url = wp_get_attachment_image_src($sliderimage_image,'full');
                         $legal_slider_active++; ?>  
                        <div class="carousel-item <?php if ($legal_slider_active == 1) { echo'active'; } ?>">
                            <img  src="<?php echo esc_url($sliderimage_image_url[0]); ?>" alt="<?php echo esc_attr($legal_slider); ?>">
                            <div class="blur-effect"></div>
                            <?php if($legal_options) { ?>
                            <div class="banner-inner-content">
                                <?php if (get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_icon',$legal_options['faicon-slider-' . $legal_slider])!='') { ?>
                                    <i class="fa <?php echo esc_attr(get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_icon',$legal_options['faicon-slider-' . $legal_slider])); ?>"></i>
                                <?php } ?>
                                <?php if (get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_title',$legal_options['slidecaption-one-' . $legal_slider])!='') { ?>
                                    <h1><?php echo esc_html(get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_title',$legal_options['slidecaption-one-' . $legal_slider])); ?></h1>
                                <?php } ?>
                                <?php if (get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_content',$legal_options['slidecaption-second-' . $legal_slider])!='' ) { ?>
                                    <p><?php echo esc_html(get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_content',$legal_options['slidecaption-second-' . $legal_slider])); ?></p>
                                <?php } ?>
                                <?php if (get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_btn_text',$legal_options['slidebuttontext-' . $legal_slider])!='' ) { ?>
                                <?php } ?>
                                    <div class="banner-button">
                                        <a href="<?php if (get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_link',$legal_options['slidebuttonlink-' . $legal_slider])!='') { echo esc_url($legal_options['slidebuttonlink-' . $legal_slider]); } else { echo '#'; } ?>">
                                            <?php echo esc_html(get_theme_mod ( 'legal_homepage_sliderimage'.$legal_slider.'_btn_text',$legal_options['slidebuttontext-' . $legal_slider])); ?>
                                        </a>
                                    </div>
                                <?php } ?>
                            </div>
                        </div>
                    <?php } ?>
                <?php endfor; ?>
            </div>
            <!-- Carousel nav -->
            <?php if ($legal_slider_active >= 2):  ?>
                    <a class="carousel-control left nav-left" href="#myCarousel" data-slide="prev"><i class="fa fa-arrow-left"></i></a>
                    <a class="carousel-control right nav-right" href="#myCarousel" data-slide="next"><i class="fa fa-arrow-right"></i></a>
            <?php  endif; ?>
        </div> 
    </div>
    <!--banner end-->
    <!--our best-->
    <div class="home-practise-section">
        <div class="container theme-container">
            <?php if (get_theme_mod ( 'legal_homepage_section_title',isset($legal_options['home-title'])?$legal_options['home-title']:'')!=''  ||  get_theme_mod ( 'legal_homepage_section_desc',isset($legal_options['home-content'])?$legal_options['home-content']:'')!='') { ?>
                <div class="home-title">
                    <?php if (get_theme_mod ( 'legal_homepage_section_title',isset($legal_options['home-title'])?$legal_options['home-title']:'')!='') { ?>
                        <h2><span><?php echo esc_html(get_theme_mod ( 'legal_homepage_section_title',isset($legal_options['home-title'])?$legal_options['home-title']:'')); ?></span></h2>
                    <?php }
                    if (get_theme_mod ( 'legal_homepage_section_desc',isset($legal_options['home-content'])?$legal_options['home-content']:'')!='') { ?>
                        <p><?php echo esc_html(get_theme_mod ( 'legal_homepage_section_desc',isset($legal_options['home-content'])?$legal_options['home-content']:'')); ?></p>
                    <?php } ?>
                </div>
            <?php }
            if (get_theme_mod('legal_homepage_first_sectionswitch',1)==1) { ?>
            <div class="row section-column">
                <?php if (get_theme_mod ( 'legal_homepage_first_section_title',isset($legal_options['benifits-title'])?$legal_options['benifits-title']:'')!='' ) { ?>
                    <div <?php if (function_exists('appointment')) { ?>class="col-sm-6 col-md-6 column-company" <?php } else { ?>class="col-sm-12 col-md-12 column-company" <?php } ?>>
                        <div class="home-title">
                            <h2><span><?php echo esc_html(get_theme_mod ( 'legal_homepage_first_section_title',isset($legal_options['benifits-title'])?$legal_options['benifits-title']:'')); ?></span></h2>
                        </div>
                        <div class="company-col1">
                            <ul>
                                <?php for ($legal_section_fafaicons = 1; $legal_section_fafaicons <= 8; $legal_section_fafaicons++): ?>
                                    <?php if (get_theme_mod ( 'legal_homepage_first_section'.$legal_section_fafaicons.'_icon',isset($legal_options['faicons-' . $legal_section_fafaicons])?$legal_options['faicons-' . $legal_section_fafaicons]:'')!='' && get_theme_mod ( 'legal_homepage_first_section'.$legal_section_fafaicons.'_title',isset($legal_options['section-title-' . $legal_section_fafaicons])?$legal_options['section-title-' . $legal_section_fafaicons]:'')!='') { ?>
                                        <li <?php if (function_exists('appointment')) { ?> class="col-md-6 col-sm-12" <?php } else { ?> class="col-md-3 col-sm-6" <?php } ?>>
                                            <i class="fa <?php echo esc_attr(get_theme_mod ( 'legal_homepage_first_section'.$legal_section_fafaicons.'_icon',isset($legal_options['faicons-' . $legal_section_fafaicons])?$legal_options['faicons-' . $legal_section_fafaicons]:'')); ?>"></i>
                                            <span><?php echo esc_html(get_theme_mod ( 'legal_homepage_first_section'.$legal_section_fafaicons.'_title',isset($legal_options['section-title-' . $legal_section_fafaicons])?$legal_options['section-title-' . $legal_section_fafaicons]:'')); ?></span>
                                        </li>
                                    <?php }
                                endfor; ?>
                            </ul> 
                            <?php if (get_theme_mod ( 'legal_homepage_first_section_desc',isset($legal_options['benifits-content'])?$legal_options['benifits-content']:'')!='' ) { ?>
                                <p><?php echo esc_html(get_theme_mod ( 'legal_homepage_first_section_desc',isset($legal_options['benifits-content'])?$legal_options['benifits-content']:'')); ?></p>
                            <?php } ?>
                        </div>
                    </div>
                <?php }?>
            </div>
            <?php } ?>
        </div>
    </div>    
    <!--end-->
    <!--home section image bg-->
    <?php if (get_theme_mod('legal_homepage_background_sectionswitch',1)==1) { ?>
        <div class="home-image-section">
            <div class="blur-effect">
                <div class="container theme-container">
                    <?php if (get_theme_mod ( 'legal_homepage_background_section_title',isset($legal_options['bg-title'])?$legal_options['bg-title']:'')!='' ) { ?>
                        <h2><?php echo esc_html(get_theme_mod ( 'legal_homepage_background_section_title',isset($legal_options['bg-title'])?$legal_options['bg-title']:'')); ?></h2>
                    <?php }
                    if (get_theme_mod ( 'legal_homepage_background_section_btn_title',isset($legal_options['bg-btn-title'])?$legal_options['bg-btn-title']:'')!='' ) { ?>
                        <div class="banner-button">
                            <a href="<?php if (get_theme_mod ( 'legal_homepage_background_section_link',isset($legal_options['bg-btn-link'])?$legal_options['bg-btn-link']:'')!='') { echo esc_url(get_theme_mod ( 'legal_homepage_background_section_link',isset($legal_options['bg-btn-link'])?$legal_options['bg-btn-link']:'')); } else { echo "#"; } ?>"><?php echo esc_html(get_theme_mod ( 'legal_homepage_background_section_btn_title',isset($legal_options['bg-btn-title'])?$legal_options['bg-btn-title']:'')); ?></a>
                        </div>
                    <?php } ?>
                </div>
            </div>     
        </div>
    <?php } ?>
    <!--end-->
    <!--our section strat-->
    <?php if(get_theme_mod('legal_homepage_second_sectionswitch',1)==1): ?>
    <div class="home-our-blog">
        <div class="container theme-container">
            <div class="home-title">
                <?php if (get_theme_mod('legal_homepage_second_section_title',isset($legal_options['post-title'])?$legal_options['post-title']:'')!='' ) { ?>
                    <h2><span><?php echo esc_html(get_theme_mod('legal_homepage_second_section_title',isset($legal_options['post-title'])?$legal_options['post-title']:'')); ?></span></h2>
                <?php }
                if (get_theme_mod('legal_homepage_second_section_desc',isset($legal_options['post-content'])?$legal_options['post-content']:'')!='') { ?>
                    <p><?php echo esc_html(get_theme_mod('legal_homepage_second_section_desc',isset($legal_options['post-content'])?$legal_options['post-content']:'')); ?></p>
                <?php } ?>
            </div>
            <div class="masonry-container masonry">
                <div class="row our-latest-blog">
                    <?php
                    $postperpage = get_theme_mod('legal_homepage_second_section_postperpage',isset($legal_options['posts-per-page-home'])?$legal_options['posts-per-page-home']:6);
                    if(get_theme_mod('legal_homepage_second_section_category',isset($legal_options['post-category'])?$legal_options['post-category']:'')!=''):                        
                        $legal_args = array('posts_per_page' => $postperpage,
                            'cat' => get_theme_mod('legal_homepage_second_section_category',isset($legal_options['post-category'])?$legal_options['post-category']:''),
                            'meta_query' => array(array('key' => '_thumbnail_id','compare' => 'EXISTS'),));
                    else:
                        $legal_args = array('posts_per_page' => $postperpage,                        
                        'meta_query' => array(array('key' => '_thumbnail_id','compare' => 'EXISTS'),));
                    endif;
                    $legal_query = new wp_query($legal_args);
                    if ($legal_query->have_posts()) {
                        while ($legal_query->have_posts()) {
                            $legal_query->the_post(); ?>
                            <div class="col-md-4 col-sm-6 our-latest-box">
                                <div class="latest-blog-img">
                                    <div class="inner-grid">
                                      <?php if(has_post_thumbnail()): ?>
                                        <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('legal-thumbnail-image'); ?></a>
                                    <?php else: ?> 
                                        <a href="<?php the_permalink(); ?>"><div class="no-img fa-stack fa-lg"> <i class="fa fa-image fa-stack-1x"></i>
                                         <i class="fa fa-ban fa-stack-1x "></i>   </div></a>
                                      <?php endif;?>
                                      <div class="post-meta">
                                        <ul>
                                          <?php legal_entry_meta(); ?>    
                                        </ul>
                                      </div>
                                    </div>
                                    <div class="latest-blog-inner">
                                        <a class="latest-blog-title" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
                                        <?php the_excerpt(); ?>
                                    </div>
                                </div>
                            </div>
                        <?php }
                    } ?>
                </div>
            </div>
        </div>
    </div>
<?php endif; ?>
    <!--end-->
</section>
<!--section end-->
<?php get_footer(); ?>