<?php

/**
 * The template for displaying playlist button
 *
 * This template can be overridden by copying it to yourtheme/movie-engine/global/button-playlist.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 = isset($args['post_id']) ? $args['post_id'] : get_the_ID();
$movie_engine_login_url = '';

if (!is_user_logged_in()) {
    $movie_engine_login_url = wp_login_url(get_permalink());
}
?>

<button class="movie-engine-action-btn me-playlist-btn <?php echo !is_user_logged_in() ? 'movie-engine-login-required-btn' : ''; ?>"
    data-post-id="<?php echo esc_attr($movie_engine_post_id); ?>"
    <?php if (!empty($movie_engine_login_url)) echo 'data-login-url="' . esc_url($movie_engine_login_url) . '"'; ?>
    data-tooltip="<?php esc_html_e('Playlist', 'cine-movie-engine'); ?>"
    aria-label="<?php esc_attr_e('Add to Playlist', 'cine-movie-engine'); ?>">
    <span class="fa-solid fa-list" aria-hidden="true"></span>
</button>