<?php
/*
Template Name: Review
*/
get_header(); global $gp;

gp_page_header( get_the_ID() );
            
?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>		

	<div id="review-content-wrapper" class="gp-container<?php if ( $gp['review_first_letter_styling'] == 'enabled' ) { ?> review-first-letter<?php } ?>">

		<div id="review-content">
	
			<article class="post-content">
	
				<?php if ( ! empty( $gp['review_subtitle'] ) OR ! empty( $gp['review_share_icons'] ) ) { ?>
	
					<header class="entry-header small-header">

						<?php if ( ! empty( $gp['review_subtitle'] ) ) { ?>
							<h2 class="subtitle"><?php echo esc_attr( $gp['review_subtitle'] ); ?></h2>
						<?php } ?>

						<?php if ( ! empty( $gp['review_share_icons'] ) ) { ?>
							<div class="share-icons"><?php echo do_shortcode( $gp['review_share_icons'] ); ?></div>
						<?php } ?>
						
					</header>
		
				<?php } ?>	

				<div class="entry-content review-text">
	
					<?php the_content(); ?>

					<?php wp_link_pages( 'before=<ul class="page-numbers single-nav">&pagelink=<span class="page-numbers">%</span>&after=</ul>' ); ?>		
		
				</div><!-- END ENTRY CONTENT -->

				<?php if ( $gp['review_meta']['tags'] == '1' ) { ?>
					<?php the_tags( '<div class="entry-meta meta-tags">', ' ', '</div>' ); ?>
				<?php } ?>

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

		</div><!-- END REVIEW CONTENT -->
	
	</div><!-- END REVIEW CONTENT WRAPPER -->
	
	<?php 
	
	$GLOBALS['gp_display_site_rating'] = '1';		
	$GLOBALS['gp_display_user_rating'] = '0';	
				
	gp_ratings( get_the_ID() );
	
	if ( ! empty( $gp['review_good_points'][0] ) OR ! empty( $gp['review_bad_points'][0] ) OR $GLOBALS['gp_site_rating_enabled'] == true ) { ?>

		<div id="review-summary" class="<?php if ( count( $GLOBALS['gp_site_rating'] ) > 1 ) { ?>rating-criteria<?php } ?>"<?php echo wp_kses_post( $GLOBALS['gp_title_bg_css'] ); ?>>

			<?php if ( $gp['title_bg_top_gradient_overlay'] == 'enabled' && ! empty( $GLOBALS['gp_title_bg'] ) ) { ?>
				<div class="top-bg-gradient-overlay"></div>
			<?php } ?>
		
			<?php if ( $gp['title_bg_overlay'] == 'enabled' && ! empty( $GLOBALS['gp_title_bg'] ) ) { ?>
				<div class="bg-overlay-light"></div>
			<?php } ?>
		
			<div class="gp-container">
			
				<div class="points-wrapper">

					<?php if ( ! empty( $gp['review_good_points'][0] ) ) { ?>
						<div class="good-points">
							<h4 class="good-title"><?php _e( 'Good', 'gp_lang' ); ?></h4>
							<ul>
								<?php foreach( $gp['review_good_points'] as $gp_good_point ) { ?>							
									<li><i class="fa fa-plus-square"></i><?php echo esc_attr( $gp_good_point ); ?></li>
								<?php } ?>
							</ul>
						</div>
					<?php } ?>

					<?php if ( ! empty( $gp['review_bad_points'][0] ) ) { ?>
						<div class="bad-points">
							<h4 class="bad-title"><?php _e( 'Bad', 'gp_lang' ); ?></h4>
							<ul>
								<?php foreach( $gp['review_bad_points'] as $gp_bad_point ) { ?>							
									<li><i class="fa fa-minus-square"></i><?php echo esc_attr( $gp_bad_point ); ?></li>
								<?php } ?>
							</ul>
						</div>
					<?php } ?>
					
				</div><!-- END POINTS WRAPPER -->

				<?php if ( $GLOBALS['gp_site_rating_enabled'] == true ) { ?>  

					<div class="rating-wrapper">
										
						<?php 	
						
						$GLOBALS['gp_site_rich_snippets'] = true;	
						get_template_part( 'lib/sections/site', 'rating' );
						$GLOBALS['gp_site_rich_snippets'] = false;	
						
						?>

						<?php if ( count( $GLOBALS['gp_site_rating'] ) > 1 && count( $GLOBALS['gp_rating_criteria'] ) > 1 ) { ?>
							<div class="site-rating-criteria-wrapper rating-<?php echo sanitize_html_class( $gp['review_site_rating_style'] ); ?>">
								<?php $site_ratings = $GLOBALS['gp_site_rating'];
								foreach( $GLOBALS['gp_rating_criteria'] as $rating => $criteria ) { ?>
									<?php if ( isset( $site_ratings[$rating] ) ) { ?>
										<div class="site-rating-criteria">
											<?php $rating_percentage = floatval( ( ( $site_ratings[$rating] / $gp['review_rating_number'] ) * 100 ) ); ?>
											<div class="site-rating-slider-wrapper">
												<div class="site-rating-unselected">
													<span class="site-rating-criteria-text"><?php echo esc_attr( $criteria ); ?> - <?php echo floatval( $site_ratings[$rating] ); ?></span>
													<div class="site-rating-selection" style="width: <?php echo floatval( $rating_percentage ); ?>%;"></div>
												</div>
											</div>
										</div>	
									<?php } ?>				
								<?php } ?>
							</div>				
						<?php } ?><!-- END RATING CRITERIA -->

					</div><!-- END RATING WRAPPER -->
				
				<?php } ?>
							
			</div>
														
		</div><!-- END REVIEW SUMMARY -->

	<?php } ?>
			
	<div id="content-wrapper"<?php if ( $GLOBALS['gp_layout'] != 'gp-fullwidth' ) { ?> class="gp-container"<?php } ?>>

		<div id="content">
	
			<article class="post-content">
			
				<?php if ( $gp['review_author_info'] == 'enabled' ) { ?>
					<?php get_template_part( 'lib/sections/author', 'info' ); ?>
				<?php } ?>

				<?php if ( $gp['review_related_items'] == 'enabled' ) { ?>
					<?php get_template_part( 'lib/sections/related', 'items' ); ?>
				<?php } ?>

				<?php if ( $GLOBALS['gp_user_rating_box'] == 'enabled' && ( $GLOBALS['gp_layout'] == 'gp-no-sidebar' OR $GLOBALS['gp_layout'] == 'gp-fullwidth' ) ) { ?>
					<?php get_template_part( 'lib/sections/user-rating-box' ); ?>
				<?php } ?>
							
				<?php comments_template(); ?>
	
			</article><!-- END ARTICLE -->
	
		</div><!-- END CONTENT -->
		
		<?php get_sidebar(); ?>
	
	</div><!-- END CONTENT WRAPPER -->
									
<?php endwhile; endif; ?>			

<?php get_footer(); ?>