
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
/**
 * Basic Template
 *
 * @link       https://codesupply.co
 * @since      1.0.0
 *
 * @package    Basic Twitter
 * @subpackage Templates
 */

/**
 * Basic
 *
 * @param array $tweets List of tweets.
 * @param array $params Parameters.
 */
function btw_default_template( $tweets, $params ) {
	?>

	<div class="btw-wrap btw-default">

		<?php
		if ( is_array( $tweets ) && $tweets ) {

			$screen_name = $tweets[0]->user->screen_name;
			$avatar      = $tweets[0]->user->profile_image_url_https;

			$avatar = str_replace( '_normal', '_bigger', $avatar );

			if ( isset( $params['header'] ) && ( 'true' === $params['header'] || 'on' === $params['header'] ) ) {	?>

				<div class="btw-header">
					<a href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" class="btw-link" target="_blank">
						<?php if ( $avatar ) { ?>
							<img src="<?php echo esc_url( $avatar ); ?>" alt="avatar" class="btw-avatar">
						<?php } ?>
						<span class="btw-username">@<?php echo wp_kses_post( $screen_name ); ?></span>
					</a>
				</div>

			<?php
			} ?>

			<div class="btw-tweets">

				<?php
				foreach ( $tweets as $tweet ) {
					$retweets    = $tweet->retweet_count > 0 ? $tweet->retweet_count : '';
					$tweet_id    = $tweet->id_str;
					$text        = btw_convert_links( $tweet->text );
					$time        = btw_relative_time( $tweet->created_at );
					?>
						<div class="btw-tweet">

							<div class="btw-content"><?php echo wp_kses_post( $text ); ?></div>
							<a href="https://twitter.com/<?php echo esc_attr( $screen_name ); ?>/status/<?php echo esc_attr( $tweet_id ); ?>" class="btw-time timestamp" target="_blank"><?php echo esc_html( $time ); ?></a>

							<div class="btw-actions">
								<ul>
									<li>
										<a onClick="window.open('https://twitter.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-reply" href="https://twitter.com/intent/tweet?in_reply_to=<?php echo esc_attr( $tweet_id ); ?>">
											<i class="btw-icon icon icon-reply"></i>
											<span class="btw-label btw-reply"><?php esc_html_e( 'Reply', 'basic-twitter' );?></span>
										</a>
									</li>
									<li>
										<a onClick="window.open('https://twitter.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-retweet" href="https://twitter.com/intent/retweet?tweet_id=<?php echo esc_attr( $tweet_id ); ?>">
											<i class="btw-icon icon icon-repeat"></i>
											<span class="btw-count"><?php echo wp_kses_post( $retweets ); ?></span>
											<span class="btw-label btw-retweet"><?php esc_html_e( 'Retweet', 'basic-twitter' ); ?></span>
										</a>
									</li>
									<li>
										<a onClick="window.open('https://twitter.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet_id ); ?>','Twitter','width=600,height=300,left='+(screen.availWidth/2-300)+',top='+(screen.availHeight/2-150)+''); return false;" class="tweet-favorite" href="https://twitter.com/intent/favorite?tweet_id=<?php echo esc_attr( $tweet_id ); ?>">
											<i class="btw-icon icon icon-heart"></i>
											<span class="btw-label btw-favorite"><?php esc_html_e( 'Favorite', 'basic-twitter' ); ?></span>
										</a>
									</li>
								</ul>
							</div>

						</div>
					<?php
				} ?>

			</div>

			<?php
			if ( isset( $params['button'] ) && ( 'true' === $params['button'] || 'on' === $params['button'] ) ) { ?>

				<div class="btw-footer">
					<a class="btw-btn btn btn-primary btn-effect" href="<?php echo esc_url( sprintf( 'https://twitter.com/%s/', $screen_name ) ); ?>" target="_blank">
						<span class="btw-follow"><?php esc_html_e( 'Follow', 'basic-twitter' ); ?></span>
						<span><i class="btw-icon icon icon-twitter"></i></span>
					</a>
				</div>

				<?php
			}
		} else { ?>
			<p><?php esc_html_e( 'No Twitter Found!', 'basic-twitter' ); ?></p>
			<?php
		} ?>
	</div>
	<?php
}
