PluginProbe
Property Hive / 2.3.1
Property Hive v2.3.1
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 / bricks-builder-widgets / property-embedded-virtual-tours.php

property-embedded-virtual-tours.php in Property Hive 2.3.1, at includes/bricks-builder-widgets/property-embedded-virtual-tours.php

106 lines 3.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Bricks Builder Property Embedded Virtual Tours Widget.
4 *
5 * @since 1.0.0
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
9
10 class Bricks_Builder_Property_Embedded_Virtual_Tours_Widget extends \Bricks\Element {
11
12 // Element properties
13 public $category = 'propertyhive';
14 public $name = 'bricks-builder-property-embedded-virtual-tours';
15 public $icon = 'fas fa-video';
16
17 public function get_label()
18 {
19 return esc_html__( 'Embedded Virtual Tours', 'propertyhive' );
20 }
21
22 public function set_control_groups()
23 {
24 /*$this->control_groups['form'] = [
25 'title' => esc_html__( 'Form', 'propertyhive' ),
26 'tab' => 'content', // content / style
27 ];*/
28 }
29
30 public function set_controls()
31 {
32 $this->controls['oembed'] = [
33 'tab' => 'content',
34 //'group' => 'settings',
35 'label' => esc_html__( 'Use oEmbed', 'propertyhive' ),
36 'type' => 'select',
37 'options' => [
38 'no' => __( 'No', 'propertyhive' ),
39 'yes' => __( 'Yes', 'propertyhive' ),
40 ],
41 'default' => __( 'no', 'propertyhive' ),
42 ];
43 }
44
45 public function render()
46 {
47 global $property;
48
49 if ( !isset($property->id) )
50 {
51 return;
52 }
53
54 $virtual_tours = $property->get_virtual_tours();
55
56 if ( empty($virtual_tours) )
57 {
58 return;
59 }
60
61 $root_classes[] = $this->name;
62
63 // Add 'class' attribute to element root tag
64 $this->set_attribute( '_root', 'class', $root_classes );
65
66 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Bricks serializes registered attributes through its documented render_attributes() API.
67 echo "<div {$this->render_attributes( '_root' )}>";
68
69 echo '<h4>' . esc_html__( 'Virtual Tours', 'propertyhive' ) . '</h4>';
70
71 foreach ( $virtual_tours as $virtual_tour )
72 {
73 if ( isset($this->settings['oembed']) && $this->settings['oembed'] == 'yes' )
74 {
75 $embed_code = wp_oembed_get($virtual_tour['url']);
76 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- wp_oembed_get() uses WordPress provider trust and sanitization; preserve supported provider scripts and trusted PHP filters.
77 echo $embed_code;
78 }
79 else
80 {
81 $virtual_tour['url'] = preg_replace(
82 "/\s*[a-zA-Z\/\/:\.]*youtu(be.com\/watch\?v=|.be\/)([a-zA-Z0-9\-_]+)([a-zA-Z0-9\/\*\-\_\?\&\;\%\=\.]*)/i",
83 "//www.youtube.com/embed/$2",
84 $virtual_tour['url']
85 );
86
87 $virtual_tour['url'] = preg_replace(
88 '#https?://(www\.)?youtube\.com/shorts/([^/?]+)#',
89 '//www.youtube.com/embed/$2',
90 $virtual_tour['url']
91 );
92
93 $virtual_tour['url'] = preg_replace(
94 '/(https?:\/\/)?(www\.)?(player\.)?vimeo\.com\/?(showcase\/)*([0-9))([a-z]*\/)*([0-9]{6,11})[?]?.*/i',
95 "//player.vimeo.com/video/$6",
96 $virtual_tour['url']
97 );
98
99 echo '<iframe src="' . esc_url($virtual_tour['url']) . '" height="500" width="100%" allowfullscreen frameborder="0" allow="fullscreen"></iframe>';
100 }
101 }
102
103 echo '</div>';
104 }
105 }
106