<?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 Smallbiz Startup
 */

get_header(); ?>

<div id="content">
<?php
    $smallbiz_startup_hidepageboxes_1 = get_theme_mod('smallbiz_startup_disabled_pgboxes_1', false);
    $smallbiz_startup_pageboxes = get_theme_mod('smallbiz_startup_pageboxes');

    if ($smallbiz_startup_hidepageboxes_1 && $smallbiz_startup_pageboxes) { ?>
  <div id="head-banner">
    <div class="container-fluid">
      <?php $smallbiz_startup_querymed = new WP_query('page_id='.esc_attr(get_theme_mod('smallbiz_startup_pageboxes',false)) ); ?>
        <?php while( $smallbiz_startup_querymed->have_posts() ) : $smallbiz_startup_querymed->the_post(); ?>
          <div class="row">
            <div class="col-lg-7 col-md-7 slider-con">
              <div class="content-inner-box">
                <?php if ( get_theme_mod('smallbiz_startup_pgboxes_title') != "") { ?>
                  <span><?php echo esc_html(get_theme_mod('smallbiz_startup_pgboxes_title','')); ?></span>
                <?php } ?>
                <h1><a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></h1> 
                <p><?php echo wp_trim_words( get_the_content(), get_theme_mod('smallbiz_startup_banner_excerpt_number',40) ); ?></p>
                <div class="pagemore">
                    <?php 
                    $smallbiz_startup_button_text = get_theme_mod('smallbiz_startup_button_text', 'GO NOW');
                    $smallbiz_startup_button_link_slider = get_theme_mod('smallbiz_startup_button_link_slider', ''); 
                    if (empty($smallbiz_startup_button_link_slider)) {
                        $smallbiz_startup_button_link_slider = get_permalink();
                    }
                    if ($smallbiz_startup_button_text || !empty($smallbiz_startup_button_link_slider)) { ?>
                      <?php if ( get_theme_mod('smallbiz_startup_button_text') != "" ) { ?>
                        <a href="<?php echo esc_url($smallbiz_startup_button_link_slider); ?>">
                          <?php echo esc_html($smallbiz_startup_button_text); ?>
                            <span class="screen-reader-text"><?php echo esc_html($smallbiz_startup_button_text); ?></span>
                        </a>
                      <?php } ?>
                    <?php } ?>
                  </div>
              </div>
            </div>
            <div class="col-lg-5 col-md-5 img-box">
              <div class="img-inner-box">
                <span class="color-inner-box">
                  <?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', 'smallbiz-startup'); ?>"/>
                  <?php } ?>
                  <span class="design-box"></span>
                </span>
              </div>
            </div>
          </div>
        <?php endwhile; wp_reset_postdata(); ?>
      <div class="clear"></div>
    </div>
  </div>
  <?php }?>
  
  <?php
    $smallbiz_startup_hidepageboxes = get_theme_mod('smallbiz_startup_hidepageboxes', false);
    $smallbiz_startup_pageboxes = get_theme_mod('smallbiz_startup_pageboxes');
    if( $smallbiz_startup_hidepageboxes && $smallbiz_startup_pageboxes){
  ?>
    <div id="services_section" class="text-center">
      <div class="container">
        <?php if ( get_theme_mod('smallbiz_startup_text') != "") { ?>
          <span><?php echo esc_html(get_theme_mod('smallbiz_startup_text','')); ?></span>
        <?php } ?>
        <?php if ( get_theme_mod('smallbiz_startup_title') != "") { ?>
          <h2><?php echo esc_html(get_theme_mod('smallbiz_startup_title','')); ?></h2>
        <?php } ?>
        <div class="row">
          <?php for($p=1; $p<4; $p++) { ?>
          <?php if( get_theme_mod('smallbiz_startup_pageboxes'.$p,false)) { ?>
            <?php $smallbiz_startup_querymed = new WP_query('page_id='.esc_attr(get_theme_mod('smallbiz_startup_pageboxes'.$p,false)) ); ?>
              <?php while( $smallbiz_startup_querymed->have_posts() ) : $smallbiz_startup_querymed->the_post(); ?>
              <div class="col-lg-4 col-md-4">
                <div class="pagecontent">
                  <div class="thumbbx">
                    <?php if(has_post_thumbnail()){
                      the_post_thumbnail('full');
                      } else{?>
                      <img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/service.png" alt="<?php echo esc_attr( 'service', 'smallbiz-startup'); ?>"/>
                    <?php } ?>
                  </div>
                  
                  <div class="text-inner-box">
                    <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> 
                    <p><?php echo esc_html( wp_trim_words( get_the_content(), 20, '...' ) );  ?></p>
                  </div>
                  <div class="serv-btn text-center">
                    <a href="<?php the_permalink(); ?>"><i class="fas fa-long-arrow-alt-right"></i></a>
                  </div>
                </div>
              </div>
            <?php endwhile; wp_reset_postdata(); ?>
          <?php } } ?>
          <div class="clear"></div>
        </div>
      </div>
    </div>
  <?php }?>

</div>

<?php get_footer(); ?>