<?php

/**
 * Template part for displaying Audio Format
 *
 * @link https://developer.wordpress.org/themes/basics/template-hierarchy/
 *
 * @package Fashion Outfits Trend
 */

?>

<article id="post-<?php the_ID(); ?>" <?php post_class() ?> >

	<?php
		// Get the post ID
		$fashion_outfits_trend_post_id = get_the_ID();

		// Check if there are audio embedded in the post content
		$fashion_outfits_trend_post = get_post($fashion_outfits_trend_post_id);
		$fashion_outfits_trend_content = do_shortcode(apply_filters('the_content', $fashion_outfits_trend_post->post_content));
		$fashion_outfits_trend_embeds = get_media_embedded_in_content($fashion_outfits_trend_content);

		if (!empty($fashion_outfits_trend_embeds)) {
			// Loop through embedded media and display only audio
			foreach ($fashion_outfits_trend_embeds as $fashion_outfits_trend_embed) {
				// Check if the embed code contains an audio tag or specific audio providers like SoundCloud
				if (strpos($fashion_outfits_trend_embed, 'audio') !== false || strpos($fashion_outfits_trend_embed, 'soundcloud') !== false) {
					?>
					<div class="custom-embedded-audio">
						<div class="media-container">
							<?php echo $fashion_outfits_trend_embed; ?>
						</div>
						<div class="media-comments">
							<?php
							// Add your comments section here
							comments_template(); // This will include the default WordPress comments template
							?>
						</div>
					</div>
					<?php
				}
			}
		}
	?>

	<div class="entry-content">
		<header class="entry-header">
			<?php 
				fashion_outfits_trend_entry_header();
				the_title( '<h3 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h3>' );
			?>
		</header>

		<div class="entry-meta">
			<?php fashion_outfits_trend_post_meta(); ?>
		</div>
		
		<div class="entry-text">
			<?php
				$fashion_outfits_trend_excerpt_limit = get_theme_mod('fashion_outfits_trend_excerpt_limit', 50);
				echo "<p>" . wp_trim_words(get_the_excerpt(), $fashion_outfits_trend_excerpt_limit) . "</p>";
			?>
		</div>

		<?php fashion_outfits_trend_edit_link(); ?>

	</div>
	
</article>