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

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