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

get_header(); ?>

<main id="skip-content">
  <?php if (get_theme_mod('social_media_marketing_banner_section_setting', false) != '') { ?>
    <section id="top-banner">
      <div class="container">
        <div class="social-link text-center">
          <?php if(get_theme_mod('social_media_marketing_facebook_url') != ''){ ?>
              <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_facebook_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('social_media_marketing_facebook_icon') ); ?>"></i></a>
          <?php }?>
          <?php if(get_theme_mod('social_media_marketing_twitter_url') != ''){ ?>
              <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_twitter_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('social_media_marketing_twitter_icon') ); ?>"></i></a>
          <?php }?>
          <?php if(get_theme_mod('social_media_marketing_intagram_url') != ''){ ?>
              <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_intagram_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('social_media_marketing_instagram_icon') ); ?>"></i></a>
          <?php }?>
          <?php if(get_theme_mod('social_media_marketing_linkedin_url') != ''){ ?>
              <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_linkedin_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('social_media_marketing_linkedin_icon') ); ?>"></i></a>
          <?php }?>
          <?php if(get_theme_mod('social_media_marketing_pintrest_url') != ''){ ?>
              <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_pintrest_url','')); ?>"><i class="<?php echo esc_attr( get_theme_mod('social_media_marketing_pinterest_icon') ); ?>"></i></a>
          <?php }?>
      </div>
        <div class="row">
          <div class="col-lg-6 col-md-6 align-self-center">
            <div class="banner-content">
              <?php if (get_theme_mod('social_media_marketing_banner_short_heading') != '') {?>
                <h5 class="short-heading"><?php echo esc_html(get_theme_mod('social_media_marketing_banner_short_heading')); ?></h5>
              <?php }?>
              <?php if (get_theme_mod('social_media_marketing_banner_heading') != '') {?>
                <h2><?php echo esc_html(get_theme_mod('social_media_marketing_banner_heading')); ?></h2>
              <?php }?>
              <?php if (get_theme_mod('social_media_marketing_banner_btn1_text') != '' || get_theme_mod('social_media_marketing_banner_btn1_url') != '' || get_theme_mod('social_media_marketing_banner_btn2_url') != '' || get_theme_mod('social_media_marketing_banner_btn2_text') != '') {?>
                <div class="banner-btn mt-3">
                  <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_banner_btn1_url')); ?>"><?php echo esc_html(get_theme_mod('social_media_marketing_banner_btn1_text')); ?><i class="fas fa-arrow-right ms-2"></i></a>
                  <a href="<?php echo esc_url(get_theme_mod('social_media_marketing_banner_btn2_url')); ?>" class="second-btn"><?php echo esc_html(get_theme_mod('social_media_marketing_banner_btn2_text')); ?><i class="fas fa-arrow-right ms-2"></i></a>
                </div>
              <?php }?>
            </div>
          </div>
          <div class="col-lg-6 col-md-6">
            <div class="banner-img">
              <?php if (get_theme_mod('social_media_marketing_banner_image') != '') {?>
                <img src="<?php echo esc_url(get_theme_mod('social_media_marketing_banner_image'));?>"/>
              <?php } else {?>
                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/banner-img.png"/>
              <?php }?>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>

  <?php if (get_theme_mod('social_media_marketing_categories_section_setting', false) != '') { ?>
    <section id="top-services" class="py-5 mt-5">
      <div class="container">
        <div class="project-heading text-center">
          <?php if(get_theme_mod('social_media_marketing_service_short_heading') != ''){ ?>
            <h5><?php echo esc_html(get_theme_mod('social_media_marketing_service_short_heading')); ?></h5>
          <?php }?>
          <?php if(get_theme_mod('social_media_marketing_service_heading') != ''){ ?>
            <h3 class="main-heading"><?php echo esc_html(get_theme_mod('social_media_marketing_service_heading')); ?></h3>
          <?php }?>
        </div>
        <div class="row">
          <div class="col-lg-2 col-md-3 service-col1">
            <div class="service-box">
              <?php $social_media_marketing_service_page1 = array();
              $social_media_marketing_mod = intval( get_theme_mod( 'social_media_marketing_service_page1' ));
              if ( 'page-none-selected' != $social_media_marketing_mod ) {
                $social_media_marketing_service_page1[] = $social_media_marketing_mod;
              }
              if( !empty($social_media_marketing_service_page1) ) :
                $social_media_marketing_args = array(
                  'post_type' => 'page',
                  'post__in' => $social_media_marketing_service_page1,
                  'orderby' => 'post__in'
                );
                $social_media_marketing_query = new WP_Query( $social_media_marketing_args );
                if ( $social_media_marketing_query->have_posts() ) : ?>
                  <?php  while ( $social_media_marketing_query->have_posts() ) : $social_media_marketing_query->the_post(); ?>
                    <div class="item-image">
                      <a href="<?php the_permalink(); ?>">
                        <?php if(has_post_thumbnail()){
                          the_post_thumbnail();
                        } else{?>
                          <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/service1.png" alt="" />
                        <?php } ?>
                      </a>
                    </div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                  <?php endwhile;
                  wp_reset_postdata();?>
                <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
            </div>
            <div class="service-box">
              <?php $social_media_marketing_service_page2 = array();
              $social_media_marketing_mod = intval( get_theme_mod( 'social_media_marketing_service_page2' ));
              if ( 'page-none-selected' != $social_media_marketing_mod ) {
                $social_media_marketing_service_page2[] = $social_media_marketing_mod;
              }
              if( !empty($social_media_marketing_service_page2) ) :
                $social_media_marketing_args = array(
                  'post_type' => 'page',
                  'post__in' => $social_media_marketing_service_page2,
                  'orderby' => 'post__in'
                );
                $social_media_marketing_query = new WP_Query( $social_media_marketing_args );
                if ( $social_media_marketing_query->have_posts() ) : ?>
                  <?php  while ( $social_media_marketing_query->have_posts() ) : $social_media_marketing_query->the_post(); ?>
                    <div class="item-image">
                      <a href="<?php the_permalink(); ?>">
                        <?php if(has_post_thumbnail()){
                          the_post_thumbnail();
                        } else{?>
                          <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/service1.png" alt="" />
                        <?php } ?>
                      </a>
                    </div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                  <?php endwhile;
                  wp_reset_postdata();?>
                <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
            </div>
          </div>
          <div class="col-lg-8 col-md-6 service-col2">
            <div class="service-box">
              <?php $social_media_marketing_service_page3 = array();
              $social_media_marketing_mod = intval( get_theme_mod( 'social_media_marketing_service_page3' ));
              if ( 'page-none-selected' != $social_media_marketing_mod ) {
                $social_media_marketing_service_page3[] = $social_media_marketing_mod;
              }
              if( !empty($social_media_marketing_service_page3) ) :
                $social_media_marketing_args = array(
                  'post_type' => 'page',
                  'post__in' => $social_media_marketing_service_page3,
                  'orderby' => 'post__in'
                );
                $social_media_marketing_query = new WP_Query( $social_media_marketing_args );
                if ( $social_media_marketing_query->have_posts() ) : ?>
                  <?php  while ( $social_media_marketing_query->have_posts() ) : $social_media_marketing_query->the_post(); ?>
                    <div class="item-image">
                      <a href="<?php the_permalink(); ?>">
                        <?php if(has_post_thumbnail()){
                          the_post_thumbnail();
                        } else{?>
                          <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/service1.png" alt="" />
                        <?php } ?>
                      </a>
                    </div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                  <?php endwhile;
                  wp_reset_postdata();?>
                <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
            </div>
          </div>
          <div class="col-lg-2 col-md-3 service-col3">
            <div class="service-box">
              <?php $social_media_marketing_service_page4 = array();
              $social_media_marketing_mod = intval( get_theme_mod( 'social_media_marketing_service_page4' ));
              if ( 'page-none-selected' != $social_media_marketing_mod ) {
                $social_media_marketing_service_page4[] = $social_media_marketing_mod;
              }
              if( !empty($social_media_marketing_service_page4) ) :
                $social_media_marketing_args = array(
                  'post_type' => 'page',
                  'post__in' => $social_media_marketing_service_page4,
                  'orderby' => 'post__in'
                );
                $social_media_marketing_query = new WP_Query( $social_media_marketing_args );
                if ( $social_media_marketing_query->have_posts() ) : ?>
                  <?php  while ( $social_media_marketing_query->have_posts() ) : $social_media_marketing_query->the_post(); ?>
                    <div class="item-image">
                      <a href="<?php the_permalink(); ?>">
                        <?php if(has_post_thumbnail()){
                          the_post_thumbnail();
                        } else{?>
                          <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/service1.png" alt="" />
                        <?php } ?>
                      </a>
                    </div>
                    <h4><a href="<?php the_permalink(); ?>"><?php echo wp_trim_words(get_the_title(), 2, '...'); ?></a></h4>
                  <?php endwhile;
                  wp_reset_postdata();?>
                <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
            </div>
            <div class="service-box">
              <?php $social_media_marketing_service_page5 = array();
              $social_media_marketing_mod = intval( get_theme_mod( 'social_media_marketing_service_page5' ));
              if ( 'page-none-selected' != $social_media_marketing_mod ) {
                $social_media_marketing_service_page5[] = $social_media_marketing_mod;
              }
              if( !empty($social_media_marketing_service_page5) ) :
                $social_media_marketing_args = array(
                  'post_type' => 'page',
                  'post__in' => $social_media_marketing_service_page5,
                  'orderby' => 'post__in'
                );
                $social_media_marketing_query = new WP_Query( $social_media_marketing_args );
                if ( $social_media_marketing_query->have_posts() ) : ?>
                  <?php  while ( $social_media_marketing_query->have_posts() ) : $social_media_marketing_query->the_post(); ?>
                    <div class="item-image">
                      <a href="<?php the_permalink(); ?>">
                        <?php if(has_post_thumbnail()){
                          the_post_thumbnail();
                        } else{?>
                          <img src="<?php echo esc_url(get_theme_file_uri()); ?>/assets/img/service1.png" alt="" />
                        <?php } ?>
                      </a>
                    </div>
                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                  <?php endwhile;
                  wp_reset_postdata();?>
                <?php else : ?>
                  <div class="no-postfound"></div>
                <?php endif;
              endif;?>
            </div>
          </div>
        </div>
      </div>
    </section>
  <?php }?>
  <section id="page-content">
    <div class="container">
      <div class="py-5">
        <?php
          if ( have_posts() ) :
            while ( have_posts() ) : the_post();
              the_content();
            endwhile;
          endif;
        ?>
      </div>
    </div>
  </section>
</main>

<?php get_footer(); ?>