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

get_header(); ?>

<main id="skip-content">
  <section id="top-slider" class="pb-md-5 mb-md-5">
    <?php if(get_theme_mod('cooking_food_blogger_slider_setting') != ''){ ?>
    <?php $cooking_food_blogger_slide_pages = array();
      for ( $cooking_food_blogger_count = 1; $cooking_food_blogger_count <= 3; $cooking_food_blogger_count++ ) {
        $cooking_food_blogger_mod = intval( get_theme_mod( 'cooking_food_blogger_top_slider_page' . $cooking_food_blogger_count ));
        if ( 'page-none-selected' != $cooking_food_blogger_mod ) {
          $cooking_food_blogger_slide_pages[] = $cooking_food_blogger_mod;
        }
      }
      if( !empty($cooking_food_blogger_slide_pages) ) :
        $cooking_food_blogger_args = array(
          'post_type' => 'page',
          'post__in' => $cooking_food_blogger_slide_pages,
          'orderby' => 'post__in'
        );
        $cooking_food_blogger_query = new WP_Query( $cooking_food_blogger_args );
        if ( $cooking_food_blogger_query->have_posts() ) :
          $cooking_food_blogger_i = 1;
    ?>
    <div class="owl-carousel" role="listbox">
      <?php  while ( $cooking_food_blogger_query->have_posts() ) : $cooking_food_blogger_query->the_post(); ?>
        <div class="slider-box">
          <?php if(has_post_thumbnail()){
            the_post_thumbnail();
            } else{?>
            <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
          <?php } ?>
          <div class="slider-inner-box">
            <?php if(get_theme_mod('cooking_food_blogger_slider_title_setting',1) == 1){ ?>
              <h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
            <?php }?>
            <?php if(get_theme_mod('cooking_food_blogger_slider_content_setting',1) == 1){ ?>
              <p><?php echo wp_trim_words( get_the_content(), esc_attr(get_theme_mod('cooking_food_blogger_slider_excerpt_length', 30)) ); ?></p>
            <?php }?>
            <?php if(get_theme_mod('cooking_food_blogger_slider_button_setting',1) == 1 && get_theme_mod('cooking_food_blogger_slider_button_text','Read More') != ''){ ?>
              <div class="slider-box-btn my-4">
                <a href="<?php the_permalink(); ?>"><?php esc_html_e(get_theme_mod('cooking_food_blogger_slider_button_text','Read More')); ?></a>
              </div>
            <?php }?>
          </div>
        </div>
      <?php $cooking_food_blogger_i++; endwhile;
      wp_reset_postdata();?>
    </div>
    <?php else : ?>
      <div class="no-postfound"></div>
    <?php endif;
    endif;?>

    <?php if( get_theme_mod('cooking_food_blogger_slider_video') != '' ){ ?>
      <div class="class-video">
        <embed width="300" height="350" src="<?php echo esc_url(get_theme_mod('cooking_food_blogger_slider_video','')); ?>" title="Slider Cooking Video" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></embed>
      </div>
    <?php }?>
 <?php if( get_theme_mod('cooking_food_blogger_social_icon_setting') != '' ){ ?>
    <div class="social-link text-center text-lg-right text-md-end">
      <?php if(get_theme_mod('cooking_food_blogger_facebook_url') != '' || get_theme_mod('cooking_food_blogger_twitter_url') != '' || get_theme_mod('cooking_food_blogger_intagram_url') != '' || get_theme_mod('cooking_food_blogger_linkedin_url') != '' || get_theme_mod('cooking_food_blogger_pintrest_url') != ''){ ?>
        <span><?php esc_html_e('Connect With Us:- ','cooking-food-blogger'); ?></span>
        <?php if(get_theme_mod('cooking_food_blogger_facebook_url') != ''){ ?>
          <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_facebook_url','')); ?>"><i class="fab fa-facebook-f"></i></a>
        <?php }?>
        <?php if(get_theme_mod('cooking_food_blogger_twitter_url') != ''){ ?>
          <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_twitter_url','')); ?>"><i class="fab fa-twitter"></i></a>
        <?php }?>
        <?php if(get_theme_mod('cooking_food_blogger_intagram_url') != ''){ ?>
          <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_intagram_url','')); ?>"><i class="fab fa-instagram"></i></a>
        <?php }?>
        <?php if(get_theme_mod('cooking_food_blogger_linkedin_url') != ''){ ?>
          <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_linkedin_url','')); ?>"><i class="fab fa-linkedin-in"></i></a>
        <?php }?>
        <?php if(get_theme_mod('cooking_food_blogger_pintrest_url') != ''){ ?>
          <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_pintrest_url','')); ?>"><i class="fab fa-pinterest-p"></i></a>
        <?php }?>
      <?php }?>
    </div>
    <?php }?>
    <?php }?>
  </section>

<?php if( get_theme_mod('cooking_food_blogger_services_setting') != '' ){ ?>
  <section class="services-sec py-5">
    <div class="container">
      <div class="row mb-4 text-center text-md-start">
        <div class="col-lg-8 col-md-8 col-sm-8 align-self-center">
          <?php if(get_theme_mod('cooking_food_blogger_services_short_heading') != ''){ ?>
            <h6><?php echo esc_html(get_theme_mod('cooking_food_blogger_services_short_heading','')); ?></h6>
          <?php }?>
          <?php if(get_theme_mod('cooking_food_blogger_services_long_heading') != ''){ ?>
            <h3><?php echo esc_html(get_theme_mod('cooking_food_blogger_services_long_heading','')); ?></h3>
          <?php }?>
        </div>
        <div class="col-lg-4 col-md-4 col-sm-4 align-self-center">
          <?php if(get_theme_mod('cooking_food_blogger_services_button_text') != '' || get_theme_mod('cooking_food_blogger_services_button_url') != ''){ ?>
            <div class="slider-box-btn text-center text-md-end">
              <a href="<?php echo esc_url(get_theme_mod('cooking_food_blogger_services_button_url','')); ?>"><?php echo esc_html(get_theme_mod('cooking_food_blogger_services_button_text','')); ?></a>
            </div>
          <?php }?>
        </div>
      </div>
      <div class="row" role="listbox">
        <?php
          $cooking_food_blogger_services_cat = get_theme_mod('cooking_food_blogger_services_sec_category','');
          $cooking_food_blogger_services_per_page = get_theme_mod('cooking_food_blogger_services_per_page',4);
          if($cooking_food_blogger_services_cat){
            $cooking_food_blogger_page_query5 = new WP_Query(array( 'category_name' => esc_html($cooking_food_blogger_services_cat,'cooking-food-blogger'),'post_per_page' => esc_attr( $cooking_food_blogger_services_per_page )));
            $i=1;
            while( $cooking_food_blogger_page_query5->have_posts() ) : $cooking_food_blogger_page_query5->the_post(); ?>
              <div class="col-lg-3 col-md-4 col-sm-4">
                <div class="box-category">
                  <div class="box-image-cat">
                    <?php the_post_thumbnail(); ?>
                    <a href="<?php the_permalink(); ?>"><i class="fas fa-play"></i></a>
                  </div>
                  <h4 class="my-3"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                </div>
              </div>
            <?php $i++; endwhile;
          wp_reset_postdata();
        } ?>
      </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(); ?>