PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.38
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.38
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.38, at admin/classes/class-wpvr-scene.php

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