<?php 
/**
 * Trending news post page
**/ 
?>
<?php get_header(); ?>

<div id="main">
	<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
	<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <div id="post-page-title">
            <h1>
                <?php the_title(); ?>
            </h1>
        </div><!--post-page-title-->
        <div id="post-page-subtitle">
                <?php  $tn_subtitle = get_post_meta(get_the_ID(), 'tn_sub_title', true); if(empty($tn_subtitle)) { echo excerpt(30); }  else { echo $tn_subtitle;}  ?>
        </div><!--post-subtitle-->
		<div id="primary">
			<div id="media-wrapper">
				<?php
        		$video_embed = wp_oembed_get(get_post_meta($post->ID, "trendingnews_video_link", true), array('width'=>636) );    	
				if ( ! get_post_format() || 'aside' == get_post_format() ): // Standard or Review
					echo '<div class="image-wrapper">'.the_post_thumbnail('solo-slider-img').'</div><!--image-wrapper-->';
				elseif ( 'video' == get_post_format() ): // Video
					echo '<div class="video-wrapper">' .$video_embed. '</div><!--video-wrapper-->';
				endif;
				?>
			</div><!--media-wrapper-->
			<div class="post-info">
                <span class="post-author">
                <?php echo get_option('tn_word_before_author'); ?>
				<?php the_author_posts_link(); ?>
				</span>
				<span class="post-page-date">
				<?php echo get_the_date(); ?>
				</span> 

			</div><!--post-info-->
			<div id="post-content">
				<?php the_content();
				  wp_link_pages(array(  
    				'before' => '<div class="pagination">' . 'Pages:',  
   					 'after' => '</div>'  
  					  ));   ?>
                      
			</div><!--post-content-->
            <?php if ( 'aside' == get_post_format() ): // Review
					echo tn_review();
				endif;?>
                
			<?php $tn_tags_title = get_option('tn_post_tags_title'); $tn_post_tags = get_option('tn_post_tags'); if ($tn_post_tags == "true") {?>
                <?php the_tags('<div class="post-tags"><div class="tags-title">'.$tn_tags_title.'</div><!--tags-title--><span class="tag-img"></span>', '', '</div><!--post-tags-->');} ?>	
			
			<?php $tn_share_post = get_option('tn_share_post'); if ($tn_share_post == "true") { ?>
			<div class="share-post">
            	<div class="share-title">
					<?php echo get_option('tn_share_this_article'); ?>
                </div>
				<ul>
					<li>
						<a href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>" target="blank" class="fb-share-icon" title="Share this post on Facebook"></a>
					</li>
				
					<li>
						<a href="https://twitter.com/intent/tweet?original_referer=<?php the_permalink(); ?>&amp;&tw_p=tweetbutton&url=<?php the_permalink(); ?>" target="_blank"  class="twitter-share-icon" title="Share this post on Twitter"></a>
					</li>
				
					<li>
						<a href="https://plusone.google.com/_/+1/confirm?hl=en-US&amp;url=<?php the_permalink(); ?>" target="_blank" class="google-share-icon" title="Share this post on Google Plus"></a>
					</li>

					<li>
						<a href="http://pinterest.com/pin/create/bookmarklet/?media=<?php $pinimg = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumb' ); echo $pinimg[0]; ?>&url=<?php the_permalink(); ?>&is_video=false&description=<?php the_title(); ?>" target="_blank" class="pinterest-share-icon" title="Share this post on Pinterest"></a>
					</li>	
					<li>
						<a href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" class="stumble-share-icon" title="Share this post on Stumbleupon"></a>
					</li>		
					<li>
						<a href="http://www.reddit.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" target="_blank" class="reddit-share-icon" title="Share this post on Reddit"></a>
					</li>		
				</ul>
			</div><!--share-post-->	
			<?php } ?>	
			<?php count_views($post->ID); ?>
			<?php $tn_nav_links = get_option('tn_next_prev_links'); if ($tn_nav_links == "true") { ?>
			<div class="nav-next-prev">
				<?php
                    $prev_post = get_previous_post();
					$next_post = get_next_post();
					
                    if ( !empty( $prev_post ) ){ 
                    ?>
				<div class="nav-previous">
					<div class="previous-article">
                    	<?php $older_article = get_option('tn_older_article');?>
						<?php previous_post_link ( '%link', $older_article); ?>
					</div><!--previous-article-->
					<div class="previous-title">
						<h2>
							<?php previous_post_link ( '%link', '%title'); ?>
						</h2>
						<div class="post-date"> <span class="bypostauthor"><?php echo get_option('tn_word_before_author'); ?> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID', $prev_post->post_author)); ?>">
							<?php the_author_meta('display_name', $prev_post->post_author); ?>
							</a> - </span> <span class="date-prev"><?php echo mysql2date('M j, Y', $prev_post->post_date); ?></span>
						</div><!--post-date-->
					</div><!--previous-title-->
				</div><!--nav-previous-->
				<?php } ?>
				<div class="splitter">
				</div><!--splitter-->
				<?php
                    if ( !empty( $next_post ) ){ 
                    ?>
				<div class="nav-next">
					<div class="next-article">
                   		<?php $next_article = get_option('tn_next_article');?>
						<?php next_post_link ( '%link', $next_article); ?>
					</div><!--next-article-->
					<div class="next-title">
						<h2>
							<?php next_post_link( '%link', '%title' ); ?>
						</h2>
						<div class="post-date"> <span class="bypostauthor"><?php echo get_option('tn_word_before_author'); ?> <a href="<?php echo get_author_posts_url(get_the_author_meta('ID', $next_post->post_author)); ?>">
							<?php the_author_meta('display_name', $next_post->post_author); ?>
							</a> - </span> <span class="date-next"><?php echo mysql2date('M j, Y', $next_post->post_date); ?></span>
						</div><!--post-date-->
					</div><!--next-title-->
				</div><!--nav-next-->
				<?php } ?>
			</div><!--nav-next-prev-->
			<?php } ?>
			<?php $tnauthorbox = get_option('tn_author_box'); if ($tnauthorbox == "true") { ?>
			<div id="author-info">
				<div id="author-image">
					<?php echo get_avatar( get_the_author_meta('email'), '96' ); ?>
				</div><!--author-image-->
				<div id="author-desc">
					<h2>
						<?php the_author_posts_link(); ?>
					</h2>
					<div class="description-author">
						<?php the_author_meta('description'); ?>
					</div><!--description-author-->
					<ul class="author-social">
						<?php if(get_the_author_meta('facebook')) { ?>
						<li> <a href="http://facebook.com/<?php the_author_meta('facebook'); ?>" class="fb-social-icon"></a> </li>
						<?php } ?>
						<?php if(get_the_author_meta('twitter')) { ?>
						<li> <a href="https://twitter.com/<?php the_author_meta('twitter'); ?>" class="twitter-social-icon"></a> </li>
						<?php } ?>
						<?php if(get_the_author_meta('google')) { ?>
						<li> <a href="http://plus.google.com/<?php the_author_meta('google'); ?>?rel=author" class="google-social-icon"></a> </li>
						<?php } ?>
						<?php if(get_the_author_meta('pinterest')) { ?>
						<li> <a href="http://www.pinterest.com/<?php the_author_meta('pinterest'); ?>?rel=author" class="pinterest-social-icon"></a> </li>
						<?php } ?>
						<?php if(get_the_author_meta('linkedin')) { ?>
						<li> <a href="http://www.linkedin.com/company/<?php the_author_meta('linkedin'); ?>?rel=author" class="linkedin-social-icon"></a> </li>
						<?php } ?>
					</ul>
				</div><!--author-desc-->
			</div><!--author-info-->
			<?php } ?>
			<?php $tn_show_comments = get_option('tn_show_comments'); if ($tn_show_comments == "true") { ?>
			<div class="comments">
				<?php comments_template(); ?>
			</div><!--comments-->
			<?php } ?>
		</div><!--primary-->
        <?php $tn_post_ad = get_option('tn_post_ad'); if (! empty($tn_post_ad)){echo '<div id="post-page-ad">'.$tn_post_ad.'</div><!--post-page-ad-->';} ?>
		<div id="secondary" class="widget-area">
            <?php $tn_related_tabber = get_option('tn_related_tabber'); if ($tn_related_tabber == "true") { ?>
			<div class="home-widget">
            	<?php if(get_option('tn_related_by')) { ?>
				<h3><span class="widget-title"><?php echo get_option('tn_related_by'); ?></span></h3>
                <?php } ?>
				<div class="tabber-container">
					<ul class="tabs">
						<li>
							<h4><a href="#tab1"><?php echo get_option('tn_post_page_related_tags'); ?></a></h4>
						</li>
						<li>
							<h4><a href="#tab2"><?php echo get_option('tn_post_page_related_category'); ?></a></h4>
						</li>
						<li>
							<h4><a href="#tab3"><?php echo get_option('tn_post_page_related_author'); ?></a></h4>
						</li>
					</ul>
					<div id="tab1" class="tabber-content">
						<?php related_posts_tags(); ?>
					</div><!--tab1-->
					<div id="tab2" class="tabber-content">
						<?php related_posts_category(); ?>
					</div><!--tab2-->
					<div id="tab3" class="tabber-content">
						<?php related_posts_author(); ?>
					</div><!--tab3-->
				</div><!--tabber-container-->
			</div><!--home-widget-->
            <?php } ?>     
            <?php $tn_post_page_popular = get_option('tn_post_page_popular'); if ($tn_post_page_popular == "true") { ?>
            <?php } ?>
            <?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Post Sidebar')): endif; ?>
		</div><!--secondary-->
	</div><!--post-->
	<?php endwhile; endif; ?>
</div><!--main-->
<?php get_footer(); ?>
