<?php get_header(); ?>
 <?php $podcastalerttime = get_post_meta(get_the_ID() , 'podcast_alert_time' , true);  ?>
 <?php $podcastregisterlink = get_post_meta(get_the_ID() , 'podcast_register_link' , true);  ?>
<?php $user_ID = get_current_user_id(); ?> 
<?php
$pluginPath = 'restrict-content-pro/restrict-content-pro.php';
if ( is_plugin_active( $pluginPath ) ) {
if( !rcp_user_has_active_membership( $user_ID ) ) { ?>
<script>
setTimeout(function(){
    
    return new swal({
      position: 'center',
      showConfirmButton: true,
      confirmButtonText: '<a href="<?php echo $podcastregisterlink; ?>">خريد اشتراک</a>',
      title: 'براي دسترسي کامل به پادکست هاي سايت وارد شوید و اشتراک ويژه سايت را تهيه نماييد.',
      showCloseButton: true,
      icon: "success",
    });

    }, <?php echo $podcastalerttime  ?> );
</script>

<?php
 }
 } 
 ?>



<?php
   $podcastlink = get_post_meta(get_the_ID() , 'podcast_link_demo' , true); 
   //echo "ali is expried";

    $pluginPath = 'restrict-content-pro/restrict-content-pro.php';
    if ( is_plugin_active( $pluginPath ) ) {

        if( rcp_user_has_active_membership( $user_ID ) ) {
            $podcastlink = get_post_meta(get_the_ID() , 'podcast_link' , true); 
            //echo "ali is active";
        } 
    }
?>

