<?php
/**
 * The Template Name: Home Page
 *
 * This is the template that displays all pages by default.
 * Please note that this is the WordPress construct of pages
 * and that other 'pages' on your WordPress site will use a
 * different template.
 *
 * @package Solar Services
 */

get_header(); ?>

<div id="content">
  <?php
    $solar_services_hidcatslide = get_theme_mod('solar_services_hide_categorysec', true);
    $solar_services_slidersection = get_theme_mod('solar_services_slidersection');

    if ($solar_services_hidcatslide && $solar_services_slidersection) { ?>
  <section id="catsliderarea">
      <div class="catwrapslider">  
        <div class="owl-carousel">
          <?php if( get_theme_mod('solar_services_slidersection',false) ) { ?>
          <?php $solar_services_queryvar = new WP_Query('cat='.esc_attr(get_theme_mod('solar_services_slidersection',false)));
            while( $solar_services_queryvar->have_posts() ) : $solar_services_queryvar->the_post(); ?>
              <div class="slidesection"> 
                <?php if(has_post_thumbnail()){
                  the_post_thumbnail('full');
                  } else{?>
                  <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'solar-services'); ?>"/>
                <?php } ?>
                <div class="cover">
                  <div class="slider-box">
                    <h1 class="big-title mb-3"><a class="text-decoration-none" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
                    <div class="slider-btn mt-md-4">
                      <?php if (get_theme_mod('solar_services_button_text', 'Our Service') != "" && get_theme_mod('solar_services_button_link_slider') != '') { ?>
                          <a class="mb-2 btn1" href="<?php echo esc_url(get_theme_mod('solar_services_button_link_slider', '')); ?>"><?php echo esc_html(get_theme_mod('solar_services_button_text', __('Our Service', 'solar-services'))); ?><i class="far fa-arrow-alt-circle-right ms-2"></i><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('solar_services_button_text', __('Our Service', 'solar-services'))); ?></span></a>
                      <?php } ?>
                      <?php 
                        $solar_services_button_text2 = get_theme_mod('solar_services_button_text2', 'More About Us');
                        $solar_services_button_text2link = get_theme_mod('solar_services_button_text2link', ''); 
                        if (empty($solar_services_button_text2link)) {
                            $solar_services_button_text2link = get_permalink();
                        }
                        if ($solar_services_button_text2 || !empty($solar_services_button_text2link)) { ?>
                          <?php if (get_theme_mod('solar_services_button_text2', 'More About Us') != "" ) { ?>
                            <a class="me-3 mb-2 btn2" href="<?php echo esc_url($solar_services_button_text2link); ?>">
                              <?php echo esc_html($solar_services_button_text2); ?>
                              <span class="screen-reader-text"><?php echo esc_html($solar_services_button_text2); ?></span>
                            </a>
                          <?php } ?>
                        <?php } ?>
                    </div>
                  </div>
                </div>
                <!-- <div class="slideroverly"></div> -->
              </div>
            <?php endwhile; wp_reset_postdata(); ?>
          <?php } ?>
        </div>
      </div>
      <div class="clear"></div>
    </section>
    
  <?php } ?>

  <?php
    $solar_services_feature_hidepageboxes = get_theme_mod('solar_services_disabled_feature_pgboxes', true);
    $solar_services_feature_cat = get_theme_mod('solar_services_feature_cat');
    if( $solar_services_feature_hidepageboxes && $solar_services_feature_cat){
  ?>
  <section id="feature_box">
    <div class="container">
      <div class="row">
        <div class="col-lg-4 col-md-4 col-sm-12">
        <div class="fea_bx">
          <h2><?php echo esc_html(get_theme_mod('solar_services_featureleftheading',__('Our Facility','solar-services'))); ?></h2>
          <p><?php echo esc_html(get_theme_mod('solar_services_featureleftdescription',__('The sun provides us with free energy, place solar panels on roof. solar cell, solar module manufacturing facilities are considerable. we must go above our customer expectations during interaction.','solar-services'))); ?></p>
          <ul>
            <li><?php echo esc_html(get_theme_mod('solar_services_featureleftlist1',__('Best Energy Solution','solar-services'))); ?></li>
            <li><?php echo esc_html(get_theme_mod('solar_services_featureleftlist2',__('End-To-End Services','solar-services'))); ?></li>
            <li><?php echo esc_html(get_theme_mod('solar_services_featureleftlist3',__('Global Expertise','solar-services'))); ?></li>
            <li><?php echo esc_html(get_theme_mod('solar_services_featureleftlist4',__('Certified Engineers','solar-services'))); ?></li>
          </ul>
          <div class="feature-btn mt-2">
            <a class="text-decoration-none" href="<?php echo esc_html(get_theme_mod('solar_services_featureleftbtnlink',__('#','solar-services'))); ?>">
              <?php echo esc_html(get_theme_mod('solar_services_featureleftbtntext',__('Our Service','solar-services'))); ?><i class="far fa-arrow-alt-circle-right"></i></a>
          </div>
        </div>
        </div>
        <div class="col-lg-8 col-md-8 col-sm-12">
          <div class="fea-rhs">
          <div class="row m-0">
            <?php if( get_theme_mod('solar_services_feature_cat',false) ) { ?>

              <?php $solar_services_queryvar = new WP_Query(
                  array( 
                    'cat' => esc_attr(get_theme_mod('solar_services_feature_cat',false)),
                    'posts_per_page' => 8
                  )
                );

                while( $solar_services_queryvar->have_posts() ) : $solar_services_queryvar->the_post(); ?>
                  <div class="col-lg-3 col-md-4 col-sm-6 odd-even">
                    <div class="feature_inner_box">
                      <div class="feature-img">
                        <?php the_post_thumbnail( 'full' ); ?>
                      </div>
                      <h3 class="feature-title pt-3 pb-2 mb-0"><a class="text-decoration-none" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                    </div>
                  </div>
                <?php endwhile; wp_reset_postdata(); ?>
              <?php } ?>
          </div>
        </div>
        </div>
      </div>
    </div>
  </section>
  <?php }?>


