<?php
/**
 * End-Content Theme 3 — Masonry Grid
 *
 * @package Relatedly
 * @since   2.0.0
 * @var array $data Template variables from AbstractTheme::template_vars().
 */
defined( 'ABSPATH' ) || exit;
?>
<div class="relatedly-end-content relatedly-end-content-masonry"
	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-masonry-grid">
		<div class="relatedly-masonry-item">
			<?php if ( $data['thumbnail_id'] ) : ?>
				<a href="<?php echo esc_url( $data['permalink'] ); ?>"
					class="relatedly-thumbnail-link 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 wp_get_attachment_image( $data['thumbnail_id'], $data['thumbnail_size'] ); ?></a>
			<?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>
