<?php
/**
 * Default file for single regular posts.
 * @package Ultra WordPress Theme
 * @since 1.0
 * @author AJ Clarke : http://wpexplorer.com
 * @copyright Copyright (c) 2012, AJ Clarke
 * @link http://wpexplorer.com
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */
 
get_header(); // Loads the header.php template
if ( have_posts( ) ) :
	while ( have_posts( ) ) : the_post( );
	
	// Show heading area unless disabled
	if ( get_post_meta( get_the_ID(), 'wpex_page_disable_heading', true ) !== 'yes' ) { ?>
		<header id="page-heading">
			<div class="boxed">
				<h1><?php the_title(); ?></h1>
				<?php
				// Yoast Breadcrumbs Support
				if( function_exists('yoast_breadcrumb') ) { 
					yoast_breadcrumb('<div id="breadcrumbs"><span class="icon-home"></span>','</div>');
				} ?>
				<ul id="post-pagination" class="clearfix">
					<?php
					// Newer post
					next_post_link('<li class="post-prev">%link</li>', '<span class="icon-arrow-left"></span>', false);
					
					// Back to blog
					if ( of_get_option('blog_page_url','') !== '' ) { ?>
						<li class="postype-main"><a href="<?php echo of_get_option('blog_page_url',''); ?>" title="<?php _e('Back To Blog','wpex'); ?>"><span class="icon-th-large"></span></a></li>
					<?php }
					
					// Older post
					previous_post_link('<li class="post-next">%link</li>', '<span class="icon-arrow-right"></span>', false); ?>
				</ul><!-- #post-pagination -->
			</div><!-- /boxed -->
		</header><!-- /page-heading -->
	<?php } ?>
		
		<div id="single-post-wrap" class="container boxed">
			<div id="post">
				
				<?php get_template_part( 'content', get_post_format() ); ?>

				<div class="blog-entry-content entry">
					<?php the_content(); ?>
				</div><!-- .blog-post-content -->

				<?php
				// Pagination pages when the next tag is used
				wp_link_pages( array( 'before' => '<div class="page-links clearfix">', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
				
				<?php
				// Post Tags
				if ( of_get_option('blog_post_tags','' ) == '1' ) {
					the_tags( '<div id="post-tags" class="clearfix">', '', '</div>');
				}
				
				// Meta
				if ( of_get_option('blog_post_meta','1') == '1' ) { ?>
					<ul class="post-meta clearfix">
						<li class="meta-date"><span class="icon-time"></span><?php echo get_the_date(); ?></li>
						<li class="meta-author"><span class="icon-user"></span><?php the_author_posts_link(); ?></li>
						<?php if(comments_open()) { ?><li class="meta-comments comments-scroll"><span class="icon-comments"></span><?php comments_popup_link(__('0 Comments', 'wpex'), __('1 Comment', 'wpex'), __('% Comments', 'wpex'), 'comments-link' ); ?></li><?php } ?>
					</ul><!-- .post-meta -->
				<?php
				}
				
				// Display author bio unless disabled in the admin
				if( function_exists( 'ts_fab' ) ) {
					ts_fab();
				} elseif( of_get_option('blog_post_author_bio','1') == '1' ) { ?>
					<div id="post-author" class="clearfix">
						<div id="post-author-inner" class="clearfix">
							<div id="post-author-image">
								<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>">
									<?php echo get_avatar( get_the_author_meta('user_email'), '80', '' ); ?>
								</a>
							</div><!-- /post-author-image --> 
							<div id="post-author-bio">
								<h4><?php _e('Written by ','wpex') . the_author_meta('display_name'); ?></h4>
								<p><?php the_author_meta('description'); ?></p>
								<div id="post-author-links">
								<a href="<?php echo get_author_posts_url(get_the_author_meta( 'ID' )); ?>" title="<?php _e('Visit Author Page','wpex'); ?>" class="tooltipster"><span class="icon-user"></span></a>
								<?php
								// Display twitter url
								if ( get_the_author_meta( 'twitter', $post->post_author ) !== '' ) { ?>
									<a href="<?php echo get_the_author_meta( 'twitter', $post->post_author ); ?>" title="Twitter" class="tooltipster"><span class="icon-twitter"></span></a>
								<?php }
								// Display facebook url
								if ( get_the_author_meta( 'facebook', $post->post_author ) !== '' ) { ?>
									<a href="<?php echo get_the_author_meta( 'facebook', $post->post_author ); ?>" title="Facebook" class="tooltipster"><span class="icon-facebook" class="tooltipster"></span></a>
								<?php }
								// Display google plus url
								if ( get_the_author_meta( 'googleplus', $post->post_author ) !== '' ) { ?>
									<a href="<?php echo get_the_author_meta( 'googleplus', $post->post_author ); ?>" title="Google Plus" class="tooltipster"><span class="icon-google-plus"></span></a>
								<?php }
								// Display pinterest plus url
								if ( get_the_author_meta( 'pinterest', $post->post_author ) !== '' ) { ?>
									<a href="<?php echo get_the_author_meta( 'pinterest', $post->post_author ); ?>" title="Pinterest" class="tooltipster"><span class="icon-pinterest"></span></a>
								<?php } ?>
								</div><!-- #post-author-links -->
							</div><!-- #post-author-bio -->
						</div><!-- #post-author-inner -->
					</div><!-- #post-author -->
				<?php } 
				
				// Related Posts
				if ( of_get_option('blog_post_related','1' ) == '1' ) {
					get_template_part( 'content', 'related-posts' );
				}
				
				// Comments Template
				comments_template(); ?>
			
		</div><!-- /post -->
		<?php
		// Load sidebar if post isn't full-width
		if( get_post_meta( get_the_ID(), 'wpex_post_layout', true ) !== 'Full Width' ) {
			get_sidebar();
		} ?>
	</div><!-- /single-post-wrap -->
	
	<?php endwhile;
endif;
get_footer(); // Loads the footer.php file ?>