PluginProbe
Property Hive / 2.2.5
Property Hive v2.2.5
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 / divi-widgets / property-embedded-virtual-tours.php

property-embedded-virtual-tours.php in Property Hive 2.2.5, at includes/divi-widgets/property-embedded-virtual-tours.php

80 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 class Divi_Property_Embedded_Virtual_Tours_Widget extends ET_Builder_Module
7 {
8 public $slug = 'et_pb_property_embedded_virtual_tours_widget';
9 public $vb_support = 'partial';
10 public $icon = '';
11
12 public function init() {
13 $this->name = esc_html__( 'Property Embedded Virtual Tours', 'propertyhive' );
14 $this->icon = 'i';
15 }
16
17 public function get_fields()
18 {
19 $fields = array();
20
21 return $fields;
22 }
23
24 public function render( $attrs, $content, $render_slug )
25 {
26 $post_id = get_the_ID();
27
28 $property = new PH_Property($post_id);
29
30 if ( !isset($property->id) ) {
31 return;
32 }
33
34 ob_start();
35
36 $virtual_tours = $property->get_virtual_tours();
37
38 if ( !empty($virtual_tours) )
39 {
40 echo '<div class="embedded-virtual-tours">';
41
42 echo '<h4>' . esc_html(__( 'Virtual Tours', 'propertyhive' )) . '</h4>';
43
44 foreach ( $virtual_tours as $virtual_tour )
45 {
46 if ( isset($settings['oembed']) && $settings['oembed'] == 'yes' )
47 {
48 $embed_code = wp_oembed_get($virtual_tour['url']);
49 echo $embed_code;
50 }
51 else
52 {
53 $virtual_tour['url'] = preg_replace(
54 "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
55 "//www.youtube.com/embed/$2",
56 $virtual_tour['url']
57 );
58
59 $virtual_tour['url'] = preg_replace(
60 '#https?://(www\.)?youtube\.com/shorts/([^/?]+)#',
61 '//www.youtube.com/embed/$2',
62 $virtual_tour['url']
63 );
64
65 $virtual_tour['url'] = preg_replace(
66 '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/?(showcase\/)*([0-9))([a-z]*\/)*([0-9]{6,11})[?]?.*/i',
67 "//player.vimeo.com/video/$6",
68 $virtual_tour['url']
69 );
70
71 echo '<iframe src="' . esc_url($virtual_tour['url']) . '" height="500" width="100%" allowfullscreen frameborder="0" allow="fullscreen"></iframe>';
72 }
73 }
74
75 echo '</div>';
76 }
77
78 return $this->_render_module_wrapper( ob_get_clean(), $render_slug );
79 }
80 }