<?php global $gp;

// Margin class
if ( $GLOBALS['gp_title_position'] == 'title-over-thumbnail' && $GLOBALS['gp_excerpt_length'] == '0' && $GLOBALS['gp_meta_author'] != '1' && $GLOBALS['gp_meta_date'] != '1' && $GLOBALS['gp_meta_comment_count'] != '1' && $GLOBALS['gp_meta_views'] != '1' && $GLOBALS['gp_meta_cats'] != '1' && $GLOBALS['gp_meta_tags'] != '1' ) {
	$margin_class = 'no-post-margin';
} else {
	$margin_class = '';
}

?>

<article <?php post_class( 'post-item ' . $margin_class ); ?>>
	
	<?php if ( get_post_format() != 'quote' && has_post_thumbnail() && $GLOBALS['gp_featured_image'] == 'enabled' ) { ?>

		<div class="post-thumbnail featured-content <?php echo sanitize_html_class( $GLOBALS['gp_image_alignment'] ); ?>">

			<?php $image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), $GLOBALS['gp_image_width'], $GLOBALS['gp_image_height'], $GLOBALS['gp_hard_crop'], false, true ); ?>
			<?php if ( $gp['retina'] == 'gp-retina' ) {
				$retina = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), $GLOBALS['gp_image_width'] * 2, $GLOBALS['gp_image_height'] * 2, $GLOBALS['gp_hard_crop'], true, true );
			} else {
				$retina = '';
			} ?>
			
			<a href="<?php if ( get_post_format() == 'link' ) { echo get_post_meta( get_the_ID(), 'link', true ); } else { the_permalink(); } ?>" title="<?php the_title_attribute(); ?>"<?php if ( get_post_format() == 'link' ) { ?> target="<?php echo get_post_meta( get_the_ID(), 'link_target', true ); ?>"<?php } ?>>
			
				<?php if ( $GLOBALS['gp_title_position'] == 'title-over-thumbnail' ) { ?>
					<div class="bottom-bg-gradient-overlay"></div>
					<div class="loop-header thumbnail-header">
						<h2 class="entry-title loop-title"><?php the_title(); ?></h2>					
					</div><!-- END ENTRY HEADER -->
				<?php } ?>
							
				<img src="<?php echo esc_url( $image[0] ); ?>" data-rel="<?php echo esc_url( $retina ); ?>" width="<?php echo absint( $image[1] ); ?>" height="<?php echo absint( $image[2] ); ?>" alt="<?php if ( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ) ) { echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true ); } else { the_title_attribute(); } ?>" class="wp-post-image" />
			
			</a>
								
		</div>

	<?php } else { ?>
		
		<?php get_template_part( 'lib/sections/entry', get_post_format() ); ?>
	
	<?php } ?>
	
	<div class="post-item-content <?php echo sanitize_html_class( $GLOBALS['gp_image_alignment'] ); ?>">
	
		<?php if ( $GLOBALS['gp_title_position'] == 'title-next-to-thumbnail' && get_post_format() != 'quote' ) { ?>
			<div class="loop-header">
				<h2 class="entry-title loop-title"><a href="<?php if ( get_post_format() == 'link' ) { echo get_post_meta( get_the_ID(), 'link', true ); } else { the_permalink(); } ?>" title="<?php the_title_attribute(); ?>"<?php if ( get_post_format() == 'link' ) { ?> target="<?php echo get_post_meta( get_the_ID(), 'link_target', true ); ?>"<?php } ?>><?php the_title(); ?></a></h2>	
			</div><!-- END ENTRY HEADER -->
		<?php } ?>
		
		<?php if ( $post->post_type == 'page' OR get_post_format() == '0' OR get_post_format() == 'audio' OR (get_post_format() == 'gallery' && ! has_shortcode( $post->post_content, 'gallery' ) )  OR get_post_format() == 'link' OR get_post_format() == 'video' ) { ?>
	
			<?php if ( $GLOBALS['gp_content_display'] == 'full_content' ) { ?>

				<div class="entry-content">
					<?php global $more; $more = 0; the_content( '[' . __( 'Read More', 'gp_lang' ) . ']' ); ?>
				</div><!-- END ENTRY CONTENT -->

			<?php } else { ?>

				<?php if ( $GLOBALS['gp_excerpt_length'] != '0' ) { ?>
					<div class="entry-content">
						<p><?php echo gp_excerpt( $GLOBALS['gp_excerpt_length'] ); ?></p>
					</div><!-- END ENTRY CONTENT -->
				<?php } ?>
			
			<?php } ?>
	
		<?php } ?>	

		<?php get_template_part( 'lib/sections/entry', 'meta' ); ?>

		<?php if ( isset( $GLOBALS['gp_meta_tags'] ) && $GLOBALS['gp_meta_tags'] == '1' ) { the_tags( '<div class="entry-meta meta-tags">', ' ', '</div>' ); } ?>
	
	</div>
		
	<?php if ( $GLOBALS['gp_size'] == 'blog-large-size' ) { ?>
		<div class="post-divider"></div>
	<?php } ?>	
				
</article><!-- END POST -->