Guest User

Untitled

a guest
Feb 10th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.85 KB | None | 0 0
  1. <?php
  2. function nt_single_property($post_id, $compare = false) {
  3.  
  4. global $post;
  5. $post = get_post($post_id);
  6. setup_postdata( $post );
  7. $gallery = get_post_meta( $post->ID, '_meta_gallery', true );
  8.  
  9. $video_thumb = get_post_meta( $post->ID, '_meta_video_thumb', true );
  10. $video_url = get_post_meta( $post->ID, '_meta_video_url', true );
  11.  
  12. $bed = (get_post_meta( $post->ID, '_meta_bedroom', true ));
  13. $bath = (get_post_meta( $post->ID, '_meta_bathroom', true ));
  14. $garage = (get_post_meta( $post->ID, '_meta_garage', true ));
  15. $area = (get_post_meta( $post->ID, '_meta_area', true ));
  16. $price = get_post_meta( $post->ID, '_meta_price', true );
  17. if(!$price) $price = nt_get_option('property', 'null_price');
  18. $per = get_post_meta( $post->ID, '_meta_per', true );
  19. $id = get_post_meta( $post->ID, '_meta_id', true );
  20. $location = get_post_meta( $post->ID, '_meta_location', true );
  21. $location_text = get_post_meta( $post->ID, '_meta_location_text', true );
  22.  
  23. $has_location = (($location[0] && $location[1] && $location[2]) || $location_text);
  24.  
  25. $agents = get_post_meta( $post->ID, '_meta_agent', true );
  26. // if(get_post_status($agent) != 'publish' || $agent == '') {
  27. // unset($agent);
  28. // }
  29.  
  30. $details = get_post_meta( $post->ID, '_meta_detail', true );
  31. $attachments = get_post_meta( $post->ID, '_meta_attachment', true );
  32. $floorplans = get_post_meta( $post->ID, '_meta_floorplan', true );
  33. $has_details = (is_array($details) || is_array($attachments) || is_array($floorplans));
  34.  
  35. $user_agent = get_post_meta( $post->ID, '_meta_user_agent', true );
  36. $favourites = (array)get_post_meta( $post->ID, '_meta_favourites', true );
  37. $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'marker' );
  38.  
  39. $property_slide_timeout = nt_get_option('property', 'slide_timeout', '4000');
  40. $property_slide_autoplay = ($property_slide_timeout)?'true':'false';
  41. ?>
  42.  
  43. <?php if($gallery):
  44. $uid = uniqid();
  45. ?>
  46.  
  47. <?php if(isset($_REQUEST['compare-with'])): ?>
  48. <div class="property-head">
  49. <div class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
  50. <ul>
  51. <?php echo get_the_term_list($post->ID, 'location', '<li>', '</li><li>', '</li>'); ?>
  52. <?php echo get_the_term_list($post->ID, 'type', '<li>', '</li><li>', '</li>'); ?>
  53. </ul>
  54. </div>
  55. <?php endif; ?>
  56.  
  57. <div class="property-hero">
  58. <div class="carousel-wrap">
  59. <div class="lt-carousel lt-carousel-single property-carousel property-carousel-<?php echo $uid; ?>" data-items="1" data-dots="false" data-auto-height="true" data-single-item="true" data-autoplay="<?php echo $property_slide_autoplay; ?>" data-autoplay-timeout="<?php echo $property_slide_timeout; ?>" data-autoplay-hover-pause="true" data-nav="true" data-loop="true" data-nav-thumb=".property-thumb-nav-<?php echo $uid; ?>">
  60.  
  61. <?php if($video_thumb):
  62. $img_src = wp_get_attachment_image_src($video_thumb, 'slide');
  63. ?>
  64. <div class="item">
  65. <a class="swipebox" rel="<?php echo $uid; ?>" href="<?php echo $video_url; ?>"><img src="<?php echo $img_src[0]; ?>" /><i class="flaticon-play43 overlay-icon"></i></a>
  66. </div>
  67. <?php endif; ?>
  68.  
  69. <?php foreach($gallery as $image):
  70. $img_src = wp_get_attachment_image_src($image, 'slide');
  71. $img_src_full = wp_get_attachment_image_src($image, 'full');
  72. ?>
  73. <div class="item"><a href="<?php echo $img_src_full[0]; ?>" class="swipebox" rel="<?php echo $uid; ?>" title="<?php echo get_the_title($image); ?>"><img src="<?php echo $img_src[0]; ?>" width="<?php echo $img_src[1]; ?>" height="<?php echo $img_src[2]; ?>" alt="<?php echo get_the_title($image); ?>" /></a></div>
  74. <?php endforeach; ?>
  75. </div>
  76.  
  77. <div class="badge">
  78. <div class="status">
  79. <ul class="meta-list">
  80. <?php echo get_the_term_list($post->ID, 'status', '<li>', '</li><li>', '</li>'); ?>
  81. </ul>
  82. </div>
  83. <?php if($price): ?><div class="price"><?php echo nt_currency($price, $per); ?></div><?php endif; ?>
  84. </div>
  85. </div>
  86.  
  87. <?php if(nt_get_option('property', 'favourite', 'on') == 'on'): ?>
  88. <a href="#" class="add-wish-list <?php if(in_array(get_current_user_id(), $favourites)): ?>active<?php endif; ?>" data-property-id="<?php echo $post->ID; ?>"><span class="lt-icon flaticon-favorite21"></span></a>
  89. <?php endif; ?>
  90.  
  91. </div>
  92. <?php endif; ?>
  93.  
  94. <?php if(count($gallery) > 1):
  95. ?>
  96. <ul class="property-thumb-nav-<?php echo $uid; ?> thumb-nav large-block-grid-8 medium-block-grid-7 small-block-grid-4 clearfix" data-nav-thumb=".property-carousel-<?php echo $uid; ?>">
  97.  
  98. <?php if($video_thumb):
  99. $img_src = wp_get_attachment_image_src($video_thumb, 'thumbnail');
  100. ?>
  101. <li><img src="<?php echo $img_src[0]; ?>" width="<?php echo $img_src[1]; ?>" height="<?php echo $img_src[2]; ?>" alt="<?php echo get_the_title($image); ?>" /><i class="flaticon-play43 overlay-icon"></i></li>
  102. <?php endif; ?>
  103.  
  104. <?php foreach($gallery as $image):
  105. $img_src = wp_get_attachment_image_src($image, 'thumbnail');
  106. ?>
  107. <li><img src="<?php echo $img_src[0]; ?>" width="<?php echo $img_src[1]; ?>" height="<?php echo $img_src[2]; ?>" alt="<?php echo get_the_title($image); ?>" /></li>
  108. <?php endforeach; ?>
  109. </ul>
  110. <?php endif; ?>
  111.  
  112. <ul class="meta-box-list">
  113. <?php if($id): ?><li><?php echo $id; ?><span class="tooltip"><?php _e('ID', 'theme_front'); ?></span></li><?php endif; ?><?php if($area): ?><li><span class="lt-icon flaticon-display6"></span> <?php echo nt_area_format($area); ?> <?php echo nt_get_option('property', 'area'); ?><span class="tooltip"><?php _e('Area', 'theme_front'); ?></span></li><?php endif; ?><?php if($bed): ?><li><i class="lt-icon flaticon-person1 big"></i> <?php echo floatval($bed); ?><span class="tooltip"><?php echo _n( 'Bedroom', 'Bedrooms', $bed, 'theme_front' ); ?></span></li><?php endif; ?><?php if($bath): ?><li><span class="lt-icon flaticon-shower5"></span> <?php echo floatval($bath); ?><span class="tooltip"><?php echo _n( 'Bathroom', 'Bathrooms', $bath, 'theme_front' ); ?></span></li><?php endif; ?><?php if($garage): ?><li><i class="lt-icon flaticon-car95"></i> <?php echo floatval($garage); ?><span class="tooltip"><?php echo _n( 'Garage', 'Garages', $garage, 'theme_front' ); ?></span></li><?php endif; ?>
  114. </ul>
  115. <div class="vspace"></div>
  116.  
  117. <?php the_content(); ?>
  118.  
  119. <div class="vspace"></div><div class="vspace"></div>
  120.  
  121. <div class="vc_tta-tabs wpb_content_element property-features-tabs" data-interval="0">
  122. <div class="vc_tta-tabs-container">
  123. <ul class="vc_tta-tabs-list">
  124. <?php if($has_details): ?><li class="tab-details"><a href="#tab-details" data-vc-tabs data-vc-container=".vc_tta"><?php _e('DETAILS', 'theme_front'); ?></a></li><?php endif; ?>
  125.  
  126. <li class="tab-features"><a href="#tab-features" data-vc-tabs data-vc-container=".vc_tta"><?php _e('FEATURES', 'theme_front'); ?></a></li>
  127.  
  128. <?php if($has_location): ?><li class="tab-location"><a href="#tab-location" data-vc-tabs data-vc-container=".vc_tta"><?php _e('LOCATION', 'theme_front'); ?></a></li><?php endif; ?>
  129.  
  130. <li class="tab-contact"><a href="#tab-contact" data-vc-tabs data-vc-container=".vc_tta"><?php _e('CONTACT', 'theme_front'); ?></a></li>
  131. </ul>
  132. </div>
  133.  
  134. <div class="vc_tta-panels-container">
  135. <div class="vc_tta-panels">
  136.  
  137. <?php if($has_details): ?>
  138. <div id="tab-details" class="vc_tta-panel" data-vc-content=".vc_tta-panel-body">
  139. <ul class="table-list">
  140. <?php if(is_array($details)) foreach($details as $detail):
  141. ?>
  142. <li><strong><?php echo esc_html($detail['stack_title']); ?></strong> <span><?php echo esc_html($detail['detail']); ?></span></li>
  143. <?php endforeach; ?>
  144.  
  145. <?php if(is_array($attachments)): ?>
  146. <li><strong><?php _e('ATTACHMENTS', 'theme_front'); ?></strong>
  147. <ul class="attachment-list">
  148. <?php foreach($attachments as $attachment):
  149. $url = wp_get_attachment_url($attachment['file']);
  150. ?><li><a href="<?php echo $url; ?>"><?php echo $attachment['stack_title']; ?></a></li><?php endforeach; ?>
  151. </ul>
  152. </li>
  153. <?php endif; ?>
  154.  
  155. <?php if(is_array($floorplans)):
  156. $uid = uniqid();
  157. ?>
  158. <li><strong><?php _e('FLOOR PLANS', 'theme_front'); ?></strong>
  159. <ul class="floorplan-list clearfix">
  160. <?php foreach($floorplans as $image):
  161. $img_src = wp_get_attachment_image_src($image, 'thumbnail');
  162. $img_full_src = wp_get_attachment_image_src($image, 'full');
  163. ?><li><a href="<?php echo $img_full_src[0]; ?>" class="swipebox" rel="<?php echo $uid; ?>" title="<?php echo get_the_title($image); ?>"><img src="<?php echo $img_src[0]; ?>" alt="<?php echo get_the_title($image); ?>" /></a></li><?php endforeach; ?>
  164. </ul>
  165. </li>
  166. <?php endif; ?>
  167. </ul>
  168. </div>
  169. <?php endif; ?>
  170.  
  171.  
  172. <div id="tab-features" class="vc_tta-panel">
  173. <ul class="large-block-grid-<?php echo ($compare)?'2':'3'; ?> medium-block-grid-2 small-block-grid-1 amenity-list">
  174. <?php
  175. $all_features = get_terms('features', array('hide_empty' => false));
  176. foreach($all_features as $feature):
  177. ?>
  178. <?php if(has_term($feature->term_id, 'features', $post->ID)): ?>
  179. <li class="active"><i class="flaticon-correct7"></i> <?php echo wp_kses_data($feature->name); ?></li>
  180. <?php else: ?>
  181. <li><i class="flaticon-cross37"></i> <?php echo wp_kses_data($feature->name); ?></li>
  182. <?php endif; ?>
  183. <?php endforeach; ?>
  184. </ul>
  185. </div>
  186.  
  187. <?php if($has_location): ?>
  188. <div id="tab-location" class="vc_tta-panel">
  189.  
  190. <?php if($location_text): ?>
  191. <?php echo apply_filters('the_content', $location_text); ?>
  192. <?php endif; ?>
  193.  
  194. <?php if(($location[0] && $location[1] && $location[2])): ?>
  195. <div class="map-outer-wrap">
  196. <div class="map-wrap" data-zoom="<?php echo isset($location[3])?$location[3]:'15'; ?>" style="height:500px;" data-latitude="<?php echo esc_attr($location[1]); ?>" data-longitude="<?php echo esc_attr($location[2]); ?>" data-style="<?php echo nt_get_option('property', 'map_style', 'bw'); ?>">
  197. <div data-latitude="<?php echo esc_attr($location[1]); ?>" data-longitude="<?php echo esc_attr($location[2]); ?>"></div>
  198. </div>
  199. <a href="https://www.google.com/maps/?q=<?php echo wp_kses_data($location[1]); ?>,<?php echo wp_kses_data($location[2]); ?>&z=10" rel="no-follow" class="overlay-link" target="_blank"><?php _e('View on Google Map', 'theme_front'); ?></a>
  200. </div>
  201. <?php endif; ?>
  202.  
  203. </div>
  204. <?php endif; ?>
  205.  
  206.  
  207. <div id="tab-contact" class="vc_tta-panel">
  208.  
  209. <?php $mailto = array(); ?>
  210.  
  211. <?php if(nt_get_option('property', 'contact_note')): ?>
  212. <div class="contact-note">
  213. <?php echo apply_filters('the_content', nt_get_option('property', 'contact_note')); ?>
  214. </div>
  215. <?php endif; ?>
  216.  
  217. <?php
  218. if(isset($agents) && $agents):
  219.  
  220. if(!is_array($agents)) {
  221. $agents = array($agents);
  222. }
  223.  
  224. foreach($agents as $agent):
  225. $agent_post = get_post($agent);
  226. $phone = get_post_meta( $agent, '_meta_phone', true );
  227. $email = sanitize_email(get_post_meta( $agent, '_meta_email', true ));
  228. $mailto[] = $email;
  229. $description = $agent_post->post_content;
  230. ?>
  231. <div class="agent-card clearfix">
  232. <div class="card-head clearfix">
  233. <a href="<?php echo get_the_permalink($agent); ?>">
  234. <?php echo get_the_post_thumbnail( $agent, 'thumbnail', array('class'=>'thumb') ); ?>
  235. </a>
  236. <div class="title"><a href="<?php echo get_the_permalink($agent); ?>"><?php echo wp_kses_data($agent_post->post_title); ?></a></div>
  237. <div class="sub">
  238. <ul class="inline-list">
  239. <?php if($phone): ?><li><?php echo wp_kses_data($phone); ?></li><?php endif; ?><?php if($email): ?><li><a href="mailto:<?php echo antispambot($email); ?>"><?php echo antispambot($email); ?></a></li><?php endif; ?>
  240. </ul>
  241. </div>
  242. </div>
  243. </div>
  244. <?php endforeach; ?>
  245.  
  246. <?php elseif(isset($user_agent) && $user_agent):
  247. $user = get_user_by('id', $user_agent);
  248. $user_agent_phone = get_user_meta($user_agent, 'phone', true);
  249. $user_agent_display_name = get_user_meta($user_agent, 'display_name', true);
  250. if(!$user_agent_display_name) $user_agent_display_name = get_user_meta($user_agent, 'nickname', true);
  251. $user_agent_description = get_user_meta($user_agent, 'description', true);
  252. $mailto[] = $user->user_email;
  253. ?>
  254. <div class="agent-card clearfix">
  255. <div class="card-head clearfix">
  256. <?php echo get_avatar($user->user_email, 512, '', $user_agent_display_name); ?>
  257. <div class="title"><?php echo wp_kses_data($user_agent_display_name); ?></div>
  258. <div class="sub">
  259. <ul class="inline-list">
  260. <?php if($user_agent_phone): ?><li><?php echo wp_kses_data($user_agent_phone); ?></li><?php endif; ?><?php if($user->user_email): ?><li><a href="mailto:<?php echo antispambot($user->user_email); ?>"><?php echo antispambot($user->user_email); ?></a></li><?php endif; ?>
  261. </ul>
  262. </div>
  263. </div>
  264.  
  265. </div>
  266. <?php endif; ?>
  267.  
  268. <script type="text/javascript">
  269. var RecaptchaOptions = {
  270. theme : 'custom',
  271. custom_theme_widget: 'recaptcha_widget'
  272. };
  273. </script>
  274. <form method="post" class="validate-form agent-contact-form">
  275. <p><input type="text" name="from" placeholder="<?php _e('Email Address', 'theme_front'); ?> *" data-rule-required="true" data-rule-email="true" data-msg-required="Email Address is required." data-msg-email="Invalid Email address."/></p>
  276. <p><input type="text" name="phone" placeholder="<?php _e('Phone Number', 'theme_front'); ?>" /></p>
  277. <p><textarea name="message" placeholder="<?php _e('Message', 'theme_front'); ?>" rows="5"></textarea></p>
  278. <p>
  279.  
  280. <input name="to" type="hidden" value="<?php echo implode(',', $mailto); ?>" />
  281. </p>
  282.  
  283. <?php if(nt_get_option('advance', 'recaptchar_site_key') && nt_get_option('advance', 'recaptchar_secret_key')): ?>
  284. <div id="recaptcha_widget" style="display:none">
  285. <div id="recaptcha_image"></div>
  286. <div class="recaptcha_only_if_incorrect_sol" style="color:red">Incorrect please try again</div>
  287. <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" placeholder="<?php _e('Enter the words above', 'theme_front'); ?> *" data-rule-required="true" data-msg-required="reCAPTCHAR is required." />
  288.  
  289. <div class="refresh"><a href="javascript:Recaptcha.reload()"><span class="lt-icon flaticon-refresh8"></span></a></div>
  290. </div>
  291.  
  292. <script type="text/javascript"
  293. src="http://www.google.com/recaptcha/api/challenge?k=<?php echo nt_get_option('advance', 'recaptchar_site_key'); ?>">
  294. </script>
  295. <noscript>
  296. <iframe src="http://www.google.com/recaptcha/api/noscript?k=<?php echo nt_get_option('advance', 'recaptchar_site_key'); ?>"
  297. height="300" width="500" frameborder="0"></iframe><br>
  298. <textarea name="recaptcha_challenge_field" rows="3" cols="40">
  299. </textarea>
  300. <input type="hidden" name="recaptcha_response_field"
  301. value="manual_challenge">
  302. </noscript>
  303. <?php endif; ?>
  304.  
  305. <div class="form-response"></div>
  306. <input type="submit" name="submit" class="full-width primary lt-button" value="<?php _e('SUBMIT', 'theme_front'); ?>" />
  307. </form>
  308.  
  309. </div>
  310.  
  311. </div>
  312.  
  313.  
  314. </div>
  315. </div>
  316.  
  317. <?php if( !$compare && nt_get_option('property', 'single_share', 'on') == 'on' ) get_template_part('section/section', 'share'); ?>
  318.  
  319. <?php if( !$compare && false ) get_template_part('section/section', 'related-property'); ?>
  320.  
  321.  
  322.  
  323. <?php
  324. }
Add Comment
Please, Sign In to add comment