HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: /var/www/html/Siyum_old/wp-content/themes/siyum-old/page-home.php
<?php /* Template Name: Home Page */
get_header();
?>
   <div class="banner-logo">
    <lottie-player 
        src="/wp-content/themes/kedushas/lottie/animation.json" 
        background="transparent" 
        speed="1" 
        loop 
        autoplay 
        id="lottie-player">
    </lottie-player>
    <audio id="radio-stream" autoplay >
    <source src="https://relax.stream.publicradio.org/relax.aac" type="audio/mpeg">
    Your browser does not support the audio element.
</audio>
      </div>
      
    <section class="video-banner">            
        <video autoplay loop muted class="banner-media">
          <source src="<?php echo get_template_directory_uri(); ?>/video/Homepage.mp4" type="video/mp4">
          Your browser does not support the video tag.
        </video>
        <div class="container custom-container">
          
          <div class="title">
            Elevate Your Shabbos <br> Embrace the Kedusha. Experience the Joy!
          </div>
          <div class="content">
            Bringing the radiance of Shabbos to your children, family & home
          </div>
          <div class="btn-sec">
            <button class="btn1 watch-video">Watch our latest video</button>
            <button class="btn1 join-btn">Join the movement</button>
          </div>
          <a href="#quote_sec" class="scroll-btm-btn">
            <span class="txt">Scroll Down</span>
            <img src="<?php echo get_template_directory_uri(); ?>/img/down-itm.svg" alt="">
          </a>
        </div>
      </section>
    <section class="quote-sec" id="quote_sec">
        <div class="container custom-container">
            <span class="quptes"><img src="<?php echo get_template_directory_uri(); ?>/img/quote1.svg" alt="quote"></span> <span class="arrow"><img src="<?php echo get_template_directory_uri(); ?>/img/ico.svg" alt="ico"></span>
            Shabbos is an opportunity for you to reset, recharge, and reconnect with what truly matters.
            <span class="quptes1"><img src="<?php echo get_template_directory_uri(); ?>/img/quote2.svg" alt="quotes"></span>
        </div>
      
    </section>

    <section class="two-col-sec">
        <div class="container custom-container">
            <div class="two-col-inner">
            <div class="left-sec">
                <img src="<?php echo get_template_directory_uri(); ?>/img/about-img.png" alt="about">
            </div>
            <div class="rt-sec">
                <div class="title1">
                    At Mekadeish HaShabbos, we are passionate about transforming your Shabbos into a sacred oasis of tranquility and connection.
                </div>
                <div class="contents">
                    Our mission is to infuse every aspect of Shabbos with meaning and joy. We invite you to join us on this journey of Shabbos growth and inspiration. Discover the beauty of Shabbos Kodesh and its power to elevate you!
                </div>
                <div class="leran-more">
                    <button class="btn-learn">Learn More</button>
                </div>
            </div>
        </div>
        </div>
    </section>

    <section class="video-series-sec">
        <div class="container custom-container">
            <div class="title-block">
                <h5>SHABBOS VIDEO SERIES</h5>
                <h2>Your Journey into the Beauty of Shabbos</h2>
                <p>Join us on a transformative journey into the beauty and depth of Shabbos with our special video series. Each week, delve into the richness of Shabbos and explore the customs, traditions, and significance of the various facets of the holy day. Be guided towards a deeper connection with Shabbos Kodesh, igniting your soul and enriching your life.</p>
            </div>
            <div class="video-tab-cover">
                <div class="video-tab-wrapper d-flex">
                    <div class="left-btn-block">
                        <div class="nav tab-btn-block flex-column nav-pills me-3 tabSlider" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                            <?php
                            // Query to get video series
                            $args = array(
                                'post_type' => 'video_series',
                                'posts_per_page' => -1, // Get all video series
                            );
                            $query = new WP_Query($args);
                            if ($query->have_posts()) :
                              $is_first = true;
                                while ($query->have_posts()) : $query->the_post();
                                    // Get custom fields (e.g., author name)
                                    $author_name = get_field('author_name'); 
                                    $author_icon = get_field('icon');
                                    $avatar = get_field('avatar');
                                    $fallback_image = get_template_directory_uri() . '/img/author.png';
                                    $video_series = get_post_meta(get_the_ID(), '_video_series', true); // Get video series data
                            ?>
                                <button class="nav-link tab-btn  <?php echo $is_first ? 'active' : ''; ?>" id="v-pills-<?php echo get_the_ID(); ?>-tab" data-bs-toggle="pill" data-bs-target="#v-pills-<?php echo get_the_ID(); ?>" type="button" role="tab" aria-controls="v-pills-<?php echo get_the_ID(); ?>" aria-selected="<?php echo $is_first ? 'true' : 'false'; ?>">
                                <div class="icon">
                                            <img src="<?php echo esc_url($avatar['url']); ?>" alt="">
                                          </div>
                                    <div class="data-label">
                                    <?php the_title(); ?>
                                    </div>
                                </button>
                            <?php
                            $is_first = false;
                                endwhile;
                                wp_reset_postdata(); // Reset after the query
                            endif;
                            ?>
                        </div>
                    </div>

                    <div class="right-content-block">
                        <div class="tab-content" id="v-pills-tabContent">
                            <?php
                            // Re-run query to display videos
                            if ($query->have_posts()) :
                              $is_first = true;
                                while ($query->have_posts()) : $query->the_post();
                                    // Fetch video source and thumbnail
                                    $video_series = get_post_meta(get_the_ID(), '_video_series', true);
                                    // $video_file = get_field('video');
                                    // $thumbnail_image = get_field('thumbnail_image');
                            ?>
                                <div class="tab-pane fade <?php echo $is_first ? 'show active' : ''; ?>" id="v-pills-<?php echo get_the_ID(); ?>" role="tabpanel" aria-labelledby="v-pills-<?php echo get_the_ID(); ?>-tab">
                                    <div class="video-slider-cover">
                                    <div class="video-series-slider-lg">
                                    <?php 
                                    if (!empty($video_series)) :
                                      $video_series = array_reverse($video_series);
                                        $featured_video = null;
                                        $other_videos = [];

                                        // Separate the first featured video and other videos
                                        foreach ($video_series as $video) {
                                            if (!empty($video['url'])) {
                                              
                                           
                                                if ($video['featured'] == 1 && $featured_video === null) {
                                                    $featured_video = $video; // Store the first featured video
                                                } else {
                                                    $other_videos[] = $video; // Store other videos
                                                }
                                            }
                                        }

                                        // Display the first featured video first
                                        if ($featured_video) :
                                    ?>
                                        <div class="item-lg featured-lg">
                                            <div class="item-lg-cover">
                                                <a href="<?php echo esc_url(get_permalink()); ?>">
                                                    <button class="lg-play-btn">
                                                        <img src="<?php echo get_template_directory_uri(); ?>/img/play-btn.svg" alt="Play">
                                                    </button>
                                                    <?php if(empty($featured_video['thumbnail']))
                                                                  {
                                                                    $vimeo_url = $featured_video['url']; 
                                                                    $thumbnail = get_vimeo_thumbnail($vimeo_url);
                                                                  }
                                                                  else
                                                                  {
                                                                    $thumbnail = $featured_video['thumbnail'];
                                                                  }
                                                              ?>
                                                    <img class="media-lg" src="<?php echo esc_url($thumbnail); ?>" alt="Thumbnail">
                                                </a>
                                            </div>
                                        </div>
                                    <?php 
                                        endif;

                                        // Display all other videos
                                        foreach ($other_videos as $video) :
                                    ?>
                                        <div class="item-lg">
                                            <div class="item-lg-cover">
                                                <a href="<?php echo esc_url(get_permalink()); ?>">
                                                    <button class="lg-play-btn">
                                                        <img src="<?php echo get_template_directory_uri(); ?>/img/play-btn.svg" alt="Play">
                                                    </button>
                                                    <?php if(empty($video['thumbnail']))
                                                                  {
                                                                    $vimeo_url = $video['url']; 
                                                                    $thumbnail = get_vimeo_thumbnail($vimeo_url);
                                                                  }
                                                                  else
                                                                  {
                                                                    $thumbnail = $video['thumbnail'];
                                                                  }
                                                              ?>
                                                    <img class="media-lg" src="<?php echo esc_url($thumbnail); ?>" alt="Thumbnail">
                                                </a>
                                            </div>
                                        </div>
                                    <?php 
                                        endforeach;
                                    endif;
                                    ?>
                                </div>


                                        <div class="video-series-slider-thumb">
                                        <?php 
                                        if (!empty($video_series)) :
                                         // $video_series = array_reverse($video_series);
                                            $featured_video = null;
                                            $other_videos = [];

                                            // Separate the first featured video and other videos
                                            foreach ($video_series as $video) {
                                                if (!empty($video['url'])) {
                                                    
                                                 
                                                    if ($video['featured'] == 1 && $featured_video === null) {
                                                        $featured_video = $video; // Store the first featured video
                                                    } else {
                                                        $other_videos[] = $video; // Store other videos
                                                    }
                                                }
                                            }

                                            // Display the first featured video first
                                            if ($featured_video) :
                                        ?>
                                            <div class="thumb-item featured-thumb">
                                                <div class="thumb-cover">
                                                    <button class="play-btn" tabindex="0">
                                                        <img src="<?php echo get_template_directory_uri(); ?>/img/play-btn.svg" alt="Play">
                                                    </button>
                                                    <?php if(empty($featured_video['thumbnail']))
                                                                  {
                                                                    $vimeo_url = $featured_video['url']; 
                                                                    $thumbnail = get_vimeo_thumbnail($vimeo_url);
                                                                  }
                                                                  else
                                                                  {
                                                                    $thumbnail = $featured_video['thumbnail'];
                                                                  }
                                                              ?>
                                                    <img class="thumb-media-item" src="<?php echo esc_url($thumbnail); ?>" alt="Thumbnail">
                                                </div>
                                            </div>
                                        <?php 
                                            endif;

                                            // Display all other videos as thumbnails
                                            foreach ($other_videos as $video) :
                                        ?>
                                            <div class="thumb-item">
                                                <div class="thumb-cover">
                                                    <button class="play-btn" tabindex="0">
                                                        <img src="<?php echo get_template_directory_uri(); ?>/img/play-btn.svg" alt="Play">
                                                    </button>
                                                    <?php if(empty($video['thumbnail']))
                                                                  {
                                                                    $vimeo_url = $video['url']; 
                                                                    $thumbnail = get_vimeo_thumbnail($vimeo_url);
                                                                  }
                                                                  else
                                                                  {
                                                                    $thumbnail = $video['thumbnail'];
                                                                  }
                                                              ?>
                                                    <img class="thumb-media-item" src="<?php echo esc_url($thumbnail); ?>" alt="Thumbnail">
                                                </div>
                                            </div>
                                        <?php 
                                            endforeach;
                                        endif;
                                        ?>
                                    </div>

                                    </div>
                                </div>
                            <?php
                            $is_first = false;
                                endwhile;
                                wp_reset_postdata(); // Reset after the query
                            endif;
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <?php
// Initialize a flag to check if any recommended publications are found
$has_recommended = false;

