<?php
/**
 * Output of the single tournament info.
 *
 * @package cyberpress/templates
 */

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

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

$tournament       = cyberpress()->get_the_tournament();
$game             = $tournament->get_game();
$total_prize_pool = $tournament->get_total_prize_pool();
$time_start       = $tournament->get_time_start_formatted();
$time_end         = $tournament->get_time_end_formatted();
$organizer        = $tournament->get_organizer();
$tournament_type  = $tournament->get_type();

if ( $time_start || $game || $total_prize_pool || $organizer || $tournament_type ) : ?>
    <div class="cyberpress-tournament">
        <ul class="cyberpress-tournament-info">
            <?php if ( $time_start ) : ?>
                <li>
                    <?php
                    echo wp_kses(
                        // translators: %1s - start date, %2s - end date.
                        sprintf( __( '<strong>Dates</strong>: %1$1s %2$2s', 'cyberpress' ), esc_html( $time_start ), $time_end ? '- ' . esc_html( $time_end ) : '' ),
                        array(
                            'strong' => array(),
                        )
                    );
                    ?>
                </li>
            <?php endif; ?>
            <?php if ( $game ) : ?>
                <li>
                    <?php
                    echo wp_kses_post(
                        sprintf(
                            // translators: %1$s - game url, %2$s - game title.
                            __( '<strong>Game</strong>: <a href="%1$s" class="cyberpress-game-inline-link">%2$s</a>', 'cyberpress' ),
                            esc_url( $game->get_url() ),
                            $game->get_thumbnail() . ' ' . esc_html( $game->get_title() )
                        )
                    );
                    ?>
                </li>
            <?php endif; ?>
            <?php if ( $organizer ) : ?>
                <li>
                    <?php
                    echo wp_kses(
                        // translators: %s organizer.
                        sprintf( __( '<strong>Organizer</strong>: %s', 'cyberpress' ), esc_html( $organizer ) ),
                        array(
                            'strong' => array(),
                        )
                    );
                    ?>
                </li>
            <?php endif; ?>
            <?php if ( $tournament_type ) : ?>
                <li>
                    <?php
                    echo wp_kses(
                        // translators: %s type.
                        sprintf( __( '<strong>Type</strong>: %s', 'cyberpress' ), esc_html( $tournament_type ) ),
                        array(
                            'strong' => array(),
                        )
                    );
                    ?>
                </li>
            <?php endif; ?>
            <?php if ( $total_prize_pool ) : ?>
                <li>
                    <?php
                    echo wp_kses(
                        // translators: %s total prize pool.
                        sprintf( __( '<strong>Total Prize pool</strong>: %s', 'cyberpress' ), esc_html( $total_prize_pool ) ),
                        array(
                            'strong' => array(),
                        )
                    );
                    ?>
                </li>
            <?php endif; ?>
        </ul>
    </div>
<?php endif; ?>
