<?php
/**
 * End-Content Theme 5 — Timeline
 *
 * @package Relatedly
 * @since   2.0.0
 * @var array $data Template variables from AbstractTheme::template_vars().
 */
defined( 'ABSPATH' ) || exit;
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound

use Relatedly\Utilities\PostHelpers;
$date = PostHelpers::formatted_date( $data['post_id'], $data['date_type'] );
?>
<div class="relatedly-end-content relatedly-end-content-timeline"
	style="<?php echo esc_attr( $data['css_vars'] ); ?>"
	data-relatedly-source="<?php echo esc_attr( $data['source_post_id'] ); ?>"
	data-relatedly-type="end_content">
	<h3 class="relatedly-heading"><?php echo esc_html( $data['label'] ); ?></h3>
	<div class="relatedly-timeline-items">
		<div class="relatedly-timeline-item">
			<?php if ( $date ) : ?>
				<span class="relatedly-date"><?php echo esc_html( $date ); ?></span>
			<?php endif; ?>
			<a href="<?php echo esc_url( $data['permalink'] ); ?>"
				class="relatedly-title relatedly-tracked-link"
				<?php if ( '_blank' === $data['link_target'] ) : ?>target="_blank" rel="noopener noreferrer"<?php elseif ( $data['link_rel'] ) : ?>rel="<?php echo esc_attr( $data['link_rel'] ); ?>"<?php endif; ?>
				<?php if ( $data['source_post_id'] ) : ?>data-relatedly-source="<?php echo esc_attr( $data['source_post_id'] ); ?>" data-relatedly-clicked="<?php echo esc_attr( $data['tracking_post_id'] ); ?>" data-relatedly-type="<?php echo esc_attr( $data['display_type'] ); ?>"<?php endif; ?>
			><?php echo esc_html( $data['title'] ); ?></a>
			<?php if ( $data['show_excerpt'] && $data['excerpt'] ) : ?>
				<p class="relatedly-excerpt"><?php echo esc_html( $data['excerpt'] ); ?></p>
			<?php endif; ?>
		</div>
	</div>
</div>
