<?php
/**
 * Template Name: Home Custom Page
 */
get_header(); ?>

<main id="main" role="main">
  <?php do_action( 'katib_writers_before_banner' ); ?>
  <div class="<?php if( get_theme_mod('katib_writers_banner_width_options', 'Full Width') == 'Container Width'){ ?>container <?php }?>">
    <?php if( get_theme_mod('katib_writers_banner_show_hide', false) != ''){ ?>
      <section id="banner">
        <?php $katib_writers_slider_pages = array();
          $mod = absint( get_theme_mod( 'katib_writers_banner_page' ));
          if ( 'page-none-selected' != $mod ) {
            $katib_writers_slider_pages[] = $mod;
          }
        if( !empty($katib_writers_slider_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $katib_writers_slider_pages,
            'orderby' => 'post__in'
          );
          $query = new WP_Query( $args );
          if ( $query->have_posts() ) :
            $count = 0;
            while ( $query->have_posts() ) : $query->the_post(); ?>  
              <?php if(has_post_thumbnail()){
               the_post_thumbnail();
              } else{?>
                <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/slider.png" alt="" />
              <?php } ?>
              <div class="box-content">
                <?php if( get_theme_mod('katib_writers_banner_title',true) != ''){ ?>
                  <h1><?php the_title(); ?></h1>
                <?php } ?>
                <?php if( get_theme_mod('katib_writers_banner_content',true) != ''){ ?>
                  <p class="py-2"><i class="fas fa-quote-left p-1"></i><?php $katib_writers_excerpt = get_the_excerpt(); echo esc_html( katib_writers_string_limit_words( $katib_writers_excerpt, esc_attr(get_theme_mod('katib_writers_slider_excerpt_number','20')))); ?><i class="fas fa-quote-right p-1"></i></p> 
                <?php } ?>
                <?php if( get_theme_mod('katib_writers_banner_contact_number',true) != ''){ ?>
                  <div class="contact">
                    <?php if( get_theme_mod( 'katib_writers_call','' ) != '') { ?>
                      <a href="tel:<?php echo esc_attr( get_theme_mod('katib_writers_call','' )); ?>" class="pe-3"><i class="<?php echo esc_attr(get_theme_mod('katib_writers_phone_number_icon_changer','fas fa-phone-volume')); ?> pe-2"></i><?php echo esc_html( get_theme_mod('katib_writers_call','') ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('katib_writers_call','') ); ?></span></a>
                    <?php }?>  
                    <?php if( get_theme_mod( 'katib_writers_email','' ) != '') { ?>
                      <a href="mailto:<?php echo esc_attr( get_theme_mod('katib_writers_call','') ); ?>"><i class="<?php echo esc_attr(get_theme_mod('katib_writers_email_icon_changer','far fa-envelope')); ?> pe-2"></i><?php echo esc_html( get_theme_mod('katib_writers_email','') ); ?><span class="screen-reader-text"><?php echo esc_html( get_theme_mod('katib_writers_call','') ); ?></span></a>
                    <?php }?>   
                  </div>     
                <?php } ?>
                <?php if( get_theme_mod('katib_writers_banner_social_media',true) != ''){ ?>
                  <div class="social-media my-3">
                    <a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blank"><i class="fab fa-facebook-f me-1" aria-hidden="true"></i><span class="screen-reader-text"><?php esc_html_e( 'Facebook','katib-writers' );?></span></a>
                    <a href="https://www.linkedin.com/shareArticle?mini=true&url=<?php the_permalink(); ?>" target="_blank"><i class="fab fa-linkedin-in me-1" aria-hidden="true"></i><span class="screen-reader-text"><?php esc_html_e( 'Linkedin','katib-writers' );?></span></a>
                    <a href="https://twitter.com/share?url=<?php the_permalink(); ?>" target="_blank" ><i class="fab fa-twitter me-1" aria-hidden="true"></i><span class="screen-reader-text"><?php esc_html_e( 'Twitter','katib-writers' );?></span></a>
                    <a href="http://www.instagram.com/submit?url=<?php the_permalink(); ?>" target="_blank" ><i class="fab fa-instagram me-1"></i><span class="screen-reader-text"><?php esc_html_e( 'Instagram','katib-writers' );?></span></a>
                  </div>
                <?php } ?>
                <?php if( get_theme_mod('katib_writers_banner_button',true) != '' || get_theme_mod('katib_writers_show_hide_banner_button',true) != ''){ ?>
                  <?php if( get_theme_mod('katib_writers_banner_button_text','READ MORE') != ''){ ?>
                    <div class ="readbutton mt-md-3">
                      <a href="<?php echo esc_url( get_theme_mod('katib_writers_slider_button_text_url','') );?>"><?php echo esc_html(get_theme_mod('katib_writers_banner_button_text','READ MORE'));?><span class="screen-reader-text"><?php echo esc_html(get_theme_mod('katib_writers_banner_button_text','READ MORE'));?></span></a>
                    </div>
                  <?php } ?>
                <?php } ?>
                <div class="clearfix"></div>
              </div>                            
            <?php $count++; endwhile; ?>
          <?php else : ?>
            <div class="no-postfound"></div>
          <?php endif;
        endif; wp_reset_postdata();?>
      </section>
    <?php }?>
  <?php do_action( 'katib_writers_after_banner' ); ?>

  <?php if( get_theme_mod('katib_writers_about_page') != ''){ ?>
    <section id="about" class="py-5">
      <div class="container">
        <?php $katib_writers_slider_pages = array();
          $mod = absint( get_theme_mod( 'katib_writers_about_page'));
          if ( 'page-none-selected' != $mod ) {
            $katib_writers_slider_pages[] = $mod;
          }
        if( !empty($katib_writers_slider_pages) ) :
          $args = array(
            'post_type' => 'page',
            'post__in' => $katib_writers_slider_pages,
            'orderby' => 'post__in'
          );
          $query = new WP_Query( $args );
          if ( $query->have_posts() ) :
            while ( $query->have_posts() ) : $query->the_post(); ?>
              <div class="about-text">
                <div class="row">
                  <div class="col-lg-4 col-md-6">
                    <?php the_post_thumbnail(); ?>
                  </div>
                  <div class="col-lg-8 col-md-6">
                    <h2 class="text-capitalize"><?php the_title(); ?></h2>
                    <?php the_excerpt(); ?>
                    <div class ="aboutbtn my-3">
                      <a href="<?php the_permalink(); ?>"><?php esc_html_e('MORE ABOUT ME','katib-writers'); ?><span class="screen-reader-text"><?php esc_html_e( 'MORE ABOUT ME','katib-writers' );?></span></a>
                    </div>
                  </div>
                </div>
              </div>
            <?php endwhile; ?>
          <?php else : ?>
              <div class="no-postfound"></div>
          <?php endif;
        endif;
        wp_reset_postdata()?>
          <div class="clearfix"></div> 
      </div>
    </section>
  <?php }?>
  <?php do_action( 'katib_writers_after_about' ); ?>

  <div class="container text">
    <?php while ( have_posts() ) : the_post();?>
      <?php the_content(); ?>
    <?php endwhile; // End of the loop.
    wp_reset_postdata(); ?>
  </div>
</main>

<?php get_footer(); ?>