// WP_Query to fetch publications
$query = new WP_Query(array(
  'post_type' => 'publications',
  'posts_per_page' => -1,
));

if ($query->have_posts()) :
  while ($query->have_posts()) : $query->the_post();
  $volumes = get_post_meta(get_the_ID(), 'publications_volumes', true);
    $recommended_publications = get_field('recommended_publications');
    if (!empty($volumes)) {
    // Check if the current post is marked as "Recommended"
    if (!empty($recommended_publications) && in_array('Yes', $recommended_publications)) {
      $has_recommended = true;
      break; // Exit loop early if we find a recommended publication
    }
  }
  endwhile;
endif;
wp_reset_postdata();
?>

<?php  if ($has_recommended) : // Only show the section if recommended publications exist ?>
<section class="publications-slider-sec">
  <div class="container custom-container">
    <div class="title-block">
      <h2>Recommended Publications </h2>
      <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries</p>
    </div>

    <div class="publications-slider-cover">
      <div class="publications-slider">
        <?php
        // Query again to display the actual posts
        $query = new WP_Query(array(
          'post_type' => 'publications',
          'posts_per_page' => -1,
        ));

        if ($query->have_posts()) :
          while ($query->have_posts()) : $query->the_post();
            $volumes = get_post_meta(get_the_ID(), 'publications_volumes', true);
            $recommended_publications = get_field('recommended_publications');
            if (!empty($recommended_publications) && in_array('Yes', $recommended_publications)) :
              if (!empty($volumes)) :
                $first_volume = reset($volumes); // Get the first volume
        ?>
                <a class="item" href="<?php the_permalink(); ?>" data-pdf-url="<?php echo esc_url($pdf_url['url']); ?>">
                  <div class="publications-card">
                    <div class="media-block">
                      <img class="media-item" src="<?php echo esc_url($first_volume['thumbnail']); ?>" alt="">
                    </div>
                    <div class="data-content">
                      <p><?php echo esc_html($first_volume['title']); ?></p>
                      <h4><?php the_title(); ?></h4>
                    </div>
                  </div>
                </a>
        <?php
              endif;
            endif;
          endwhile;
        endif;
        wp_reset_postdata();
        ?>
      </div>
    </div>
  </div>
