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

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

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

$team             = cyberpress()->get_the_team();
$team_country     = $team->get_country_of_foundation();
$team_founded     = $team->get_date_of_foundation_formatted();
$team_game        = $team->get_game();
$team_players     = $team->get_players();
$team_site_url    = $team->get_site_url();
$team_youtube_url = $team->get_youtube_channel_url();
$team_twitch_url  = $team->get_twitch_channel_url();

if ( $team_country || $team_founded || $team_game || $team_site_url || $team_twitch_url || $team_youtube_url || $team_players ) : ?>
    <ul class="cyberpress-team-info">
        <?php if ( $team_country && $team_country['flag'] ) : ?>
            <li>
                <?php
                echo sprintf(
                    // translators: %s country.
                    wp_kses_post( __( '<strong>Country</strong>: %s', 'cyberpress' ) ),
                    wp_kses( $team_country['flag'] . ' ' . $team_country['name'], cyberpress()->get_kses_allowed_img() )
                );
                ?>
            </li>
        <?php endif; ?>
        <?php if ( $team_founded ) : ?>
            <li>
                <?php
                echo wp_kses(
                    // translators: %s foundation date.
                    sprintf( __( '<strong>Founded</strong>: %s', 'cyberpress' ), esc_html( $team_founded ) ),
                    array(
                        'strong' => array(),
                    )
                );
                ?>
            </li>
        <?php endif; ?>
        <?php if ( $team_game ) : ?>
            <li>
                <?php
                echo wp_kses_post(
                    sprintf(
                        // translators: %1$s - game url, %2$s - game title.
                        __( '<strong>Main Game</strong>: <a href="%1$s" class="cyberpress-game-inline-link">%2$s</a>', 'cyberpress' ),
                        esc_url( $team_game->get_url() ),
                        $team_game->get_thumbnail() . ' ' . esc_html( $team_game->get_title() )
                    )
                );
                ?>
            </li>
        <?php endif; ?>
        <?php if ( $team_site_url ) : ?>
            <li>
                <?php
                echo wp_kses(
                    // translators: %1$s - site url, %2$s - site url.
                    sprintf( __( '<strong>Site</strong>: <a href="%1$s">%2$s</a>', 'cyberpress' ), esc_url( $team_site_url ), esc_url( $team_site_url ) ),
                    array(
                        'strong' => array(),
                        'a'      => array(
                            'href' => array(),
                        ),
                    )
                );
                ?>
            </li>
        <?php endif; ?>
        <?php if ( $team_twitch_url ) : ?>
            <li>
                <?php
                echo wp_kses(
                    // translators: %1$s - site url, %2$s - site url.
                    sprintf( __( '<strong>Twitch</strong>: <a href="%1$s">%2$s</a>', 'cyberpress' ), esc_url( $team_twitch_url ), esc_url( $team_twitch_url ) ),
                    array(
                        'strong' => array(),
                        'a'      => array(
                            'href' => array(),
                        ),
                    )
                );
                ?>
            </li>
        <?php endif; ?>
        <?php if ( $team_youtube_url ) : ?>
            <li>
                <?php
                echo wp_kses(
                    // translators: %1$s - site url, %2$s - site url.
                    sprintf( __( '<strong>YouTube</strong>: <a href="%1$s">%2$s</a>', 'cyberpress' ), esc_url( $team_youtube_url ), esc_url( $team_youtube_url ) ),
                    array(
                        'strong' => array(),
                        'a'      => array(
                            'href' => array(),
                        ),
                    )
                );
                ?>
            </li>
        <?php endif; ?>
        <li>
            <?php
            echo wp_kses(
                // translators: %s players count.
                sprintf( __( '<strong>Players</strong>: %s', 'cyberpress' ), $team_players ? count( $team_players ) : '-' ),
                array(
                    'strong' => array(),
                )
            );
            ?>
        </li>
    </ul>
<?php endif; ?>
