<?php

/**
 * The template for displaying archive filter person bar
 *
 * This template can be overridden by copying it to yourtheme/movie-engine/archive/filter-person-bar.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_current_sort = isset($_GET['orderby']) ? sanitize_text_field(wp_unslash($_GET['orderby'])) : 'title'; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
?>

<div class="movie-engine-filter-bar">
    <div class="movie-engine-filter-form">
        <div class="movie-engine-filter-group me-search-group">
            <input type="search" class="movie-engine-search-field" placeholder="<?php esc_html_e('Search people...', 'cine-movie-engine'); ?>" value="<?php echo esc_attr(get_search_query()); ?>" name="s">
            <button type="button" class="movie-engine-search-submit">
                <span class="fa-solid fa-magnifying-glass"></span>
            </button>
        </div>

        <div class="movie-engine-filter-group">
            <select name="orderby" class="movie-engine-filter-select">
                <option value="title" <?php selected($movie_engine_current_sort, 'title'); ?>><?php esc_html_e('Name (A-Z)', 'cine-movie-engine'); ?></option>
                <option value="date" <?php selected($movie_engine_current_sort, 'date'); ?>><?php esc_html_e('Newest First', 'cine-movie-engine'); ?></option>
                <option value="oldest" <?php selected($movie_engine_current_sort, 'oldest'); ?>><?php esc_html_e('Oldest First', 'cine-movie-engine'); ?></option>
            </select>
        </div>

        <div class="movie-engine-filter-actions">
            <button type="button" class="movie-engine-btn me-btn-reset">
                <span class="fa-solid fa-rotate-left"></span>
                <?php esc_html_e('Reset', 'cine-movie-engine'); ?>
            </button>
        </div>
    </div>
</div>