<?php
/**
 * The template for displaying single posts for all formats
 *
 * @package WordPress
 * @subpackage Edition
 * @since Edition 1.0
 */
get_header();

global $fields_installed; ?>

<?php while ( have_posts() ) : the_post();  // Start the loop ?>
	<?php $tw_entry = themewich_post_options();   // Get post options from functions.php  ?>

	<!-- Post Wrapper -->
		<div <?php post_class($tw_entry->post_classes); ?>>
			<?php get_template_part(TW_TEMPLATES_DIR . '/full-top-thumbnail'); ?>

			<div class="container">
				<div class="rightside">
					<?php get_template_part(TW_TEMPLATES_DIR . '/no-full-thumbnail'); // Full thumbnail ?>

					<div class="postcontentwrap">
					<?php if ($tw_entry->sharing) {
						get_template_part(TW_TEMPLATES_DIR . '/sharing'); // Sharing icons
					} ?>

						<div class="rightcontent">

							<?php if ( ($tw_entry->thumbnail_class == 'no-thumbnail' || ! $tw_entry->featured_image) || $tw_entry->has_media ) : ?>
								<h1 class="title entry-title" <?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) { echo 'itemprop="itemreviewed"'; } ?>>
									<?php the_title(); ?>
								</h1>
								<div class="authorinfo not-full">
									<span class="author vcard">
										<?php _e( 'By', 'themewich' );?>
										<span class="fn" <?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) { echo 'itemprop="reviewer"'; } ?>>
											<?php tw_author_link('posts'); ?>
										</span>
									</span>
									<span class="tw-bullet">&nbsp;&bull;&nbsp;</span>
									<span <?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) { echo 'itemprop="dtreviewed" datetime="' . get_the_time('c') . '"'; } ?>></span>
									<span class="updated">
										<?php themewich_date('human'); ?>
									</span>
									<span class="tw-bullet">&nbsp;&bull;&nbsp;</span>
									<?php echo ag_get_cats(3, true); ?>
								</div>
							<?php endif; ?>

							<?php if ($tw_entry->review_placement == 'top-bottom') { ?>
								<div class="reviewtop">
									<?php echo themewich_review_circle( 'title' ); // Review circle ?>
								</div>
							<?php } ?>

							<div class="postcontent content">
								<?php if ( $fields_installed && $subheadline = get_field( 'post_subtitle' ) ) : ?>
									<h2 class="post-subtitle" <?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) { echo 'itemprop="summary"'; } ?>>
										<?php echo wp_kses_post( $subheadline ); ?>
									</h2>
								<?php endif; ?>

								<?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) : ?>
									<span itemprop="description">
								<?php endif; ?>

									<?php the_content(); // Post content ?>

								<?php if ( tw_issetor($tw_entry->review_post) == 'yes' ) : ?>
									</span>
								<?php endif; ?>

							</div>

							<div class="afterpost-items">
								<?php
									$page_args = array(
									    'before'           => '<p class="link-pages"><span class="title">' . __( 'Page', 'themewich' ) . '</span>',
									    'after'            => '</p>',
									    'link_before' => '<span class="page-link">',
										'link_after'  => '</span>'
									);
									wp_link_pages($page_args);

									// Review Breakdown
									get_template_part(TW_TEMPLATES_DIR . '/entry-breakdown'); // Breakdown

									// Tags
									the_tags('<div class="tagcloud badge"><h5>'.__("Tags", "themewich"). '</h5>', ' ', '</div><div class="clear"></div>');

									// Author Box
									if ( $tw_entry->author_box && ( get_the_author_meta( 'description' ) || tw_social_links( get_the_author_meta('ID') ) ) ) { ?>
										<div class="authorboxwrap">
											<div class="section-title">
												<p><span><?php _e('The Author', 'themewich'); ?></span></p>
											</div>
											<?php get_template_part(TW_TEMPLATES_DIR . '/author-box'); ?>
										</div>
									<?php }

									// Related Posts
									if ( $tw_entry->related ) {
										get_template_part(TW_TEMPLATES_DIR . '/related'); // Related Posts
									}

									// If comments are open or we have at least one comment, load up the comment template.
									if ( comments_open() || get_comments_number() ) {
										comments_template();
									}
								?>
							</div>

						</div><!-- .rightcontent -->
						<div class="clear"></div>
					</div><!-- .postcontentwrap -->
				</div><!-- .rightside -->

	            <?php if ( ! ( $tw_entry->post_columns == 1 ) ) : ?>
					<div class="sidebar">
						<div class="sidebarcontent">
							<?php dynamic_sidebar( 'Blog Sidebar' ); ?>
						</div><!-- .sidebarcontent -->
					</div><!-- .sidebar -->
				<?php endif; ?>

			</div><!-- .container -->
		</div><!-- Post Wrapper -->

<?php endwhile; ?>

<?php get_footer();