</section>
<?php endif; // End check for recommended publications ?>

    <section class="boxes">
      <div class="container custom-container">
        <div class="inner-box inner-box1">
          <div class="logo"><img src="<?php echo get_template_directory_uri(); ?>/img/madmin-llogo.png" alt="log"></div>
          <div class="contents">
            When it comes to Shabbos - there’s so much to love! We all know that Shabbos is the source of all Brachah and
            Kedusha, but how do we tap into it? Elevate your Shabbos by understanding what Shabbos is really about and you
            will love Shabbos.
          </div>
        </div>
        <div class="inner-box">
          <div class="logo"><img src="<?php echo get_template_directory_uri(); ?>/img/logo1.png" alt="log"></div>
          <div class="contents">
            When it comes to Shabbos - there’s so much to love! We all know that Shabbos is the source of all Brachah and
            Kedusha, but how do we tap into it? Elevate your Shabbos by understanding what Shabbos is really about and you
            will love Shabbos.
          </div>
        </div>
    
      </div>
    </section>

    <section class="newsletter-section">
    <div class="container custom-container">
        <div class="subtitle">Subscribe to our Newsletter </div>
        <div class="sub-content"> Sign up for our weekly updates to be the first to receive inspiring content, news, events, and downloads.</div>
        <div class="form-sec">
            <form id="newsletter-form">
                <div class="row form-inner">
                    <div class="col-md-4">
                        <input type="text" id="name" class="form-control" placeholder="Name*" required>
                        
                    </div>
                    <div class="col-md-4">
                        <input type="email" id="email" class="form-control" placeholder="Email*" required>
                         
                    </div>
                    <div class="col-md-2">
                        <button type="submit" class="btn btn-submit btn-subscribe w-100">Subscribe</button>
                    </div>
                </div>
            </form>
            <div id="subAlert" class="alert alert-success" role="alert" style="text-align: center; display: none;top: 10px;"></div>      </div>
          
        </div>
    </div>
</section>

<?php 
function get_vimeo_thumbnail($video_url) {
    $api_url = "https://vimeo.com/api/oembed.json?url=" . urlencode($video_url);
    
    // Fetch the video details from the Vimeo API
    $response = wp_remote_get($api_url);

    if (is_wp_error($response)) {
        return false;
    }

    $body = wp_remote_retrieve_body($response);
    $data = json_decode($body, true);

    if (!empty($data['thumbnail_url'])) {
        $thumbnail_url = $data['thumbnail_url'];
        
        // Ensure the last part of the URL (e.g., _295x166) is replaced with _1280x720
        $thumbnail_url = preg_replace('/_\d+x\d+$/', '_1280x720', $thumbnail_url);

        return $thumbnail_url;
    }

    return false;
}

 get_footer(); ?>