<?php
/**
 * Template Name: Custom Home Page
 */

get_header(); 

?>

<main role="main" id="skip_content">
  <?php if( get_theme_mod('startup_solutions_slider_hide', false) != '' || get_theme_mod( 'startup_solutions_display_slider',true) != ''){ ?>
    <section id="slider" class=" wow slideInLeft delay-1000" data-wow-duration="2s">              
      <?php $startup_solutions_slider_pages = array();
        for ( $startup_solutions_count = 1; $startup_solutions_count <= 3; $startup_solutions_count++ ) {
          $mod = intval( get_theme_mod( 'startup_solutions_slider_page' . $startup_solutions_count ));
          if ( 'page-none-selected' != $mod ) {
            $startup_solutions_slider_pages[] = $mod;
          }
        }
        if( !empty($startup_solutions_slider_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $startup_solutions_slider_pages,
            'orderby' => 'post__in'
          );
          $query = new WP_Query( $args );?>
          <div class="owl-carousel">
            <?php
            if ( $query->have_posts() ) :
              $startup_solutions_count = 1;
              while ( $query->have_posts() ) : $query->the_post(); ?>
              
                <div class="inner_carousel">
                    <div class="image-overlay"></div>
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail(); 
                    } else{?>

                      <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/slider.png" alt="<?php echo esc_attr( 'slider', 'startup-solutions'); ?>" />

                    <?php } ?>
                    <div class="carousel-caption">
                      <?php if( get_theme_mod('startup_solutions_slider_heading',true) != ''){ ?>
                        <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?><span class="screen-reader-text"><?php the_title(); ?></span></a></h1>
                      <?php } ?>  
                      
                      <?php if( get_theme_mod('startup_solutions_slider_text',true) != ''){ ?>
                        <p><?php $startup_solutions_excerpt = get_the_excerpt(); echo esc_html( startup_solutions_string_limit_words( $startup_solutions_excerpt, esc_attr(get_theme_mod('startup_solutions_slider_excerpt_number','30')))); ?></p>
                      <?php } ?>  
                      <?php if( get_theme_mod('startup_solutions_show_slider_button',true) != ''){ ?>
                       <?php if( get_theme_mod('startup_solutions_slider_button_text','Read More') != '' || get_theme_mod('startup_solutions_slider_button_link') != ''){ ?>                          
                          <a class="read-more font-weight-bold btn my-4" href="<?php echo esc_url(get_theme_mod('startup_solutions_slider_button_link')!= '') ? esc_url(get_theme_mod('startup_solutions_slider_button_link')) : esc_url(get_permalink()); ?>" class="p-3"><?php echo esc_html( get_theme_mod('startup_solutions_slider_button_text',__('Read More','startup-solutions'))); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('startup_solutions_slider_button_text',__('Read More','startup-solutions'))); ?></span></a>                          
                        <?php } ?>
                      <?php }?>
                    </div>
                </div>

              <?php $startup_solutions_count++; endwhile; 
            wp_reset_postdata();?>
          </div>  
          <?php else : ?>
            <div class="no-postfound"></div>
      <?php endif;
      endif;?>
      <div class="clearfix"></div>
        
    </section>
  <?php }?>  

<!-- portfolio section -->
<?php if( get_theme_mod('startup_solutions_portfolio_hide', false) != '') { ?>
    <section id="portfolio-section" class="py-2">
      <div class="container wow fadeInUp">
        <div class="row my-3">
          <div class="portfolio-head my-3">
            <?php if(get_theme_mod('startup_solutions_porfolio_section_title') != '') {?>
              <h3 class="text-center"><?php echo esc_html(get_theme_mod('startup_solutions_porfolio_section_title')); ?></h3>
            <?php }?>
            <?php if(get_theme_mod('startup_solutions_porfolio_text') != '') {?>
              <p class="text-center"><?php echo esc_html(get_theme_mod('startup_solutions_porfolio_text')); ?></p>
            <?php }?>
          </div>
          <div class="row portfolio-content">
            <?php if ( get_theme_mod('startup_solutions_post_category') != '' ) {
              $page_query = new WP_Query(array( 'category_name' => esc_html(get_theme_mod('startup_solutions_post_category')))); ?>
              <?php while( $page_query->have_posts() ) : $page_query->the_post(); ?>
                <div class="col-lg-4 col-md-6">

                  <div class="box">
                      <?php the_post_thumbnail(); ?>
                      <div class="box-content">
                          <h4 ><?php the_title(); ?></h4>
                          <p class="my-3"><?php $startup_solutions_excerpt = get_the_excerpt(); echo esc_html( startup_solutions_string_limit_words( $startup_solutions_excerpt, 12)); ?></p>
                            <a href="<?php the_permalink(); ?>" class="more-btn "><?php echo esc_html('READ MORE', 'startup-solutions'); ?><span class="screen-reader-text"><?php echo esc_html('READ MORE', 'startup-solutions'); ?></span></a>
                      </div>
                      <ul class="icon">
                          <li><a href="<?php the_permalink(); ?>"><i class="fa fa-search"></i></a></li>
                      </ul>
                  </div>

                </div>  
              <?php endwhile; wp_reset_query(); ?>
            <?php } ?>
            <div class="clearfix"></div>
          </div>     
        </div>
      </div>
    </section>
<?php }?>  

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

<?php get_footer(); ?>