<?php get_header();
$sDateAndTimeFormat = get_option( 'date_format' ).' '.get_option( 'time_format' );
// with sidebar
if ( ot_get_option( 'uni_single_post_with_sidebar' ) == 'on' ) {
?>
	<section class="uni-container singlePostWithSidebar">

        <div class="wrapper clear">
            <div class="contentLeft">
                <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="postItemV2Meta">
                        <time class="postItemTime" datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( $sDateAndTimeFormat ); ?></time>
                    </div>

                    <div id="post-<?php the_ID(); ?>" <?php post_class('singlePostWrap clear') ?>>
						
						<h1 class="singleTitle"><?php the_title() ?></h1>

                        <?php the_content() ?>

                    </div>

                    <div class="singleLinkPages">
                        <?php wp_link_pages(); ?>
                        <br>
                    </div>
                    <div class="singlePostTags clear">
                        <span><?php esc_html_e('Categories', 'asana') ?>:</span>
                <?php
                $aTags = wp_get_post_terms( $post->ID, 'category' );
                if ( $aTags && !is_wp_error( $aTags ) ) :
                $s = count($aTags);
                $i = 1;
                foreach ( $aTags as $oTerm ) {
                    echo '<a href="'.esc_url( get_term_link( $oTerm->slug, 'category' ) ).'">'.esc_html( $oTerm->name ).'</a>';
                    if ($i < $s) echo ', ';
                    $i++;
                }
                endif;
                ?>
                <br><br>
                <?php the_tags( '<span>'.esc_html__('Tags', 'asana').':</span>', ', ', '' ); ?>

                    </div>

                    <div class="postNavigation clear">
                    <?php
                    $oAdjacentPost  = get_adjacent_post(false,'',true);
                    $sPrevPostId    = ( isset($oAdjacentPost) && !empty($oAdjacentPost) ) ? $oAdjacentPost->ID : '';
                    $oAdjacentPost  = get_adjacent_post(false,'',false);
                    $sNextPostId    = ( isset($oAdjacentPost) && !empty($oAdjacentPost) ) ? $oAdjacentPost->ID : '';
                    ?>
                            <?php if ( isset($sPrevPostId) && !empty($sPrevPostId) ) { ?>
                                <a href="<?php echo esc_url( get_permalink( $sPrevPostId ) ); ?>" class="postPrev">
                                    <i>
                                        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="&#1057;&#1083;&#1086;&#1081;_1" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
                                            <path fill="#333" class="postNavigationArrowIcon" d="M0.95 4.636L6.049 0L7 0.864L1.899 5.5L7 10.136L6.049 11L0 5.5L0.95 4.636z"/>
                                        </svg>
                                    </i>
                                    <?php _e('previous', 'bauhaus') ?>
                                </a>
                            <?php } ?>
                            <?php if ( isset($sNextPostId) && !empty($sNextPostId) ) { ?>
                                <a href="<?php echo esc_url( get_permalink( $sNextPostId ) ); ?>" class="postNext">
                                    <i>
                                        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="&#1057;&#1083;&#1086;&#1081;_2" x="0px" y="0px" width="7px" height="11px" viewBox="0 0 7 11" enable-background="new 0 0 7 11" xml:space="preserve">
                                            <path fill="#333" class="postNavigationArrowIcon" d="M6.05 6.364L0.951 11L0 10.136L5.102 5.5L0 0.864L0.951 0L7 5.5L6.05 6.364z"/>
                                        </svg>
                                    </i>
                                    <?php _e('next', 'bauhaus') ?>
                                </a>
                            <?php } ?>

                            <?php include(locate_template('includes/social-links-custom.php')); ?>

                        </div>

                    <?php comments_template(); ?>

                <?php endwhile; endif; ?>
            </div>

            <?php get_sidebar() ?>

        </div>

        <?php if ( !ot_get_option( 'uni_display_similar_posts' ) || ot_get_option( 'uni_display_similar_posts' ) != 'off' ) { ?>
        <?php uni_relative_posts_by_tags(); ?>
        <?php } ?>

	</section>
<?php
// without sidebar
} else {
?>
	<section class="uni-container">

        <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
		<div class="wrapper">

            <time class="postItemTime" datetime="<?php the_time('Y-m-d'); ?>"><?php the_time( $sDateAndTimeFormat ); ?></time>

			<div id="post-<?php the_ID(); ?>" <?php post_class('singlePostWrap clear') ?>>

				<h1 class="singleTitle"><?php the_title() ?></h1>

                <?php the_content() ?>

			</div>

            <div class="singleLinkPages">
                <?php wp_link_pages(); ?>
                <br>
            </div>
			<div class="singlePostTags clear">
			    <span><?php esc_html_e('Categories', 'asana') ?>:</span>
        <?php
        $aTags = wp_get_post_terms( $post->ID, 'category' );
        if ( $aTags && !is_wp_error( $aTags ) ) :
        $s = count($aTags);
        $i = 1;
	    foreach ( $aTags as $oTerm ) {
	        echo '<a href="'.esc_url( get_term_link( $oTerm->slug, 'category' ) ).'">'.esc_html( $oTerm->name ).'</a>';
            if ($i < $s) echo ', ';
            $i++;
	    }
        endif;
        ?>
        <br><br>
        <?php the_tags( '<span>'.esc_html__('Tags', 'asana').':</span>', ', ', '' ); ?>

			</div>

            <?php include(locate_template('includes/social-links.php')); ?>

            <?php comments_template(); ?>

		</div>

        <?php if ( !ot_get_option( 'uni_display_similar_posts' ) || ot_get_option( 'uni_display_similar_posts' ) != 'off' ) { ?>
        <?php uni_relative_posts_by_tags(); ?>
        <?php } ?>

        <?php endwhile; endif; ?>

	</section>
<?php
}
get_footer(); ?>