<?php while ( have_posts() ) : the_post(); ?>
	<?php $banner = get_post_meta(get_the_ID(), '_triptip_banner', true); ?>
	<!-- listing-detail
		================================================== -->
	<section class="listing-detail">

		<div class="listing-detail__gal">
			<picture>
				<img src="<?php echo esc_url($banner); ?>" alt="<?php the_title_attribute();?>">
			</picture>
			<div class="listing-detail__gal-box">
				<div class="container">
					<div class="row">
						<div class="col-md-6">
							<?php if( function_exists('triptip_comment_rating_get_average_ratings') ){ triptip_comment_rating_get_average_ratings(get_the_ID()); }  ?>
							<h1 class="listing-detail__title"><?php the_title(); ?></h1>
							<?php 
								$address = get_post_meta(get_the_ID(), '_triptip_address', true);
								if($address!=''){ 
							?>
								<p class="listing-detail__address"><i class="fa fa-map-marker"></i> <?php echo esc_html($address); ?></p>
							<?php } ?>
							
						</div>
						<div class="col-md-6">
							<div class="listing-detail__buttons">
								<a class="btn-default navigate-btn" href="#leave-review">
									<i class="la la-pencil" aria-hidden="true"></i>
									<?php esc_html_e('Write a Review','triptip'); ?>
								</a>
								<?php if( function_exists('get_simple_likes_button') ) echo get_simple_likes_button(get_the_ID());?>
								<?php echo do_shortcode('[share_button text="'.esc_html__('Share','triptip').'"]'); ?>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

		<div class="listing-detail__scroll-menu-box scroller-menu">
			<div class="container">
				<ul class="listing-detail__scroll-menu navigate-section">
					<li>
						<a class="active" href="#overview-box"><?php esc_html_e('Overview', 'triptip'); ?></a>
					</li>
					<li>
						<a href="#gallery-box"><?php esc_html_e('Gallery', 'triptip'); ?></a>
					</li>
					<li>
						<a href="#tips-reviews-box"><?php esc_html_e('Tips and Reviews', 'triptip'); ?></a>
					</li>
				</ul>
			</div>
		</div>

		<div class="listing-detail__content">
			<div class="container">
				<div class="row">
					<div class="col-lg-8">
						<div class="listing-detail__content-box">

							<!-- overview box -->
							<div class="listing-detail__overview element-waypoint" id="overview-box">
								<h2 class="heading2 listing-detail__content-title"><?php esc_html_e('Overview', 'triptip'); ?></h2>
								<?php the_content(); ?>
							</div>
							<?php 
							    $gallery = get_post_meta(get_the_ID(), '_triptip_gallery', true);
							?>
							<?php if(is_array($gallery) and $gallery!=''){ ?>
								<!-- gallery-box -->
								<div class="listing-detail__gallery element-waypoint" id="gallery-box">
									<h2 class="heading2 listing-detail__content-title"><?php esc_html_e('Gallery', 'triptip'); ?></h2>
									<div class="listing-detail__gallery-inner owl-wrapper">
										<div class="owl-carousel" data-num="4">
											<?php $j=0; foreach($gallery as $id => $url) {?>
												<?php $img = wp_get_attachment_image_src($id, 'triptip-thumb'); ?>
												<?php $img_full = wp_get_attachment_image_src($id, 'triptip-thumb'); ?>
												<div class="item">
													<a href="<?php echo esc_url($img_full[0]); ?>" class="zoom">
														<img src="<?php echo esc_url($img[0]); ?>" alt="<?php the_title_attribute(); ?>" />
													</a>
												</div>
										
											<?php } ?>

										</div>
									</div>
								</div>
							<?php } ?>
							<!-- tips & reviews-box -->
							<?php if ( comments_open() || get_comments_number() ) {  ?>
				                <?php comments_template(); ?>   
				            <?php } ?>

						</div>
					</div>
					<div class="col-lg-4">
						<div class="sidebar">
							<?php $brand = get_post_meta(get_the_ID(), '_triptip_brand', true); ?>
							<?php if($brand!=''){ ?>
								<div class="sidebar__map-widget">
									<h2 class="heading2 sidebar__widget-title">
										<?php esc_html_e('Logo Brand', 'triptip'); ?>
									</h2>
									<img class="logo-brand" src="<?php echo esc_url($brand); ?>" alt="<?php the_title_attribute();?>">
								</div>
							<?php } ?>
							<div class="sidebar__map-widget">
								<?php 
									$latitude = get_post_meta(get_the_ID(), '_triptip_latitude', true);
									$longitude = get_post_meta(get_the_ID(), '_triptip_longitude', true);
									$icon = get_post_meta(get_the_ID(), '_triptip_mapicon', true);
								?>
								<?php if($longitude!='' and $latitude!=''){ ?>
									<h2 class="heading2 sidebar__widget-title">
										<?php esc_html_e('Location', 'triptip'); ?>
									</h2>
									<div id="mapSingle" data-latitude="<?php echo esc_attr($latitude); ?>" data-longitude="<?php echo esc_attr($longitude); ?>" data-map-icon="<?php echo esc_attr($icon); ?>"></div>
								<?php } ?>
							</div>

							<div class="sidebar__widget sidebar__widget-listing-details">
								<h2 class="heading2 sidebar__widget-title">
									<?php esc_html_e('Details', 'triptip'); ?>
								</h2>
								<ul class="sidebar__listing-list">
									<li>
										<?php 
										if($address!=''){ ?>
											<i class="la la-map-marker"></i>
											<?php echo esc_html($address); ?>
										<?php } ?>
									</li>
									<?php $phone = get_post_meta(get_the_ID(), '_triptip_phone', true); ?>
									<?php if($phone!=''){ ?>
										<li>
											<i class="la la-mobile-phone"></i>
											<a href="tel:<?php echo esc_attr($phone); ?>"><?php echo esc_html($phone); ?></a>
										</li>
									<?php } ?>
									<?php $email = get_post_meta(get_the_ID(), '_triptip_email', true); ?>
									<?php if($email!=''){ ?>
										<li>
											<i class="la la-envelope-o"></i>
											<a href="mailto:<?php echo esc_attr($email); ?>"><?php echo esc_html($email); ?></a>
										</li>
									<?php } ?>
									<?php $website = get_post_meta(get_the_ID(), '_triptip_website', true); ?>
									<?php if($website!=''){ ?>
										<li>
											<i class="la la-link"></i>
											<a href="<?php echo esc_url($website); ?>" target="_blank"><?php echo esc_html($website); ?></a>
										</li>
									<?php } ?>
									<?php $custom_meta = get_post_meta( get_the_ID(), 'custom_meta', true ); ?>
									<?php if($custom_meta!=null){ ?>
										<?php 
											$i=1; foreach ( (array) $custom_meta as $key => $entry ) { ?>
											<li>
												<?php if($entry['icon']!=''){ ?>
													<i class="<?php echo esc_attr($entry['icon']); ?>"></i>
												<?php } ?>
												<?php echo esc_html($entry['title']); ?>: <?php echo esc_html($entry['value']); ?>
											</li>
										<?php $i++; }?>
									<?php } ?>
								</ul>
								<?php if( function_exists('qkl_business_hours') ){ qkl_business_hours(); } ?>
							</div>
							<?php if(qkl_get_setting('author_block')!='off'){ ?>
								<div class="sidebar__widget sidebar__widget-author">
									<h2 class="heading2 sidebar__widget-title">
										<?php esc_html_e('Author', 'triptip'); ?>
									</h2>
									
									<!-- Author-wrapper module -->
									<div class="author-wrapper">
										<div class="author-wrapper__profile">
											<div class="row">
												<div class="col-7">
													<div class="author-wrapper__content">
														<a class="author-wrapper__image" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>">
														<?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 author-wrapper__title">
															<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ), get_the_author_meta( 'user_nicename' ) ); ?>"><?php echo esc_html(get_the_author_meta('display_name'));?></a>
															<?php if(get_user_meta(get_the_author_meta('ID'), '_triptip_user_address' ,true)!=''){ ?>
																<span class="author-wrapper__location">
																	<?php echo get_user_meta(get_the_author_meta('ID'), '_triptip_user_address' ,true); ?>
																</span>
															<?php } ?>
														</h3>
													</div>
												</div>
												
											</div>
										</div>
										<ul class="author-wrapper__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>
											<?php  if( function_exists('qkl_comment_count') ){ ?>
												<li>
													<span><?php  qkl_comment_count(); ?></span>
													<?php esc_html_e('Reviews', 'triptip'); ?>
												</li>
											<?php } ?>
										</ul>
									</div>
									<!-- End Author-wrapper module-->
								</div>
							<?php } ?>
							<div class="sidebar__widget sidebar__widget-tags">
								<h2 class="heading2 sidebar__widget-title">
									<?php esc_html_e('Listing Tags', 'triptip'); ?>
								</h2>
								<?php 
									$tags = wp_get_post_terms( get_the_ID(), 'listing-tag' ); 
								?>
								<?php if($tags){ ?>
									<ul class="sidebar__tags-list">
										<?php foreach($tags as $tag){ ?>
											<li><a href="<?php echo get_term_link($tag->slug, 'listing-tag'); ?>"><?php echo esc_html($tag->name); ?></a></li>
										<?php } ?>
									</ul>
								<?php } ?>
							</div>

							<?php 
								if(is_active_sidebar('sidebar-list')){
									dynamic_sidebar('sidebar-list');
								}
							?>

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


	</section>
	<!-- End listing-detail -->
<?php endwhile; ?>