<link href="<?php bloginfo(
    "template_url"
); ?>/css/podcast.css" rel="stylesheet" type="text/css">
<script src="<?php bloginfo("template_url"); ?>/js/podcast.js"></script>
<div class="container">
	<div class="single-podcasts">
		<?php if (have_posts()):
      while (have_posts()):
          the_post(); ?>
		<?php gt_set_post_view(); ?>
		<div class="box-shadow">
			<div class="top-single-podcast">
				<div class="single-podcast-thumbnail">
					<figure>
						<?php the_post_thumbnail(); ?>
					</figure>
				</div>
				<div class="single-podcast-info">
					<div class="single-podcast-meta">
						<i class="fas fa-user"></i>
						<span>
						<?php 
						$podcast_speaker = get_post_meta(get_the_ID(), 'podcast_speaker', true); 
						if ( ! empty( $podcast_speaker ) ) {
							echo esc_html( $podcast_speaker );
						} else {
							the_author();
						}
						?>
						</span>
					</div>
					<div class="single-podcast-meta">
						<i class="fas fa-eye"></i>
						<span><?= gt_get_post_view() ?></span>
					</div>

                    <h1 class="podcast-title"><?php the_title(); ?></h1>

					<div class="pcast-player">
						<div class="pcast-player-controls">
                            <div class="pcast-col1">
                              
								<a class="pcast-download" href="<?php echo $podcastlink;?>"><svg class="" width="18" height="18" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path stroke="currentColor" d="M12.5332 8.22481L8.84688 11.9111M8.84688 11.9111L5.16055 8.22481M8.84688 11.9111L8.84688 1.58942" stroke-width="1.278" stroke-linecap="round" stroke-linejoin="round"></path>
                                    <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M3.68651 4.62351C3.68651 4.1992 3.28628 3.8838 2.88853 4.03158C0.617663 4.87528 0 6.67058 0 10.2195C0 15.8624 1.56153 17.0718 8.84718 17.0718C16.1328 17.0718 17.6944 15.8624 17.6944 10.2195C17.6944 6.6708 17.0768 4.8755 14.8062 4.03173C14.4085 3.88392 14.0082 4.19932 14.0082 4.62365C14.0082 4.91374 14.2015 5.16395 14.4707 5.27204C14.7817 5.39691 15.0255 5.53679 15.2203 5.68772C15.993 6.28618 16.4164 7.40014 16.4164 10.2195C16.4164 13.0389 15.993 14.1529 15.2203 14.7513C14.7991 15.0776 14.1493 15.3522 13.0864 15.5352C12.0239 15.7181 10.6465 15.7938 8.84718 15.7938C7.04784 15.7938 5.67049 15.7181 4.60797 15.5352C3.54511 15.3522 2.89526 15.0776 2.47403 14.7513C1.70134 14.1529 1.278 13.0389 1.278 10.2195C1.278 7.40014 1.70134 6.28618 2.47403 5.68772C2.66897 5.53674 2.91286 5.39681 3.224 5.27191C3.49322 5.16383 3.68651 4.91361 3.68651 4.62351Z"></path>
                                    </svg>دانلود</a>
								<button class="pcast-speed">1x</button>
								<button class="pcast-mute"><i class="fa fa-volume-up"></i><span>Mute/Unmute</span></button>
							</div>
                            
								<button class="pcast-rewind"><svg width="30" height="25" viewBox="0 0 30 25" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                              <path d="M0.971452 15.1588V13.8316C1.58716 13.8042 2.01816 13.7632 2.26444 13.7085C2.65667 13.6218 2.97593 13.4485 3.22221 13.1885C3.39096 13.0107 3.51866 12.7735 3.60532 12.477C3.65549 12.2992 3.68057 12.1669 3.68057 12.0802H5.30194V22H3.3043V15.1588H0.971452ZM9.48082 19.3456C9.55835 19.7698 9.70658 20.0981 9.9255 20.3307C10.1444 20.5588 10.4637 20.6728 10.8833 20.6728C11.3667 20.6728 11.7339 20.5041 11.9847 20.1666C12.2401 19.8245 12.3678 19.3958 12.3678 18.8804C12.3678 18.3742 12.2492 17.9477 12.0121 17.6011C11.7749 17.2499 11.4055 17.0743 10.9038 17.0743C10.6666 17.0743 10.4614 17.104 10.2881 17.1633C9.98251 17.2727 9.75219 17.4757 9.59712 17.7721L7.84577 17.69L8.54358 12.2102H14.0097V13.8658H9.95286L9.59712 16.0345C9.89813 15.8384 10.133 15.7084 10.3018 15.6445C10.5845 15.5396 10.9289 15.4872 11.3348 15.4872C12.1557 15.4872 12.8718 15.7631 13.4829 16.315C14.0941 16.8668 14.3997 17.6695 14.3997 18.7231C14.3997 19.6398 14.1055 20.4584 13.5171 21.1791C12.9288 21.8997 12.0486 22.26 10.8764 22.26C9.93234 22.26 9.157 22.0068 8.55042 21.5006C7.94383 20.9943 7.60633 20.276 7.53792 19.3456H9.48082Z" fill="currentColor"></path>
                                                              <path fill-rule="evenodd" clip-rule="evenodd" d="M28 12C28 15.6913 27.0778 18.0925 25.5838 19.5852C24.0895 21.0782 21.6852 22 17.9895 22C17.4507 22 17 22.4279 17 22.9667V23.0238C17 23.5579 17.4206 23.9992 17.9546 24C17.9662 24 17.9779 24 17.9895 24C25.9965 24 30 20 30 12C30 4 25.9965 0 17.9895 0C11.9753 0 8.21982 2.25674 6.72301 6.77022C6.51726 7.39066 7.00486 8 7.65852 8C8.12059 8 8.51933 7.68706 8.67212 7.25097C9.08734 6.06579 9.67483 5.13467 10.3953 4.41483C11.8896 2.92181 14.2939 2 17.9895 2C21.6852 2 24.0895 2.92181 25.5838 4.41483C27.0778 5.90753 28 8.30873 28 12Z" fill="currentColor"></path>
                                                              <path d="M6.98012 1V7H12.9854" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                                             </svg><span>Rewind</span></button>
								<button class="pcast-play"><i class="fa fa-play"></i><span>Play</span></button>
								<button class="pcast-pause"><i class="fa fa-pause"></i><span>Pause</span></button>
								<button class="pcast-forward"><svg width="30" height="25" viewBox="0 0 30 25" fill="none" xmlns="http://www.w3.org/2000/svg">
                                                              <path d="M14.9715 15.1588V13.8316C15.5872 13.8042 16.0182 13.7632 16.2644 13.7085C16.6567 13.6218 16.9759 13.4485 17.2222 13.1885C17.391 13.0107 17.5187 12.7735 17.6053 12.477C17.6555 12.2992 17.6806 12.1669 17.6806 12.0802H19.3019V22H17.3043V15.1588H14.9715ZM23.4808 19.3456C23.5584 19.7698 23.7066 20.0981 23.9255 20.3307C24.1444 20.5588 24.4637 20.6728 24.8833 20.6728C25.3667 20.6728 25.7339 20.5041 25.9847 20.1666C26.2401 19.8245 26.3678 19.3958 26.3678 18.8804C26.3678 18.3742 26.2492 17.9477 26.0121 17.6011C25.7749 17.2499 25.4055 17.0743 24.9038 17.0743C24.6666 17.0743 24.4614 17.104 24.2881 17.1633C23.9825 17.2727 23.7522 17.4757 23.5971 17.7721L21.8458 17.69L22.5436 12.2102H28.0097V13.8658H23.9529L23.5971 16.0345C23.8981 15.8384 24.133 15.7084 24.3018 15.6445C24.5845 15.5396 24.9289 15.4872 25.3348 15.4872C26.1557 15.4872 26.8718 15.7631 27.4829 16.315C28.0941 16.8668 28.3997 17.6695 28.3997 18.7231C28.3997 19.6398 28.1055 20.4584 27.5171 21.1791C26.9288 21.8997 26.0486 22.26 24.8764 22.26C23.9323 22.26 23.157 22.0068 22.5504 21.5006C21.9438 20.9943 21.6063 20.276 21.5379 19.3456H23.4808Z" fill="currentColor"></path>
                                                              <path fill-rule="evenodd" clip-rule="evenodd" d="M2 12C2 15.6913 2.92221 18.0925 4.41621 19.5852C5.91053 21.0782 8.31482 22 12.0105 22C12.5493 22 13 22.4279 13 22.9667V23.0238C13 23.5579 12.5794 23.9992 12.0454 24C12.0338 24 12.0221 24 12.0105 24C4.00349 24 0 20 0 12C0 4 4.00349 0 12.0105 0C18.0247 0 21.7802 2.25674 23.277 6.77022C23.4827 7.39066 22.9951 8 22.3415 8C21.8794 8 21.4807 7.68706 21.3279 7.25097C20.9127 6.06579 20.3252 5.13467 19.6047 4.41483C18.1104 2.92181 15.7061 2 12.0105 2C8.31482 2 5.91053 2.92181 4.41621 4.41483C2.92221 5.90753 2 8.30873 2 12Z" fill="currentColor"></path>
                                                              <path d="M23.0199 1V7H17.0146" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"></path>
                                                              </svg><span>forward</span></button>
							<a  href="#ralated-posts-show"  id="comment-scroll" class="more-podcast"><svg width="18" height="17" viewBox="0 0 18 17" fill="none" xmlns="http://www.w3.org/2000/svg">
									<path fill="currentColor" d="M3.21112 3.53419C1.43767 3.53419 0 5.00316 0 6.81522C0 8.51705 1.26808 9.91627 2.89146 10.0802L4.60578 15.5705C4.7784 16.1234 5.29188 16.5 5.87294 16.5C6.60585 16.5 7.2 15.908 7.2 15.1777V10.3371C8.81788 10.74 10.3504 11.5873 11.8301 12.4055C12.3505 12.6932 12.8643 12.9773 13.373 13.2372C16.228 14.6957 16.9977 11.8078 17.2045 9.31414C17.4808 9.29502 17.6593 9.2453 17.7891 9.11597C18 8.90585 18 8.56767 18 7.8913V5.73913C18 5.06277 18 4.72459 17.7891 4.51447C17.6593 4.38514 17.4808 4.33541 17.2045 4.31629C16.9977 1.82265 16.228 -1.06529 13.373 0.393278C12.8643 0.653165 12.3505 0.937249 11.8302 1.22494C10.3189 2.0605 8.75268 2.92649 7.09667 3.31846C6.41236 3.48042 6.07021 3.56141 5.91511 3.75696C5.76 3.95252 5.76 4.25822 5.76 4.86961V5.73914C5.76 6.13534 5.43765 6.45653 5.04 6.45653C4.64235 6.45653 4.32 6.13534 4.32 5.73914V4.63905C4.32 4.27775 4.32 4.0971 4.25618 3.95631C4.18404 3.79714 4.0561 3.66966 3.89635 3.59777C3.75504 3.53419 3.57374 3.53419 3.21112 3.53419Z"></path>
								</svg>پادکست های پیشنهادی</a>

							
							<span class="pcast-currenttime pcast-time">00:00</span>
							<progress class="pcast-progress" value="0"></progress>
							<span class="pcast-duration pcast-time">00:00</span>
						</div>
                                <div class="audio_file"><audio class="audio" src="<?php echo $podcastlink;?>"></audio></div>
					</div>

				</div>
			</div>

			<div class="post-content">
				<?php the_content(); ?>
			</div>
		</div>
		<?php
      endwhile;
  endif; ?>

		<?php if ($parsa_opt["share_tv"]) { ?>
		<div class="box-shadow">
			<div class="social-share-box">
				<span class="title">اشتراک گذاری </span>
				<a target="_blank" href="https://twitter.com/intent/tweet?text=<?php echo get_permalink(); ?>" class="twitter-share-button">
					<i class="fab fa-twitter"></i>
				</a>
				<a target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=<?php echo get_permalink(); ?>" class="linkedin-share-button">
					<i class="fab fa-linkedin"></i>
				</a>
				<a target="_blank" href="https://pinterest.com/pin/create/button/?url=<?php echo get_permalink(); ?>" class="pinterest-share-button">
					<i class="fab fa-pinterest"></i>
				</a>
				<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php echo get_permalink(); ?>" class="facebook-share-button">
					<i class="fab fa-facebook"></i>
				</a>
				<a target="_blank" href="https://telegram.me/share/url?url=<?php echo get_permalink(); ?>" class="telegram-share-button">
					<i class="fab fa-telegram"></i>
				</a>
			</div>
		</div>
		<?php } ?>

		<?php if ($parsa_opt["active_related_tv"]): ?>
		<div class="box-shadow">
			<section class="ralated-posts" id="ralated-posts-show">
				<div class="ralated-title">
					<h3>پادکست های پیشنهادی</h3>
				</div>
				<div class="post-slider">
					
						<?php
      $tv_related = new WP_Query([
          "post_type" => "podcast",
          "posts_per_page" => 5,
          "orderby" => "rand",
          "post__not_in" => [$post->ID],
      ]);
      if ($tv_related->have_posts()) {
          while ($tv_related->have_posts()):
              $tv_related->the_post(); ?>
						<div class="related-podcast-item">
							<a href="<?php the_permalink(); ?>">
								<figure>
									<div class="podcast-related-image">
										<?php if (has_post_thumbnail()) {
              the_post_thumbnail();
          } else {
               ?><img src="<?php echo get_template_directory_uri() .
    "/img/pro-nothumbnail.png"; ?>"> <?php
          } ?>
									</div>
                                    <div class="podcast-view">
										<span class="views-podcast"><?= gt_get_post_view() ?></span>
                                    <?php
                                     $time = get_post_meta(get_the_ID(), "podcast_time", true);
                                        if (
                                               !empty($time)
                                           ) { ?><span class="times-podcast"><?php echo $time; ?><i class="fas fa-clock"></i> </span><?php }
                                    ?>
                                    </div>
                                    <a href="<?php the_permalink(); ?>">
									<h2><?php the_title(); ?>
                                    <svg viewBox="-91 0 512 512" xmlns="http://www.w3.org/2000/svg" class="related-pod-svg"><path d="m120 376h90v120h-90zm0 0" fill="#7ed8f6"></path><path d="m165 376h45v120h-45zm0 0" fill="#66c0ee"></path><path d="m330 196v30c0 90.898438-74.097656 165-165 165s-165-74.101562-165-165v-30c0-8.402344 6.597656-15 15-15h60c8.402344 0 15 6.597656 15 15 0 8.398438-6.597656 15-15 15h-45v15c0 74.398438 60.601562 135 135 135s135-60.601562 135-135v-15h-45c-8.402344 0-15-6.601562-15-15 0-8.402344 6.597656-15 15-15h60c8.402344 0 15 6.597656 15 15zm0 0" fill="#a8ebfa"></path><path d="m330 196v30c0 90.898438-74.097656 165-165 165v-30c74.398438 0 135-60.601562 135-135v-15h-45c-8.402344 0-15-6.601562-15-15 0-8.402344 6.597656-15 15-15h60c8.402344 0 15 6.597656 15 15zm0 0" fill="#7ed8f6"></path><path d="m270 106v75l-30 30h-150l-30-30v-75c0-57.898438 47.101562-106 105-106s105 48.101562 105 106zm0 0" fill="#a8ebfa"></path><path d="m240 211h-75v-211c57.898438 0 105 48.101562 105 106v75zm0 0" fill="#7ed8f6"></path><path d="m300 497c0 8.398438-6.597656 15-15 15h-240c-8.402344 0-15-6.601562-15-15 0-8.402344 6.597656-15 15-15h240c8.402344 0 15 6.597656 15 15zm0 0" fill="#00607f"></path><path d="m150 76c0 8.285156-6.714844 15-15 15s-15-6.714844-15-15 6.714844-15 15-15 15 6.714844 15 15zm0 0" fill="#00607f"></path><path d="m210 76c0 8.285156-6.714844 15-15 15s-15-6.714844-15-15 6.714844-15 15-15 15 6.714844 15 15zm0 0" fill="#00465f"></path><path d="m210 136c0 8.285156-6.714844 15-15 15s-15-6.714844-15-15 6.714844-15 15-15 15 6.714844 15 15zm0 0" fill="#00465f"></path><path d="m150 136c0 8.285156-6.714844 15-15 15s-15-6.714844-15-15 6.714844-15 15-15 15 6.714844 15 15zm0 0" fill="#00607f"></path><path d="m300 497c0 8.398438-6.597656 15-15 15h-120v-30h120c8.402344 0 15 6.597656 15 15zm0 0" fill="#00465f"></path><path d="m270 181v45c0 57.898438-47.101562 105-105 105s-105-47.101562-105-105v-45zm0 0" fill="#00607f"></path><path d="m270 181v45c0 57.898438-47.101562 105-105 105v-150zm0 0" fill="#00465f"></path></svg>
                                    </h2>
                                    </a>
                                    <a href="<?php the_permalink(); ?>">
                                    <span class="read-podcast">
                                    <svg width="16" height="11" viewBox="0 0 16 11" fill="none" xmlns="http://www.w3.org/2000/svg">
                                    <path opacity="0.4" d="M11.1898 4.38459L14.3778 4.10265C15.0932 4.10265 15.6733 4.68836 15.6733 5.41077C15.6733 6.13318 15.0932 6.71889 14.3778 6.71889L11.1898 6.43695C10.6285 6.43695 10.1735 5.97749 10.1735 5.41077C10.1735 4.84309 10.6285 4.38459 11.1898 4.38459" fill="currentColor"></path>
                                    <path d="M0.484342 4.43642C0.534169 4.38611 0.720315 4.17347 0.895179 3.9969C1.91522 2.89098 4.57861 1.08258 5.97189 0.529142C6.18342 0.440858 6.71835 0.252899 7.00509 0.239609C7.27867 0.239609 7.54003 0.303211 7.78916 0.428517C8.10034 0.604136 8.34854 0.881329 8.4858 1.20788C8.57323 1.43382 8.71049 2.11256 8.71049 2.1249C8.84681 2.86629 8.92108 4.07189 8.92108 5.4047C8.92108 6.67295 8.84681 7.82918 8.73493 8.58292C8.72271 8.59621 8.58545 9.43823 8.43597 9.72681C8.16239 10.2546 7.62746 10.5812 7.05492 10.5812H7.00509C6.63186 10.5688 5.84779 10.2413 5.84779 10.2299C4.52879 9.6765 1.92838 7.95544 0.882957 6.81154C0.882957 6.81154 0.587756 6.51726 0.459899 6.33405C0.260591 6.07015 0.160937 5.74359 0.160937 5.41704C0.160937 5.05251 0.272812 4.71361 0.484342 4.43642" fill="currentColor"></path>
                                    </svg>
                                    برای گوش دادن کلیک کنید
                                    </span>
                                    </a>
								</figure>
							</a>
						</div>

						<?php
          endwhile;
      } else {
          echo "<p>مطلبی پیدا نشد</p>";
      }
      wp_reset_postdata();
      ?>
					</div>
				
			</section>
		</div>
		<?php endif; ?>
		<div class="box-shadow">
			<div class="post-comments">
				<div class="comments-title">
					<h3>نظرات:</h3>
				</div>
				<?php if (comments_open() || get_comments_number()):
        comments_template();
    endif; ?>
			</div>
		</div>
	</div>
</div>

<?php get_footer(); ?>
<script>
		$(document).ready(function(){
		  $('#comment-scroll').on('click', function(event) {
		    if (this.hash !== "") {
		      event.preventDefault();
		      var hash = this.hash;
		      // The optional number (800) specifies the number of milliseconds it takes to scroll to the specified area
		      $('html, body').animate({
		        scrollTop: $(hash).offset().top
		      }, 800, function(){
		        window.location.hash = hash;
		      });
		    }
		  });
		});
</script>