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/single-publications.php
<?php  
get_header();
?>

      <section class="inner-banner-sec">
		<video class="banner-media" autoplay loop>
			<source src="<?php echo get_template_directory_uri(); ?>/video/publication.mp4" type="video/mp4">
			Your browser does not support the video tag.
		</video>
        <div class="overlay"></div>
		<div class="container custom-container">
			<div class="title-block">
				<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>
    <div class="banner-logo vid-sec">
        <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>
    </a>
	</section>

  <section class="inner-tab-sec">
    <div class="container custom-container-1500">
        <div class="inner-tab-cover">
            <div class="video-tab-cover">
                <div class="video-tab-wrapper">
                    <div class="left-btn-block">
                        <!-- <div class="nav tab-btn-block nav-pills tabSlider" id="v-pills-tab" role="tablist" aria-orientation="vertical">
                            <?php
							$selected_post= get_the_ID();
                           
                            $args = array(
                                'post_type' => 'publications', // Or the custom post type slug you're using
                                'posts_per_page' => -1, // To display all posts, adjust as needed
                            );
							
                            $query = new WP_Query($args);

                            // Check if there are any posts
                            if ($query->have_posts()) :
								 
								if($selected_post)
								{
									$is_active = ($selected_post) ? 'active' : '';
								}
								else {
								$is_active = ($query->current_post == 0) ? 'active' : '';
								}
                                // Loop through the posts
                                while ($query->have_posts()) : $query->the_post();
								//echo get_the_ID();
                $pdf_url = get_field('publication_pdf');
								$is_active = ($selected_post==get_the_ID() ) ? 'active' : '';
								 
                                    ?>
                                    <button class="nav-link tab-btn <?php echo $is_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="true"
                                            data-pdf-url="<?php echo esc_url($pdf_url['url']); ?>">
                                        <div class="data-label">
                                            <?php the_title(); ?>
                                        </div>
                                    </button>
                                    <?php
                                endwhile;
                                wp_reset_postdata();
                            else :
                                echo '<p>No publications found.</p>';
                            endif;
                            ?>
                        </div> -->
                        <div class="nav tab-btn-block nav-pills tabSlider" id="v-pills-tab" role="tablist" aria-orientation="vertical">
    <?php
    $selected_post = get_the_ID();

    $args = array(
        'post_type'      => 'publications', // Custom post type
        'posts_per_page' => -1, // Display all posts
    );

    $query = new WP_Query($args);
    $posts = [];

    if ($query->have_posts()) {
        while ($query->have_posts()) {
            $query->the_post();
            $posts[] = [
                'id'      => get_the_ID(),
                'title'   => get_the_title(),
                'pdf_url' => get_field('publication_pdf')['url'] ?? '',
            ];
        }
    }
    wp_reset_postdata();

    // Move selected post to the top of the list
    usort($posts, function ($a, $b) use ($selected_post) {
        return ($a['id'] == $selected_post) ? -1 : 1;
    });

    foreach ($posts as $index => $post) {
        $is_active = ($post['id'] == $selected_post) ? 'active' : '';
    ?>
        <button class="nav-link tab-btn <?php echo $is_active; ?>" 
                id="v-pills-<?php echo $post['id']; ?>-tab" 
                data-bs-toggle="pill" 
                data-bs-target="#v-pills-<?php echo $post['id']; ?>" 
                type="button" 
                role="tab" 
                aria-controls="v-pills-<?php echo $post['id']; ?>" 
                aria-selected="<?php echo ($is_active) ? 'true' : 'false'; ?>" 
                data-pdf-url="<?php echo esc_url($post['pdf_url']); ?>">
            <div class="data-label">
                <?php echo esc_html($post['title']); ?>
            </div>
        </button>
    <?php
    }
    ?>
