<?php
// Get template args
extract(royal_event_template_get_args('counters'));

$show_all_counters = false;
$counters_tag = is_single() ? 'span' : 'a';

// Views
if ($show_all_counters || royal_event_strpos($post_options['counters'], 'views')!==false) {
	?>
	<<?php royal_event_show_layout($counters_tag); ?> class="post_counters_item post_counters_views icon-eye" title="<?php echo esc_attr( sprintf(__('Views - %s', 'royal-event'), $post_data['post_views']) ); ?>" href="<?php echo esc_url($post_data['post_link']); ?>"><span class="post_counters_number"><?php royal_event_show_layout($post_data['post_views']); ?></span><?php if (royal_event_strpos($post_options['counters'], 'captions')!==false) echo ' '.esc_html__('Views', 'royal-event'); ?></<?php royal_event_show_layout($counters_tag); ?>>
	<?php
}

// Comments
if ($show_all_counters || royal_event_strpos($post_options['counters'], 'comments')!==false) {
	?>
	<a class="post_counters_item post_counters_comments icon-comment" title="<?php echo esc_attr( sprintf(__('Comments - %s', 'royal-event'), $post_data['post_comments']) ); ?>" href="<?php echo esc_url($post_data['post_comments_link']); ?>"><span class="post_counters_number"><?php royal_event_show_layout($post_data['post_comments']); ?></span><?php if (royal_event_strpos($post_options['counters'], 'captions')!==false) echo ' '.esc_html__('Comments', 'royal-event'); ?></a>
	<?php 
}
 
// Rating
$rating = $post_data['post_reviews_'.(royal_event_get_theme_option('reviews_first')=='author' ? 'author' : 'users')];
if ($rating > 0 && ($show_all_counters || royal_event_strpos($post_options['counters'], 'rating')!==false)) { 
	?>
	<<?php royal_event_show_layout($counters_tag); ?> class="post_counters_item post_counters_rating icon-star" title="<?php echo esc_attr( sprintf(__('Rating - %s', 'royal-event'), $rating) ); ?>" href="<?php echo esc_url($post_data['post_link']); ?>"><span class="post_counters_number"><?php royal_event_show_layout($rating); ?></span></<?php royal_event_show_layout($counters_tag); ?>>
	<?php
}

// Likes
if ($show_all_counters || royal_event_strpos($post_options['counters'], 'likes')!==false) {
	// Load core messages
	royal_event_enqueue_messages();
	$likes = isset($_COOKIE['royal_event_likes']) ? $_COOKIE['royal_event_likes'] : '';
	$allow = royal_event_strpos($likes, ','.($post_data['post_id']).',')===false;
	?>
	<a class="post_counters_item post_counters_likes icon-heart <?php echo !empty($allow) ? 'enabled' : 'disabled'; ?>" title="<?php echo !empty($allow) ? esc_attr__('Like', 'royal-event') : esc_attr__('Dislike', 'royal-event'); ?>" href="#"
		data-postid="<?php echo esc_attr($post_data['post_id']); ?>"
		data-likes="<?php echo esc_attr($post_data['post_likes']); ?>"
		data-title-like="<?php esc_attr_e('Like', 'royal-event'); ?>"
		data-title-dislike="<?php esc_attr_e('Dislike', 'royal-event'); ?>"><span class="post_counters_number"><?php royal_event_show_layout($post_data['post_likes']); ?></span><?php if (royal_event_strpos($post_options['counters'], 'captions')!==false) echo ' '.esc_html__('Likes', 'royal-event'); ?></a>
	<?php
}

// Edit page link
if (royal_event_strpos($post_options['counters'], 'edit')!==false) {
	edit_post_link( esc_html__( 'Edit', 'royal-event' ), '<span class="post_edit edit-link">', '</span>' );
}

// Markup for search engines
if (is_single() && royal_event_strpos($post_options['counters'], 'markup')!==false) {
	?>
	<meta itemprop="interactionCount" content="User<?php echo esc_attr(royal_event_strpos($post_options['counters'],'comments')!==false ? 'Comments' : 'PageVisits'); ?>:<?php echo esc_attr(royal_event_strpos($post_options['counters'], 'comments')!==false ? $post_data['post_comments'] : $post_data['post_views']); ?>" />
	<?php
}
?>