<?php
/**
 * The template for displaying home page.
 *
 * Template Name: Custom Home Page
 *
 * @package SEO Agency Lite
 */
get_header(); ?>

<main id="main" role="main">
  
<?php if( get_theme_mod( 'digital_advertising_slider_hide_show', false ) != '' || get_theme_mod( 'digital_advertising_slider_responsive', true ) != '' ) {?>
    <div class="slider-section position-relative">
      <section id="slider">
        <div id="carouselExampleIndicators" class="carousel slide" data-bs-ride="carousel" data-bs-interval="3000"> 
          <?php $digital_advertising_slider_pages = array();
            for ( $count = 1; $count <= 4; $count++ ) {
              $mod = intval( get_theme_mod( 'digital_advertising_slider_page' . $count ));
              if ( 'page-none-selected' != $mod ) {
                $digital_advertising_slider_pages[] = $mod;
              }
            }
            if( !empty($digital_advertising_slider_pages) ) :
              $args = array(
                'post_type' => 'page',
                'post__in' => $digital_advertising_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"';}?>>
              <div class="slider-bgimage">
                <?php if(has_post_thumbnail()){
                  the_post_thumbnail();
                  } else{?>
                  <img src="<?php echo esc_url(get_theme_file_uri()); ?>/images/banner.png" alt="" />
                <?php }?>
              </div>
              <div class="carousel-caption wow zoomIn">
                <div class="inner_carousel">
                  <?php if( get_theme_mod('digital_advertising_slider_title',true) != ''){ ?>
                    <h1><?php the_title(); ?></h1>
                  <?php }?> 
                  <?php if( get_theme_mod('digital_advertising_slider_content',true) != ''){ ?> 
                    <p class="mb-3"><?php $excerpt = get_the_excerpt(); echo esc_html( digital_advertising_string_limit_words( $excerpt,esc_attr(get_theme_mod('digital_advertising_slider_excerpt_length','20')))); ?></p>
                  <?php }?>  
                  <?php if(get_theme_mod('digital_advertising_slider_button',true) != '' || get_theme_mod('digital_advertising_slider_button_responsive',true) != ''|| get_theme_mod('digital_advertising_slider_button_text','Get Started') != ''|| get_theme_mod('digital_advertising_slider_button_link') != '') {?>  
                    <div class="read-btn mt-lg-4">
                     <a href="<?php echo esc_url(get_theme_mod('digital_advertising_slider_button_link')!= '') ? esc_url(get_theme_mod('digital_advertising_slider_button_link')) : esc_url(get_permalink()); ?>" class="blogbutton-small"><?php echo esc_html(get_theme_mod('digital_advertising_slider_button_text',__('Get Started', 'seo-agency-lite'))); ?><span class="screen-reader-text"><?php echo esc_html('Get Started', 'seo-agency-lite'); ?></span>
                      </a>
                    </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('digital_advertising_slider_arrow',true) != ''){ ?>
          <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-bs-slide="prev">
            <span class="carousel-control-prev-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('digital_advertising_slider_prev_icon','fas fa-long-arrow-alt-left')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Previous','seo-agency-lite');?></span>
          </a>
          <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-bs-slide="next">
            <span class="carousel-control-next-icon" aria-hidden="true"><i class="<?php echo esc_attr(get_theme_mod('digital_advertising_slider_next_icon','fas fa-long-arrow-alt-right')); ?>"></i></span><span class="screen-reader-text"><?php esc_html_e( 'Next','seo-agency-lite');?></span>
          </a>
          <?php }?>
        </div> 
      </section> 
    </div>
  <?php }?>

  <?php do_action( 'digital_advertising_before_product_section' ); ?>
    <?php if( get_theme_mod( 'digital_advertising_about_hide_show', false )){?>
      <?php if(get_theme_mod('seo_agency_lite_about_post') != '') {?>
        <section id="about-section" class="py-5">
          <div class="container">
            <?php $args = array( 'name' => get_theme_mod('seo_agency_lite_about_post'));
                $query = new WP_Query( $args );
                if ( $query->have_posts() ) :
                  $count = 0;
                  while ( $query->have_posts() ) : $query->the_post(); ?>
                    <div class="row">
                      <div class="col-lg-6 col-md-6 align-self-center">
                        <div class="image-box position-relative wow zoomIn">
                          <div class="about-list">
                            <span class="list"><i class="fas fa-desktop me-2"></i><?php echo esc_html(get_theme_mod('digital_advertising_about_list_text1'));?></span>
                          </div>
                          <?php
                            $content = apply_filters( 'the_content', get_the_content() );
                            $video = false;
                            // Only get video from the content if a playlist isn't present.
                            if ( false === strpos( $content, 'wp-playlist-script' ) ) {
                              $video = get_media_embedded_in_content( $content, array( 'video', 'object', 'embed', 'iframe' ) );
                            }
                          ?>
                          <?php
                            if ( ! is_single() ) {
                              // If not a single post, highlight the video file.
                              if ( ! empty( $video ) ) {
                                foreach ( $video as $video_html ) {
                                  echo '<div class="entry-video">';
                                    echo $video_html;
                                  echo '</div>';
                                }
                              }
                              elseif(has_post_thumbnail()) { 
                                the_post_thumbnail(); 
                              } 
                            }; 
                          ?>    
                          <div class="about-list second-child">
                            <span class="list"><i class="fas fa-desktop me-2"></i><?php echo esc_html(get_theme_mod('digital_advertising_about_list_text2'));?></span>
                          </div>
                        </div>
                      </div>
                      <div class="col-lg-6 col-md-6 align-self-center wow zoomIn">
                        <div class="about-content position-relative">
                          <?php if(get_theme_mod('digital_advertising_section_title') != ''){ ?>
                            <h2><?php echo esc_html(get_theme_mod('digital_advertising_section_title')); ?></h2>
                          <?php }?>
                          <h3><?php the_title(); ?></h3>
                          <p><?php the_excerpt(); ?></p>
                          <div class="read-btn mt-lg-4">
                            <a href="<?php echo esc_url( get_permalink() );?>" class="blogbutton-small"><?php echo esc_html('Get In Touch', 'seo-agency-lite'); ?><span class="screen-reader-text"><?php echo esc_html('Get In Touch', 'seo-agency-lite'); ?></span>
                            </a>
                          </div>
                        </div>
                      </div>
                    </div>
                  <?php endwhile; 
                wp_reset_postdata();?>
              <?php else : ?>
                <div class="no-postfound"></div>
              <?php endif; ?>
          </div>
        </section>
      <?php }?>
    <?php }?>
  <?php do_action( 'digital_advertising_after_product_section' ); ?>

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

<?php get_footer(); ?>