<?php
/*
Template Name: Hub
*/
$ratings = new gp_user_rating(); 
get_header(); global $gp; ?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>		
		
	<?php gp_page_header( get_the_ID() ); ?>
		
	<div id="content-wrapper"<?php if ( $GLOBALS['gp_layout'] != 'gp-fullwidth' ) { ?> class="gp-container"<?php } ?>>

		<div id="content">

			<article <?php post_class( 'image-wrap-left' ); ?>>

				<div class="entry-content">
			
					<?php if ( $gp['hub_details'] == 'enabled' ) { ?>
				
						<div id="hub-details">
				
							<div class="hub-block hub-block-one">
								<h2 class="entry-title"><?php the_title_attribute(); ?></h2>
							</div>
			
							<div class="hub-block hub-block-two"<?php echo wp_kses_post( $GLOBALS['gp_title_bg_css'] ); ?>>
						
								<div class="bg-overlay-dark"></div>
						
								<div class="foreground-overlay">
					
									<?php if ( has_post_thumbnail( get_the_ID() ) ) { ?>

										<div class="post-thumbnail featured-content image-align-left">

											<?php $image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), $gp['hub_image']['width'], $gp['hub_image']['height'], $gp['hub_hard_crop'], false, true ); ?>
											<?php if ( $gp['retina'] == 'gp-retina' ) {
												$retina = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), $gp['hub_image']['width'] * 2, $gp['hub_image']['width'] * 2, $gp['hub_hard_crop'], true, true );
											} else {
												$retina = '';
											} ?>

											<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" />
		
										</div>

									<?php } ?>	
					
									<div class="hub-synopsis image-align-left">
										<?php echo wpautop( do_shortcode( $gp['hub_synopsis'] ), false ); ?>
									</div>
						
								</div>
							
							</div>	
						
							<div class="hub-block hub-block-three">
						
								<?php foreach( $gp['hub_fields'] as $gp_hub_field ) {
									$gp_hub_field_slug = sanitize_title( $gp_hub_field );
									$gp_hub_field_slug = substr( $gp_hub_field_slug, 0, 32 );
									$term_list = get_the_term_list( get_the_ID(), $gp_hub_field_slug, '<span><strong>' . $gp_hub_field . ':</strong>', ', ', '</span>' );
									if ( ! $term_list OR is_wp_error( $term_list ) ) {
										continue;
									}	
									echo wp_kses_post( $term_list );
								} ?>
										
							</div>	
					
						</div><!-- HUB DETAILS -->
					
					<?php } ?>
				
					<?php if ( ( $GLOBALS['gp_hub_header'] == true OR is_page_template( 'review-template.php' ) ) && ( $GLOBALS['gp_layout'] == 'gp-no-sidebar' OR $GLOBALS['gp_layout'] == 'gp-fullwidth' ) ) { ?>
						<?php if ( $GLOBALS['gp_user_rating_box'] == 'enabled' ) { ?>
							<?php get_template_part( 'lib/sections/user-rating-box' ); ?>
						<?php } ?>
					<?php } ?>
					
					

					<?php the_content(); ?>
			
				</div><!-- END ENTRY CONTENT -->

			</article><!-- END ARTICLE -->		

		</div><!-- END CONTENT -->

		<?php get_sidebar(); ?>

	</div><!-- END CONTENT WRAPPER -->
		
<?php endwhile; endif; ?>	
			
<?php get_footer(); ?>