<?php

/**
 * The template for displaying archive person
 *
 * This template can be overridden by copying it to yourtheme/movie-engine/archive-person.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
}

get_header(); ?>

<div class="movie-engine-archive-wrapper movie-engine-plugin">
    <div class="movie-engine-container">

        <header class="movie-engine-archive-header">
            <h1 class="movie-engine-archive-title"><?php esc_html_e('Cast & Crew', 'cine-movie-engine'); ?></h1>
            <div class="movie-engine-archive-description">
                <?php esc_html_e('Browse all the people involved in movies and series.', 'cine-movie-engine'); ?>
            </div>
        </header>

        <div class="movie-engine-archive-content movie-engine-ajax-container" data-action="movie_engine_filter_movies" data-post_type="movie_engine_person">
            <?php if (have_posts()) : ?>
                <div class="movie-engine-movie-grid">
                    <?php while (have_posts()) : the_post(); ?>
                        <?php \MovieEngine\Utils\TemplateLoader::get_template_part('loop/content', 'person'); ?>
                    <?php endwhile; ?>
                </div>

                <?php echo \MovieEngine\Utils\Helpers::kses_post(\MovieEngine\Utils\Helpers::render_pagination(get_query_var('paged') ?: 1, $wp_query->max_num_pages)); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- kses_post sanitizes HTML ?>

            <?php else : ?>
                <div class="movie-engine-no-results">
                    <p><?php esc_html_e('No people found.', 'cine-movie-engine'); ?></p>
                </div>
            <?php endif; ?>
        </div>

    </div>
</div>

<?php get_footer(); ?>