<?php get_header(); ?>
		<!-- user-detail
			================================================== -->
		<section class="user-detail">
			<div class="user-detail__profile">
				<?php $curauth = $wp_query->get_queried_object(); ?>
				<div class="container">
					<div class="row">
						<div class="col-lg-5">
							<div class="user-detail__profile-box">
								<a class="user-detail__profile-image" href="#">
									<?php if(get_user_meta(get_the_author_meta('ID'), '_triptip_avatar' ,true)!=''){ ?>
								        <?php $image = get_user_meta(get_the_author_meta('ID'), '_triptip_avatar' ,true); ?>
								            <img src="<?php echo esc_url($image); ?>" />
								        <?php }else{ ?>
								          <?php echo get_avatar(get_the_author_meta('user_email'),$size='100',$default='https://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=120' ); ?>
								        <?php } ?>
								</a>
								<h3 class="heading3 user-detail__profile-title">
									<a href="#"><?php echo esc_html($curauth->display_name); ?></a>
									<?php if(get_user_meta($curauth->ID, '_triptip_user_address' ,true)!=''){ ?>
										<span class="user-detail__profile-location">
											<i class="fa fa-map-marker"></i>
											<?php echo get_user_meta($curauth->ID, '_triptip_user_address' ,true); ?>
										</span>
									<?php } ?>
								</h3>
							</div>
						</div>
						<div class="col-lg-7">
							
							<ul class="user-detail__profile-list">
								<li>
									<span><?php echo count_user_posts( get_the_author_meta( 'ID' ) , 'listing' ); ?></span>
									<?php esc_html_e('Listing', 'triptip'); ?>
								</li>
								<li>
									<span><?php echo count_user_posts( get_the_author_meta( 'ID' ) ); ?></span>
									<?php esc_html_e('Posts', 'triptip'); ?>
								</li>
								
								<li>
									<span><?php  qkl_comment_count(); ?></span>
									<?php esc_html_e('Reviews', 'triptip'); ?>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>

			<!-- user scroll menu box -->
			<div class="user-detail__scroll-menu-box scroller-menu">
				<div class="container">
					<ul class="user-detail__scroll-menu navigate-section">
						<li>
							<a class="active" href="#my-lists-box" data-offset="30"><?php esc_html_e('My Lists', 'triptip'); ?></a>
						</li>
						<li>
							<a href="#tips-review-box" data-offset="30"><?php esc_html_e('Tips and Reviews', 'triptip'); ?></a>
						</li>
						<li>
							<a href="#cities-box" data-offset="30"><?php esc_html_e('Cities Visited', 'triptip'); ?></a>
						</li>
						<li>
							<a href="#favorites-box" data-offset="30"><?php esc_html_e('My Favorites', 'triptip'); ?></a>
						</li>
					</ul>
				</div>
			</div>

			<!-- my lists box -->
			<div class="user-detail__mylist element-waypoint" id="my-lists-box">
				<div class="container">
					<h2 class="heading2 user-detail__subtitle"><?php esc_html_e('My Lists','triptip'); ?> <span>(<?php echo count_user_posts( get_the_author_meta( 'ID' ) , 'listing' ); ?>)</span></h2>
					<div class="user-detail__mylist-box iso-call">
						<?php 
							$args = array(
							    'post_type' => 'listing',
							    'post_status' => 'publish',
							    'no_found_rows' => true,
							    'author' => get_the_author_meta( 'ID' )
							  );
							$portfolio = new WP_Query($args);
						?>
						<?php if($portfolio->have_posts()) :
					             $i=1; while($portfolio->have_posts()) : $portfolio->the_post(); 
					    ?>
						<div class="item">

					      <!-- place-post module -->
					      <div class="place-post">
					        <div class="place-post__gal-box">
					          <?php the_post_thumbnail('', ['class' => 'place-post__image']); ?>
					          <?php if( function_exists('triptip_post__ratings_get_average') ) triptip_post__ratings_get_average(get_the_ID()); ?>
					          
					          <?php if( function_exists('get_simple_likes_button') ) echo get_simple_likes_button(get_the_ID());?>
					        </div>
					        <div class="place-post__content">
					          <?php if( function_exists('qkl_working_status') ){ qkl_working_status(); } ?>
					          <h2 class="heading2 place-post__title">
					            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
					          </h2>
					          <p class="place-post__description">
					            <?php 
					              if( function_exists('qkl_listing_category') ){ qkl_listing_category(get_the_ID()); }
					              
					            ?>
					            
					            <?php if( function_exists('triptip_price_range') ){  triptip_price_range(); }  ?>
					            
					            <span class="place-post__description-review">
					              <i class="fa fa-comment-o" aria-hidden="true"></i>
					              <?php comments_number( esc_html__('0 Reviews','triptip'), esc_html__('1 Review','triptip'), esc_html__('% Reviews','triptip') ); ?>
					            </span>
					          </p>
							 <?php if(get_post_meta(get_the_ID(), '_triptip_address',true)){ ?>
					          <p class="place-post__address">
					            <i class="fa fa-map-marker" aria-hidden="true"></i>
					            <?php echo get_post_meta(get_the_ID(), '_triptip_address',true); ?>
					          </p>
							 <?php } ?>
					        </div>
					      </div>
					      <!-- end place-post module -->
					        
					    </div>  

					  <?php $i++; endwhile; ?>
					  <?php endif; ?>
					  <?php wp_reset_postdata(); ?>

					</div>
				</div>
			</div>

			<!-- tips reviews box -->
			<div class="user-detail__review element-waypoint" id="tips-review-box">
				<div class="container">
					<h2 class="heading2 user-detail__subtitle"><?php esc_html_e('Tips and Reviews','triptip'); ?> <?php  if( function_exists('qkl_comment_count') ){ ?><span>(<?php  qkl_comment_count(); ?>)</span><?php } ?></h2>

					<?php
					$args = array(
					    'author_email' => get_the_author_meta( 'user_email' ), 
					    'no_found_rows' => true,
					    'order' => 'DESC',
					    'post_type' => 'listing',
					);
					$comments_query = new WP_Comment_Query;
					$comments = $comments_query->query( $args );
					if ( $comments ) {
					?>

					<div class="user-detail__review-box owl-wrapper">
						<div class="owl-carousel" data-num="3">
							<?php  foreach ( $comments as $comment ) { ?>
								<div class="item">

									<!-- review item module -->
									<div class="review-item">
										
										<div class="review-item__post">
											<div class="review-item__post-image">
												<?php 
													echo get_the_post_thumbnail($comment->comment_post_ID, 'thumbmail', ['class' => 'review-item__image']);
												?>
											</div>
											<div class="review-item__post-content">
												<h2 class="heading2 review-item__post-title">
													<a href="<?php echo get_permalink($comment->comment_post_ID); ?>"><?php echo get_the_title($comment->comment_post_ID); ?></a>
												</h2>
												<?php $address = get_post_meta($comment->comment_post_ID, '_triptip_address', true); ?>
												<?php if($address!=''){ ?>
													<p class="review-item__post-location">
														<i class="fa fa-map-marker"></i>
														<?php echo esc_html($address); ?>
													</p>
												<?php } ?>
												<span class="review-item__post-reviews">
													<i class="fa fa-comment-o"></i>
													<?php echo get_comments_number($comment->comment_post_ID); ?> <?php esc_html_e('Reviews', 'triptip'); ?>
												</span>
											</div>
										</div>
										<div class="review-item__content">
											<p class="review-item__date">
												<?php if( function_exists('triptip_post__ratings_get_average') ) triptip_post__ratings_get_average($comment->comment_post_ID); ?>
												<?php esc_html_e('Posted', 'triptip'); ?>: <?php echo esc_html($comment->comment_date_gmt); ?>
											</p>
											
											<p class="review-item__description">
												<?php echo do_shortcode($comment->comment_content); ?>
											</p>
											<a class="review-item__reply" href="<?php echo get_permalink($comment->comment_post_ID); ?>#comment-<?php echo esc_attr($comment->comment_ID); ?>">
												<i class="la la-mail-forward"></i>
												Reply
											</a>
										</div>	
									</div>
									<!-- end review item module -->

								</div>
							
							<?php } ?>

						</div>
					</div>
				<?php } ?>
				</div>
			</div>
			<?php 
			
                $args = array(
                    'type' => 'listing',
                    'parent' => 0,          // Gets only top level categories
                    'orderby' => 'count',   // Orders the list by post count
                    'order' => 'desc',
                    'hide_empty' => 1,      // Hides categories with no posts
                    'number' => '',         // No of categories to return
                    'taxonomy' => 'listing-region',
                    'no_found_rows' => true, // Skip SQL_CALC_FOUND_ROWS for performance (no pagination).

                );
                $top_categories = get_categories( $args ); // do not show any markup if we do not have any category at all.
                if (!empty($top_categories)){
             	$locations = count($top_categories);
			?>
				<!-- cities box -->
				<div class="user-detail__cities element-waypoint" id="cities-box">
					<div class="container">
						<h2 class="heading2 user-detail__subtitle"><?php esc_html_e('Cities Visited', 'triptip'); ?> <span>(<?php echo esc_html($locations);?>)</span></h2>
						<div class="user-detail__cities-box iso-call" data-item-showen="4">

							<?php foreach ( $top_categories as $cat ) { ?>
								<?php $banner = get_term_meta($cat->term_id, 'qkl_region_banner', true); ?>
								<div class="item">

									<!-- cities-post module-->
									<div class="cities-post">
										<img class="cities-post__image" src="<?php echo esc_url($banner); ?>" alt="<?php echo esc_attr($cat->name); ?>"/>
										<h2 class="heading2 cities-post__title"><a href="<?php echo get_term_link($cat->term_id); ?>"><?php echo esc_html($cat->name); ?></a></h2>
										<ul class="cities-post__list">
											<li><?php echo esc_html($cat->count); ?> <?php esc_html_e('Lists Created', 'triptip'); ?></li>
										</ul>
										<a class="cities-post__link text-btn" href="<?php echo get_term_link($cat->term_id); ?>"><?php esc_html_e('View All Lists', 'triptip'); ?></a>
									</div>
									<!-- End cities-post module-->

								</div>

							<?php } ?>

						</div>
						<div class="center-button">
							<a  href="#" 
								class="text-btn load-others"
								data-less-text="Show Less Cities"
								data-more-text="Show More Cities"
								data-parent-class="user-detail__cities">
								<i class="la la-angle-down"></i>
								<span><?php esc_html_e('Show More Cities', 'triptip'); ?></span>
							</a>
						</div>
					</div>
				</div>
			<?php } ?>
			<?php 
				$args = array(
				    'post_type' => 'listing',
				    'post_status' => 'publish',
				    'meta_query' => array (
						array (
						  'key' => '_user_liked',
						  'value' => get_the_author_meta( 'ID' ),
						  'compare' => 'LIKE'
						)
					  )
				  );
				$like_query = new WP_Query($args);
				
			?>
			
			<!-- my lists box -->
			<div class="user-detail__favorites element-waypoint" id="favorites-box">
				<div class="container">
					<h2 class="heading2 user-detail__subtitle"><?php echo esc_html_e('My Favorites','triptip'); ?> <span>(<?php echo esc_html($like_query->found_posts) ;?>)</span></h2>
					<div class="user-detail__favorites-box iso-call" data-item-showen="3">
						<?php if ( $like_query->have_posts() ) :
								while ( $like_query->have_posts() ) : $like_query->the_post(); ?>

						<div class="item">

							<!-- place-post module -->
						      <div class="place-post">
						        <div class="place-post__gal-box">
						          <?php the_post_thumbnail('', ['class' => 'place-post__image']); ?>
						          <?php if( function_exists('triptip_post__ratings_get_average') ) triptip_post__ratings_get_average(get_the_ID()); ?>
						          
						          <?php if( function_exists('get_simple_likes_button') ) echo get_simple_likes_button(get_the_ID());?>
						        </div>
						        <div class="place-post__content">
						          <?php if( function_exists('qkl_working_status') ){ qkl_working_status(); } ?>
						          <h2 class="heading2 place-post__title">
						            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
						          </h2>
						          <p class="place-post__description">
						            <?php 
						              if( function_exists('qkl_listing_category') ){ qkl_listing_category(get_the_ID()); }
						              
						            ?>
						            
						            <?php if( function_exists('triptip_price_range') ){  triptip_price_range(); }  ?>
						            
						            <span class="place-post__description-review">
						              <i class="fa fa-comment-o" aria-hidden="true"></i>
						              <?php comments_number( esc_html__('0 Reviews','triptip'), esc_html__('1 Review','triptip'), esc_html__('% Reviews','triptip') ); ?>
						            </span>
						          </p>
								 <?php if(get_post_meta(get_the_ID(), '_triptip_address',true)){ ?>
						          <p class="place-post__address">
						            <i class="fa fa-map-marker" aria-hidden="true"></i>
						            <?php echo get_post_meta(get_the_ID(), '_triptip_address',true); ?>
						          </p>
								 <?php } ?>
						        </div>
						      </div>
						      <!-- end place-post module -->

						</div>
						
						<?php endwhile; ?>

						<?php else : ?>

						<div class="blog-post not-found">
					      <div class="alert alert-info" role="alert">
					        <strong><?php esc_html_e('You do not like anything yet.','triptip'); ?></strong>
					      </div>
					    </div>
					    <?php 
						endif; 
						wp_reset_postdata(); 
						?>
					</div>
					<div class="center-button">
						<a  href="#" 
							class="text-btn load-others"
							data-less-text="Show Less Favorites"
							data-more-text="Show More Favorites"
							data-parent-class="user-detail__favorites-box">
							<i class="la la-angle-down"></i>
							<span><?php esc_html_e('Show More Favorites','triptip'); ?></span>
						</a>
					</div>
				</div>
			</div>

		</section>
		<!-- End user-detail -->
<?php get_footer(); ?>