<?php get_header(); ?>

<?php gp_page_header(); ?>

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

	<div id="content">

		<?php 
		
		gp_query_variables();

		// Get author ID
		$author = get_user_by( 'id', get_query_var( 'author' ) );
		$GLOBALS['gp_author_id'] = $author->ID;

		$args = array(
			'post_status' => 'publish',
			'author' => $GLOBALS['gp_author_id'],
			'post_type' => array( 'post', 'page', 'gp_user_review' ),
			'posts_per_page' => $GLOBALS['gp_per_page'],
			'meta_query' => array(
				'relation' => 'OR',		
				array(
					'key' => '_wp_page_template',
					'value' => array( 'hub-template.php', 'review-template.php' ),
					'compare' => 'IN',
				),
				array(
					'key' => '_wp_page_template',
					'compare' => 'NOT EXISTS',
				),						
			), 	
			'paged' => $GLOBALS['gp_paged'],
			'date_query' => array( $GLOBALS['gp_date_posted_value'], $GLOBALS['gp_date_modified_value'] ),		
		);

		$gp_query = new wp_query( $args ); ?>
		
		<div class="blog-wrapper <?php echo sanitize_html_class( $GLOBALS['gp_format'] ); ?> <?php echo sanitize_html_class( $GLOBALS['gp_size'] ); ?>"<?php echo gp_data_properties( 'author' ); ?>>

			<?php if ( $gp_query->have_posts() ) : ?>

				<?php get_template_part( 'lib/sections/filter' ); ?>
									
				<div class="inner-loop <?php echo sanitize_html_class( $gp['ajax'] ); ?>">

					<?php while ( $gp_query->have_posts() ) : $gp_query->the_post(); ?>

						<?php if ( get_post_meta( get_the_ID(), '_wp_page_template', true ) == 'review-template.php' OR get_post_meta( get_the_ID(), '_wp_page_template', true ) == 'hub-template.php' OR $post->post_type == 'gp_user_review' ) { 
								get_template_part( 'review', 'loop' ); 
							} else {
								get_template_part( 'post', 'loop' ); 
							} ?>

					<?php endwhile; ?>
			
				</div>

				<?php echo gp_pagination( $gp_query->max_num_pages ); ?>

			<?php else : ?>

				<strong class="no-items-found"><?php _e( 'No items found.', 'gp_lang' ); ?></strong>

			<?php endif; wp_reset_postdata(); ?>
			
		</div><!-- END BLOG WRAPPER -->
					
	</div><!-- END CONTENT -->

	<?php get_sidebar(); ?>

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

<?php get_footer(); ?>