<?php
/**
 * Single entry template - games loop items.
 *
 * @var $attributes - attributes
 *
 * @package cyberpress/templates
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

$game           = cyberpress()->get_the_game();
$thumbnail_size = CyberPress_Settings::get_option( 'games_archive_thumbnail_size', 'cyberpress_games' );
$game_url       = $game->get_url();
$game_title     = $game->get_title();

?>

<?php do_action( 'cyberpress_games_before_loop', $attributes ); ?>

<li id="post-<?php echo esc_attr( $game->get_id() ); ?>" <?php $game->game_classes( 'cyberpress-col cyberpress-game' ); ?>>

    <?php do_action( 'cyberpress_games_loop_before_thumbnail' ); ?>

    <?php if ( '' !== $game->check_thumbnail() && $attributes['displayMetaThumbnail'] ) : ?>
        <div class="cyberpress-game-thumbnail">
            <a href="<?php echo esc_url( $game_url ); ?>">
                <?php echo wp_kses( $game->get_thumbnail( $thumbnail_size ), cyberpress()->get_kses_allowed_img() ); ?>
            </a>
        </div><!-- .post-thumbnail -->
    <?php endif; ?>

    <?php do_action( 'cyberpress_games_loop_after_thumbnail', $attributes ); ?>

    <?php do_action( 'cyberpress_games_loop_before_title', $attributes ); ?>

    <?php if ( $game_title && $attributes['displayMetaTitle'] ) : ?>
        <h2 class="cyberpress-game-title">
            <a href="<?php echo esc_url( $game_url ); ?>">
                <?php echo esc_html( $game_title ); ?>
            </a>
        </h2>
    <?php endif; ?>

    <?php do_action( 'cyberpress_games_loop_after_title', $attributes ); ?>

</li><!-- #post-## -->

<?php do_action( 'cyberpress_games_after_loop', $attributes ); ?>