</div>

                    </div>

                    <div class="right-content-block">
                        <div class="tab-content" id="v-pills-tabContent">
							
                            <?php
                            // Query again for post details and content
							//<?php echo ($query->current_post == 0) ? 'show active' : ''; 
							
                            $query = new WP_Query($args);
                            if ($query->have_posts()) :
                              $pdf_url = get_field('publication_pdf');
                                while ($query->have_posts()) : $query->the_post();
                                $volumes = get_post_meta(get_the_ID(), 'publications_volumes', true);  // Adjust the custom field name as per your setup
                                $issue = get_post_meta(get_the_ID(), 'issue', true);    // Adjust the custom field name as per your setup
                                $thumbnail = get_post_meta(get_the_ID(), 'thumbnail', true); // Assuming 'thumbnail' is the custom field for the image
								                $is_active = ($selected_post==get_the_ID() ) ? 'active show' : ''; 
                                $subtitle = get_field('subtitle');
                                $post_id = get_the_ID();
                                $additional_description = get_field('description');
                                ?>
                                    <div class="tab-pane fade <?php echo $is_active; ?>" 
                                         id="v-pills-<?php echo get_the_ID(); ?>" 
                                         role="tabpanel" 
                                         aria-labelledby="v-pills-<?php echo get_the_ID(); ?>-tab">
                                        <div class="tab-data-content">
                                            <div class="data-title">
                                            <h2><?php the_title(); ?></h2>
                                                <h6><?php echo $subtitle; ?></h6>
                                                <p><?php echo $additional_description; ?></p> <!-- or the_content() to display the full content -->
                                            </div>

                                            <div class="video-slider-cover">
                                                <div class="video-series-slider-lg">
                                                <?php
                                                 
                                                  if (!empty($volumes)) {
                                                   foreach ($volumes as $volume) {

                                                     ?>
                                                    <div class="item-lg">
                                                        <div class="item-lg-cover">
                                                            <button class="lg-play-btn publication-btn" data-bs-toggle="modal"
                                                            data-bs-target="#customModal" data-title="<?php echo esc_attr($volume['title']); ?>"
                                                            data-subtitle="<?php echo esc_attr($volume['subtitle']); ?>"
                                                            data-thumbnail="<?php echo esc_attr(json_encode($volume['thumbnail'])); ?>"
                                                            data-pdf="<?php echo esc_attr(json_encode($volume['pdf'])); ?>"
                                                            data-mainpdf-url="<?php echo esc_url($pdf_url['url']); ?>"
                                                            data-post-id="<?php echo $post_id; ?>"
                                                            data-description="<?php echo esc_attr(json_encode($volume['description'])); ?>"
                                                           >
                                                                <img src="<?php echo get_template_directory_uri(); ?>/img/download-btn.svg" alt="">
                                                            </button>
                                                            <img class="media-lg" src="<?php echo esc_url($volume['thumbnail']); ?>" alt="">
                                                        </div>
                                                    </div>
                                                    <?php } } ?>
                                                   
                                                </div>

                                                <div class="video-series-slider-thumb">
                                                    <!-- Thumbnails for the slider -->
                                                     <?php
                                                  
                                                     if (!empty($volumes)) {
                                                      foreach ($volumes as $volume) {

                                                        ?>
                                                    <div class="thumb-item">
                                                        <div class="thumb-cover">
                                                            <img class="thumb-media-item" src="<?php echo esc_url($volume['thumbnail']); ?>" alt="">
                                                      
                                                        </div>
                                                        <div class="thumb-det">
                                                        <h5><?php echo esc_html($volume['title']) ?></h5>
                                                        <p><?php echo esc_html($volume['subtitle']) ?></p>
                                                      </div>
                                                    </div>
                                                    <?php } } ?>
                                                   
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <?php
                                endwhile;
                                wp_reset_postdata();
                            else :
                                echo '<p>No publications found.</p>';
                            endif;
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>


   
    <section class="enjoy-shabbos">
        <div class="custom-container container">
            <div class="inner-sec">
                <div class="title">Enjoy Shabbos on Shabbos</div>
                  <div class="inner-content">Print out Ki Heim Chayeinu and enjoy it on Shabbos, share it with family and elevate<br> Shabbos in your home</div>
                  <div class="two-btn">
                  <button class="btn whatsap" onclick="location.href='https://chat.whatsapp.com/ABCDE12345FGHIJ67890';">
                  <span class="ico">
                  <img src="<?php echo get_template_directory_uri(); ?>/img/whatsap.svg" alt="whatsap">
                  </span>
                  <span>Join WhatsApp Group</span>
                  </button>

                  <div class="email-input">
                  <button class="btn receive-email">
                  <span class="ico"><img src="<?php echo get_template_directory_uri(); ?>/img/mail-ico.svg" alt="Email"></span>
                  Receive Email
                  </button>
                  <?php
                  $pdf_url = get_field('publication_pdf');

                  if ($pdf_url && isset($pdf_url['url'])) {
                  // Safe to output the URL
                  $pdfurl= esc_url($pdf_url['url']);
                  }else {  $pdfurl='';  } ?>
                  <input type="email" placeholder="Enter your email" class="form-control email" id="email-input">
                  <input type="hidden" value="<?php echo $pdfurl; ?>"  id="email-pdf"  class="form-control">
                  <button class="send-btn" data-pdf-url="<?php echo $pdfurl; ?>" onclick="validateEmail()">
                  <img src="<?php echo get_template_directory_uri(); ?>/img/send.svg" alt="Send">
                  </button>

                  </div>
                </div>
                <div id="successAlert" class="alert alert-success" role="alert" style="text-align: center; display: none;"></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="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>


      <!-- Modal -->
 <div class="modal inner-popup fade" id="customModal" tabindex="-1" aria-hidden="true">
   <div class="modal-dialog modal-dialog-centered modal-lg">
     <div class="modal-content">
       <div class="modal-header">
         
         <button
           type="button"
           class="btn-close"
           data-bs-dismiss="modal"
           aria-label="Close"
         ></button>
       </div>
       <div class="modal-body">
        <div>
            <div class="modal-title"></div>
            <div class="subtitle"></div>
          </div>
         <!-- Slick Slider -->
          <div class="img-slider">
            <div class="pdf-image">
                <img src="<?php echo get_template_directory_uri(); ?>/img/popup-image.png" alt="popup-image">
             </div>
             
            
          </div>
          <div class="left-arw-dy" ><img src="<?php echo get_template_directory_uri(); ?>/img/rt-arrow.svg"></div>
          <div class="right-arw-dy"><img src="<?php echo get_template_directory_uri(); ?>/img/rt-arrow.svg"></div>
           
    

         <!-- Email Input and Button  -->
          <div class="input-sec">
         
                <div class="form-inner">
                    <div class="two-btn">
                        <button class="btn btn-primary">
                            <span class="ico"><img src="<?php echo get_template_directory_uri(); ?>/img/pdf.svg" alt="pdf"></span> <span>Download PDF</span>
                           </button>
                           <button class="btn whatsap" onclick="location.href='https://chat.whatsapp.com/ABCDE12345FGHIJ67890';">
								<span class="ico">
									<img src="<?php echo get_template_directory_uri(); ?>/img/whatsap.svg" alt="whatsap">
								</span>
								<span>Join WhatsApp Group</span>
							</button>

                 
                         </div>
                         <!-- <div class="single-btn">
                      <button class="next-btn prev-btn">
                        <span class="ico1"><img src="<?php echo get_template_directory_uri(); ?>/img/back-arw.svg"></span> <span>Back</span> 
                        </button>
                        <button class="next-btn">
                        <span>Next</span> <span class="ico1"><img src="<?php echo get_template_directory_uri(); ?>/img/arrow.png" alt="whatsap"></span>
                        </button>
                     </div>----->
                     
                </div>
       
            </div>
            <p class="content">
            
            </p>
            
         <!-- Description  -->
        
          </div>
        

       </div>
     </div>
   </div>


<?php get_footer(); ?>