<?php

/**
 * The template for displaying liked content item
 *
 * This template can be overridden by copying it to yourtheme/movie-engine/myaccount/content-liked.php.
 *
 * HOWEVER, on occasion MovieEngine will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @note Please do not delete our CSS classes when you customize, as it may break functionality.
 * @package Movie_Engine
 * @subpackage Movie_Engine/templates
 * @version 1.0.0
 * @since 1.0.0
 */

if (! defined("ABSPATH")) {
    exit; // Exit if accessed directly
}

$movie_engine_post_id = get_the_ID();
$movie_engine_poster = get_the_post_thumbnail_url($movie_engine_post_id, 'medium');
$movie_engine_title = get_the_title();
?>

<div class="movie-engine-movie-card me-liked-card" data-post-id="<?php echo esc_attr($movie_engine_post_id); ?>">
    <div class="movie-engine-card-poster">
        <a href="<?php the_permalink(); ?>" class="movie-engine-card-link">
            <?php if ($movie_engine_poster) : ?>
                <img src="<?php echo esc_url($movie_engine_poster); ?>" alt="<?php the_title_attribute(); ?>">
            <?php else : ?>
                <div class="movie-engine-poster-placeholder">
                    <span class="fa-solid fa-film"></span>
                </div>
            <?php endif; ?>

            <div class="movie-engine-card-overlay">
                <span class="fa-solid fa-play"></span>
            </div>
        </a>

        <button class="movie-engine-card-like-btn me-like-btn active" data-post-id="<?php echo esc_attr($movie_engine_post_id); ?>" title="<?php esc_html_e('Unlike', 'cine-movie-engine'); ?>">
            <span class="fa-solid fa-heart"></span>
        </button>
    </div>

    <div class="movie-engine-card-content">
        <h3 class="movie-engine-card-title">
            <a href="<?php the_permalink(); ?>"><?php echo esc_html($movie_engine_title); ?></a>
        </h3>
        <div class="movie-engine-card-meta">
            <span class="movie-engine-likes-count">
                <span class="fa-solid fa-heart"></span>
                <?php
                $movie_engine_likes_count = get_post_meta($movie_engine_post_id, '_movie_engine_likes_count', true) ?: 0;
                echo esc_html(\MovieEngine\Utils\Helpers::format_number($movie_engine_likes_count)) . ' ' . esc_html__('Likes', 'cine-movie-engine');
                ?>
            </span>
        </div>
    </div>
</div>