PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.68
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.68
9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 8.5.4 All 221 releases
wpvr / admin / classes / class-wpvr-scene.php

class-wpvr-scene.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.68, at admin/classes/class-wpvr-scene.php

3,324 lines 167.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 /**
4 * Responsible for managing Scene tab on Setup meta box
5 *
6 * @link http://rextheme.com/
7 * @since 8.0.0
8 *
9 * @package Wpvr
10 * @subpackage Wpvr/admin/classes
11 */
12
13 class WPVR_Scene {
14
15 /**
16 * Instance of WPVR_Hotspot class
17 *
18 * @var object
19 * @since 8.0.0
20 */
21 protected $hotspot;
22
23 /**
24 * Instance of WPVR_Format class
25 *
26 * @var object
27 * @since 8.0.0
28 */
29 protected $format;
30
31 /**
32 * Instance of WPVR_Validator class
33 *
34 * @var object
35 * @since 8.0.0
36 */
37 private $validator;
38
39 /**
40 * Number of scene or hotspot item
41 *
42 * @var integer
43 * @since 8.0.0
44 */
45 protected $data_limit;
46
47 /**
48 * Pro version license status
49 *
50 * @var string
51 * @since 8.0.0
52 */
53 protected $status;
54
55
56 function __construct()
57 {
58 $this->hotspot = new WPVR_Hotspot();
59 $this->format = new WPVR_Format();
60 $this->validator = new WPVR_Validator();
61
62 $this->status = apply_filters( 'check_pro_license_status', $this->status );
63
64 if ($this->status !== false && $this->status == 'valid') {
65 $this->data_limit = 999999999;
66 } else {
67 $this->data_limit = 5;
68 }
69 }
70
71 /**
72 * Render Scene Settings Content
73 *
74 * @param array $postdata
75 *
76 * @return void
77 * @since 8.0.0
78 */
79 public function render_scene($postdata)
80 {
81 ob_start();
82 ?>
83
84 <!-- Scene and Hotspot repeater -->
85 <div class="scene-setup rex-pano-sub-tabs" data-limit="<?= $this->data_limit + 1;?>">
86 <?php $this->render_scene_repeater_list($postdata); ?>
87 </div>
88
89 <?php
90 // ob_end_flush();
91 }
92
93
94 /**
95 * Render scene setup data repeater list
96 *
97 * @param array $postdata
98 *
99 * @return void
100 * @since 8.0.0
101 */
102 private function render_scene_repeater_list($postdata)
103 {
104 ob_start();
105 ?>
106 <nav class="rex-pano-tab-nav rex-pano-nav-menu scene-nav">
107 <?php $this->render_nav_menu($postdata); // Will render scene navigation bar ?>
108 </nav>
109
110 <div data-repeater-list="scene-list" class="rex-pano-tab-content">
111
112 <!-- Default empty repeater -->
113 <div data-repeater-item class="single-scene rex-pano-tab" data-title="0" id="scene-0">
114 <?php $this->render_default_repeater_item(); ?>
115 </div>
116 <!-- Empty repeater end -->
117
118 <?php $s = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
119 foreach ($postdata['panodata']["scene-list"] as $pano_scene) { ?>
120
121 <div data-repeater-item class="single-scene rex-pano-tab <?php if($pano_scene['scene-id'] == $firstvalue['scene-id']) { echo 'active'; }; ?>" data-title="1" id="scene-<?php echo $s;?>">
122 <?php $this->render_repeater_item_with_panodata($pano_scene, $s); ?>
123 </div>
124
125 <?php $s++; } ?>
126 </div>
127 <?php
128 // ob_end_flush();
129 }
130
131
132 /**
133 * Render scene nav menu
134 *
135 * @param array $postdata
136 *
137 * @return void
138 * @since 8.0.0
139 */
140 private function render_nav_menu($postdata)
141 {
142 ob_start();
143 ?>
144 <ul>
145 <?php $i = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
146 foreach ($postdata['panodata']["scene-list"] as $pano_scene) { ?>
147
148 <li class="<?php if ($pano_scene['scene-id'] == $firstvalue['scene-id']) {echo 'active';};?>">
149 <span data-index="<?php echo $i;?>" data-href="#scene-<?php echo $i;?>">
150 <i class="fa fa-image"></i>
151 </span>
152 </li>
153
154 <?php $i++; } ?>
155 <li class="add" data-repeater-create><span><i class="fa fa-plus-circle"></i></span></li>
156 </ul>
157 <?php
158 ob_end_flush();
159 }
160
161
162 /**
163 * Render repeater item for default scene
164 *
165 * @param int $data_limit
166 *
167 * @return void
168 * @since 8.0.0
169 */
170 private function render_default_repeater_item()
171 {
172 ob_start();
173 ?>
174 <div class="active_scene_id"><p></p></div>
175 <div class="scene-content">
176 <?php $this->render_default_repeater_item_scene_content(); ?>
177 </div>
178
179 <!-- hotspot setup -->
180 <div class="hotspot-setup rex-pano-sub-tabs" data-limit="<?= $this->data_limit;?>">
181 <?php $this->hotspot->render_hotspot($s = 0, $h =1)?>
182 </div>
183 <button data-repeater-delete type="button" title="Delete Scene" class="delete-scene"><i class="far fa-trash-alt"></i></button>
184 <?php
185 ob_end_flush();
186 }
187
188
189 /**
190 * Render repeater items while scene has panaromic data
191 *
192 * @param array $pano_scene
193 * @param int $s scene number increment var
194 *
195 * @return void
196 * @since 8.0.0
197 */
198 private function render_repeater_item_with_panodata($pano_scene, $s)
199 {
200 ob_start();
201 ?>
202 <div class="active_scene_id"><p></p></div>
203 <div class="scene-content">
204 <!--
205 - Render repeater item scene content
206 - If scene has panaromic data
207 -->
208 <?php $this->render_repeater_scene_content_with_data($pano_scene); ?>
209 </div>
210 <!--
211 - Render repeater item hotspot content
212 -->
213 <?php $this->render_repeater_item_hotspot_content($pano_scene, $s); ?>
214
215 <button data-repeater-delete type="button" title="Delete Scene" class="delete-scene"><i class="far fa-trash-alt"></i></button>
216 <?php
217 ob_end_flush();
218 }
219
220
221 /**
222 * Render scene content for default repeater item
223 *
224 * @return void
225 * @since 8.0.0
226 */
227 private function render_default_repeater_item_scene_content()
228 {
229 ob_start();
230 ?>
231
232 <h6 class="title"><i class="fa fa-cog"></i> <?php echo __('Scene Settings','wpvr') ?> </h6>
233
234 <div class="scene-left">
235 <?php WPVR_Meta_Field::render_scene_left_fields_empty_panodata(); ?>
236 </div>
237
238 <div class="scene-right">
239 <?php do_action( 'wpvr_pro_scene_empty_right_fields' ) ?>
240 </div>
241
242 <?php
243 ob_end_flush();
244 }
245
246
247 /**
248 * Render repeater item scene content is scene has panaromic data
249 *
250 * @param mixed $dscene
251 * @param mixed $scene_id
252 * @param mixed $scene_photo
253 *
254 * @return void
255 * @since 8.0.0
256 */
257 private function render_repeater_scene_content_with_data($pano_scene)
258 {
259 ob_start();
260 ?>
261 <h6 class="title"><i class="fa fa-cog"></i> <?php echo __('Scene Settings','wpvr') ?> </h6>
262
263 <div class="scene-left">
264 <?php WPVR_Meta_Field::render_scene_left_fields_with_panodata($pano_scene) ;?>
265 </div>
266
267 <div class="scene-right">
268 <?php do_action( 'wpvr_pro_scene_right_fields', $pano_scene ) ?>
269 </div>
270
271
272 <?php
273 ob_end_flush();
274 }
275
276
277 /**
278 * Render repeater item hotspot content
279 *
280 * @param array $pano_hotspots
281 * @param int $data_limit
282 * @param int $s
283 *
284 * @return void
285 * @since 8.0.0
286 */
287 private function render_repeater_item_hotspot_content($pano_scene, $s)
288 {
289 if (!empty($pano_scene['hotspot-list'])) { ?>
290 <div class="hotspot-setup rex-pano-sub-tabs" data-limit="<?= $this->data_limit;?>">
291
292 <?php $this->hotspot->render_hotspot_with_panodata($pano_scene['hotspot-list'], $s); //Render hotspot while scene has hotspot data ?>
293
294 </div>
295 <?php } else { ?>
296 <div class="hotspot-setup rex-pano-sub-tabs" data-limit="<?= $this->data_limit;?>">
297
298 <?php $this->hotspot->render_hotspot($s, $h = 1); //Render hotspot while scene has no hotspot data ?>
299
300 </div>
301 <?php }
302 }
303
304
305 /**
306 * Update post meta data
307 *
308 * @param integer $postid
309 * @param integer $panoid
310 * @param boolean $is_publish_action
311 *
312 * @return void
313 * @since 8.0.0
314 */
315 public function wpvr_update_meta_box($postid, $panoid, $is_publish_action = false)
316 {
317 $panodata = $this->format->prepare_panodata(isset($_POST['panodata']) ? $_POST['panodata'] : '');
318 $default_scene = $this->format->prepare_default_scene($panodata);
319 $previewtext = isset($_POST['previewtext']) ? $this->validator->preview_text_validation($_POST['previewtext']) : '';
320
321 $gzoom = $this->format->set_pro_checkbox_value(@$_POST['gzoom']);
322 $default_global_zoom = '';
323 $max_global_zoom = '';
324 $min_global_zoom = '';
325 if ($gzoom == 'on') {
326 $default_global_zoom = isset($_POST['dzoom']) ? $_POST['dzoom'] : '';
327 $max_global_zoom = isset($_POST['maxzoom']) ? $_POST['maxzoom'] : '';
328 $min_global_zoom = isset($_POST['minzoom']) ? $_POST['minzoom'] : '';
329 }
330
331 $custom_control = isset($_POST['customcontrol']) ? $_POST['customcontrol'] : null;
332
333 $vrgallery = $this->format->set_checkbox_value(@$_POST['vrgallery']);
334 $vrgallery_title = $this->format->set_checkbox_value(@$_POST['vrgallery_title']);
335 $vrgallery_display = $this->format->set_checkbox_value(@$_POST['vrgallery_display']);
336 $vrgallery_icon_size = $this->format->set_checkbox_value(@$_POST['vrgallery_icon_size']);
337
338 $mouseZoom = $this->format->set_pro_checkbox_value(@$_POST['mouseZoom']);
339 $draggable = $this->format->set_pro_checkbox_value(@$_POST['draggable']);
340 $diskeyboard = $this->format->set_pro_checkbox_value(@$_POST['diskeyboard']);
341 $keyboardzoom = $this->format->set_checkbox_value(@$_POST['keyboardzoom']);
342 $compass = $this->format->set_checkbox_on_value(@$_POST['compass']);
343 //===Gyroscopre control===//
344 $gyro = $this->format->set_pro_checkbox_value(@$_POST['gyro']);
345 if ($gyro == 'on') {
346 if (!is_ssl()) {
347 wp_send_json_error('<p><span>Warning:</span> Please add SSL to enable Gyroscope for WP VR. </p>');
348 die();
349 }
350 $gyro = true;
351 $deviceorientationcontrol = $this->format->set_checkbox_value(@$_POST['deviceorientationcontrol']);
352 } else {
353 $gyro = false;
354 $deviceorientationcontrol = false;
355 }
356 //===Gyroscopre control===//
357
358 $autoload = $this->format->set_checkbox_value(isset($_POST['autoload']) ? $_POST['autoload'] : '');
359 $control = $this->format->set_checkbox_value(isset($_POST['control']) ? $_POST['control'] : '');
360
361 $scene_fade_duration = isset($_POST['scenefadeduration']) ? sanitize_text_field($_POST['scenefadeduration']) : '';
362 $preview = isset($_POST['preview']) ? esc_url($_POST['preview']) : '';
363 $rotation = isset($_POST['rotation']) ? sanitize_text_field($_POST['rotation']) : '';
364 $autorotation = isset($_POST['autorotation']) ? sanitize_text_field($_POST['autorotation']) : '';
365
366 $autorotationinactivedelay = isset($_POST['autorotationinactivedelay']) ? sanitize_text_field($_POST['autorotationinactivedelay']) : '';
367 $autorotationstopdelay = isset($_POST['autorotationstopdelay']) ? sanitize_text_field($_POST['autorotationstopdelay']) : '';
368
369 //===generic form===//
370 $genericform = sanitize_text_field(isset($_POST['genericform']) ? $_POST['genericform'] : 'off');
371 $genericformshortcode = isset($_POST['genericformshortcode']) ? sanitize_text_field($_POST['genericformshortcode']) : '' ;
372 //===generic form===//
373
374
375 if(isset($_POST['rotation']) && sanitize_text_field($_POST['rotation']) === 'on' ) {
376 $this->validator->basic_setting_validation($autorotationinactivedelay, $autorotationstopdelay); // Basic setting error control and validation //
377 }
378
379 //===Company Logo===//
380 $cpLogoSwitch = isset($_POST['cpLogoSwitch']) ? $_POST['cpLogoSwitch'] : 'off';
381 $cpLogoImg = isset($_POST['cpLogoImg']) ? $_POST['cpLogoImg'] : '';
382 $cpLogoContent = isset($_POST['cpLogoContent']) ? sanitize_text_field($_POST['cpLogoContent']) : '';
383 //===Company Logo===//
384
385 //===Explainer video===//
386 $explainerSwitch = isset($_POST['explainerSwitch']) ? $_POST['explainerSwitch'] : 'off';
387 $explainerContent = '';
388 $explainerContent = isset($_POST['explainerContent']) ? $_POST['explainerContent'] : '';
389 //===Explainer video===//
390
391
392 $scene_fade_duration = '';
393 $scene_fade_duration = isset($_POST['scenefadeduration']) ? sanitize_text_field($_POST['scenefadeduration']) : '';
394
395 // Only validate when publishing, not when saving drafts
396 if ($is_publish_action) {
397 $this->validator->scene_validation($panodata); // Scene content error control and validation //
398
399 $this->validator->empty_scene_validation($panodata); // Empty scene content error control and validation //
400
401 $this->validator->duplicate_hotspot_validation($panodata); // Duplicate error control and validation //
402 }
403
404 $panodata = $this->format->remove_empty_scene_and_hotspot($panodata); // Remove Empty scene and hotspot //
405
406 //===audio===//
407 $bg_music = isset($_POST['bg_music']) ? sanitize_text_field($_POST['bg_music']) : 'off';
408 $bg_music_url = isset($_POST['bg_music_url']) ? esc_url_raw($_POST['bg_music_url']) : '';
409 $autoplay_bg_music = isset($_POST['autoplay_bg_music']) ? sanitize_text_field($_POST['autoplay_bg_music']) : 'off';
410 $loop_bg_music = isset($_POST['loop_bg_music']) ? sanitize_text_field($_POST['loop_bg_music']) : 'off';
411 if ($bg_music == 'on') {
412 if (empty($bg_music_url)) {
413 wp_send_json_error('<p><span>Warning:</span> Please add an audio file as you enabled audio for this tour </p>');
414 die();
415 }
416 }
417 //===audio===//
418 $advanced_control = array(
419 'keyboardzoom' => $keyboardzoom,
420 'diskeyboard' => $diskeyboard,
421 'draggable' => $draggable,
422 'mouseZoom' => $mouseZoom,
423 'gyro' => $gyro,
424 'deviceorientationcontrol' => $deviceorientationcontrol,
425 'compass' => $compass,
426 'vrgallery' => $vrgallery,
427 'vrgallery_title' => $vrgallery_title,
428 'vrgallery_display' => $vrgallery_display,
429 'vrgallery_icon_size' => $vrgallery_icon_size,
430 'bg_music' => $bg_music,
431 'bg_music_url' => $bg_music_url,
432 'autoplay_bg_music' => $autoplay_bg_music,
433 'loop_bg_music' => $loop_bg_music,
434 'cpLogoSwitch' => $cpLogoSwitch,
435 'cpLogoImg' => $cpLogoImg,
436 'cpLogoContent' => $cpLogoContent,
437 'hfov' => $default_global_zoom,
438 'maxHfov' => $max_global_zoom,
439 'minHfov' => $min_global_zoom,
440 'explainerSwitch' => $explainerSwitch,
441 'explainerContent' => $explainerContent,
442 );
443
444 $pano_array = array();
445 $pano_array = array(
446 "panoid" => $panoid,
447 "autoLoad" => $autoload,
448 "showControls" => $control,
449 "customcontrol" => $custom_control,
450 "autoRotate" => $autorotation,
451 "autoRotateInactivityDelay" => $autorotationinactivedelay,
452 "autoRotateStopDelay" => $autorotationstopdelay,
453 "genericform" => $genericform,
454 "genericformshortcode" => $genericformshortcode,
455 "preview" => $preview,
456 "defaultscene" => $default_scene,
457 "scenefadeduration" => $scene_fade_duration,
458 "panodata" => $panodata,
459 "previewtext" => $previewtext);
460 $pano_array = apply_filters( 'prepare_scene_pano_array_with_pro_version', $pano_array, $_POST, $advanced_control );
461 $pano_array = $this->format->prepare_rotation_wrapper_data($pano_array, $rotation);
462 // Prepare tour rotation wrapper data /
463 update_post_meta($postid, 'panodata', $pano_array);
464 do_action( 'wpvr_hotspot_saved', $postid, $pano_array );
465 $response = array(
466 'success' => true,
467 'data' => array(
468 'post_ID' => $postid,
469 'post_status' => get_post_status($postid)
470 )
471 );
472
473 do_action( 'wpvr_tour_settings_saved', $postid );
474
475
476 /**
477 * Delete orphaned analytics data
478 *
479 * @param integer $postid POST ID
480 *
481 * @return void
482 * @since 8.5.16
483 */
484 do_action('wpvr_pro_delete_orphaned_analytics_data', $postid);
485
486 wp_send_json($response);
487 die();
488
489 }
490
491
492 /**
493 * Allow iframe but disallow script tags in user input
494 * @since 8.5.16
495 */
496 public function wpvr_sanitize_iframe_only( $input ) {
497 // Start with standard allowed post HTML (p, a, strong, etc.)
498 $allowed_tags = wp_kses_allowed_html( 'post' );
499
500 // Explicitly allow <iframe> with specific safe attributes
501 $allowed_tags['iframe'] = array(
502 'src' => true,
503 'width' => true,
504 'height' => true,
505 'title' => true,
506 'frameborder' => true,
507 'allow' => true,
508 'allowfullscreen' => true,
509 'referrerpolicy' => true,
510 );
511
512 // Sanitize input
513 return wp_kses( $input, $allowed_tags );
514 }
515
516
517
518 /**
519 * Responsible for showing Scene Preview
520 *
521 * @param string $panoid
522 * @param string $panovideo
523 *
524 * @return wp_send_json_success
525 * @since 8.0.0
526 */
527 public function wpvr_scene_preview($panoid, $panovideo)
528 {
529 $panodata = $this->format->prepare_panodata($_POST['panodata']);
530
531 $control = $this->format->set_checkbox_value($_POST['control']);
532 $autoload = $this->format->set_checkbox_value($_POST['autoload']);
533
534 $compass = $this->format->set_checkbox_on_value(@$_POST['compass']);
535 $mouseZoom = $this->format->set_checkbox_value(@$_POST['mouseZoom']);
536 $draggable = $this->format->set_checkbox_value($_POST['draggable'] ?? null);
537 $gzoom = $this->format->set_pro_checkbox_value(@$_POST['gzoom']);
538 $diskeyboard = $this->format->set_checkbox_value(@$_POST['diskeyboard']);
539 $keyboardzoom = $this->format->set_checkbox_value(@$_POST['keyboardzoom']);
540
541 $gyro = $this->format->set_checkbox_on_value(@$_POST['gyro']);
542 $deviceorientationcontrol = $this->format->set_checkbox_value(@$_POST['deviceorientationcontrol']);
543
544 $floor_plan_enabler = $this->format->set_pro_checkbox_value(@$_POST['wpvr_floor_plan_enabler']);
545 $floor_plan_image = isset($_POST['wpvr_floor_plan_image']) ? $_POST['wpvr_floor_plan_image'] : '';
546
547 $scene_fade_duration = sanitize_text_field($_POST['scenefadeduration']);
548 $preview = esc_url($_POST['preview']);
549
550 $default_scene = '';
551
552 $rotation = sanitize_text_field($_POST['rotation']);
553 $autorotation = sanitize_text_field($_POST['autorotation']);
554 $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']);
555 $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']);
556
557 $default_global_zoom = '';
558 $max_global_zoom = '';
559 $min_global_zoom = '';
560 if ($gzoom == 'on') {
561 $default_global_zoom = $_POST['dzoom'];
562 $max_global_zoom = $_POST['maxzoom'];
563 $min_global_zoom = $_POST['minzoom'];
564 }
565
566 $default_scene = $this->format->prepare_default_scene($panodata);
567
568 if(isset($_POST['rotation']) && sanitize_text_field($_POST['rotation']) === 'on' ) {
569 $this->validator->basic_setting_validation($autorotationinactivedelay, $autorotationstopdelay); // Basic setting error control and validation //
570 }
571 $this->validator->scene_validation($panodata); // Scene content error control and validation //
572
573 $this->validator->empty_scene_validation($panodata); // Empty scene content error control and validation //
574
575 $this->validator->duplicate_hotspot_validation($panodata);
576 if($floor_plan_enabler == 'on'){
577 $this->validator->empty_floor_plan_image_validation($floor_plan_image);
578 }
579
580 $default_data = array();
581 if ($gzoom == 'on') {
582 $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration, "hfov" => $default_global_zoom, "maxHfov" => $max_global_zoom, "minHfov" => $min_global_zoom);
583 } else {
584 $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration);
585 }
586
587 $scene_data = $this->format->prepare_scene_data_for_preview($panodata);
588
589
590 $pano_id_array = array();
591 $pano_id_array = array("panoid" => $panoid);
592 $pano_response = array();
593 $pano_response = array("autoLoad" => $autoload, "defaultZoom" => $default_global_zoom, "minZoom" => $min_global_zoom, "maxZoom" => $max_global_zoom, "showControls" => $control, "compass" => $compass, "orientationOnByDefault" => $deviceorientationcontrol, "mouseZoom" => $mouseZoom, "draggable" => $draggable, "disableKeyboardCtrl" => $diskeyboard, 'keyboardZoom' => $keyboardzoom, "preview" => $preview, "autoRotate" => $autorotation, "autoRotateInactivityDelay" => $autorotationinactivedelay, "autoRotateStopDelay" => $autorotationstopdelay, "default" => $default_data, "scenes" => $scene_data);
594
595 $pano_response = $this->format->prepare_rotation_wrapper_data($pano_response, $rotation);
596
597 $is_pro = apply_filters('is_wpvr_pro_active',false);
598 $status = get_option('wpvr_edd_license_status');
599 $pano_floor_plan = array();
600 $call_to_action = array();
601 if ($status !== false && 'valid' == $status && $is_pro) {
602 $pano_floor_plan = array(
603 "floor_plan_tour_enabler" => $floor_plan_enabler,
604 "floor_plan_attachment_url" => $floor_plan_image
605 );
606 if ( 'on' === $floor_plan_enabler ) {
607 do_action( 'wpvr_floor_plan_configured', $postid, $pano_floor_plan );
608 }
609 $call_to_action = array(
610 'button_enable' =>sanitize_text_field($_POST['callToAction']),
611 'button_text' =>sanitize_text_field($_POST['buttontext']),
612 'button_url' =>sanitize_text_field($_POST['buttonurl'])
613 );
614 }
615
616 $response = array();
617 $response = array($pano_id_array, $pano_response, $panovideo,$pano_floor_plan,$call_to_action);
618 wp_send_json_success($response);
619 }
620
621
622 /**
623 * Render shortcode for scene and hotspot post data
624 *
625 * @param array $postdata
626 * @param string $panoid
627 * @param integer $id
628 * @param mixed $radius
629 * @param mixed $width
630 * @param mixed $height
631 *
632 * @return string
633 * @since 8.0.0
634 */
635 public function render_scene_shortcode($postdata, $panoid, $id, $radius, $width, $height, $mobile_height)
636 {
637 if (
638 ( isset($_GET['bricks']) && $_GET['bricks'] === 'run' ) ||
639 ( defined('DOING_AJAX') && DOING_AJAX && isset($_REQUEST['action']) && $_REQUEST['action'] === 'bricks_render_element' ) ||
640 ( defined('REST_REQUEST') && REST_REQUEST && isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '/wp-json/bricks/v1/render_element') !== false )
641 ) {
642 return esc_html__('Bricks Editor Mode - WPVR Preview is not available.', 'wpvr');
643 }
644
645 do_action('rex_wpvr_embadded_tour', $id);
646
647 $control = false;
648 if (isset($postdata['showControls'])) {
649 $control = $postdata['showControls'];
650 }
651
652 if ($control) {
653 if (isset($postdata['customcontrol']) && is_array($postdata['customcontrol'])) {
654 $custom_control = $postdata['customcontrol'];
655 $custom_control['gyroSwitch'] = isset($postdata['gyro']) && $postdata['gyro'] ? 'on' : 'off';
656 if ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on" || $custom_control['gyroscopeSwitch'] == "on" || $custom_control['backToHomeSwitch'] == "on") {
657 $control = false;
658 }
659 }
660 }
661
662 $vrgallery = false;
663 if (isset($postdata['vrgallery'])) {
664 $vrgallery = $postdata['vrgallery'];
665 }
666
667 $vrgallery_title = false;
668 if (isset($postdata['vrgallery_title'])) {
669 $vrgallery_title = $postdata['vrgallery_title'];
670 }
671
672 $vrgallery_display = false;
673 if (isset($postdata['vrgallery_display'])) {
674 $vrgallery_display = $postdata['vrgallery_display'];
675 }
676 $vrgallery_icon_size = false;
677 if (isset($postdata['vrgallery_icon_size'])) {
678 $vrgallery_icon_size = $postdata['vrgallery_icon_size'];
679 }
680 $gyro = false;
681 $gyro_orientation = false;
682 if (isset($postdata['gyro'])) {
683 $gyro = $postdata['gyro'];
684 if (isset($postdata['deviceorientationcontrol'])) {
685 $gyro_orientation = $postdata['deviceorientationcontrol'];
686 }
687 }
688 //== Floor plan handle ==//
689 $floor_plan_enable = 'off';
690 $floor_plan_image = '';
691 if (isset($postdata['floor_plan_tour_enabler']) && $postdata['floor_plan_tour_enabler'] == 'on'){
692 $floor_plan_enable = $postdata['floor_plan_tour_enabler'];
693 if(isset($postdata['floor_plan_attachment_url']) && !empty($postdata['floor_plan_attachment_url'])){
694 $floor_plan_image = $postdata['floor_plan_attachment_url'];
695 }
696 }
697
698 $compass = false;
699 $audio_right = "5px";
700 if (isset($postdata['compass'])) {
701 $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
702 if ($compass) {
703 $audio_right = "60px";
704 }
705 }
706 $floor_map_right = "25px";
707 if((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')){
708 $floor_map_right = "85px";
709 }elseif(isset($postdata['compass']) && $postdata['compass'] == 'on'){
710 $floor_map_right = "55px";
711 }elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
712 $floor_map_right = "25px";
713 }
714
715
716 //===explainer handle===//
717
718 $explainer_right = "10px";
719 if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ( $floor_plan_enable == 'on' && !empty($floor_plan_image) ) ) {
720 $explainer_right = "130px";
721 } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on' && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) {
722 $explainer_right = "100px";
723 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) {
724 $explainer_right = "55px";
725 } elseif((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') ) {
726 $explainer_right = "80px";
727 }elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
728 $explainer_right = "55px";
729 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
730 $explainer_right = "30px";
731 } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image) ) {
732 $explainer_right = "70px";
733 }
734
735
736 $enable_cardboard = '';
737 $is_cardboard = get_option('wpvr_cardboard_disable');
738 if(wpvr_isMobileDevice() && $is_cardboard == 'true' ){
739 $enable_cardboard = 'enable-cardboard';
740 $audio_right = "73px";
741 if (isset($postdata['compass'])) {
742 $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
743 if ($compass) {
744 $audio_right = "130px";
745 }
746 }
747 //===Floor plan handle===//
748 $floor_map_right = "60px";
749 if((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')){
750 $floor_map_right = "150px";
751 }elseif(isset($postdata['compass']) && $postdata['compass'] == 'on'){
752 $floor_map_right = "120px";
753 }elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
754 $floor_map_right = "90px";
755 }
756
757 //===explainer handle===//
758 $explainer_right = "65px";
759
760 if ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
761 $explainer_right = "150px";
762 } elseif((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) {
763 $explainer_right = "180px";
764 } elseif (isset($postdata['compass']) && $postdata['compass'] == true && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) {
765 $explainer_right = "150px";
766 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image) )) {
767 $explainer_right = "120px";
768 }elseif (isset($postdata['compass']) && $postdata['compass'] == true) {
769 $explainer_right = "130px";
770 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
771 $explainer_right = "90px";
772 }elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image) ) {
773 $explainer_right = "90px";
774 }
775 }
776
777 //===explainer handle===//
778
779 $mouseZoom = true;
780 if (isset($postdata['mouseZoom'])) {
781 if($postdata['mouseZoom'] == "off") {
782 $mouseZoom = false;
783 }
784 else {
785 $mouseZoom = true;
786 }
787 }
788
789 $draggable = true;
790 if (isset($postdata['draggable'])) {
791 $draggable = $postdata['draggable'] == 'off' || $postdata['draggable'] == null ? false : true;
792 }
793
794 $diskeyboard = false;
795 if (isset($postdata['diskeyboard'])) {
796 $diskeyboard = $postdata['diskeyboard'] == 'off' || $postdata['diskeyboard'] == null ? false : true;
797 }
798
799 $keyboardzoom = true;
800 if (isset($postdata['keyboardzoom'])) {
801 $keyboardzoom = $postdata['keyboardzoom'];
802 }
803
804 $autoload = false;
805
806 if (isset($postdata['autoLoad'])) {
807 $autoload = $postdata['autoLoad'];
808 }
809
810 $default_scene = '';
811 if (isset($postdata['defaultscene'])) {
812 $default_scene = $postdata['defaultscene'];
813 }
814
815 $default_global_zoom = '';
816 if (isset($postdata['hfov'])) {
817 $default_global_zoom = $postdata['hfov'];
818 }
819
820 $max_global_zoom = '';
821 if (isset($postdata['maxHfov'])) {
822 $max_global_zoom = $postdata['maxHfov'];
823 }
824
825 $min_global_zoom = '';
826 if (isset($postdata['minHfov'])) {
827 $min_global_zoom = $postdata['minHfov'];
828 }
829
830 $preview = '';
831 if (isset($postdata['preview'])) {
832 $preview = $postdata['preview'];
833 }
834
835 $autorotation = '';
836 if (isset($postdata["autoRotate"])) {
837 $autorotation = $postdata["autoRotate"];
838 }
839 $autorotationinactivedelay = '';
840 if (isset($postdata["autoRotateInactivityDelay"])) {
841 $autorotationinactivedelay = $postdata["autoRotateInactivityDelay"];
842 }
843 $autorotationstopdelay = '';
844 if (isset($postdata["autoRotateStopDelay"])) {
845 $autorotationstopdelay = $postdata["autoRotateStopDelay"];
846 }
847
848 $scene_fade_duration = '';
849 if (isset($postdata['scenefadeduration'])) {
850 $scene_fade_duration = $postdata['scenefadeduration'];
851 }
852
853 $panodata = '';
854 if (isset($postdata['panodata'])) {
855 $panodata = $postdata['panodata'];
856 }
857
858 $hotspoticoncolor = '#00b4ff';
859 $hotspotblink = 'on';
860 $default_data = array();
861 if ($default_global_zoom != '' && $max_global_zoom != '' && $min_global_zoom != '') {
862 $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration, "hfov" => $default_global_zoom, "maxHfov" => $max_global_zoom, "minHfov" => $min_global_zoom);
863 } else {
864 $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration);
865 }
866
867 $scene_data = array();
868
869 if (!empty($panodata["scene-list"])) {
870 foreach ($panodata["scene-list"] as $panoscenes) {
871 $scene_ititle = '';
872 if (isset($panoscenes["scene-ititle"])) {
873 $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]);
874 }
875
876 $scene_author = '';
877 if (isset($panoscenes["scene-author"])) {
878 $scene_author = sanitize_text_field($panoscenes["scene-author"]);
879 }
880
881 $scene_author_url = '';
882 if (isset($panoscenes["scene-author-url"])) {
883 $scene_author_url = esc_url($panoscenes["scene-author-url"]);
884 }
885
886 $scene_vaov = 180;
887 if (isset($panoscenes["scene-vaov"])) {
888 $scene_vaov = (float)$panoscenes["scene-vaov"];
889 }
890
891 $scene_haov = 360;
892 if (isset($panoscenes["scene-haov"])) {
893 $scene_haov = (float)$panoscenes["scene-haov"];
894 }
895
896
897 $scene_vertical_offset = 0;
898 if (isset($panoscenes["scene-vertical-offset"])) {
899 $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
900 }
901
902 $default_scene_pitch = null;
903 if (isset($panoscenes["scene-pitch"])) {
904 $default_scene_pitch = (float)$panoscenes["scene-pitch"];
905 }
906
907 $default_scene_yaw = null;
908 if (isset($panoscenes["scene-yaw"])) {
909 $default_scene_yaw = (float)$panoscenes["scene-yaw"];
910 }
911
912 $scene_max_pitch = '';
913 if (isset($panoscenes["scene-maxpitch"])) {
914 $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
915 }
916
917
918 $scene_min_pitch = '';
919 if (isset($panoscenes["scene-minpitch"])) {
920 $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
921 }
922
923
924 $scene_max_yaw = '';
925 if (isset($panoscenes["scene-maxyaw"])) {
926 $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
927 }
928
929
930 $scene_min_yaw = '';
931 if (isset($panoscenes["scene-minyaw"])) {
932 $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
933 }
934
935 $default_zoom = 100;
936 if (isset($panoscenes["scene-zoom"]) && $panoscenes["scene-zoom"] != "") {
937 $default_zoom = $panoscenes["scene-zoom"];
938 } else {
939 if ($default_global_zoom != '') {
940 $default_zoom = (int)$default_global_zoom;
941 }
942 }
943
944
945 $max_zoom = 120;
946 if (isset($panoscenes["scene-maxzoom"]) && $panoscenes["scene-maxzoom"] != '') {
947 $max_zoom = (int)$panoscenes["scene-maxzoom"];
948 } else {
949 if ($max_global_zoom != '') {
950 $max_zoom = (int)$max_global_zoom;
951 }
952 }
953
954
955
956 $min_zoom = 50;
957 if (isset($panoscenes["scene-minzoom"]) && $panoscenes["scene-minzoom"] != '') {
958 $min_zoom = (int)$panoscenes["scene-minzoom"];
959 } else {
960 if ($min_global_zoom != '') {
961 $min_zoom = (int)$min_global_zoom;
962 }
963 }
964
965
966 $hotspot_datas = array();
967 if (isset($panoscenes["hotspot-list"])) {
968 $hotspot_datas = $panoscenes["hotspot-list"];
969 }
970
971 $hotspots = array();
972
973
974 foreach ($hotspot_datas as $hotspot_data) {
975 $status = get_option('wpvr_edd_license_status');
976 if ($status !== false && $status == 'valid') {
977 if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
978 $hotspot_data['hotspot-customclass'] = $hotspot_data["hotspot-customclass-pro"] . ' custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot_data['hotspot-title']);
979 }
980 if (isset($hotspot_data['hotspot-blink'])) {
981 $hotspotblink = $hotspot_data['hotspot-blink'];
982 }
983 }
984 $hotspot_scene_pitch = '';
985 if (isset($hotspot_data["hotspot-scene-pitch"])) {
986 $hotspot_scene_pitch = $hotspot_data["hotspot-scene-pitch"];
987 }
988 $hotspot_scene_yaw = '';
989 if (isset($hotspot_data["hotspot-scene-yaw"])) {
990 $hotspot_scene_yaw = $hotspot_data["hotspot-scene-yaw"];
991 }
992
993 $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"];
994 $hotspot_content = '';
995
996 ob_start();
997 do_action('wpvr_hotspot_content', $hotspot_data);
998 $hotspot_content = ob_get_clean();
999
1000 if (!$hotspot_content) {
1001 $hotspot_content = $hotspot_data["hotspot-content"];
1002 }
1003
1004 if (isset($hotspot_data["wpvr_url_open"][0])) {
1005 $wpvr_url_open = $hotspot_data["wpvr_url_open"][0];
1006 } else {
1007 $wpvr_url_open = "off";
1008 }
1009 $on_hover_content = preg_replace_callback(
1010 '/<p>\s*(<img[^>]*>)\s*<br>\s*<\/p>/i',
1011 function ($matches) {
1012 return $matches[1];
1013 },
1014 $hotspot_data['hotspot-hover'] ?? ''
1015 );
1016
1017
1018 if('fluent_form' !== $hotspot_data["hotspot-type"]){
1019 $on_hover_content = $this->sanitize_content_preserve_styles($on_hover_content ?? '');
1020 $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1021 $on_click_content = $this->sanitize_content_preserve_styles($on_click_content ?? '');
1022 }else{
1023 $on_hover_content = $on_hover_content ?? '';
1024 $on_click_content = $hotspot_content ?? '';
1025 }
1026
1027 $hotspot_shape = 'round';
1028 if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
1029 $hotspot_shape = isset($hotspot_data["hotspot-shape"]) ? $hotspot_data["hotspot-shape"] : 'round';
1030 }
1031 $hotspot_data_for_on_click=[];
1032 if( ('info' === $hotspot_type || 'fluent_form' === $hotspot_data["hotspot-type"]) && !empty($on_click_content)){
1033 $hotspot_data_for_on_click = [
1034 'on_click_content' => $on_click_content,
1035 'tour_id' => $id,
1036 'scene_id' => $panoscenes['scene-id'],
1037 'hotspot_id' => sanitize_html_class($hotspot_data['hotspot-title']),
1038 ];
1039 } elseif('info' === $hotspot_type && !empty($hotspot_data["hotspot-url"])){
1040 $hotspot_data_for_on_click = [
1041 'on_click_content' => '',
1042 'tour_id' => $id,
1043 'scene_id' => $panoscenes['scene-id'],
1044 'hotspot_id' => sanitize_html_class($hotspot_data['hotspot-title']),
1045 ];
1046 }
1047
1048 $hotspot_info = array(
1049 "text" => esc_html(sanitize_text_field($hotspot_data["hotspot-title"])),
1050 "pitch" => $hotspot_data["hotspot-pitch"],
1051 "yaw" => $hotspot_data["hotspot-yaw"],
1052 "type" => $hotspot_type,
1053 "cssClass" => $hotspot_data["hotspot-customclass"],
1054 "URL" => $hotspot_data["hotspot-url"],
1055 "wpvr_url_open" => $wpvr_url_open,
1056 "clickHandlerArgs" => $hotspot_data_for_on_click,
1057 'createTooltipArgs' => !empty(trim($on_hover_content)) ? trim($on_hover_content) : '',
1058 "sceneId" => $hotspot_data["hotspot-scene"],
1059 "targetPitch" => (float)$hotspot_scene_pitch,
1060 "targetYaw" => (float)$hotspot_scene_yaw,
1061 'hotspot_type' => $hotspot_data['hotspot-type'],
1062 'hotspot_target' => 'notBlank',
1063 'hotspot_shape' => $hotspot_shape,
1064 );
1065 $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1066
1067 if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1068 unset($hotspot_info["cssClass"]);
1069 }
1070 if (empty($hotspot_data["hotspot-scene"])) {
1071 unset($hotspot_info['targetPitch']);
1072 unset($hotspot_info['targetYaw']);
1073 }
1074 array_push($hotspots, $hotspot_info);
1075 }
1076
1077 $device_scene = $panoscenes['scene-attachment-url'];
1078 $mobile_media_resize = get_option('mobile_media_resize');
1079 $file_accessible = ini_get('allow_url_fopen');
1080 if ($mobile_media_resize == "true" && $device_scene ) {
1081 if ($file_accessible == "1") {
1082 $image_info = getimagesize($device_scene);
1083 if ( isset($image_info[0]) && $image_info[0] > 4096) {
1084 $src_to_id_for_mobile = '';
1085 $src_to_id_for_desktop = '';
1086 if (wpvr_isMobileDevice()) {
1087 $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1088 if ($src_to_id_for_mobile) {
1089 $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1090 if ($mobile_scene[3]) {
1091 $device_scene = $mobile_scene[0];
1092 }
1093 }
1094 } else {
1095 $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1096 if ($src_to_id_for_desktop) {
1097 $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1098 if (isset($desktop_scene[0])) {
1099 $device_scene = $desktop_scene[0];
1100 }
1101 }
1102 }
1103 }
1104 }
1105 }
1106
1107 $scene_info = array();
1108
1109 if ($panoscenes["scene-type"] == 'cubemap') {
1110 $pano_attachment = array(
1111 $panoscenes["scene-attachment-url-face0"],
1112 $panoscenes["scene-attachment-url-face1"],
1113 $panoscenes["scene-attachment-url-face2"],
1114 $panoscenes["scene-attachment-url-face3"],
1115 $panoscenes["scene-attachment-url-face4"],
1116 $panoscenes["scene-attachment-url-face5"]
1117 );
1118
1119 $scene_info = array("type" => $panoscenes["scene-type"], "cubeMap" => $pano_attachment, "pitch" => $default_scene_pitch, "maxPitch" => $scene_max_pitch, "minPitch" => $scene_min_pitch, "maxYaw" => $scene_max_yaw, "minYaw" => $scene_min_yaw, "yaw" => $default_scene_yaw, "hfov" => $default_zoom, "maxHfov" => $max_zoom, "minHfov" => $min_zoom, "title" => $scene_ititle, "author" => $scene_author, "authorURL" => $scene_author_url, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, "hotSpots" => $hotspots);
1120 } else {
1121 $scene_info = array("type" => $panoscenes["scene-type"], "panorama" => $device_scene, "pitch" => $default_scene_pitch, "maxPitch" => $scene_max_pitch, "minPitch" => $scene_min_pitch, "maxYaw" => $scene_max_yaw, "minYaw" => $scene_min_yaw, "yaw" => $default_scene_yaw, "hfov" => $default_zoom, "maxHfov" => $max_zoom, "minHfov" => $min_zoom, "title" => $scene_ititle, "author" => $scene_author, "authorURL" => $scene_author_url, "vaov" => $scene_vaov, "haov" => $scene_haov, "vOffset" => $scene_vertical_offset, "hotSpots" => $hotspots);
1122 }
1123
1124
1125 if (isset($panoscenes["ptyscene"])) {
1126 if ($panoscenes["ptyscene"] == "off") {
1127 unset($scene_info['pitch']);
1128 unset($scene_info['yaw']);
1129 }
1130 }
1131
1132 if (empty($panoscenes["scene-ititle"])) {
1133 unset($scene_info['title']);
1134 }
1135 if (empty($panoscenes["scene-author"])) {
1136 unset($scene_info['author']);
1137 }
1138 if (empty($panoscenes["scene-author-url"])) {
1139 unset($scene_info['authorURL']);
1140 }
1141
1142 if (empty($scene_vaov)) {
1143 unset($scene_info['vaov']);
1144 }
1145
1146 if (empty($scene_haov)) {
1147 unset($scene_info['haov']);
1148 }
1149
1150 if (empty($scene_vertical_offset)) {
1151 unset($scene_info['vOffset']);
1152 }
1153
1154 if (isset($panoscenes["cvgscene"])) {
1155 if ($panoscenes["cvgscene"] == "off") {
1156 unset($scene_info['maxPitch']);
1157 unset($scene_info['minPitch']);
1158 }
1159 }
1160 if (empty($panoscenes["scene-maxpitch"])) {
1161 unset($scene_info['maxPitch']);
1162 }
1163
1164 if (empty($panoscenes["scene-minpitch"])) {
1165 unset($scene_info['minPitch']);
1166 }
1167
1168 if (isset($panoscenes["chgscene"])) {
1169 if ($panoscenes["chgscene"] == "off") {
1170 unset($scene_info['maxYaw']);
1171 unset($scene_info['minYaw']);
1172 }
1173 }
1174 if (empty($panoscenes["scene-maxyaw"])) {
1175 unset($scene_info['maxYaw']);
1176 }
1177
1178 if (empty($panoscenes["scene-minyaw"])) {
1179 unset($scene_info['minYaw']);
1180 }
1181
1182 // if (isset($panoscenes["czscene"])) {
1183 // if ($panoscenes["czscene"] == "off") {
1184 // unset($scene_info['hfov']);
1185 // unset($scene_info['maxHfov']);
1186 // unset($scene_info['minHfov']);
1187 // }
1188 // }
1189
1190 $scene_array = array();
1191 $scene_array = array(
1192 $panoscenes["scene-id"] => $scene_info
1193 );
1194 $scene_data[$panoscenes["scene-id"]] = $scene_info;
1195 }
1196 }
1197
1198 $pano_id_array = array();
1199 $pano_id_array = array("panoid" => $panoid);
1200 $pano_response = array();
1201 $pano_response = array("autoLoad" => $autoload, "showControls" => $control, "orientationSupport" => 'false', "compass" => $compass, 'orientationOnByDefault' => $gyro_orientation, "mouseZoom" => $mouseZoom, "draggable" => $draggable, 'disableKeyboardCtrl' => $diskeyboard, 'keyboardZoom' => $keyboardzoom, "preview" => $preview, "autoRotate" => $autorotation, "autoRotateInactivityDelay" => $autorotationinactivedelay, "autoRotateStopDelay" => $autorotationstopdelay, "default" => $default_data, "scenes" => $scene_data);
1202 if (empty($autorotation)) {
1203 unset($pano_response['autoRotate']);
1204 unset($pano_response['autoRotateInactivityDelay']);
1205 unset($pano_response['autoRotateStopDelay']);
1206 }
1207 if (empty($autorotationinactivedelay)) {
1208 unset($pano_response['autoRotateInactivityDelay']);
1209 }
1210 if (empty($autorotationstopdelay)) {
1211 unset($pano_response['autoRotateStopDelay']);
1212 }
1213 $response = array();
1214 $response = array($pano_id_array, $pano_response);
1215 if (!empty($response)) {
1216 $response = json_encode($response);
1217 }
1218
1219
1220 if (empty($width)) {
1221 $width = '600px';
1222 }
1223 if (empty($height)) {
1224 $height = '400px';
1225 }
1226 $foreground_color = '#fff';
1227 $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1228 $rgb = wpvr_HTMLToRGB($hotspoticoncolor);
1229 $hsl = wpvr_RGBToHSL($rgb);
1230 if ($hsl->lightness > 200) {
1231 $foreground_color = '#000000';
1232 } else {
1233 $foreground_color = '#fff';
1234 }
1235 $html = '';
1236
1237 $html .= '<style>';
1238 if ($width == 'embed') {
1239 $html .= 'body{
1240 overflow: hidden;
1241 }';
1242 }
1243 $status = get_option('wpvr_edd_license_status');
1244 if ($status !== false && $status == 'valid') {
1245 if(isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on'){
1246 $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
1247 }
1248 }
1249 $panoid2 = 'pano2'.$id;
1250 $status = get_option('wpvr_edd_license_status');
1251 if ($status !== false && $status == 'valid') {
1252 foreach ($panodata['scene-list'] as $panoscenes){
1253
1254 foreach($panoscenes['hotspot-list'] as $hotspot){
1255 if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1256 $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1257 } else {
1258 $hotspoticoncolor = "#00b4ff";
1259 }
1260 $hotspot_border = '';
1261 if(isset($hotspot['hotspot-border']) && $hotspot['hotspot-border'] == 'on'){
1262 $border_width = $hotspot['hotspot-border-width'];
1263 $border_color = $hotspot['hotspot-border-color'];
1264 $border_style = $hotspot['hotspot-border-style'];
1265 $hotspot_border = 'border: '.$border_width.'px '.$border_style.' '.$border_color.';';
1266 }
1267 $hotspot_background_color = 'background-color: ' . $hotspoticoncolor . ';';
1268 $hotspot_animation = ' animation: icon-pulse' . $panoid . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1269 '. $hotspot_border.'';
1270 $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1271 if (isset($hotspot["hotspot-customclass-pro"]) && $hotspot["hotspot-customclass-pro"] != 'none') {
1272 $border_radius = ' border-radius: 100%;';
1273 $hotspot_shape = isset($hotspot["hotspot-shape"]) ? $hotspot["hotspot-shape"] : 'round';
1274 if($hotspot_shape === 'square'){
1275 $border_radius = '';
1276 }
1277 if ($hotspot_shape === 'hexagon') {
1278 $border_radius = '';
1279 $hotspot_background_color = 'background-color: transparent;';
1280 $hotspot_animation = '';
1281 }
1282
1283 if(isset($hotspot['hotspot-custom-icon-color-value']) && !empty($hotspot['hotspot-custom-icon-color-value'])){
1284 $foreground_color = $hotspot['hotspot-custom-icon-color-value'];
1285 }
1286
1287 $html .= '#' . $panoid . ' div.pnlm-hotspot-base.fas.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1288 #' . $panoid . ' div.pnlm-hotspot-base.fab.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1289 #' . $panoid . ' div.pnlm-hotspot-base.fa-solid.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1290 #' . $panoid . ' div.pnlm-hotspot-base.fa.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1291 #' . $panoid . ' div.pnlm-hotspot-base.far.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).' {
1292 display: block !important;
1293 '.$hotspot_background_color.'
1294 color: ' . $foreground_color . ';
1295 '.$border_radius.'
1296 width: 30px;
1297 height: 30px;
1298 font-size: 16px;
1299 line-height: 30px;
1300 '.$hotspot_animation.'
1301 }';
1302
1303 if($hotspot_shape === 'hexagon'){
1304
1305 $html .= '#' . $panoid . ' .custom-' . $id . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' .hexagon-wrapper svg path {
1306 fill: ' . $hotspoticoncolor . ';
1307 }';
1308
1309 $html .= '#' . $panoid . ' .custom-' . $id . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . '.pnlm-tooltip:after{
1310 content: "";
1311 position: absolute;
1312 left: 50%;
1313 top: 50%;
1314 transform: translate(-50%, -50%);
1315 width: 85%;
1316 height: 85%;
1317 animation: icon-pulse' . $panoid . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1318 border-radius: 100%;
1319 z-index: -2;
1320 }';
1321
1322 }
1323
1324 $html .= '#' . $panoid2 . ' div.pnlm-hotspot-base.fas.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1325 #' . $panoid2 . ' div.pnlm-hotspot-base.fab.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1326 #' . $panoid2 . ' div.pnlm-hotspot-base.fa-solid.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1327 #' . $panoid2 . ' div.pnlm-hotspot-base.fa.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).',
1328 #' . $panoid2 . ' div.pnlm-hotspot-base.far.custom-' . $id.'-' . $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']).' {
1329 display: block !important;
1330 '.$hotspot_background_color.'
1331 color: ' . $foreground_color . ';
1332 '.$border_radius.'
1333 width: 30px;
1334 height: 30px;
1335 font-size: 16px;
1336 line-height: 30px;
1337 '.$hotspot_animation.'
1338 }';
1339 }
1340 if (isset($hotspot['hotspot-blink'])) {
1341 $hotspotblink = $hotspot['hotspot-blink'];
1342 if ($hotspotblink == 'on') {
1343 $html .= '@-webkit-keyframes icon-pulse' .$panoid .'-'. $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']) .' {
1344 0% {
1345 box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1);
1346 }
1347 100% {
1348 box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0);
1349 }
1350 }
1351 @keyframes icon-pulse' . $panoid . ' {
1352 0% {
1353 box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1);
1354 }
1355 100% {
1356 box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0);
1357 }
1358 }';
1359 $html .= '@-webkit-keyframes icon-pulse' .$panoid2 .'-'. $panoscenes['scene-id'] .'-'. sanitize_html_class($hotspot['hotspot-title']) .' {
1360 0% {
1361 box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1);
1362 }
1363 100% {
1364 box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0);
1365 }
1366 }
1367 @keyframes icon-pulse' . $panoid . ' {
1368 0% {
1369 box-shadow: 0 0 0 0px rgba(' . $pulse_color[0] . ', 1);
1370 }
1371 100% {
1372 box-shadow: 0 0 0 10px rgba(' . $pulse_color[0] . ', 0);
1373 }
1374 }';
1375 }
1376 }
1377
1378 }
1379
1380 }
1381
1382 }
1383
1384 $status = get_option('wpvr_edd_license_status');
1385 if ($status !== false && $status == 'valid') {
1386 if (!$gyro) {
1387 $html .= '#' . $panoid . ' div.pnlm-orientation-button {
1388 display: none;
1389 }';
1390 }
1391 } else {
1392 $html .= '#' . $panoid . ' div.pnlm-orientation-button {
1393 display: none;
1394 }';
1395 }
1396 $floor_plan_custom_color = isset($postdata['floor_plan_custom_color']) ? $postdata['floor_plan_custom_color'] : '#cca92c';
1397 $foreground_color_pointer = '#fff';
1398 if($floor_plan_custom_color != ''){
1399 $pointer_pulse = wpvr_hex2rgb($floor_plan_custom_color);
1400 $floor_rgb = wpvr_HTMLToRGB($floor_plan_custom_color);
1401 $floor_hsl = wpvr_RGBToHSL($floor_rgb);
1402 if ($floor_hsl->lightness > 200) {
1403 $foreground_color_pointer = '#000000';
1404 }
1405 $html .= '
1406 .wpvr-floor-map .floor-plan-pointer.add-pulse:before {
1407 border: 17px solid '.$floor_plan_custom_color.';
1408 }
1409 @-webkit-keyframes pulse {
1410 0% {
1411 -webkit-box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0.7);
1412 }
1413 70% {
1414 -webkit-box-shadow: 0 0 0 10px rgba('.$pointer_pulse[0].', 0);
1415 }
1416 100% {
1417 -webkit-box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0);
1418 }
1419 }
1420 @keyframes pulse {
1421 0% {
1422 -moz-box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0.7);
1423 box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0.7);
1424 }
1425 70% {
1426 -moz-box-shadow: 0 0 0 10px rgba('.$pointer_pulse[0].', 0);
1427 box-shadow: 0 0 0 10px rgba('.$pointer_pulse[0].', 0);
1428 }
1429 100% {
1430 -moz-box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0);
1431 box-shadow: 0 0 0 0 rgba('.$pointer_pulse[0].', 0);
1432 }
1433 }';
1434 }
1435
1436 $html .= '</style>';
1437
1438
1439 $scene_animation = isset($postdata['sceneAnimation']) ? $postdata['sceneAnimation'] : 'off';
1440
1441 if( $scene_animation === 'on' && is_plugin_active( 'wpvr-pro/wpvr-pro.php' ) ) {
1442 $animation_type = isset($postdata['sceneAnimationName']) ? $postdata['sceneAnimationName'] : 'none';
1443 $animationDuration = isset($postdata['sceneAnimationTransitionDuration']) ? $postdata['sceneAnimationTransitionDuration'] : '500ms';
1444 $animationDelay = isset($postdata['sceneAnimationTransitionDelay']) ? $postdata['sceneAnimationTransitionDelay'] : '0ms';
1445 $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration,$animationDelay,$postdata,$id);
1446 $html .= $animation_css;
1447 }
1448
1449 if ($width == 'fullwidth') {
1450 $width = "100%";
1451 }
1452
1453 if (wpvr_isMobileDevice()) {
1454 $html .= '<div id="master-container" class="wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $width . '; width: 100%; height: ' . $mobile_height . '; border-radius:' . $radius . '; direction:ltr; ">';
1455 } else {
1456 $html .= '<div id="master-container" class="wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $width . '; width: 100%; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr; ">';
1457 }
1458 $is_pro = apply_filters('is_wpvr_pro_active',false);
1459 $status = get_option('wpvr_edd_license_status');
1460 $is_cardboard = get_option('wpvr_cardboard_disable');
1461 if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true' ) {
1462 $html .= '<button class="fullscreen-button">';
1463 $html .= '<span class="expand">';
1464 $html .= '<i class="fas fa-expand" aria-hidden="true"></i>';
1465 $html .= '</span>';
1466
1467 $html .= '<span class="compress">';
1468 $html .= '<i class="fas fa-minimize" aria-hidden="true"></i>';
1469 $html .= '</span>';
1470 $html .= '</button>';
1471 $embed_mode = '';
1472 if($width == "embed"){
1473 $embed_mode = "vr-embade-mode";
1474 }
1475 $html .= '<label class="wpvr-cardboard-switcher '.$embed_mode.'">
1476 <input type="checkbox" class="vr_mode_change' . $id . '" name="vr_mode_change" value="off">
1477 <span class="switcher-box">
1478 <span class="normal-mode-tooltip">Normal VR Mode</span>
1479 <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1480 <path d="M42.25 21.4286C42.25 22.2811 41.9076 23.0986 41.2981 23.7014C40.6886 24.3042 39.862 24.6429 39 24.6429C38.138 24.6429 37.3114 24.3042 36.7019 23.7014C36.0924 23.0986 35.75 22.2811 35.75 21.4286C35.75 20.5761 36.0924 19.7585 36.7019 19.1557C37.3114 18.5529 38.138 18.2143 39 18.2143C39.862 18.2143 40.6886 18.5529 41.2981 19.1557C41.9076 19.7585 42.25 20.5761 42.25 21.4286ZM19.5 30C18.9254 30 18.3743 30.2258 17.9679 30.6276C17.5616 31.0295 17.3333 31.5745 17.3333 32.1429C17.3333 32.7112 17.5616 33.2562 17.9679 33.6581C18.3743 34.06 18.9254 34.2857 19.5 34.2857H28.1667C28.7413 34.2857 29.2924 34.06 29.6987 33.6581C30.1051 33.2562 30.3333 32.7112 30.3333 32.1429C30.3333 31.5745 30.1051 31.0295 29.6987 30.6276C29.2924 30.2258 28.7413 30 28.1667 30H19.5ZM47.6667 32.1429C47.6667 31.5745 47.8949 31.0295 48.3013 30.6276C48.7076 30.2258 49.2587 30 49.8333 30H58.5C59.0746 30 59.6257 30.2258 60.0321 30.6276C60.4384 31.0295 60.6667 31.5745 60.6667 32.1429C60.6667 32.7112 60.4384 33.2562 60.0321 33.6581C59.6257 34.06 59.0746 34.2857 58.5 34.2857H49.8333C49.2587 34.2857 48.7076 34.06 48.3013 33.6581C47.8949 33.2562 47.6667 32.7112 47.6667 32.1429ZM32.5 0C31.9254 0 31.3743 0.225765 30.9679 0.627629C30.5616 1.02949 30.3333 1.57454 30.3333 2.14286V8.57143H18.4167C14.8693 8.57183 11.4528 9.89617 8.84994 12.2798C6.24706 14.6634 4.64954 17.9306 4.37667 21.4286H2.16667C1.59203 21.4286 1.04093 21.6543 0.634602 22.0562C0.228273 22.4581 0 23.0031 0 23.5714V36.4286C0 36.9969 0.228273 37.5419 0.634602 37.9438C1.04093 38.3457 1.59203 38.5714 2.16667 38.5714H4.33333V46.0714C4.33333 49.7655 5.81711 53.3083 8.45825 55.9204C11.0994 58.5325 14.6815 60 18.4167 60H25.3933C29.1269 59.9986 32.7071 58.5311 35.347 55.92L37.921 53.3786C38.0618 53.2393 38.229 53.1288 38.4131 53.0534C38.5971 52.978 38.7943 52.9392 38.9935 52.9392C39.1927 52.9392 39.3899 52.978 39.5739 53.0534C39.758 53.1288 39.9252 53.2393 40.066 53.3786L42.6357 55.92C45.2766 58.5322 48.8586 59.9998 52.5937 60H59.5833C63.3185 60 66.9006 58.5325 69.5418 55.9204C72.1829 53.3083 73.6667 49.7655 73.6667 46.0714V38.5714H75.8333C76.408 38.5714 76.9591 38.3457 77.3654 37.9438C77.7717 37.5419 78 36.9969 78 36.4286V23.5714C78 23.0031 77.7717 22.4581 77.3654 22.0562C76.9591 21.6543 76.408 21.4286 75.8333 21.4286H73.6233C73.3505 17.9306 71.753 14.6634 69.1501 12.2798C66.5472 9.89617 63.1307 8.57183 59.5833 8.57143H47.6667V2.14286C47.6667 1.57454 47.4384 1.02949 47.0321 0.627629C46.6257 0.225765 46.0746 0 45.5 0H32.5ZM69.3333 22.5V46.0714C69.3333 48.6289 68.3061 51.0816 66.4776 52.89C64.6491 54.6983 62.1692 55.7143 59.5833 55.7143H52.5937C50.0093 55.7132 47.5311 54.6973 45.7037 52.89L43.1297 50.3486C42.5864 49.8108 41.9413 49.3842 41.2312 49.0931C40.5211 48.8021 39.76 48.6522 38.9913 48.6522C38.2227 48.6522 37.4616 48.8021 36.7515 49.0931C36.0414 49.3842 35.3963 49.8108 34.853 50.3486L32.2833 52.89C30.4559 54.6973 27.9777 55.7132 25.3933 55.7143H18.4167C15.8308 55.7143 13.3509 54.6983 11.5224 52.89C9.6939 51.0816 8.66667 48.6289 8.66667 46.0714V22.5C8.66667 19.9426 9.6939 17.4899 11.5224 15.6815C13.3509 13.8731 15.8308 12.8571 18.4167 12.8571H59.5833C62.1692 12.8571 64.6491 13.8731 66.4776 15.6815C68.3061 17.4899 69.3333 19.9426 69.3333 22.5Z" fill="#216DF0"/>
1481 </svg>
1482 </span>
1483 </label>';
1484
1485 }
1486
1487 if ($width == 'fullwidth') {
1488 if (wpvr_isMobileDevice()) {
1489 $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
1490 $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left cardboard-half" style="width: 49%!important; border-radius:' . $radius . ' text-align:center; direction:ltr;" ><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1491 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%; text-align:center; direction:ltr; border-radius:' . $radius . '" >';
1492 } else {
1493 $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1494 if ($radius) {
1495 $html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr;" >';
1496 } else {
1497 $html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; direction:ltr;" >';
1498 }
1499 }
1500 } elseif ($width == 'embed') {
1501 $html .= '<div class="cardboard-vrembed vrembed">';
1502 $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style=" width: 49%!important; text-align:center; direction:ltr;" ><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1503 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" text-align:center; direction:ltr;" >';
1504 } else {
1505 if (wpvr_isMobileDevice()) {
1506 $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left cardboard-half" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1507 if ($radius) {
1508 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" width: 100%; border-radius:' . $radius . ';">';
1509 } else {
1510 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" width: 100%; ">';
1511 }
1512 } else {
1513 $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1514
1515 if ($radius) {
1516 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%; border-radius:' . $radius . ';">';
1517 } else {
1518 $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%;">';
1519 }
1520 }
1521 }
1522 // Vr mode transction scene to scene
1523 if ($status !== false && 'valid' == $status && $is_pro) {
1524 $html .= '<div id="center-pointer' . $id . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
1525 }
1526 $social_logo_top = '';
1527 //===company logo===//
1528 if (isset($postdata['cpLogoSwitch'])) {
1529 $cpLogoImg = $postdata['cpLogoImg'];
1530 $cpLogoContent = $postdata['cpLogoContent'];
1531 if ($postdata['cpLogoSwitch'] == 'on' && 'valid' == $status && $is_pro) {
1532 $html .= '<div id="cp-logo-controls">';
1533 $html .= '<div class="cp-logo-ctrl" id="cp-logo">';
1534 if ($cpLogoImg) {
1535 $social_logo_top = '50px';
1536 $html .= '<img loading="lazy" src="' . $cpLogoImg . '" alt="Company Logo">';
1537 }
1538
1539 if ($cpLogoContent) {
1540 $html .= '<div class="cp-info">' . esc_attr($cpLogoContent) . '</div>';
1541 }
1542 $html .= '</div>';
1543 $html .= '</div>';
1544 }
1545 }
1546 //===company logo ends===//
1547
1548 //===Generic Form===//
1549 if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on' && 'valid' == $status && $is_pro) {
1550 // Process shortcode with fallback handling
1551 $shortcode_content = '';
1552 if (isset($postdata["genericformshortcode"]) && !empty(trim($postdata["genericformshortcode"]))) {
1553 $shortcode_content = do_shortcode( $postdata["genericformshortcode"] );
1554 } else {
1555 $shortcode_content = '<p class="error-message">No shortcode found.</p>';
1556 }
1557
1558 // Generate the form trigger button
1559 $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr($id) . '">';
1560 $html .= '<div class="generic-form-icon" title ="Generic Form" id="generic_form_target_' . esc_attr($id) . '"><i class="fab fa-wpforms" style="color:#f7fffb;"></i></div>';
1561 $html .= '</div>';
1562
1563 // Generate the modal form container
1564 $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr($id) . '" style="display: none">';
1565 $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
1566 $html .= '<div class="generic-form-container">' . $shortcode_content . '</div>';
1567 $html .= '</div>';
1568 }
1569 //===Generic Form ends===//
1570
1571 //===Background Tour===//
1572 if (isset($postdata['bg_tour_enabler'])) {
1573
1574 $bg_tour_enabler = $postdata['bg_tour_enabler'];
1575 if ($bg_tour_enabler == 'on') {
1576 $bg_tour_navmenu = $postdata['bg_tour_navmenu'] ?? 'off';
1577 $bg_tour_title = $postdata['bg_tour_title'] ?? '';
1578 $bg_tour_subtitle = $postdata['bg_tour_subtitle'] ?? '';
1579
1580 if ($bg_tour_navmenu == 'on') {
1581 $menuLocations = get_nav_menu_locations();
1582 if (!empty($menuLocations['primary'])) {
1583 $menuID = $menuLocations['primary'];
1584 $primaryNav = wp_get_nav_menu_items($menuID);
1585 $html .= '<ul class="wpvr-navbar-container">';
1586 foreach ($primaryNav as $primaryNav_key => $primaryNav_value) {
1587 if ($primaryNav_value->menu_item_parent == "0") {
1588 $html .= '<li>';
1589 $html .= '<a href="' . $primaryNav_value->url . '">' . $primaryNav_value->title . '</a>';
1590 $html .= '<ul class="wpvr-navbar-dropdown">';
1591 foreach ($primaryNav as $pm_key => $pm_value) {
1592 if ($pm_value->menu_item_parent == $primaryNav_value->ID) {
1593 $html .= '<li>';
1594 $html .= '<a href="' . $pm_value->url . '">' . $pm_value->title . '</a>';
1595 $html .= '</li>';
1596 }
1597 }
1598 $html .= '</ul>';
1599 $html .= '</li>';
1600 }
1601 }
1602 $html .= '</ul>';
1603 }
1604 }
1605 if($is_pro && 'valid' == $status ){
1606 $html .= '<div class="wpvr-home-content">';
1607 $html .= '<div class="wpvr-home-title">' . $bg_tour_title . '</div>';
1608 $html .= '<div class="wpvr-home-subtitle">' . $bg_tour_subtitle . '</div>';
1609 $html .= '</div>';
1610 }
1611 }
1612 }
1613 //===Background Tour End===//
1614
1615 //===Custom Control===//
1616 if (isset($custom_control)) {
1617 if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || ( $custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on") || $custom_control['backToHomeSwitch'] == "on") {
1618 $html .= '<div id="zoom-in-out-controls' . $id . '" class="zoom-in-out-controls">';
1619
1620 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
1621 $html .= '<div class="ctrl" id="backToHome' . $id . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . $custom_control['backToHomeColor'] . ';"></i></div>';
1622 }
1623
1624 if ($custom_control['panZoomInSwitch'] == "on" && 'valid' == $status && $is_pro) {
1625 $html .= '<div class="ctrl" id="zoom-in' . $id . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . $custom_control['panZoomInColor'] . ';"></i></div>';
1626 }
1627
1628 if ($custom_control['panZoomOutSwitch'] == "on" && 'valid' == $status && $is_pro) {
1629 $html .= '<div class="ctrl" id="zoom-out' . $id . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . $custom_control['panZoomOutColor'] . ';"></i></div>';
1630 }
1631 if ($custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on" && 'valid' == $status && $is_pro) {
1632 $html .= '<div class="ctrl" id="gyroscope' . $id . '" ><i class="' . $custom_control['gyroscopeIcon'] . '" id="' . $custom_control['gyroscopeIcon'] . '" style="color:' . $custom_control['gyroscopeColor'] . ';"></i></div>';
1633 }
1634 $html .= '</div>';
1635 }
1636 //===zoom in out Control===//
1637
1638 if (($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on" ) && 'valid' == $status && $is_pro) {
1639 //===Custom Control===//
1640 $html .= '<div class="controls" id="controls' . $id . '">';
1641
1642 if ($custom_control['panupSwitch'] == "on") {
1643 $html .= '<div class="ctrl pan-up" id="pan-up' . $id . '"><i class="' . $custom_control['panupIcon'] . '" style="color:' . $custom_control['panupColor'] . ';"></i></div>';
1644 }
1645
1646 if ($custom_control['panDownSwitch'] == "on") {
1647 $html .= '<div class="ctrl pan-down" id="pan-down' . $id . '"><i class="' . $custom_control['panDownIcon'] . '" style="color:' . $custom_control['panDownColor'] . ';"></i></div>';
1648 }
1649
1650 if ($custom_control['panLeftSwitch'] == "on") {
1651 $html .= '<div class="ctrl pan-left" id="pan-left' . $id . '"><i class="' . $custom_control['panLeftIcon'] . '" style="color:' . $custom_control['panLeftColor'] . ';"></i></div>';
1652 }
1653
1654 if ($custom_control['panRightSwitch'] == "on") {
1655 $html .= '<div class="ctrl pan-right" id="pan-right' . $id . '"><i class="' . $custom_control['panRightIcon'] . '" style="color:' . $custom_control['panRightColor'] . ';"></i></div>';
1656 }
1657
1658 if ($custom_control['panFullscreenSwitch'] == "on") {
1659 $html .= '<div class="ctrl fullscreen" id="fullscreen' . $id . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . $custom_control['panFullscreenColor'] . ';"></i></div>';
1660 }
1661 $html .= '</div>';
1662 }
1663 }
1664 //===Custom Control===//
1665
1666 //===explainer button===//
1667 $html .= wpvr_render_explainer_button(
1668 isset( $custom_control ) ? $custom_control : null,
1669 $postdata,
1670 $is_pro,
1671 $autoload,
1672 $explainer_right,
1673 $id
1674 );
1675 //===explainer button end===//
1676
1677 //===Floor map button===//
1678 $status = get_option('wpvr_edd_license_status');
1679 if ($status !== false && 'valid' == $status && $is_pro){
1680 if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
1681 $html .= '<div class="floor_map_button" id="floor_map_button_' . $id . '" style="right:'.$floor_map_right.'">';
1682 $html .= '<div class="ctrl" id="floor_map_target_' . $id . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1683 $html .= '</div>';
1684 }
1685 }
1686 //===floor map button===//
1687
1688 if ($vrgallery && 'valid' == $status && $is_pro ) {
1689 //===Carousal setup===//
1690 $size = '';
1691 if($vrgallery_icon_size){
1692 $size = 'vrg-icon-size-large';
1693 }
1694 $html .= '<div id="vrgcontrols' . $id . '" class="vrgcontrols">';
1695
1696 $html .= '<div class="vrgctrl' . $id . ' vrbounce '.$size.'">';
1697 $html .= '</div>';
1698 $html .= '</div>';
1699
1700 $html .= '<div id="sccontrols' . $id . '" class="scene-gallery vrowl-carousel owl-theme ">';
1701 if (isset($panodata["scene-list"])) {
1702 foreach ($panodata["scene-list"] as $panoscenes) {
1703 $scene_key = $panoscenes['scene-id'];
1704
1705 if ($vrgallery_title == 'on') {
1706 $scene_key_title = isset($panoscenes['scene-ititle']) ? sanitize_text_field($panoscenes['scene-ititle']) : '';
1707 } else {
1708 $scene_key_title = "";
1709 }
1710
1711 if ($panoscenes['scene-type'] == 'cubemap') {
1712 $img_src_url = $panoscenes['scene-attachment-url-face0'];
1713 } else {
1714 $img_src_url = $panoscenes['scene-attachment-url'];
1715 }
1716
1717 $src_to_id = attachment_url_to_postid($img_src_url);
1718 $thumbnail_array = wp_get_attachment_image_src($src_to_id, 'thumbnail');
1719 if ($thumbnail_array) {
1720 $thumbnail = $thumbnail_array[0];
1721 } else {
1722 $thumbnail = $img_src_url;
1723 }
1724
1725 if( isset($postdata['tourLayout']['layout']) && 'layout1' !== $postdata['tourLayout']['layout']) {
1726 $html .= '<ul><li title="Double click to view scene"><span class="scene-title" title="' . esc_attr($scene_key_title) . '">' . $scene_key_title . '</span><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"></li></ul>';
1727 }else {
1728 $html .= '<ul><li title="Double click to view scene"><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"><span class="scene-title" title="' . esc_attr($scene_key_title) . '">' . $scene_key_title . '</span></li></ul>';
1729 }
1730 }
1731 }
1732
1733 $html .= '</div>';
1734
1735 $html .= '
1736 <div class="owl-nav wpvr_slider_nav">
1737 <button type="button" role="presentation" class="owl-prev wpvr_owl_prev">
1738 <div class="nav-btn prev-slide"><i class="fa fa-angle-left"></i></div>
1739 </button>
1740 <button type="button" role="presentation" class="owl-next wpvr_owl_next">
1741 <div class="nav-btn next-slide"><i class="fa fa-angle-right"></i></div>
1742 </button>
1743 </div>
1744 ';
1745
1746 //===Carousal setup end===//
1747 }
1748
1749 //===Call TO action Button===//
1750 $bg_music = isset($postdata['bg_music']) ? $postdata['bg_music'] : 'off';
1751 $bg_music_url = isset($postdata['bg_music_url']) ? $postdata['bg_music_url'] : '';
1752 $autoplay_bg_music = isset($postdata['autoplay_bg_music']) ? $postdata['autoplay_bg_music'] : 'off';
1753 $loop_bg_music = isset($postdata['loop_bg_music']) ? $postdata['loop_bg_music'] : 'off';
1754
1755 $bg_loop = ($loop_bg_music === 'on') ? 'loop' : '';
1756 $autoplay_attr = ($autoplay_bg_music === 'on') ? 'autoplay' : '';
1757 $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
1758 $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
1759
1760 if ($bg_music === 'on' && 'valid' == $status && $is_pro) {
1761 $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1762 $html .= '<audio id="vrAudio' . esc_attr($id) . '" class="vrAudioDefault" data-autoplay="' . esc_attr($autoplay_bg_music) . '" onended="audionEnd' . esc_attr($id) . '()" ' . $autoplay_attr . ' ' . $audio_muted_attr . ' ' . $bg_loop . '>
1763 <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
1764 Your browser does not support the audio element.
1765 </audio>';
1766 $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
1767 <i id="vr-volume' . esc_attr($id) . '" class="wpvrvolumeicon' . esc_attr($id) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
1768 </button>';
1769 $html .= '</div>';
1770 }
1771 //===Explainer video section===//
1772 $explainerContent = "";
1773 if (isset($postdata['explainerContent'])) {
1774 $explainerContent = $this->wpvr_sanitize_iframe_only($postdata['explainerContent']);
1775 }
1776 $html .= '<div class="explainer" id="explainer' . $id . '" style="display: none">';
1777 $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
1778 $html .= '' . $explainerContent . '';
1779 $html .= '</div>';
1780 //===Explainer video section End===//
1781
1782 //===Scene navigation Control===//
1783 if (isset($postdata['scene_navigation']) && $postdata['scene_navigation'] === 'on' && 'valid' == $status && $is_pro) {
1784 $html .= '<style>
1785 #et-boc .et-l .pnlm-controls-container,
1786 .pnlm-controls-container{
1787 top: 33px;
1788 }
1789
1790 #et-boc .et-l .zoom-in-out-controls,
1791 .zoom-in-out-controls {
1792 top: 37px;
1793 }
1794 </style>';
1795 $html .= '<div id="custom-scene-navigation' . $id . '" class="custom-scene-navigation">
1796 <span class="hamburger-menu"><svg width="16" height="10" fill="none" viewBox="0 0 22 15" xmlns="http://www.w3.org/2000/svg"><rect width="21.177" height="2.647" fill="#f7fffb" rx="1.324"/><rect width="21.177" height="2.647" y="6.177" fill="#f7fffb" rx="1.324"/><rect width="21.177" height="2.647" y="12.352" fill="#f7fffb" rx="1.324"/></svg></span>
1797 </div>
1798
1799 <div id="custom-scene-navigation-nav' . $id . '" class="custom-scene-navigation-nav">
1800 <ul></ul>
1801 </div>
1802 ';
1803 }
1804 //===Scene navigation Control===//
1805
1806
1807 if( 'embed' === $width){
1808 if(WPVR_Helper::is_enable_social_share($postdata) === 'on'){
1809 $html .= '<div id="wpvr-social-share-bg-box'.$id.'" class="wpvr-social-share-bg-box" style="top:'.$social_logo_top.'">
1810 <span class="share-btn-svg"><svg fill="none" viewBox="0 0 24 24" width="24" height="24" ><path fill="#1F1CF4" d="M18.4 2.4a3.2 3.2 0 00-3.2 3.2 3.2 3.2 0 00.075.67L8.01 9.901A3.2 3.2 0 005.6 8.8a3.2 3.2 0 101.325 6.112 3.2 3.2 0 001.086-.812l7.261 3.632a3.2 3.2 0 101.803-2.242c-.415.189-.786.466-1.085.81l-7.261-3.63A3.2 3.2 0 008.8 12a3.2 3.2 0 00-.075-.667L15.991 7.7a3.2 3.2 0 002.41 1.1 3.2 3.2 0 100-6.4z"/></svg></span>
1811 <nav class="wpvr-share-nav">
1812 '.WPVR_Helper::social_media_share_links_display_in_embed(home_url().'/?embed_page='. $id).'
1813 </nav>
1814 </div>';
1815 }
1816 }
1817 //===Floor plan section===//
1818 $floor_map_image = "";
1819 $floor_map_pointer = array();
1820 $floor_map_scene_id = '';
1821 $floor_plan_custom_color = '#cca92c';
1822 $floor_plan_direction_indicator = isset($postdata['floor_plan_direction_indicator']) ? $postdata['floor_plan_direction_indicator'] : 'on';
1823
1824 if (isset($postdata['floor_plan_attachment_url'])) {
1825 $floor_map_image = $postdata['floor_plan_attachment_url'];
1826 $floor_map_pointer = $postdata['floor_plan_pointer_position'];
1827 $floor_map_scene_id = $postdata['floor_plan_data_list'];
1828 $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
1829 }
1830 $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
1831 $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
1832 $html .= '<img loading="lazy" src="'.$floor_map_image.'">';
1833 foreach($floor_map_pointer as $key=> $pointer_position){
1834 $html .= '<div class="floor-plan-pointer ui-draggable ui-draggable-handle" scene_id = "'.$floor_map_scene_id[$key]->value.'" id="'.$pointer_position->id.'" data-top="'.$pointer_position->data_top.'" data-left="'.$pointer_position->data_left.'" style="'.$pointer_position->style.'">
1835 <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1836 <circle cx="12" cy="12" r="11.5" stroke="'.$floor_plan_custom_color.'"/>
1837 <circle cx="12" cy="12" r="5" fill="'.$foreground_color_pointer.'"/>
1838 </svg>';
1839
1840 // Only add the floor pointer flash SVG if floor_plan_direction_indicator is "on"
1841 if ($floor_plan_direction_indicator === "on") {
1842 $html .= '<svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
1843 <path d="M0.454054 1.32433L11.7683 34.3243C11.9069 34.7285 12.287 35 12.7143 35H41.2857C41.713 35 42.0931 34.7285 42.2317 34.3243L53.5459 1.32432C53.7685 0.675257 53.2862 0 52.6 0H1.4C0.713843 0 0.231517 0.675258 0.454054 1.32433Z" fill="url(#paint0_linear_1_10)"/>
1844 <defs>
1845 <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
1846 <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
1847 <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
1848 </linearGradient>
1849 </defs>
1850 </svg>';
1851 }
1852 $html .= '</div>';
1853 }
1854 $html .= '</div>';
1855 //===Floor plan section===//
1856
1857 $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
1858 $html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>';
1859 $html .= '<div class="wpvr-hotspot-tweak-contents-flex">';
1860 $html .= '<div class="wpvr-hotspot-tweak-contents">';
1861 ob_start();
1862 do_action('wpvr_hotspot_tweak_contents', $scene_data);
1863 $hotspot_content = ob_get_clean();
1864 $html .= $hotspot_content;
1865 $html .= '</div>';
1866 $html .= '</div>';
1867 $html .= '</div>';
1868
1869 $html .= '<div class="custom-ifram-wrapper" style="display: none;">';
1870 $html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>';
1871
1872 $html .= '<div class="custom-ifram-flex">';
1873 $html .= '<div class="custom-ifram">';
1874 $html .= '</div>';
1875 $html .= '</div>';
1876 $html .= '</div>';
1877
1878 $html .= '</div>';
1879 $html .= '</div>';
1880 if( "embed" == $width ){
1881 $html .= '</div>';
1882 }
1883
1884
1885 if ($status !== false && 'valid' == $status && $is_pro) {
1886 $call_to_action = isset($postdata['calltoaction']) ? $postdata['calltoaction'] : 'off';
1887 if( 'on' == $call_to_action){
1888 $buttontext = isset($postdata['buttontext']) ? $postdata['buttontext'] : '';
1889 $buttonurl = isset($postdata['buttonurl']) ? $postdata['buttonurl'] : '';
1890 $cta_btn_style = isset($postdata['button_configuration']) ? $postdata['button_configuration'] : array();
1891
1892 $button_open_new_tab = isset($cta_btn_style['button_open_new_tab']) ? $cta_btn_style['button_open_new_tab'] : "off";
1893 $target = '_self';
1894 $button_position = isset($cta_btn_style['button_position']) ? $cta_btn_style['button_position'] : "";
1895 $background_color = isset($cta_btn_style['button_background_color']) ? $cta_btn_style['button_background_color'] : "";
1896 $color = isset($cta_btn_style['button_font_color']) ? $cta_btn_style['button_font_color'] : "";
1897 $font_size = isset($cta_btn_style['button_font_size']) ? $cta_btn_style['button_font_size'] : "";
1898 $font_weight = isset($cta_btn_style['button_font_weight']) ? $cta_btn_style['button_font_weight'] : "";
1899 $text_align = isset($cta_btn_style['button_alignment']) ? $cta_btn_style['button_alignment'] : "";
1900 $text_transform = isset($cta_btn_style['button_transform']) ? $cta_btn_style['button_transform'] : "";
1901 $font_style = isset($cta_btn_style['button_text_style']) ? $cta_btn_style['button_text_style'] : "";
1902 $text_decoration = isset($cta_btn_style['button_text_decoration']) ? $cta_btn_style['button_text_decoration'] : "";
1903 $line_height = isset($cta_btn_style['button_line_height']) ? $cta_btn_style['button_line_height'] : "";
1904 $letter_spacing = isset($cta_btn_style['button_letter_spacing']) ? $cta_btn_style['button_letter_spacing'] : "";
1905 $word_spacing = isset($cta_btn_style['button_word_spacing']) ? $cta_btn_style['button_word_spacing'] : "";
1906
1907 $border_width = isset($cta_btn_style['button_border_width']) ? $cta_btn_style['button_border_width'] : "";
1908 $border_style = isset($cta_btn_style['button_border_style']) ? $cta_btn_style['button_border_style'] : "";
1909 $border_color = isset($cta_btn_style['button_border_color']) ? $cta_btn_style['button_border_color'] : "";
1910 $border_radius = isset($cta_btn_style['button_border_radius']) ? $cta_btn_style['button_border_radius'] : "";
1911
1912 $button_pt = isset($cta_btn_style['button_pt']) ? $cta_btn_style['button_pt'] : "";
1913 $button_pr = isset($cta_btn_style['button_pr']) ? $cta_btn_style['button_pr'] : "";
1914 $button_pb = isset($cta_btn_style['button_pb']) ? $cta_btn_style['button_pb'] : "";
1915 $button_pl = isset($cta_btn_style['button_pl']) ? $cta_btn_style['button_pl'] : "";
1916
1917 if($button_open_new_tab == 'on'){
1918 $target = '_blank';
1919 }
1920 $style = 'background-color: '.$background_color.';
1921 color: '.$color.';
1922 font-size: '.$font_size.'px;
1923 font-weight: '.$font_weight.';
1924 text-align: center;
1925 display: inline-block;
1926 text-transform: '.$text_transform.';
1927 font-style: '.$font_style.';
1928 text-decoration: '.$text_decoration.';
1929 line-height: '.$line_height.';
1930 letter-spacing: '.$letter_spacing.'px;
1931 word-spacing: '.$word_spacing.'px;
1932 border: '.$border_width.'px '.$border_style.' '.$border_color.';
1933 border-radius: '.$border_radius.'px;
1934 padding: '.$button_pt.'px '.$button_pr.'px '.$button_pb.'px '.$button_pl.'px;
1935 ';
1936 $html .= '<div class="wpvr-call-to-action-button position-'.$text_align.'" style="max-width:' . $width.'">
1937 <a href="'.$buttonurl.'" style="'.$style.'" target="'.$target.'">'.$buttontext.'</a>
1938 </div>';
1939
1940 }
1941 }
1942
1943
1944 //script started
1945 $html .= '<script>';
1946 if (isset($postdata['bg_music']) && $bg_music == 'on' && 'valid' == $status && $is_pro) {
1947 $html .= '
1948 var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
1949 var playing' . $id . ' = false;
1950 var autoplaySupported' . $id . ' = false;
1951 var alertShown' . $id . ' = false;
1952 var autoplayChecked' . $id . ' = false;
1953
1954 function playPause' . $id . '() {
1955 if (playing' . $id . ') {
1956 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1957 x' . $id . '.pause();
1958 jQuery("#audio_control' . $id . '").attr("data-play", "off");
1959 playing' . $id . ' = false;
1960 } else {
1961 x' . $id . '.muted = false;
1962 x' . $id . '.play().then(function() {
1963 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1964 jQuery("#audio_control' . $id . '").attr("data-play", "on");
1965 playing' . $id . ' = true;
1966 }).catch(function(e) {
1967 console.log("Play failed:", e);
1968 });
1969 }
1970 }
1971
1972 function audionEnd' . $id . '() {
1973 playing' . $id . ' = false;
1974 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1975 jQuery("#audio_control' . $id . '").attr("data-play", "off");
1976 }
1977
1978 x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
1979
1980 if ($autoplay_bg_music == 'on') {
1981 $html .= '
1982
1983 x' . $id . '.addEventListener("loadeddata", function() {
1984 if (!autoplayChecked' . $id . ') {
1985 checkAutoplayStatus' . $id . '();
1986 }
1987 });
1988
1989 x' . $id . '.addEventListener("canplay", function() {
1990 if (!autoplayChecked' . $id . ') {
1991 checkAutoplayStatus' . $id . '();
1992 }
1993 });
1994
1995 x' . $id . '.addEventListener("canplaythrough", function() {
1996 if (!autoplayChecked' . $id . ') {
1997 checkAutoplayStatus' . $id . '();
1998 }
1999 });
2000
2001 setTimeout(function() {
2002 if (!autoplayChecked' . $id . ') {
2003 checkAutoplayStatus' . $id . '();
2004 }
2005 }, 1000);
2006
2007 x' . $id . '.addEventListener("play", function() {
2008 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2009 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2010 playing' . $id . ' = true;
2011 });
2012
2013 x' . $id . '.addEventListener("pause", function() {
2014 if (!playing' . $id . ') {
2015 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2016 jQuery("#audio_control' . $id . '").attr("data-play", "off");
2017 }
2018 });
2019
2020 function checkAutoplayStatus' . $id . '() {
2021 autoplayChecked' . $id . ' = true;
2022
2023 x' . $id . '.muted = true;
2024 var playPromise = x' . $id . '.play();
2025
2026 if (playPromise !== undefined) {
2027 playPromise.then(function () {
2028 if (x' . $id . '.muted || x' . $id . '.volume === 0) {
2029 handleAutoplayBlocked' . $id . '();
2030 } else {
2031 autoplaySupported' . $id . ' = true;
2032 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2033 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2034 playing' . $id . ' = true;
2035 }
2036 }).catch(function () {
2037 handleAutoplayBlocked' . $id . '();
2038 });
2039 } else {
2040 setTimeout(function () {
2041 if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2042 handleAutoplayBlocked' . $id . '();
2043 } else {
2044 autoplaySupported' . $id . ' = true;
2045 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2046 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2047 playing' . $id . ' = true;
2048 }
2049 }, 300);
2050 }
2051 }
2052
2053 function handleAutoplayBlocked' . $id . '() {
2054 autoplaySupported' . $id . ' = false;
2055 if (!alertShown' . $id . ') {
2056 alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2057 alertShown' . $id . ' = true;
2058 }
2059
2060 x' . $id . '.pause();
2061 x' . $id . '.currentTime = 0;
2062 x' . $id . '.muted = true;
2063
2064 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2065 jQuery("#audio_control' . $id . '").attr("data-play", "off");
2066
2067 document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2068 document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2069 document.addEventListener("click", musicPlay' . $id . ', { once: true });
2070 }
2071
2072 function musicPlay' . $id . '() {
2073 x' . $id . '.muted = false;
2074 var playPromise = x' . $id . '.play();
2075
2076 if (playPromise !== undefined) {
2077 playPromise.then(function () {
2078 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2079 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2080 playing' . $id . ' = true;
2081 }).catch(function(e) {
2082 console.log("Play failed:", e);
2083 });
2084 } else {
2085 setTimeout(function () {
2086 if (!x' . $id . '.paused) {
2087 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2088 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2089 playing' . $id . ' = true;
2090 }
2091 }, 100);
2092 }
2093
2094 document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2095 document.removeEventListener("touchstart", musicPlay' . $id . ');
2096 document.removeEventListener("click", musicPlay' . $id . ');
2097 }
2098 ';
2099 }
2100 }
2101 $html .= '(function ($) {';
2102 $html .= 'jQuery(document).ready(function() {';
2103 $html .= 'var response = ' . $response . ';';
2104 $html .= 'var scenes = response[1];';
2105 $html .= 'if(scenes) {';
2106 $html .= 'var scenedata = scenes.scenes;';
2107 $html .= 'for(var i in scenedata) {';
2108 $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2109 $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2110 $html .= 'if(scenehotspot[i].type === "info") {';
2111 $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2112 $html .= '} else if(scenehotspot[i].type === "scene") {';
2113 $html .= ' scenehotspot[i]["clickHandlerArgs"] = scenehotspot[i]["text"];';
2114 $status = get_option('wpvr_edd_license_status');
2115 if ($status !== false && $status == 'valid') {
2116 $html .='if(wpvr_public.is_pro_active) {';
2117 $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspotscene;';
2118 $html .='}';
2119 }
2120 $html .= '}';
2121
2122 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2123 } else {
2124 $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2125 $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2126 $html .= '}';
2127 }
2128
2129 $html .= '}';
2130 $html .= '}';
2131 $html .= '}';
2132 $html .= 'var panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2133 $html .= '
2134
2135 if(!wpvr_public.is_pro_active || !wpvr_public.is_license_active) {
2136 panoshow' . $id . '.on("load", function() {
2137 jQuery(".pnlm-panorama-info").hide();
2138 jQuery(".pnlm-compass").hide();
2139 });
2140
2141 panoshow' . $id . '.on("scenechange", function() {
2142 jQuery(".pnlm-panorama-info").hide();
2143 jQuery(".pnlm-compass").hide();
2144 });
2145 }';
2146 //===Dplicate mode only for vr mode===//
2147 $response2 = json_decode($response);
2148 $response2[1]->compass = false;
2149 $response2[1]->autoRotate = false;
2150 $response = json_encode($response2);
2151 $html .= 'var response_duplicate = ' . $response . ';';
2152 $html .= 'var scenes_duplicate = response_duplicate[1];';
2153
2154 $html .= 'if(scenes_duplicate) {';
2155 $html .= 'var scenedata = scenes_duplicate.scenes;';
2156 $html .= 'for(var i in scenedata) {';
2157 $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2158 $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2159 $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2160 $html .= 'scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2161 $html .= '}';
2162 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2163 } else {
2164 $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2165 $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2166 $html .= '}';
2167 }
2168 $html .= '}';
2169 $html .= '}';
2170 $html .= '}';
2171
2172 $is_pro = apply_filters('is_wpvr_pro_active',false);
2173 $status = get_option('wpvr_edd_license_status');
2174 $html .= 'var vr_mode = "off";';
2175 if ($status !== false && 'valid' == $status && $is_pro) {
2176 $html .= 'var panoshow2' . $id . ' = pannellum.viewer("pano2' . $id . '", scenes_duplicate);';
2177 // Show Cardboard Mode in Tour
2178 $html .= '
2179 var tim;
2180 var im = 0;
2181 var active_scene = "'.$default_scene.'";
2182 var c_time;
2183 c_time = new Date();
2184 var timer = c_time.getTime() + 2000;
2185 function panoShowCardBoardOnTrigger(data){
2186 if(scenes_duplicate) {
2187 var scenedata = scenes_duplicate.scenes;
2188 for(var i in scenedata) {
2189 if(active_scene === i) {
2190 var scenehotspot = scenedata[i].hotSpots;
2191 for(var j in scenehotspot) {
2192 var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2193 var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2194 var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2195 var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2196 var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2197 var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2198 if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2199 if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2200 jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2201 var getScene = scenehotspot[j].sceneId;
2202 if(scenehotspot[j].type == "scene"){
2203 panoshow' . $id . '.loadScene(getScene);
2204 panoshow2' . $id . '.loadScene(getScene);
2205 // var inside_current_time_object = new Date();
2206 // var inside_timer = inside_current_time_object.getTime();
2207 // if(inside_timer > timer) {
2208 // panoshow' . $id . '.loadScene(getScene);
2209 // panoshow2' . $id . '.loadScene(getScene);
2210 // jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2211 // }
2212 }else{
2213 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2214 }
2215 }
2216 else {
2217 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2218 c_time = new Date();
2219 timer = c_time.getTime() + 2000;
2220 }
2221 }
2222 else {
2223 c_time = new Date();
2224 timer = c_time.getTime() + 2000;
2225 }
2226 }
2227 }
2228 }
2229 }
2230 };
2231 function vrDeviseOrientation(){
2232 var data = {
2233 pitch: panoshow' . $id . '.getPitch(),
2234 yaw: panoshow' . $id . '.getYaw(),
2235 };
2236 panoShowCardBoardOnTrigger(data);
2237 }';
2238 $html .= '
2239 function requestFullScreen(){
2240 var elem = document.getElementById("master-container");
2241 if (elem.requestFullscreen) {
2242 elem.requestFullscreen();
2243 } else if (elem.webkitRequestFullscreen) { /* Safari */
2244 elem.webkitRequestFullscreen();
2245 } else if (elem.msRequestFullscreen) { /* IE11 */
2246 elem.msRequestFullscreen();
2247 }
2248 }
2249 function requestExitFullscreen(){
2250 var elem = document.getElementById("master-container");
2251 if (document.exitFullscreen) {
2252 document.exitFullscreen();
2253 } else if (document.webkitExitFullscreen) { /* Safari */
2254 document.webkitExitFullscreen();
2255 } else if (document.msExitFullscreen) { /* IE11 */
2256 document.msExitFullscreen();
2257 }
2258 }
2259 jQuery(document).on("click",".fullscreen-button .expand",function() {
2260 jQuery(this).hide()
2261 jQuery(this).parent().find(".compress").show()
2262 requestFullScreen()
2263 });
2264 jQuery(document).on("click",".fullscreen-button .compress",function() {
2265 jQuery(this).hide()
2266 jQuery(this).parent().find(".expand").show()
2267 requestExitFullscreen()
2268 screen.orientation.unlock();
2269 });
2270 let onLoadAnalytics = false;
2271 let sceneLoadAnalytics = false;
2272
2273 function storeAnalyticsData(data) {
2274 if (typeof wpvrAnalyticsObj !== "undefined" && wpvr_public.is_pro_active) {
2275 jQuery.ajax({
2276 url: wpvrAnalyticsObj.ajaxUrl,
2277 type: "POST",
2278 data: {
2279 action: "store_scene_hotspot_data",
2280 scene_id: data.scene_id,
2281 tour_id: data.tour_id,
2282 type: data.type,
2283 hotspot_id: data.hotspot_id || "",
2284 user_agent: navigator.userAgent,
2285 device_type: getDeviceType() || "desktop",
2286 nonce: wpvrAnalyticsObj.nonce,
2287 },
2288 success: function (response) {
2289 console.log("Data stored successfully");
2290 },
2291 error: function (error) {
2292 console.log("Error in storing data");
2293 }
2294 });
2295 } else {
2296 console.warn("Analytics object not available or pro not active");
2297 }
2298 }
2299 function getDeviceType() {
2300 const userAgent = navigator.userAgent.toLowerCase();
2301 if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)) {
2302 return "mobile";
2303 } else if (/tablet|ipad/i.test(userAgent)) {
2304 return "tablet";
2305 } else {
2306 return "desktop";
2307 }
2308 }
2309 panoshow' . $id . '.on("scenechange", function(scene) {
2310 onLoadAnalytics = true;
2311 sceneLoadAnalytics = true;
2312 let scene_id = scene;
2313 let tour_id = ' . $id . ';
2314 let type = "scene";
2315 let hotspot_id = "";
2316 let user_agent = navigator.userAgent;
2317 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2318 storeAnalyticsData({
2319 scene_id: scene_id,
2320 tour_id: tour_id,
2321 type: type,
2322 hotspot_id: hotspot_id,
2323 user_agent: user_agent,
2324 device_type: device_type,
2325 });
2326 });
2327 panoshow' . $id . '.on("load", function() {
2328 let scene_id = panoshow' . $id . '.getScene();
2329 let tour_id = ' . $id . ';
2330 let type = "scene";
2331 let hotspot_id = "";
2332 let user_agent = navigator.userAgent;
2333 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2334 if(!onLoadAnalytics && !sceneLoadAnalytics) {
2335 storeAnalyticsData({
2336 scene_id: scene_id,
2337 tour_id: tour_id,
2338 type: type,
2339 hotspot_id: hotspot_id,
2340 user_agent: user_agent,
2341 device_type: device_type,
2342 });
2343 }
2344 });
2345 function wpvrhotspotscene(hotSpotDiv, args) {
2346 onLoadAnalytics = true;
2347 let scene_id = panoshow' . $id . '.getScene();
2348 let tour_id = ' . $id . ';
2349 let type = "hotspot";
2350 let hotspot_id = args;
2351 let user_agent = navigator.userAgent;
2352 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2353 storeAnalyticsData({
2354 scene_id: scene_id,
2355 tour_id: tour_id,
2356 type: type,
2357 hotspot_id: hotspot_id,
2358 user_agent: user_agent,
2359 device_type: device_type
2360 });
2361 }
2362 ';
2363 $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2364 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2365 active_scene = scene;
2366 // if(localStorage.getItem("vr_mode") == "on") {
2367 if(vr_mode == "on") {
2368 jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2369 jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2370 }
2371 });
2372 var compassBlock = "";
2373 var infoBlock = "";
2374 jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2375 jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2376 jQuery("#pano' . $id . ' .pnlm-load-button").trigger("click");
2377 var getValue = jQuery(this).val();
2378 var getParent = jQuery(this).parent().parent();
2379 var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2380 var panoInfo = getParent.find("#pano' . $id . ' .pnlm-panorama-info").css("display");
2381 if(compass == "block"){
2382 compassBlock = "block";
2383 }
2384 if(panoInfo == "block"){
2385 infoBlock = "block";
2386 }
2387 if (getValue == "off") {
2388 requestFullScreen()
2389 screen.orientation.lock("landscape-primary").then(function() {
2390 }).catch(function(error) {
2391 alert("VR Glass Mode not supported in this device");
2392 });
2393 // localStorage.setItem("vr_mode", "on");
2394 vr_mode = "on";
2395 jQuery(".vr-mode-title").show();
2396 jQuery(this).val("on");
2397 getParent.find("#pano2' . $id . '").css({
2398 "opacity": "1",
2399 "visibility": "visible",
2400 "position": "relative",
2401 });
2402 gyroSwitch = true;
2403 panoshow' . $id . '.startOrientation();
2404 panoshow2' . $id . '.startOrientation();
2405 panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
2406 panoshow2' . $id . '.setYaw(panoshow' . $id . '.getYaw(), 0);
2407 getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2408 getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").hide();
2409 getParent.find("#pano' .$id. ' #controls'.$id.'").hide();
2410 getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").hide();
2411 getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
2412 getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").hide();
2413 getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").hide();
2414 getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2415 getParent.find("#pano' .$id. ' #adcontrol'.$id.'").hide();
2416 getParent.find("#pano' .$id. ' .owl-nav.wpvr_slider_nav").hide();
2417 getParent.find("#pano' .$id. ' #cp-logo-controls").hide();
2418 getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").hide();
2419 getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
2420 getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
2421 getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2422 getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2423 getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
2424 getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
2425 getParent.find("#pano' . $id . '").addClass("cardboard-half");
2426 getParent.find("#center-pointer' . $id . '").show();
2427 getParent.find(".fullscreen-button").hide();
2428 getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
2429 if (window.DeviceOrientationEvent) {
2430 window.addEventListener("deviceorientation", vrDeviseOrientation);
2431 }
2432 panoshow' . $id . '.on("zoomchange", function (data){
2433 panoshow2' . $id . '.setHfov(data, 0);
2434 });
2435 panoshow2' . $id . '.on("zoomchange", function (data){
2436 panoshow' . $id . '.setHfov(data, 0);
2437 });
2438 jQuery(document).on("click","#pano2' . $id . '",function(event) {
2439 panoshow' . $id . '.startOrientation();
2440 panoshow2' . $id . '.startOrientation();
2441 });
2442 jQuery(document).on("click","#pano' . $id . '",function(event) {
2443 panoshow' . $id . '.startOrientation();
2444 panoshow2' . $id . '.startOrientation();
2445 });
2446 panoshow' . $id . '.on("mousemove", function (data){
2447 panoshow2' . $id . '.setPitch(data.pitch, 0);
2448 panoshow2' . $id . '.setYaw(data.yaw, 0);
2449 panoShowCardBoardOnTrigger(data);
2450 });
2451 panoshow2' . $id . '.on("mousemove", function (data){
2452 panoshow' . $id . '.setPitch(data.pitch, 0);
2453 panoshow' . $id . '.setYaw(data.yaw, 0);
2454 panoShowCardBoardOnTrigger(data);
2455 });
2456 panoshow' . $id . '.on("touchmove", function (data){
2457 panoshow' . $id . '.stopOrientation();
2458 panoshow2' . $id . '.stopOrientation();
2459 panoshow2' . $id . '.setPitch(data.pitch, 0);
2460 panoshow2' . $id . '.setYaw(data.yaw, 0);
2461 panoShowCardBoardOnTrigger(data);
2462 });
2463 panoshow2' . $id . '.on("touchmove", function (data){
2464 panoshow' . $id . '.stopOrientation();
2465 panoshow2' . $id . '.stopOrientation();
2466 panoshow' . $id . '.setPitch(data.pitch, 0);
2467 panoshow' . $id . '.setYaw(data.yaw, 0);
2468 panoShowCardBoardOnTrigger(data);
2469 });
2470 } else if(getValue == "on") {
2471 screen.orientation.unlock();
2472 requestExitFullscreen();
2473 // localStorage.setItem("vr_mode", "off");
2474 vr_mode = "off";
2475 jQuery(".vr-mode-title").hide();
2476 jQuery(this).val("off");
2477 getParent.find("#pano2' . $id . '").css({
2478 "opacity": "0",
2479 "visibility": "hidden",
2480 "position": "absolute",
2481 });
2482 getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
2483 getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").show();
2484 getParent.find("#pano' .$id. ' #controls'.$id.'").show();
2485 getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").show();
2486 getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
2487 getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").show();
2488 getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
2489 getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
2490 getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").show();
2491 getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2492 getParent.find("#pano' .$id. ' #adcontrol'.$id.'").show();
2493 getParent.find("#pano' .$id. ' .owl-nav.wpvr_slider_nav").hide();
2494 getParent.find("#pano' .$id. ' #cp-logo-controls").show();
2495 getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").show();
2496 getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").show();
2497 if(compassBlock == "block"){
2498 getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2499 getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2500 }
2501 if(infoBlock == "block"){
2502 getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
2503 getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
2504 }
2505 getParent.find("#pano' . $id . '").removeClass("cardboard-half");
2506 getParent.find("#center-pointer' . $id . '").hide();
2507 getParent.find(".fullscreen-button").hide();
2508 panoshow' . $id . '.off("mousemove");
2509 panoshow' . $id . '.off("touchmove");
2510 panoshow2' . $id . '.off("mousemove");
2511 panoshow2' . $id . '.off("touchmove");
2512 if (window.DeviceOrientationEvent) {
2513 window.removeEventListener("deviceorientation", vrDeviseOrientation);
2514 }
2515 }
2516 });';
2517 $html .= 'panoshow2' . $id . '.on("load", function (){
2518 // if(localStorage.getItem("vr_mode") == "off") {
2519 if( vr_mode == "off") {
2520 jQuery(".vr-mode-title").hide();
2521 }
2522 else {
2523 jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2524 jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2525 jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2526 jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2527 jQuery(".vr-mode-title").show();
2528 }
2529 });';
2530 }
2531 //=== end Dplicate mode only for vr mode===//
2532 $html .= 'jQuery("#pano' . $id . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
2533 var scene_id = jQuery(this).attr("scene_id");
2534 panoshow' . $id . '.loadScene(scene_id)
2535 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2536 jQuery(this).addClass("add-pulse")
2537 });';
2538 if ($scene_animation == 'on' && is_plugin_active('wpvr-pro/wpvr-pro.php')) {
2539 $animation_type = $postdata['sceneAnimationName'] ?? 'none';
2540 $animationDuration = $postdata['sceneAnimationTransitionDuration'] ?? '500ms';
2541 $animationDelay = $postdata['sceneAnimationTransitionDelay'] ?? '0ms';
2542 $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
2543 if (!empty($animation_js)) {
2544 $html .= $animation_js;
2545 $html .= 'panoshow' . $id . '.on("load", function (scene){
2546 if (typeof changeScene === "function") {
2547 changeScene();
2548 } else {
2549 console.warn("changeScene function is not defined.");
2550 }
2551 });';
2552 }
2553 }
2554
2555 $html .= 'panoshow' . $id . '.on("mousemove", function (data){
2556 jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
2557 });
2558 ';
2559 $status = get_option('wpvr_edd_license_status');
2560 if ($status !== false && 'valid' == $status && $is_pro){
2561 $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2562 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2563 jQuery(".floor-plan-pointer").each(function(index ,element){
2564 var scene_id = jQuery(this).attr("scene_id");
2565 if( active_scene == scene_id ){
2566 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2567 jQuery(this).addClass("add-pulse")
2568 }
2569 });
2570 });';
2571 $html .= 'panoshow' . $id . '.on("load", function (){
2572 if(jQuery(".floor-plan-pointer").length > 0){
2573 jQuery(".floor-plan-pointer").each(function(index ,element){
2574 var scene_id = jQuery(this).attr("scene_id");
2575 if( active_scene == scene_id ){
2576 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2577 jQuery(this).addClass("add-pulse")
2578 }
2579 });
2580 }
2581 });';
2582 }
2583 if ($status !== false && 'valid' == $status && $is_pro){
2584 $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
2585 $html .= 'jQuery("#pano' . $id . ' .custom-scene-navigation").on("click", function() {
2586 jQuery("#custom-scene-navigation-nav' . $id . ' ul").empty();
2587 if (scenes) {
2588 var scene_navigation_content_type = "' . $scene_navigation_content_type . '";
2589 var sceneList = scenes.scenes;
2590 var getScene = panoshow' . $id . '.getScene();
2591 for (const key in sceneList) {
2592 let title;
2593 if (scene_navigation_content_type === "scene_title") {
2594 if (sceneList[key].title) {
2595 title = sceneList[key].title;
2596 } else {
2597 if (title == "" || title == undefined) {
2598 if (sceneList[key].panorama) {
2599 title = getImageNameWithoutExtension(sceneList[key].panorama);
2600 }
2601 }
2602 }
2603 } else if (scene_navigation_content_type === "scene_image_name") {
2604 if (sceneList[key].panorama) {
2605 title = getImageNameWithoutExtension(sceneList[key].panorama);
2606 }
2607 } else {
2608 title = key;
2609 }
2610 if (sceneList.hasOwnProperty(key)) {
2611 let ulElement = document.querySelector("#custom-scene-navigation-nav' . $id . ' ul");
2612 if (ulElement) {
2613 let liElement = document.createElement("li");
2614 liElement.className = "scene-navigation-list" + (key === getScene ? " active" : "");
2615 liElement.setAttribute("scene_id", key);
2616 liElement.textContent = title;
2617 ulElement.appendChild(liElement);
2618 }
2619 }
2620 }
2621 jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
2622 }
2623 });';
2624 $html .='function getImageNameWithoutExtension(imageUrl) {
2625 // Split the URL by "/"
2626 var parts = imageUrl.split("/");
2627 // Get the last part which contains the image name
2628 var imageNameWithExtension = parts[parts.length - 1];
2629 // Split the image name by period (.)
2630 var imageNameParts = imageNameWithExtension.split(".");
2631 // Remove the last part (which is the extension) and join the remaining parts
2632 var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
2633 // Return the image name without extension
2634 return imageNameWithoutExtension;
2635 }';
2636 $html .= 'jQuery("#pano' . $id . ' #custom-scene-navigation-nav' . $id . ' ul").on("click", "li.scene-navigation-list", function() {
2637 if (scenes) {
2638 jQuery(this).siblings("li").removeClass("active");
2639 jQuery(this).addClass("active");
2640 var scene_key = jQuery(this).attr("scene_id");
2641 panoshow' . $id . '.loadScene(scene_key);
2642 }
2643 });';
2644 }
2645 $html .= 'const node = document.querySelector(".add-pulse");
2646 panoshow' . $id . '.on("compasschange", function (data){
2647 // const node = document.querySelector(".add-pulse");
2648 // node.style.transform = data;
2649 // jQuery(".add-pulse").css({"transform":data});
2650 });';
2651 $html .= 'panoshow' . $id . '.on("load", function (){
2652 // if(localStorage.getItem("vr_mode") == "off") {
2653 if(vr_mode == "off") {
2654 jQuery(".vr-mode-title").hide();
2655 } else {
2656 jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2657 jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2658 jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2659 jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2660 jQuery(".vr-mode-title").show();
2661 }
2662 setTimeout(() => {
2663 window.dispatchEvent(new Event("resize"));
2664 }, 200);
2665 if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
2666 jQuery("#controls' . $id . '").css("bottom", "80px");
2667 }
2668 else {
2669 jQuery("#controls' . $id . '").css("bottom", "5px");
2670 }
2671 });';
2672 $html .= 'panoshow' . $id . '.on("render", function (){
2673 window.dispatchEvent(new Event("resize"));
2674 });';
2675 $html .= 'if (scenes.autoRotate) {
2676 panoshow' . $id . '.on("load", function (){
2677 setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2678 });
2679 panoshow' . $id . '.on("scenechange", function (){
2680 setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2681 });
2682 }';
2683 $html .= 'var touchtime = 0;';
2684 if ($vrgallery) {
2685 if (isset($panodata["scene-list"])) {
2686 foreach ($panodata["scene-list"] as $panoscenes) {
2687 $scene_key = $panoscenes['scene-id'];
2688 $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
2689 $img_src_url = $panoscenes['scene-attachment-url'];
2690 // $html .= 'document.getElementById("'.$scene_key_gallery.'").addEventListener("click", function(e) { ';
2691 // $html .= 'if (touchtime == 0) {';
2692 // $html .= 'touchtime = new Date().getTime();';
2693 // $html .= '} else {';
2694 // $html .= 'if (((new Date().getTime()) - touchtime) < 800) {';
2695 // $html .= 'panoshow'.$id.'.loadScene("'.$scene_key.'");';
2696 // $html .= 'touchtime = 0;';
2697 // $html .= '} else {';
2698 // $html .= 'touchtime = new Date().getTime();';
2699 // $html .= '}';
2700 // $html .= '}';
2701 // $html .= '});';
2702 $html .= 'jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
2703 panoshow' . $id . '.loadScene("' . $scene_key . '");
2704 });';
2705 }
2706 }
2707 }
2708 //===Custom Control===//
2709 if (isset($custom_control)) {
2710 if ($custom_control['panupSwitch'] == "on" && 'valid' == $status && $is_pro) {
2711 $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
2712 $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() + 10);';
2713 $html .= '});';
2714 }
2715 if ($custom_control['panDownSwitch'] == "on" && 'valid' == $status && $is_pro) {
2716 $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
2717 $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() - 10);';
2718 $html .= '});';
2719 }
2720 if ($custom_control['panLeftSwitch'] == "on" && 'valid' == $status && $is_pro) {
2721 $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
2722 $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() - 10);';
2723 $html .= '});';
2724 }
2725 if ($custom_control['panRightSwitch'] == "on" && 'valid' == $status && $is_pro) {
2726 $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
2727 $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() + 10);';
2728 $html .= '});';
2729 }
2730 if ($custom_control['panZoomInSwitch'] == "on") {
2731 $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
2732 $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() - 10);';
2733 $html .= '});';
2734 }
2735 if ($custom_control['panZoomOutSwitch'] == "on") {
2736 $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
2737 $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() + 10);';
2738 $html .= '});';
2739 }
2740 if ($custom_control['panFullscreenSwitch'] == "on" && 'valid' == $status && $is_pro) {
2741 $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
2742 $html .= 'panoshow' . $id . '.toggleFullscreen();';
2743 $html .= '});';
2744 $html .= '(function() {';
2745 $html .= 'function wpvrFsChange' . $id . '() {';
2746 $html .= 'var fsIcon = document.querySelector("#fullscreen' . $id . ' i");';
2747 $html .= 'if (!fsIcon) return;';
2748 $html .= 'if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {';
2749 $html .= 'fsIcon.classList.remove("fa-expand"); fsIcon.classList.add("fa-minimize");';
2750 $html .= '} else {';
2751 $html .= 'fsIcon.classList.remove("fa-minimize"); fsIcon.classList.add("fa-expand");';
2752 $html .= '}';
2753 $html .= '}';
2754 $html .= 'document.addEventListener("fullscreenchange", wpvrFsChange' . $id . ');';
2755 $html .= 'document.addEventListener("webkitfullscreenchange", wpvrFsChange' . $id . ');';
2756 $html .= 'document.addEventListener("mozfullscreenchange", wpvrFsChange' . $id . ');';
2757 $html .= 'document.addEventListener("MSFullscreenChange", wpvrFsChange' . $id . ');';
2758 $html .= '})();';
2759 }
2760 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
2761 $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
2762 $html .= 'panoshow' . $id . '.loadScene("' . $default_scene . '");';
2763 $html .= '});';
2764 }
2765 if ($custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on" && 'valid' == $status && $is_pro) {
2766 $html .= '
2767 var element = document.getElementById("gyroscope' . $id . '");
2768 var gyroSwitch = true;
2769 var isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
2770 var permissionGranted = false;
2771
2772 function requestOrientationPermission() {
2773 if (isIOS) {
2774 if (typeof DeviceOrientationEvent.requestPermission === "function") {
2775 DeviceOrientationEvent.requestPermission()
2776 .then(function(state) {
2777 if (state === "granted") {
2778 permissionGranted = true;
2779 startOrientation();
2780 } else {
2781 element.children[0].style.color = "red";
2782 gyroSwitch = false;
2783 alert("Permission to use motion sensors was denied.");
2784 }
2785 })
2786 .catch(function(error) {
2787 element.children[0].style.color = "red";
2788 gyroSwitch = false;
2789 console.error("Error requesting device orientation permission:", error);
2790 });
2791 }
2792 } else {
2793 startOrientation();
2794 }
2795 }
2796
2797 function startOrientation() {
2798 panoshow' . $id . '.startOrientation();
2799 element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2800 gyroSwitch = true;
2801 }
2802
2803 panoshow' . $id . '.on("load", function() {
2804 if (!isIOS || permissionGranted) {
2805 if (gyroSwitch) {
2806 startOrientation();
2807 } else {
2808 panoshow' . $id . '.stopOrientation();
2809 element.children[0].style.color = "red";
2810 }
2811 }
2812 });
2813
2814 panoshow' . $id . '.on("scenechange", function() {
2815 if (!isIOS || permissionGranted) {
2816 if (panoshow' . $id . '.isOrientationActive()) {
2817 element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2818 } else {
2819 element.children[0].style.color = "red";
2820 }
2821 }
2822 });
2823
2824 panoshow' . $id . '.on("touchstart", function() {
2825 if (!isIOS || permissionGranted) {
2826 if (panoshow' . $id . '.isOrientationActive()) {
2827 gyroSwitch = true;
2828 element.children[0].style.color = "'.$custom_control['gyroscopeColor'].'";
2829 } else {
2830 gyroSwitch = false;
2831 element.children[0].style.color = "red";
2832 }
2833 }
2834 });';
2835
2836 $html .= 'document.getElementById("gyroscope' . $id . '").addEventListener("click", function(e) {
2837 var element = document.getElementById("gyroscope' . $id . '");
2838 if (isIOS && typeof DeviceOrientationEvent.requestPermission === "function" && !permissionGranted) {
2839 requestOrientationPermission();
2840 } else {
2841 if (panoshow' . $id . '.isOrientationActive()) {
2842 panoshow' . $id . '.stopOrientation();
2843 gyroSwitch = false;
2844 element.children[0].style.color = "red";
2845 } else {
2846 startOrientation();
2847 }
2848 }
2849 });';
2850 }
2851 }
2852 $angle_up = '<i class="fa fa-angle-up"></i>';
2853 $angle_down = '<i class="fa fa-angle-down"></i>';
2854 $sin_qout = "'";
2855
2856 //===Explainer Script===//
2857
2858 if ($autoplay_bg_music == 'on') {
2859 $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
2860 jQuery("#explainer' . $id . '").slideToggle();
2861 playing' . $id . ' = false;
2862 var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
2863 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up");
2864 jQuery("#vr-volume' . $id . '").addClass("fas fa-volume-mute");
2865 x' . $id . '.pause();
2866 });
2867 jQuery(document).on("click",".close-explainer-video",function() {
2868 jQuery(this).parent(".explainer").hide();
2869 var el_src = jQuery(".vr-iframe").attr("src");
2870 jQuery(".vr-iframe").attr("src", el_src);
2871 });';
2872 } else {
2873 $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
2874 jQuery("#explainer' . $id . '").slideToggle(function(){
2875 var $explainerVideoId = jQuery("#explainer' . $id . '");
2876 var $explainerVideoIframe = $explainerVideoId.find("iframe");
2877 var explainerVideoIframSrc = $explainerVideoIframe.attr("src");
2878 $explainerVideoIframe.attr("src", "");
2879 $explainerVideoIframe.attr("src", explainerVideoIframSrc);
2880 });
2881 });
2882 jQuery(document).on("click", ".close-explainer-video", function() {
2883 var $explainer = jQuery(this).parent(".explainer");
2884 var $iframe = $explainer.find("iframe");
2885 var el_src = $iframe.attr("src");
2886 $iframe.attr("src", "");
2887 $explainer.hide();
2888 $iframe.attr("src", el_src);
2889 });';
2890 }
2891
2892 $html .= '
2893 jQuery(document).on("click","#pano' . $id . '",function(event) {
2894 var isActiveModal = event.target.closest(".custom-ifram-wrapper");
2895 var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
2896 var isHotspot = event.target.closest(".pnlm-hotspot-base");
2897 if( isActiveModal == null && isForm == null && isHotspot == null){
2898 jQuery(".custom-ifram-wrapper .custom-ifram").empty();
2899 jQuery(".custom-ifram-wrapper").hide();
2900 jQuery(this).removeClass("show-modal");
2901 jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
2902 }else if(isForm != null){
2903 jQuery(this).addClass("show-modal");
2904 }
2905 });';
2906
2907 //===Explainer Script End===//
2908
2909 //===generic form script===//
2910 if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
2911 $html .= '
2912 jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
2913 jQuery("#wpvr-generic-form' . $id . '").fadeToggle();
2914 });
2915
2916 jQuery(document).on("click",".close-generic-form",function() {
2917 jQuery(this).parent(".wpvr-generic-form").fadeOut()
2918 });
2919 ';
2920 }
2921 //===generic from script===//
2922
2923 //===Floor map Script===//
2924 $html .= 'jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
2925 jQuery("#wpvr-floor-map' . $id . '").toggle().removeClass("fullwindow");
2926 });
2927 jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
2928 jQuery(this).addClass("fullwindow");
2929 jQuery(this).parents(".pano-wrap").addClass("show-modal");
2930 });
2931 jQuery(document).on("click",".close-floor-map-plan",function() {
2932 jQuery(this).parent(".wpvr-floor-map").hide();
2933 jQuery(this).parent(".wpvr-floor-map").removeClass("fullwindow");
2934 jQuery(this).parents(".pano-wrap").removeClass("show-modal");
2935 });';
2936 //===Floor map Script End===//
2937
2938 if ($vrgallery_display) {
2939
2940 if (!$autoload) {
2941 $html .= 'jQuery(document).ready(function($){
2942 jQuery("#sccontrols' . $id . '").hide();
2943 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2944 jQuery("#sccontrols' . $id . '").hide();
2945 jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
2946 });';
2947 $html .= 'var slide' . $id . ' = "down";
2948 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2949 if (slide' . $id . ' == "up") {
2950 jQuery(".vrgctrl' . $id . '").empty();
2951 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2952 slide' . $id . ' = "down";
2953 jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
2954 jQuery("#sccontrols' . $id . '").slideToggle(function(){
2955 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
2956 if (jQuery(this).is(":visible")) {
2957 jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
2958 "display": "flex",
2959 "justify-content": "center",
2960 "align-items": "center",
2961 "gap": "15px"
2962 });
2963 }
2964 }
2965 if (jQuery(".bricks-is-frontend").length) {
2966 if (jQuery(this).is(":visible")) {
2967 jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
2968 "display": "flex",
2969 "justify-content": "center",
2970 "align-items": "center"
2971 });
2972 }
2973 }
2974 });
2975 }
2976 else {
2977 jQuery(".vrgctrl' . $id . '").empty();
2978 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2979 slide' . $id . ' = "up";
2980 jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
2981 jQuery("#sccontrols' . $id . '").slideToggle(function(){
2982 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
2983 if (jQuery(this).is(":visible")) {
2984 jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
2985 "display": "flex",
2986 "justify-content": "center",
2987 "align-items": "center",
2988 "gap": "15px"
2989 });
2990 }
2991 }
2992 if (jQuery(".bricks-is-frontend").length) {
2993 if (jQuery(this).is(":visible")) {
2994 jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
2995 "display": "flex",
2996 "justify-content": "center",
2997 "align-items": "center"
2998 });
2999 }
3000 }
3001 });
3002 }
3003 });';
3004 } else {
3005 $html .= 'jQuery(document).ready(function($){
3006 jQuery("#sccontrols' . $id . '").show();
3007 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3008 jQuery("#pano' . $id . ' .wpvr_slider_nav").show();
3009 });';
3010 $html .= 'var slide' . $id . ' = "down";
3011 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3012 if (slide' . $id . ' == "up") {
3013 jQuery(".vrgctrl' . $id . '").empty();
3014 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3015 slide' . $id . ' = "down";
3016 } else {
3017 jQuery(".vrgctrl' . $id . '").empty();
3018 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3019 slide' . $id . ' = "up";
3020 }
3021 jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3022 jQuery("#sccontrols' . $id . '").slideToggle(function(){
3023 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3024 if (jQuery(this).is(":visible")) {
3025 jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3026 "display": "flex",
3027 "justify-content": "center",
3028 "align-items": "center",
3029 "gap": "15px"
3030 });
3031 }
3032 }
3033 if (jQuery(".bricks-is-frontend").length) {
3034 if (jQuery(this).is(":visible")) {
3035 jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3036 "display": "flex",
3037 "justify-content": "center",
3038 "align-items": "center"
3039 });
3040 }
3041 }
3042 });
3043 });';
3044 }
3045 } else {
3046 $html .= 'jQuery(document).ready(function($){
3047 jQuery("#sccontrols' . $id . '").hide();
3048 jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3049 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3050 });';
3051 $html .= 'var slide' . $id . ' = "down";
3052 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3053 if (slide' . $id . ' == "up") {
3054 jQuery(".vrgctrl' . $id . '").empty();
3055 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3056 slide' . $id . ' = "down";
3057 }
3058 else {
3059 jQuery(".vrgctrl' . $id . '").empty();
3060 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3061 slide' . $id . ' = "up";
3062 }
3063 jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3064 jQuery("#sccontrols' . $id . '").slideToggle(function(){
3065 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3066 if (jQuery(this).is(":visible")) {
3067 jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3068 "display": "flex",
3069 "justify-content": "center",
3070 "align-items": "center",
3071 "gap": "15px"
3072 });
3073 }
3074 }
3075 if (jQuery(".bricks-is-frontend").length) {
3076 if (jQuery(this).is(":visible")) {
3077 jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3078 "display": "flex",
3079 "justify-content": "center",
3080 "align-items": "center"
3081 });
3082 }
3083 }
3084 });
3085 });';
3086 }
3087 if (!$autoload) {
3088 $html .= 'jQuery(document).ready(function(){
3089 jQuery("#controls' . $id . '").hide();
3090 jQuery("#zoom-in-out-controls' . $id . '").hide();
3091 jQuery("#adcontrol' . $id . '").hide();
3092 jQuery("#explainer_button_' . $id . '").hide();
3093 jQuery("#generic_form_button_' . $id . '").hide();
3094 jQuery("#floor_map_button_' . $id . '").hide();
3095 jQuery("#vrgcontrols' . $id . '").hide();
3096 jQuery("#cp-logo-controls").hide();
3097 jQuery(".custom-scene-navigation").hide();
3098 jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
3099 });';
3100 if ($vrgallery_display) {
3101 $html .= 'var load_once = "true";';
3102 $html .= 'panoshow' . $id . '.on("load", function (){
3103 if (load_once == "true") {
3104 load_once = "false";
3105 jQuery("#sccontrols' . $id . '").slideToggle(function(){
3106 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3107 if (jQuery(this).is(":visible")) {
3108 jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css("display", "flex");
3109 }
3110 }
3111 if (jQuery(".bricks-is-frontend").length) {
3112 if (jQuery(this).is(":visible")) {
3113 jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3114 "display": "flex",
3115 "justify-content": "center",
3116 "align-items": "center"
3117 });
3118 }
3119 }
3120 });
3121 jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3122 }
3123 });';
3124 }
3125 $html .= 'panoshow' . $id . '.on("load", function (){
3126 jQuery("#controls' . $id . '").show();
3127 jQuery("#zoom-in-out-controls' . $id . '").show();
3128 jQuery("#adcontrol' . $id . '").show();
3129 jQuery("#explainer_button_' . $id . '").show();
3130 jQuery("#generic_form_button_' . $id . '").show();
3131 jQuery("#floor_map_button_' . $id . '").show();
3132 jQuery("#vrgcontrols' . $id . '").show();
3133 jQuery("#cp-logo-controls").show();
3134 jQuery(".custom-scene-navigation").show();
3135 jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
3136 });';
3137 }
3138
3139 //==Old code working properly==//
3140
3141 $previeword = "Click to Load Panorama";
3142 if (isset($postdata['previewtext']) && $postdata['previewtext'] != '') {
3143 $previeword = $postdata['previewtext'];
3144 }
3145 $html .= 'jQuery(".elementor-tab-title").click(function(){
3146 var element_id;
3147 var pano_id;
3148 var element_id = this.id;
3149 element_id = element_id.split("-");
3150 element_id = element_id[3];
3151 jQuery("#elementor-tab-content-"+element_id).find("#master-container").children("div").eq(1).addClass("awwww");
3152 var pano_id = jQuery(".awwww").attr("id");
3153 jQuery("#elementor-tab-content-"+element_id).find("#master-container").children("div").eq(1).removeClass("awwww");;
3154 if (pano_id != undefined) {
3155 pano_id = pano_id.split("o");
3156 pano_id = pano_id[1];
3157 if (pano_id == "' . $id . '") {
3158 jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3159 jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3160 panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);
3161 jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '")
3162 setTimeout(function() {
3163 // panoshow' . $id . '.loadScene("' . $default_scene . '");
3164 window.dispatchEvent(new Event("resize"));
3165 if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3166 jQuery("#controls' . $id . '").css("bottom", "55px");
3167 } else {
3168 jQuery("#controls' . $id . '").css("bottom", "5px");
3169 }
3170 }, 200);
3171 }
3172 }
3173 });';
3174 $html .= 'jQuery(".geodir-tab-head dd, #vr-tour-tab").click(function(){
3175 jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3176 jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3177 panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);
3178 setTimeout(function() {
3179 panoshow' . $id . '.loadScene("' . $default_scene . '");
3180 window.dispatchEvent(new Event("resize"));
3181 if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3182 jQuery("#controls' . $id . '").css("bottom", "55px");
3183 }
3184 else {
3185 jQuery("#controls' . $id . '").css("bottom", "5px");
3186 }
3187 }, 200);
3188 });';
3189 if (isset($previeword) && $previeword != '') {
3190 $html .= '
3191 jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '")
3192 ';
3193 }
3194 if ($default_global_zoom != '' || $max_global_zoom != '' || $min_global_zoom != '') {
3195 $html .= 'jQuery(".globalzoom").val("on").change();';
3196 }
3197
3198 $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3199 jQuery(this).attr("title", jQuery(this).text());
3200 });
3201 jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3202 jQuery(this).removeAttr("title");
3203 });';
3204 $html .= '});';
3205 $html .= '})(jQuery);';
3206 $html .= '</script>';
3207 $tour_data = [];
3208 if(defined("WPVR_PRO_VERSION")){
3209 $tour_data = array(
3210 'explainerControlSwitch' => ( isset( $custom_control['explainerSwitch'] ) && $custom_control['explainerSwitch'] === 'on' ) ? 'on' : 'off',
3211 'floor_plan_enable' => $floor_plan_enable ?? '',
3212 'floor_plan_image' => $floor_plan_image ?? '',
3213 'custom_control' => $custom_control ?? '',
3214 );
3215 }
3216 ob_start();
3217 echo $html;
3218 $output = ob_get_clean();
3219 return apply_filters('wpvr_generate_tour_layout_html', $output ,$postdata ,$id, $tour_data);
3220 }
3221
3222 function replace_callback($matches){
3223 foreach ($matches as $match){
3224 return str_replace('<img','<img decoding="async"',$match);
3225 }
3226
3227 }
3228
3229 private function sanitize_content_preserve_styles($content) {
3230 // Decode HTML entities first (in case content was encoded in database)
3231 $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
3232
3233 // Escape <script> blocks to display as text instead of removing them
3234 $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
3235 return esc_html($matches[0]); // Convert to plain text
3236 }, $content);
3237
3238 // Strip dangerous URL-based attributes
3239 $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*(javascript|vbscript|data|about):/i', '$1=""', $content);
3240
3241 // Escape inline event handlers (onclick, onhover, etc.) to display as text
3242 $content = preg_replace_callback('/\s*(on\w+)\s*=\s*(["\'])([^"\']*)\2/i', function($matches) {
3243 // Escape the attribute value but keep the attribute name visible as text
3244 return ' ' . esc_html($matches[1]) . '=' . $matches[2] . esc_html($matches[3]) . $matches[2];
3245 }, $content);
3246 $content = preg_replace_callback('/\s*(on\w+)\s*=\s*([^>\s]+)/i', function($matches) {
3247 // Handle unquoted event handlers
3248 return ' ' . esc_html($matches[1]) . '=' . esc_html($matches[2]);
3249 }, $content);
3250
3251 // Remove all unsafe embedded/interactive elements except iframe
3252 $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
3253 $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
3254
3255 // Clean style attributes safely
3256 $content = preg_replace_callback('/style\s*=\s*["\']([^"\']*)["\']/', function($matches) {
3257 $style = $matches[1];
3258 $style = preg_replace('/expression\s*\(/i', '', $style);
3259 $style = preg_replace('/(javascript|vbscript|data|about)\s*:/i', '', $style);
3260 $style = preg_replace('/url\s*\(\s*["\']?\s*(javascript|vbscript|data):/i', '', $style);
3261 $style = preg_replace('/behavior\s*:/i', '', $style);
3262 $style = preg_replace('/-moz-binding\s*:/i', '', $style);
3263 return 'style="' . esc_attr($style) . '"';
3264 }, $content);
3265
3266 // Sanitize <style> blocks
3267 $content = preg_replace_callback('/<style\b[^>]*>(.*?)<\/style>/si', function($matches) {
3268 $css = $matches[1];
3269 $css = preg_replace('/(expression|javascript|vbscript|data|about)\s*:/i', '', $css);
3270 $css = preg_replace('/url\s*\(\s*["\']?\s*(javascript|vbscript|data):/i', '', $css);
3271 $css = preg_replace('/behavior\s*:/i', '', $css);
3272 $css = preg_replace('/-moz-binding\s*:/i', '', $css);
3273 return '<style>' . esc_html($css) . '</style>';
3274 }, $content);
3275
3276 // Allow iframes from safe sources only (e.g., YouTube, Vimeo)
3277 $allowed_tags = wp_kses_allowed_html('post');
3278 $allowed_tags['iframe'] = [
3279 'src' => true,
3280 'width' => true,
3281 'height' => true,
3282 'frameborder' => true,
3283 'allowfullscreen' => true,
3284 'class' => true,
3285 'style' => true,
3286 'title' => true,
3287 'allow' => true,
3288 'name' => true,
3289 'referrerpolicy' => true,
3290 'loading' => true,
3291 'sandbox' => true,
3292 ];
3293 $allowed_tags['img'] = [
3294 'src' => true,
3295 'alt' => true,
3296 'title' => true,
3297 'width' => true,
3298 'height' => true,
3299 'class' => true,
3300 'id' => true,
3301 'style' => true,
3302 'loading' => true,
3303 'srcset' => true,
3304 'sizes' => true,
3305 ];
3306
3307 // Apply wp_kses() to keep only allowed tags/attributes
3308 $content = wp_kses($content, $allowed_tags);
3309
3310 // Finally, validate iframe src for security (allow https only, block javascript: etc.)
3311 $content = preg_replace_callback('/<iframe[^>]+src=["\']([^"\']+)["\'][^>]*>(?:<\/iframe>)?/i', function($matches) {
3312 $src = $matches[1];
3313 // Allow any https:// or http:// URL, but block javascript:, data:, vbscript:, etc.
3314 if (preg_match('/^(https?:)?\/\//i', $src) && !preg_match('/^(javascript|data|vbscript|about):/i', $src)) {
3315 return $matches[0]; // keep safe iframe
3316 }
3317 // Strip unsafe iframe
3318 return '';
3319 }, $content);
3320
3321 return $content;
3322 }
3323
3324 }