<?php
$podcastin_options = podcastin_theme_options();

$episode_sec_title = $podcastin_options['episode_sec_title'];
$episode_full_width = $podcastin_options['episode_full_width'];

?>
<div class="episode-section section-spacing">
	<div class="container">
		<div class="row">
			<div class="col-md-12">
                <?php
                    if ($episode_sec_title): ?>
                    <div class="section-headings" data-aos="fade-up" >
                        <?php    echo '<h2>' . esc_html($episode_sec_title) . '</h2>';
                            ?>
                    </div>
                <?php endif; ?>
			</div>

			
<?php if($episode_full_width==1){?>
<div class="col-md-12 episode-column onecolumn">
<?php } else{ ?>
<div class="col-md-12 episode-column twocolumn">
<?php } ?>


					<?php
		$check_plugin_active = in_array('seriously-simple-podcasting/seriously-simple-podcasting.php', apply_filters('active_plugins', get_option('active_plugins'))) ? true : false;

					if ($check_plugin_active): 
				        $args = array(
				            'post_type'           => array( 'podcast' ),
			                'posts_per_page' => 4,
			                'post_status' => 'publish',
				            'order'               => 'DESC',
				            'orderby'             => 'date',
				        );

				    $query = new WP_Query($args);
			        

			         $query = new WP_Query($args);
			         	if ($query->have_posts()) :
                        while ($query->have_posts()) : $query->the_post();
                            global $post;
                            $post_format = get_post_format($post->ID);
                            $post_thumbnail_id = get_post_thumbnail_id(get_the_ID());
                            $image = wp_get_attachment_image_src($post_thumbnail_id, 'full');

							if(!empty($image[0])){
							  $background_img = "style='background-image:url(".esc_url($image[0]).")'";
							}
							else{
							  $background_img = '';
							}
                            
                            ?>
				            <div class="episode-list" data-aos="fade-up">
				                
				                
				                    <div class="col-md-4" <?php echo wp_kses_post($background_img); ?>>
				                    </div>

				                    <div class="col-md-8">
				                        <div class="episode-content-wrap">

				                        <h3><a href="<?php echo esc_url(get_the_permalink()); ?>"><?php the_title(); ?></a></h3>
				                         <?php echo do_shortcode('[ss_player]'); ?>
				                        <a href="<?php echo esc_url(get_the_permalink()); ?>" class="read-more"><?php esc_html_e('View Episode' , 'podcastin'); ?><svg class="svg-icon" viewBox="0 0 20 20">
	<path fill="none" d="M1.729,9.212h14.656l-4.184-4.184c-0.307-0.306-0.307-0.801,0-1.107c0.305-0.306,0.801-0.306,1.106,0
	l5.481,5.482c0.018,0.014,0.037,0.019,0.053,0.034c0.181,0.181,0.242,0.425,0.209,0.66c-0.004,0.038-0.012,0.071-0.021,0.109
	c-0.028,0.098-0.075,0.188-0.143,0.271c-0.021,0.026-0.021,0.061-0.045,0.085c-0.015,0.016-0.034,0.02-0.051,0.033l-5.483,5.483
	c-0.306,0.307-0.802,0.307-1.106,0c-0.307-0.305-0.307-0.801,0-1.105l4.184-4.185H1.729c-0.436,0-0.788-0.353-0.788-0.788
	S1.293,9.212,1.729,9.212z"></path>
</svg></a>

				                            
				                        
				                       
				                        </div>
				                    </div>
				             
				            </div>
                        <?php  

                    endwhile;
                        wp_reset_postdata();
                         endif;
                         endif; ?>

			</div>

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