<?php
/**
 * Default file for single portfolio 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' ) {
	$posttype_obj = get_post_type_object( get_post_type( ) ); ?>

		<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 next_post_link('<li class="post-prev">%link</li>', '<span class="icon-arrow-left"></span>', false); ?>
						<li class="postype-main"><a href="<?php echo get_post_type_archive_link( $post->post_type ); ?>" title="<?php echo $posttype_obj->label; ?>"><span class="icon-th-large"></span></a></li>
					<?php 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 portfolio-post clearfix"> 
			<div id="post">
				<?php
				// Get Media
				if ( ! post_password_required() )
				get_template_part( 'content', 'portfolio' ); // content-portfolio.php outputs the portfolio entries/posts content ?>
				<div class="portfolio-entry-text clearfix">
					<?php
					// Project details
					if ( get_post_meta(get_the_ID(), 'wpex_portfolio_post_details', true ) !=='' ) {
						echo '<div id="portfolio-post-details" class="clearfix">'. do_shortcode( wpautop( htmlspecialchars_decode( get_post_meta(get_the_ID(), 'wpex_portfolio_post_details', true ) ) ) ) .'</div>';
					} ?>
					<div class="portfolio-entry-content entry <?php if ( get_post_meta(get_the_ID(), 'wpex_portfolio_post_details', true ) !=='' ) echo 'portfolio-entry-content-float'; ?>"> 
						<?php the_content(); ?>
						<?php wp_link_pages( array( 'before' => '<div class="page-links clearfix">', 'after' => '</div>', 'link_before' => '<span>', 'link_after' => '</span>' ) ); ?>
					</div><!-- .portfolio-entry-content -->
				</div><!-- /portfolio-entry-text -->
				<?php
				// Show portfolio comments
				if ( of_get_option('portfolio_comments') == '1' ) {
					comments_template();
				} ?>
			</div><!-- #post -->
			<?php
			// Load sidebar if post isn't full-width
			if( get_post_meta( get_the_ID(), 'wpex_post_layout', true) !== '' &&
				get_post_meta( get_the_ID(), 'wpex_post_layout', true) !== 'Full Width' ) {
					get_sidebar();
			} ?>
		</div><!-- #single-post-wrap -->

	<?php
	endwhile;
endif;

// Show other portfolio items
if ( ! post_password_required( ) && of_get_option('portfolio_related','1') == '1' ) {
	get_template_part('content-portfolio','related'); // Show Related Portfolio items ( if post is not pass protected )
}

get_footer(); // Loads the footer.php file