<?php
/**
 * Template part for displaying single post content
 *
 * @package HomeProz
 */

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}
?>

<article id="post-<?php the_ID(); ?>" <?php post_class('single-post'); ?>>
    <header class="post-header">
        <div class="post-meta">
            <time datetime="<?php echo esc_attr(get_the_date('c')); ?>">
                <?php echo esc_html(get_the_date()); ?>
            </time>
            <?php
            $categories = get_the_category();
            if ($categories) :
                ?>
                <span class="meta-separator">|</span>
                <span class="post-categories">
                    <?php
                    $cat_links = array();
                    foreach ($categories as $category) {
                        $cat_links[] = '<a href="' . esc_url(get_category_link($category->term_id)) . '">' . esc_html($category->name) . '</a>';
                    }
                    echo implode(', ', $cat_links);
                    ?>
                </span>
            <?php endif; ?>
        </div>

        <?php the_title('<h1 class="post-title">', '</h1>'); ?>
    </header>

    <?php if (has_post_thumbnail()) : ?>
        <div class="post-featured-image">
            <?php the_post_thumbnail('large'); ?>
        </div>
    <?php endif; ?>

    <div class="entry-content">
        <?php
        the_content();

        wp_link_pages(array(
            'before' => '<div class="page-links">' . esc_html__('Pages:', 'homeproz'),
            'after'  => '</div>',
        ));
        ?>
    </div>

    <footer class="post-footer">
        <?php
        $tags = get_the_tags();
        if ($tags) :
            ?>
            <div class="post-tags">
                <span class="tags-label">Tags:</span>
                <?php
                foreach ($tags as $tag) {
                    echo '<a href="' . esc_url(get_tag_link($tag->term_id)) . '" class="tag-link">' . esc_html($tag->name) . '</a>';
                }
                ?>
            </div>
        <?php endif; ?>
    </footer>
</article>
