PluginProbe
Property Hive / 2.2.3
Property Hive v2.2.3
2.3.1 2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 All 261 releases
propertyhive / includes / elementor-widgets / property-tabbed-details.php

property-tabbed-details.php in Property Hive 2.2.3, at includes/elementor-widgets/property-tabbed-details.php

920 lines 27.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elementor Property Tabbed Details Widget.
4 *
5 * @since 1.0.0
6 */
7 class Elementor_Property_Tabbed_Details_Widget extends \Elementor\Widget_Base {
8
9 public function get_name() {
10 return 'property-tabbed-details';
11 }
12
13 public function get_title() {
14 return __( 'Tabbed Details', 'propertyhive' );
15 }
16
17 public function get_icon() {
18 return 'eicon-tabs';
19 }
20
21 public function get_categories() {
22 return [ 'property-hive' ];
23 }
24
25 public function get_keywords() {
26 return [ 'property hive', 'propertyhive', 'property', 'tab', 'tabs', 'tabbed' ];
27 }
28
29 public function get_style_depends(): array {
30 return [ 'widget-tabs' ];
31 }
32
33 protected function register_controls() {
34
35 $this->start_controls_section(
36 'section_tabs',
37 [
38 'label' => __( 'Tabs', 'propertyhive' ),
39 ]
40 );
41
42 $this->add_control(
43 'type',
44 [
45 'label' => __( 'Type', 'propertyhive' ),
46 'type' => \Elementor\Controls_Manager::SELECT,
47 'default' => 'horizontal',
48 'options' => [
49 'horizontal' => __( 'Horizontal', 'propertyhive' ),
50 'vertical' => __( 'Vertical', 'propertyhive' ),
51 ],
52 'prefix_class' => 'elementor-widget-tabs elementor-tabs-view-',
53 ]
54 );
55
56 $this->add_control(
57 'property_tabs',
58 [
59 'label' => __( 'Tabs Items', 'propertyhive' ),
60 'type' => \Elementor\Controls_Manager::REPEATER,
61 'default' => [
62 [
63 'tab_title' => __( 'Details', 'propertyhive' ),
64 'tab_display' => array('features', 'summary_description', 'full_description'),
65 ],
66 [
67 'tab_title' => __( 'Floorplan', 'propertyhive' ),
68 'tab_display' => array('floorplan'),
69 ],
70 [
71 'tab_title' => __( 'Brochure', 'propertyhive' ),
72 'tab_display' => array('brochure'),
73 ],
74 [
75 'tab_title' => __( 'EPC', 'propertyhive' ),
76 'tab_display' => array('epc'),
77 ],
78 [
79 'tab_title' => __( 'Virtual Tour', 'propertyhive' ),
80 'tab_display' => array('embedded_virtual_tour'),
81 ],
82 [
83 'tab_title' => __( 'Map View', 'propertyhive' ),
84 'tab_display' => array('map'),
85 ],
86 [
87 'tab_title' => __( 'Street View', 'propertyhive' ),
88 'tab_display' => array('street_view'),
89 ],
90 [
91 'tab_title' => __( 'Make Enquiry', 'propertyhive' ),
92 'tab_display' => array('make_enquiry'),
93 ],
94 ],
95 'fields' => [
96 [
97 'name' => 'tab_title',
98 'label' => __( 'Title', 'propertyhive' ),
99 'type' => \Elementor\Controls_Manager::TEXT,
100 'default' => __( 'Tab Title', 'propertyhive' ),
101 'placeholder' => __( 'Tab Title', 'propertyhive' ),
102 'label_block' => true,
103 ],
104 [
105 'name' => 'tab_display',
106 'label' => __( 'Display', 'propertyhive' ),
107 'type' => \Elementor\Controls_Manager::SELECT2,
108 'multiple' => true,
109 'default' => array(),
110 'label_block' => true,
111 'options' => apply_filters( 'propertyhive_elementor_tabbed_details_display_options', array(
112 'features' => __( 'Features', 'propertyhive' ),
113 'summary_description' => __( 'Summary Description', 'propertyhive' ),
114 'full_description' => __( 'Full Description', 'propertyhive' ),
115 'gallery' => __( 'Gallery', 'propertyhive' ),
116 'floorplan' => __( 'Floorplans', 'propertyhive' ),
117 'brochure' => __( 'Brochures', 'propertyhive' ),
118 'epc' => __( 'EPCs', 'propertyhive' ),
119 'virtual_tour' => __( 'Virtual Tour Links', 'propertyhive' ),
120 'embedded_virtual_tour' => __( 'Virtual Tours Embedded', 'propertyhive' ),
121 'map' => __( 'Map View', 'propertyhive' ),
122 'street_view' => __( 'Street View', 'propertyhive' ),
123 'make_enquiry' => __( 'Make Enquiry Form', 'propertyhive' ),
124 'content' => __( 'Other Content', 'propertyhive' ),
125 ) )
126 ],
127 [
128 'name' => 'tab_content',
129 'label' => __( 'Other Content', 'propertyhive' ),
130 'type' => \Elementor\Controls_Manager::WYSIWYG,
131 'dynamic' => [ 'active' => true ],
132 'label_block' => true,
133 'conditions' => [
134 'terms' => [
135 [
136 'name' => 'tab_display',
137 'operator' => 'contains',
138 'value' => 'content',
139 ],
140 ],
141 ],
142 ],
143 ],
144 'title_field' => '{{{ tab_title }}}',
145 ]
146 );
147
148 $this->end_controls_section();
149
150 $this->start_controls_section(
151 'section_tabs_style',
152 [
153 'label' => __( 'Tabs', 'propertyhive' ),
154 'tab' => \Elementor\Controls_Manager::TAB_STYLE,
155 ]
156 );
157
158 $this->add_control(
159 'navigation_width',
160 [
161 'label' => __( 'Navigation Width', 'propertyhive' ),
162 'type' => \Elementor\Controls_Manager::SLIDER,
163 'default' => [
164 'unit' => '%',
165 ],
166 'range' => [
167 '%' => [
168 'min' => 10,
169 'max' => 50,
170 ],
171 ],
172 'selectors' => [
173 '{{WRAPPER}} .elementor-tabs-wrapper' => 'width: {{SIZE}}{{UNIT}}',
174 ],
175 'condition' => [
176 'type' => 'vertical',
177 ],
178 ]
179 );
180
181 $this->add_control(
182 'border_width',
183 [
184 'label' => __( 'Border Width', 'propertyhive' ),
185 'type' => \Elementor\Controls_Manager::SLIDER,
186 'default' => [
187 'size' => 1,
188 ],
189 'range' => [
190 'px' => [
191 'min' => 0,
192 'max' => 10,
193 ],
194 ],
195 'selectors' => [
196 '{{WRAPPER}} .elementor-tab-title, {{WRAPPER}} .elementor-tab-title:before, {{WRAPPER}} .elementor-tab-title:after, {{WRAPPER}} .elementor-tab-content, {{WRAPPER}} .elementor-tabs-content-wrapper' => 'border-width: {{SIZE}}{{UNIT}};',
197 ],
198 ]
199 );
200
201 $this->add_control(
202 'border_color',
203 [
204 'label' => __( 'Border Color', 'propertyhive' ),
205 'type' => \Elementor\Controls_Manager::COLOR,
206 'selectors' => [
207 '{{WRAPPER}} .elementor-tab-mobile-title, {{WRAPPER}} .elementor-tab-desktop-title.elementor-active, {{WRAPPER}} .elementor-tab-title:before, {{WRAPPER}} .elementor-tab-title:after, {{WRAPPER}} .elementor-tab-content, {{WRAPPER}} .elementor-tabs-content-wrapper' => 'border-color: {{VALUE}};',
208 ],
209 ]
210 );
211
212 $this->add_control(
213 'background_color',
214 [
215 'label' => __( 'Background Color', 'propertyhive' ),
216 'type' => \Elementor\Controls_Manager::COLOR,
217 'selectors' => [
218 '{{WRAPPER}} .elementor-tab-desktop-title.elementor-active' => 'background-color: {{VALUE}};',
219 '{{WRAPPER}} .elementor-tabs-content-wrapper' => 'background-color: {{VALUE}};',
220 ],
221 ]
222 );
223
224 $this->add_control(
225 'heading_title',
226 [
227 'label' => __( 'Title', 'propertyhive' ),
228 'type' => \Elementor\Controls_Manager::HEADING,
229 'separator' => 'before',
230 ]
231 );
232
233 $this->add_control(
234 'tab_color',
235 [
236 'label' => __( 'Color', 'propertyhive' ),
237 'type' => \Elementor\Controls_Manager::COLOR,
238 'selectors' => [
239 '{{WRAPPER}} .elementor-tab-title' => 'color: {{VALUE}};',
240 ],
241 'global' => [
242 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_PRIMARY,
243 ],
244 ]
245 );
246
247 $this->add_control(
248 'tab_active_color',
249 [
250 'label' => __( 'Active Color', 'propertyhive' ),
251 'type' => \Elementor\Controls_Manager::COLOR,
252 'selectors' => [
253 '{{WRAPPER}} .elementor-tab-title.elementor-active' => 'color: {{VALUE}};',
254 ],
255 'global' => [
256 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_ACCENT,
257 ],
258 ]
259 );
260
261 $this->add_group_control(
262 \Elementor\Group_Control_Typography::get_type(),
263 [
264 'name' => 'tab_typography',
265 'selector' => '{{WRAPPER}} .elementor-tab-title',
266 'global' => [
267 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_PRIMARY,
268 ],
269 ]
270 );
271
272 $this->add_control(
273 'heading_content',
274 [
275 'label' => __( 'Content', 'propertyhive' ),
276 'type' => \Elementor\Controls_Manager::HEADING,
277 'separator' => 'before',
278 ]
279 );
280
281 $this->add_control(
282 'content_color',
283 [
284 'label' => __( 'Color', 'propertyhive' ),
285 'type' => \Elementor\Controls_Manager::COLOR,
286 'selectors' => [
287 '{{WRAPPER}} .elementor-tab-content' => 'color: {{VALUE}};',
288 ],
289 'global' => [
290 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Colors::COLOR_TEXT,
291 ],
292 ]
293 );
294
295 $this->add_group_control(
296 \Elementor\Group_Control_Typography::get_type(),
297 [
298 'name' => 'content_typography',
299 'selector' => '{{WRAPPER}} .elementor-tab-content',
300 'global' => [
301 'default' => \Elementor\Core\Kits\Documents\Tabs\Global_Typography::TYPOGRAPHY_TEXT,
302 ],
303 ]
304 );
305
306 $this->end_controls_section();
307
308 }
309
310 private function show_tab($item)
311 {
312 global $property;
313
314 if ( is_null($property) && isset($post->ID) && get_post_type($post->ID) == 'property' )
315 {
316 $property = new PH_Property($post->ID);
317 }
318
319 if ( is_null($property) )
320 {
321 return false;
322 }
323
324 $tab_display = $item['tab_display'];
325
326 $show = false;
327
328 foreach ( $item['tab_display'] as $display )
329 {
330 switch ( $display )
331 {
332 case "gallery":
333 {
334 if ( get_option('propertyhive_images_stored_as', '') == 'urls' )
335 {
336 $photo_urls = $property->photo_urls;
337 if ( !is_array($photo_urls) ) { $photo_urls = array(); }
338
339 if ( !empty($photo_urls) )
340 {
341 return true;
342 }
343 }
344 else
345 {
346 $attachment_ids = $property->get_gallery_attachment_ids();
347 if ( !empty($attachment_ids) )
348 {
349 return true;
350 }
351 }
352 break;
353 }
354 case "floorplan":
355 {
356 if ( get_option('propertyhive_floorplans_stored_as', '') == 'urls' )
357 {
358 $floorplan_urls = $property->floorplan_urls;
359 if ( !is_array($floorplan_urls) ) { $floorplan_urls = array(); }
360
361 if ( !empty($floorplan_urls) )
362 {
363 return true;
364 }
365 }
366 else
367 {
368 $attachment_ids = $property->get_floorplan_attachment_ids();
369 if ( !empty($attachment_ids) )
370 {
371 return true;
372 }
373 }
374 break;
375 }
376 case "brochure":
377 {
378 if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
379 {
380 $brochure_urls = $property->brochure_urls;
381 if ( !is_array($brochure_urls) ) { $brochure_urls = array(); }
382
383 if ( !empty($brochure_urls) )
384 {
385 return true;
386 }
387 }
388 else
389 {
390 $attachment_ids = $property->get_brochure_attachment_ids();
391 if ( !empty($attachment_ids) )
392 {
393 return true;
394 }
395 }
396 break;
397 }
398 case "epc":
399 {
400 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
401 {
402 $epc_urls = $property->epc_urls;
403 if ( !is_array($epc_urls) ) { $epc_urls = array(); }
404
405 if ( !empty($epc_urls) )
406 {
407 return true;
408 }
409 }
410 else
411 {
412 $attachment_ids = $property->get_epc_attachment_ids();
413 if ( !empty($attachment_ids) )
414 {
415 return true;
416 }
417 }
418 break;
419 }
420 case "virtual_tour":
421 case "embedded_virtual_tour":
422 {
423 $virtual_tours = $property->get_virtual_tours();
424 if ( !empty($virtual_tours) )
425 {
426 return true;
427 }
428 break;
429 }
430 case "map":
431 case "street_view":
432 {
433 if ( $property->latitude != '' && $property->latitude != '0' && $property->longitude != '' && $property->longitude != '0' )
434 {
435 return true;
436 }
437 break;
438 }
439 case "features":
440 {
441 if ( !empty($property->get_features()) )
442 {
443 return true;
444 }
445 break;
446 }
447 case "content":
448 {
449 if ( ! empty( $item['tab_content'] ) )
450 {
451 return true;
452 }
453 break;
454 }
455 default:
456 {
457 return apply_filters( 'propertyhive_elementor_tabbed_details_show_tab', true, $property, $display );
458 }
459 }
460 }
461
462 return $show;
463 }
464
465 protected function render() {
466
467 global $property, $post;
468
469 if ( is_null($property) && isset($post->ID) && get_post_type($post->ID) == 'property' )
470 {
471 $property = new PH_Property($post->ID);
472 }
473
474 $tabs = $this->get_settings( 'property_tabs' );
475
476 $id_int = substr( $this->get_id_int(), 0, 3 );
477 ?>
478 <!--<div class="elementor-widget-tabs elementor-tabs-view-horizontal">-->
479 <div class="elementor-tabs" role="tablist">
480 <div class="elementor-tabs-wrapper">
481 <?php
482 foreach ( $tabs as $index => $item )
483 {
484 $show_tab = $this->show_tab($item);
485 if ($show_tab)
486 {
487 $tab_count = $index + 1;
488
489 $tab_title_setting_key = $this->get_repeater_setting_key( 'tab_title', 'tabs', $index );
490
491 $onclick = '';
492 if ( in_array('map', $item['tab_display']) )
493 {
494 $onclick .= 'setTimeout(function() { initialize_property_map(); }, 10);';
495 }
496 if ( in_array('street_view', $item['tab_display']) )
497 {
498 $onclick .= 'setTimeout(function() { initialize_property_street_view(); }, 10);';
499 }
500 if ( in_array('gallery', $item['tab_display']) )
501 {
502 $onclick .= 'setTimeout(function() { jQuery(window).trigger(\'resize\'); }, 10);';
503 }
504 $onclick = apply_filters( 'propertyhive_elementor_tabbed_details_tab_onclick', $onclick, $property, $item );
505
506 $this->add_render_attribute( $tab_title_setting_key, [
507 'id' => 'elementor-tab-title-' . $id_int . $tab_count,
508 'class' => [ 'elementor-tab-title', 'elementor-tab-desktop-title' ],
509 'data-tab' => $tab_count,
510 'tabindex' => $id_int . $tab_count,
511 'role' => 'tab',
512 'aria-controls' => 'elementor-tab-content-' . $id_int . $tab_count,
513 'onclick' => $onclick
514 ] );
515 ?>
516 <div <?php echo $this->get_render_attribute_string( $tab_title_setting_key ); ?>><?php echo $item['tab_title']; ?></div>
517 <?php
518 }
519 }
520 ?>
521 </div>
522 <div class="elementor-tabs-content-wrapper">
523 <?php
524 foreach ( $tabs as $index => $item )
525 {
526 $show_tab = $this->show_tab($item);
527 if ($show_tab)
528 {
529 $tab_count = $index + 1;
530
531 $tab_content_setting_key = $this->get_repeater_setting_key( 'tab_content', 'tabs', $index );
532
533 $tab_title_mobile_setting_key = $this->get_repeater_setting_key( 'tab_title_mobile', 'tabs', $tab_count );
534
535 $onclick = '';
536 if ( in_array('map', $item['tab_display']) )
537 {
538 $onclick .= 'setTimeout(function() { initialize_property_map(); }, 10);';
539 }
540 if ( in_array('street_view', $item['tab_display']) )
541 {
542 $onclick .= 'setTimeout(function() { initialize_property_street_view(); }, 10);';
543 }
544 if ( in_array('gallery', $item['tab_display']) )
545 {
546 $onclick .= 'setTimeout(function() { jQuery(window).trigger(\'resize\'); }, 10);';
547 }
548 $onclick = apply_filters( 'propertyhive_elementor_tabbed_details_tab_onclick', $onclick, $property, $item );
549
550 $this->add_render_attribute( $tab_content_setting_key, [
551 'id' => 'elementor-tab-content-' . $id_int . $tab_count,
552 'class' => [ 'elementor-tab-content', 'elementor-clearfix' ],
553 'data-tab' => $tab_count,
554 'role' => 'tabpanel',
555 'aria-labelledby' => 'elementor-tab-title-' . $id_int . $tab_count,
556 ] );
557
558 $this->add_render_attribute( $tab_title_mobile_setting_key, [
559 'class' => [ 'elementor-tab-title', 'elementor-tab-mobile-title' ],
560 'tabindex' => $id_int . $tab_count,
561 'data-tab' => $tab_count,
562 'role' => 'tab',
563 'onclick' => $onclick
564 ] );
565
566 $this->add_inline_editing_attributes( $tab_content_setting_key, 'advanced' );
567 ?>
568 <div <?php echo $this->get_render_attribute_string( $tab_title_mobile_setting_key ); ?>><?php echo esc_html($item['tab_title']); ?></div>
569 <div <?php echo $this->get_render_attribute_string( $tab_content_setting_key ); ?>><?php
570 foreach ( $item['tab_display'] as $display )
571 {
572 switch ( $display )
573 {
574 case "features":
575 {
576 propertyhive_template_single_features();
577 break;
578 }
579 case "summary_description":
580 {
581 propertyhive_template_single_summary();
582 break;
583 }
584 case "full_description":
585 {
586 propertyhive_template_single_description();
587 break;
588 }
589 case "gallery":
590 {
591 echo '<style type="text/css">
592 .tabbed-gallery-container {
593
594 }
595 .tabbed-gallery {
596 display: grid;
597 grid-template-columns: repeat(4, 1fr); /* 4 items per row */
598 gap: 10px;
599 }
600 .tabbed-gallery a { }
601 .tabbed-gallery a img {
602 width: 100%; /* Ensure the images fill their grid cell */
603 height: auto; /* Maintain aspect ratio */
604 display: block; /* Ensure no extra space below images */
605 }
606 </style>';
607 if ( get_option('propertyhive_images_stored_as', '') == 'urls' )
608 {
609 $photo_urls = $property->photo_urls;
610 if ( !is_array($photo_urls) ) { $photo_urls = array(); }
611
612 if ( !empty($photo_urls) )
613 {
614 echo '<div class="tabbed-gallery">';
615
616 foreach ( $photo_urls as $photo )
617 {
618 echo '<a href="' . esc_url($photo['url']) . '" data-fancybox="tabbed_photos" rel="nofollow"><img src="' . esc_url($photo['url']) . '" alt=""></a>';
619 }
620
621 echo '</div>';
622 }
623 }
624 else
625 {
626 $gallery_attachment_ids = $property->get_gallery_attachment_ids();
627
628 if ( !empty($gallery_attachment_ids) )
629 {
630 echo '<div class="tabbed-gallery">';
631
632 foreach ( $gallery_attachment_ids as $attachment_id )
633 {
634 $image_medium_url = '';
635 $image = wp_get_attachment_image_src( $attachment_id, 'medium' );
636 if ( $image !== false )
637 {
638 $image_medium_url = $image[0];
639 }
640 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="tabbed_photos" rel="nofollow"><img src="' . esc_url($image_medium_url) . '" alt=""></a>';
641 }
642
643 echo '</div>';
644 }
645 }
646 break;
647 }
648 case "floorplan":
649 {
650 if ( get_option('propertyhive_floorplans_stored_as', '') == 'urls' )
651 {
652 $floorplan_urls = $property->floorplan_urls;
653 if ( !is_array($floorplan_urls) ) { $floorplan_urls = array(); }
654
655 if ( !empty($floorplan_urls) )
656 {
657 echo '<div class="floorplans">';
658
659 foreach ( $floorplan_urls as $floorplan )
660 {
661 echo '<a href="' . esc_url($floorplan['url']) . '" data-fancybox="floorplans" rel="nofollow"><img src="' . esc_url($floorplan['url']) . '" alt=""></a>';
662 }
663
664 echo '</div>';
665 }
666 }
667 else
668 {
669 $floorplan_attachment_ids = $property->get_floorplan_attachment_ids();
670
671 if ( !empty($floorplan_attachment_ids) )
672 {
673 echo '<div class="floorplans">';
674
675 foreach ( $floorplan_attachment_ids as $attachment_id )
676 {
677 if ( wp_attachment_is_image($attachment_id) )
678 {
679 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="floorplans" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
680 }
681 else
682 {
683 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View Floorplan', 'propertyhive' )) . '</a>';
684 }
685 }
686
687 echo '</div>';
688 }
689 }
690 break;
691 }
692 case "brochure":
693 {
694 if ( get_option('propertyhive_brochures_stored_as', '') == 'urls' )
695 {
696 $brochure_urls = $property->brochure_urls;
697 if ( !is_array($brochure_urls) ) { $brochure_urls = array(); }
698
699 if ( !empty($brochure_urls) )
700 {
701 echo '<div class="brochures">';
702
703 foreach ( $brochure_urls as $brochure )
704 {
705 echo '<a href="' . esc_url($brochure['url']). '" target="_blank" rel="nofollow">' . esc_html(__( 'View Brochure', 'propertyhive' )) . '</a>';
706 }
707
708 echo '</div>';
709 }
710 }
711 else
712 {
713 $brochure_attachment_ids = $property->get_brochure_attachment_ids();
714
715 if ( !empty($brochure_attachment_ids) )
716 {
717 echo '<div class="brochures">';
718
719 foreach ( $brochure_attachment_ids as $attachment_id )
720 {
721 if ( wp_attachment_is_image($attachment_id) )
722 {
723 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="brochures" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
724 }
725 else
726 {
727 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View Brochure', 'propertyhive' )) . '</a>';
728 }
729 }
730
731 echo '</div>';
732 }
733 }
734 break;
735 }
736 case "epc":
737 {
738 if ( get_option('propertyhive_epcs_stored_as', '') == 'urls' )
739 {
740 $epc_urls = $property->epc_urls;
741 if ( !is_array($epc_urls) ) { $epc_urls = array(); }
742
743 if ( !empty($epc_urls) )
744 {
745 echo '<div class="epcs">';
746
747 foreach ( $epc_urls as $epc )
748 {
749 echo '<a href="' . esc_url($epc['url']) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url($epc['url']) . '" alt=""></a>';
750 }
751
752 echo '</div>';
753 }
754 }
755 else
756 {
757 $epc_attachment_ids = $property->get_epc_attachment_ids();
758
759 if ( !empty($epc_attachment_ids) )
760 {
761 echo '<div class="epcs">';
762
763 foreach ( $epc_attachment_ids as $attachment_id )
764 {
765 if ( wp_attachment_is_image($attachment_id) )
766 {
767 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" data-fancybox="epcs" rel="nofollow"><img src="' . esc_url(wp_get_attachment_url($attachment_id)) . '" alt=""></a>';
768 }
769 else
770 {
771 echo '<a href="' . esc_url(wp_get_attachment_url($attachment_id)) . '" target="_blank" rel="nofollow">' . esc_html(__( 'View EPC', 'propertyhive' )) . '</a>';
772 }
773 }
774
775 echo '</div>';
776 }
777 }
778 break;
779 }
780 case "virtual_tour":
781 {
782 $virtual_tours = $property->get_virtual_tours();
783
784 if ( !empty($virtual_tours) )
785 {
786 echo '<div class="virtual-tours">';
787
788 foreach ( $virtual_tours as $virtual_tour )
789 {
790 echo '<a href="' . esc_url($virtual_tour['url']) . '" target="_blank" rel="nofollow">' . esc_html($virtual_tour['label']) . '</a>';
791 }
792
793 echo '</div>';
794 }
795 break;
796 }
797 case "embedded_virtual_tour":
798 {
799 $virtual_tours = $property->get_virtual_tours();
800
801 if ( !empty($virtual_tours) )
802 {
803 echo '<div class="virtual-tours">';
804
805 $fb_sdk_printed = false;
806
807 foreach ( $virtual_tours as $virtual_tour )
808 {
809 $virtual_tour['url'] = preg_replace(
810 "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
811 "//www.youtube.com/embed/$2",
812 $virtual_tour['url']
813 );
814
815 $virtual_tour['url'] = preg_replace(
816 '#https?://(www\.)?youtube\.com/shorts/([^/?]+)#',
817 '//www.youtube.com/embed/$2',
818 $virtual_tour['url']
819 );
820
821 if ( strpos($virtual_tour['url'], 'vimeo') !== FALSE && strpos($virtual_tour['url'], 'player.') === FALSE )
822 {
823 $virtual_tour['url'] = preg_replace(
824 '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/?(showcase\/)*([0-9))([a-z]*\/)*([0-9]{6,11})[?]?.*/i',
825 "//player.vimeo.com/video/$6",
826 $virtual_tour['url']
827 );
828 }
829
830 if ( preg_match('#^https?://(www\.)?facebook\.com/reel/[^?\s]+#i', $virtual_tour['url']) )
831 {
832 // Print SDK once (uses en_GB locale to match your site)
833 if ( ! $fb_sdk_printed )
834 {
835 $fb_sdk_printed = true;
836 echo '<div id="fb-root"></div>';
837 // Use the standard SDK include; id prevents double-loading
838 echo '<script async defer crossorigin="anonymous" id="facebook-jssdk" src="https://connect.facebook.net/en_GB/sdk.js#xfbml=1&version=v20.0"></script>';
839 }
840
841 // Output the Reel embed container; the SDK converts it into a player
842 echo '<div class="fb-video" data-href="' . esc_url( $virtual_tour['url'] ) . '" data-allowfullscreen="true" data-width="auto" style="max-width:100%;"></div>';
843
844 // Skip the generic iframe path for FB Reels
845 continue;
846 }
847
848 echo '<iframe src="' . esc_url($virtual_tour['url']) . '" height="500" width="100%" allowfullscreen frameborder="0" allow="fullscreen"></iframe>';
849 }
850
851 echo '</div>';
852 }
853 break;
854 }
855 case "map":
856 {
857 echo do_shortcode('[property_map scrollwheel="false"' . ( ( $tab_count > 1 ) ? ' init_on_load="false"' : '' ) . ']');
858 break;
859 }
860 case "street_view":
861 {
862 echo do_shortcode('[property_street_view' . ( ( $tab_count > 1 ) ? ' init_on_load="false"' : '' ) . ']');
863 break;
864 }
865 case "make_enquiry":
866 {
867 propertyhive_enquiry_form();
868 break;
869 }
870 case "content":
871 {
872 if ( ! empty( $item['tab_content'] ) )
873 {
874 echo '<div class="tabbed-custom-content">';
875 echo $this->parse_text_editor( $item['tab_content'] );
876 echo '</div>';
877 }
878 break;
879 }
880 }
881
882 do_action( 'propertyhive_elementor_tabbed_details_tab_contents', $property, $display );
883 }
884 ?></div>
885 <?php
886 }
887 }
888 ?>
889 </div>
890 </div>
891 <!--</div>-->
892
893 <script>
894 jQuery(document).ready(function()
895 {
896 jQuery('[data-widget_type=\'property-tabbed-details.default\']').each(function()
897 {
898 jQuery(this).attr('data-widget_type', 'tabs.default');
899 });
900 });
901
902 jQuery(window).on('load', function()
903 {
904 jQuery(window).trigger('resize');
905 });
906
907 jQuery(window).on('resize', function()
908 {
909 jQuery('.tabbed-gallery img').each(function()
910 {
911 var ratio = 3/4;
912 jQuery(this).height( jQuery(this).width() * ratio );
913 })
914 });
915 </script>
916 <?php
917
918 }
919
920 }