<?php
    $solar_services_service_hidepageboxes = get_theme_mod('solar_services_service_hidepageboxes', true);
    $solar_services_blog_cat = get_theme_mod('solar_services_blog_cat');
    if( $solar_services_service_hidepageboxes && $solar_services_blog_cat){
  ?>
  <section id="blog" class="py-4 mt-4">
        <div class="container">
          <div class="blog_bx">
            <div class="subhed"><?php echo esc_html(get_theme_mod('solar_services_headingtext1','solar-services')); ?></div>
            <h4><?php echo esc_html(get_theme_mod('solar_services_headingtext_para','solar-services')); ?></h4>
          </div>
            
          <div class="mx-auto">
              <div class="row justify-content-center">

                <?php if( get_theme_mod('solar_services_blog_cat',false) ) { ?>

                <?php $solar_services_queryvar = new WP_Query(
                  array( 
                    'cat' => esc_attr(get_theme_mod('solar_services_blog_cat',false)),
                    'posts_per_page' => esc_attr(get_theme_mod('solar_services_blog_count',3,false))
                  )
                );
               
                while( $solar_services_queryvar->have_posts() ) : $solar_services_queryvar->the_post(); ?>

                <div class="col-lg-4 col-md-6 col-sm-12 ">
                  <div class="blog h-100">
                    <?php the_post_thumbnail( 'full' ); ?>

                    <div class="box position-relative content ">
                      <li class="cmm">
                      <a href="javascript:void(0);"><i class="fas fa-comment-alt"></i> <?php echo esc_html(get_comments_number($post->ID)); ?></a>
                    </li>
                    <li class="date">
                      <?php echo esc_html(get_the_date('M ')); echo esc_html(get_the_date('j'));?>,<?php echo esc_html(get_the_date(' Y')); ?>
                    </li>
                      
                        <!-- Heading -->
                        <h5 class="fw-bolder" style="color: #011a43;"><a class="text-decoration-none" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>

                        <!-- Text -->
                        <?php
                        $solar_services_trimexcerpt = get_the_excerpt();
                        $solar_services_shortexcerpt = wp_trim_words( $solar_services_trimexcerpt, $num_words = 20 );
                        echo '<p class="lh-sm mb-1" style="color: #8e8e8f;">' . esc_html( $solar_services_shortexcerpt ) . '</p>'; 
                        ?>

                      <!-- Link -->
                      <div class="blog-btn">
                        <a class="text-decoration-none " href="#" style="color: #fff;"><?php esc_html_e('Read More','solar-services'); ?><i class="far fa-arrow-alt-circle-right"></i></a>
                      </div>
                    </div>
                  </div>
                </div>

                <?php endwhile; wp_reset_postdata(); ?>
                <?php } ?>

              </div>
          </div>
        </div>
  </section>
<?php }?>

</div>

<?php get_footer(); ?>