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

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