<?php

// Disable direct call
if ( ! defined( 'ABSPATH' ) ) { exit; }


/* Theme setup section
-------------------------------------------------------------------- */

if ( !function_exists( 'writer_ancora_template_date_theme_setup' ) ) {
	add_action( 'writer_ancora_action_before_init_theme', 'writer_ancora_template_date_theme_setup', 1 );
	function writer_ancora_template_date_theme_setup() {
		writer_ancora_add_template(array(
			'layout' => 'date',
			'mode'   => 'blogger',
			'title'  => esc_html__('Blogger layout: Timeline', 'writer-ancora')
			));
	}
}

// Template output
if ( !function_exists( 'writer_ancora_template_date_output' ) ) {
	function writer_ancora_template_date_output($post_options, $post_data) {
		$swiper_scroll = isset($post_options['scroll']) ? 'swiper-slide' : '';
		if (writer_ancora_param_is_on($post_options['scroll'])) writer_ancora_enqueue_slider();
        if (function_exists('writer_ancora_reviews_theme_setup')) {
            require writer_ancora_get_file_dir('templates/_parts/reviews-summary.php');
        }
		?>
		
		<div class="post_item <?php echo esc_attr($swiper_scroll);?> sc_blogger_item
			<?php if ($post_options['number'] == $post_options['posts_on_page'] && !writer_ancora_param_is_on($post_options['loadmore'])) echo ' sc_blogger_item_last'; ?>"
			<?php echo 'horizontal'==$post_options['dir'] && writer_ancora_param_is_off($post_options['scroll']) ? ' style="width:'.(100/$post_options['posts_on_page']).'%"' : ''; ?>>
			<div class="sc_blogger_date">
				<span class="day_month"><?php writer_ancora_show_layout($post_data['post_date_part1']); ?></span>
				<span class="year"><?php writer_ancora_show_layout($post_data['post_date_part2']); ?></span>
			</div>

			<div class="post_content">
				<h6 class="post_title sc_title sc_blogger_title">
					<?php echo (!isset($post_options['links']) || $post_options['links'] ? '<a href="' . esc_url($post_data['post_link']) . '">' : ''); ?>
					<?php writer_ancora_show_layout(get_the_title($post_data['post_id'])); ?>
					<?php echo (!isset($post_options['links']) || $post_options['links'] ? '</a>' : ''); ?>
				</h6>
				
				<?php writer_ancora_show_layout($reviews_summary); ?>
	
				<?php if (writer_ancora_param_is_on($post_options['info'])) { ?>
				<div class="post_info">
					<span class="post_info_item post_info_posted_by"><?php esc_html_e('by', 'writer-ancora'); ?> <a href="<?php echo esc_url($post_data['post_author_url']); ?>" class="post_info_author"><?php echo esc_html($post_data['post_author']); ?></a></span>
					<span class="post_info_item post_info_counters">
						<?php echo 'comments'==$post_options['orderby'] || 'comments'==$post_options['counters'] ? esc_html__('Comments', 'writer-ancora') : esc_html__('Views', 'writer-ancora'); ?>
						<span class="post_info_counters_number"><?php echo 'comments'==$post_options['orderby'] || 'comments'==$post_options['counters'] ? esc_html($post_data['post_comments']) : esc_html($post_data['post_views']); ?></span>
					</span>
				</div>
				<?php } ?>

			</div>	<!-- /.post_content -->
		
		</div>		<!-- /.post_item -->

		<?php
		if ($post_options['number'] == $post_options['posts_on_page'] && writer_ancora_param_is_on($post_options['loadmore'])) {
		?>
			<div class="load_more"<?php echo 'horizontal'==$post_options['dir'] ? ' style="width:'.(100/$post_options['posts_on_page']).'%"' : ''; ?>></div>
		<?php
		}
	}
}
?>