<?php

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


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

if ( !function_exists( 'writer_ancora_template_plain_theme_setup' ) ) {
	add_action( 'writer_ancora_action_before_init_theme', 'writer_ancora_template_plain_theme_setup', 1 );
	function writer_ancora_template_plain_theme_setup() {
		writer_ancora_add_template(array(
			'layout' => 'plain',
			'template' => 'plain',
			'need_terms' => true,
			'mode'   => 'blogger',
			'title'  => esc_html__('Blogger layout: Plain', 'writer-ancora')
			));
	}
}

// Template output
if ( !function_exists( 'writer_ancora_template_plain_output' ) ) {
	function writer_ancora_template_plain_output($post_options, $post_data) {
		$swiper_scroll = isset($post_options['scroll']) ? 'swiper-slide' : '';
		?>
		<div class="post_item <?php echo esc_attr($swiper_scroll);?> sc_blogger_item sc_plain_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
			if (!empty($post_data['post_terms'][$post_data['post_taxonomy']]->terms_links)) {
				?>
				<div class="post_category">
					<span class="post_category_label"><?php esc_html_e('in', 'writer-ancora'); ?></span> <?php echo join(', ', $post_data['post_terms'][$post_data['post_taxonomy']]->terms_links); ?>
				</div>
				<?php
			}

			if (!isset($post_options['links']) || $post_options['links']) { 
				?><h4 class="post_title"><a href="<?php echo esc_url($post_data['post_link']); ?>"><?php writer_ancora_show_layout(get_the_title($post_data['post_id'])); ?></a></h4><?php
			} else {
				?><h4 class="post_title"><?php writer_ancora_show_layout(get_the_title($post_data['post_id'])); ?></h4><?php
			}
			
			if (!$post_data['post_protected'] && $post_options['info']) {
				$info_parts = array('counters'=>true, 'terms'=>false, 'author' => false);
				require writer_ancora_get_file_dir('templates/_parts/post-info.php');
			}
			?>

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

		<?php
	}
}
?>