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

get_header(); ?>

<?php if (get_theme_mod('vr_games_slider_section_setting', true) != '') { ?>
<section id="top-slider">
  <?php if (get_theme_mod( 'vr_games_slider_background_image' )) { ?>
    <img class="slider-bg-img" src="<?php echo esc_url( get_theme_mod( 'vr_games_slider_background_image' )); ?>">
  <?php } else { ?>
    <img class="slider-bg-img" src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
  <?php } ?>
  <div class="main-slider">
    <div class="container">
      <?php $vr_games_slide_pages = array();
        for ( $vr_games_count = 1; $vr_games_count <= 3; $vr_games_count++ ) {
          $vr_games_mod = intval( get_theme_mod( 'vr_games_top_slider_page' . $vr_games_count ));
          if ( 'page-none-selected' != $vr_games_mod ) {
            $vr_games_slide_pages[] = $vr_games_mod;
          }
        }
        if( !empty($vr_games_slide_pages) ) :
          $vr_games_args = array(
            'post_type' => 'page',
            'post__in' => $vr_games_slide_pages,
            'orderby' => 'post__in'
          );
          $vr_games_query = new WP_Query( $vr_games_args );
          if ( $vr_games_query->have_posts() ) :
            $i = 1;
      ?>
      <div class="owl-carousel" role="listbox">
        <?php  while ( $vr_games_query->have_posts() ) : $vr_games_query->the_post(); ?>
          <div class="slide-box row m-0 pt-5">
            <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
              <div class="slider-inner-box">
                <?php if(get_theme_mod('vr_games_slider_title_setting',1) == 1){ ?>
                  <h3 class="m-0"><?php the_title(); ?></h3>
                <?php }?>
                <?php if(get_theme_mod('vr_games_slider_content_setting',1) == 1){ ?>
                  <p class="content mt-3"><?php echo esc_html( wp_trim_words( get_the_content(), esc_attr(get_theme_mod('vr_games_slider_excerpt_length', 15)) )); ?></p>
                <?php }?>
                <?php if(get_theme_mod('vr_games_slider_button_setting',1) == 1 && get_theme_mod('vr_games_slider_button_text','Join Community') != ''){ ?>
                  <div class="slide-btn mt-4">
                    <a href="<?php the_permalink(); ?>"><?php esc_html_e(get_theme_mod('vr_games_slider_button_text','Join Community')); ?></a>
                  </div>
                <?php }?>
              </div>
            </div>
            <div class="slider-image col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
              <?php if (has_post_thumbnail()) { ?><img class="sider-img" src="<?php the_post_thumbnail_url('full'); ?>" /><?php } else { ?><img class="sider-img" src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" /> <?php } ?>
            </div>
          </div>
        <?php $i++; endwhile;
        wp_reset_postdata();?>
      </div>
      <?php else : ?>
        <div class="no-postfound"></div>
      <?php endif;
      endif;?>
    </div>
  </div>
</section>
<?php } ?>
<?php if (get_theme_mod('vr_games_activities_section_setting', true) != '') { ?>
  <section id="skip-content" class="featured py-5">
    <div class="container">
      <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center about-image">
          <?php if (get_theme_mod( 'vr_games_about_us_image' )) { ?>
            <img class="about-img" src="<?php echo esc_url( get_theme_mod( 'vr_games_about_us_image' )); ?>">
          <?php } else { ?>
            <img class="about-img" src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/img/slider.png" alt="" />
          <?php } ?>
          <div class="box-heading">
            <?php if(get_theme_mod('vr_games_about_us_box_number') != ''){ ?>
              <h5 class="box-title mb-3 mt-3"><?php echo esc_html(get_theme_mod('vr_games_about_us_box_number')); ?></h5>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_box_title') != ''){ ?>
              <h6 class="box-short mb-3"><?php echo esc_html(get_theme_mod('vr_games_about_us_box_title')); ?></h6>
            <?php }?>
          </div>
        </div>
        <div class="col-lg-6 col-md-6 col-sm-12 col-12 align-self-center">
          <div class="heading text-lg-left mb-4">
            <?php if(get_theme_mod('vr_games_about_us_title') != ''){ ?>
              <h5 class="main-title mb-3 mt-3"><?php echo esc_html(get_theme_mod('vr_games_about_us_title')); ?></h5>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_short_title') != ''){ ?>
              <h6 class="main-short mb-3"><?php echo esc_html(get_theme_mod('vr_games_about_us_short_title')); ?></h6>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_heading') != ''){ ?>
              <h3 class="main-heading mb-3"><?php echo esc_html(get_theme_mod('vr_games_about_us_heading')); ?></h3>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_content_1') != ''){ ?>
              <p class="content"><?php echo esc_html(get_theme_mod('vr_games_about_us_content_1')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_content_2') != ''){ ?>
              <p class="content mb-4 pb-2"><?php echo esc_html(get_theme_mod('vr_games_about_us_content_2')); ?></p>
            <?php }?>
            <?php if(get_theme_mod('vr_games_about_us_button_url') != '' || get_theme_mod('vr_games_about_us_button_text') != ''){ ?>
              <div class="about-btn mt-4">
                <a href="<?php echo esc_url(get_theme_mod('vr_games_about_us_button_url')); ?>"><?php echo esc_html(get_theme_mod('vr_games_about_us_button_text')); ?></a>
              </div>
            <?php }?>
          </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>

<?php get_footer(); ?>