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

wpvr.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.35, at wpvr.php

3,376 lines 155.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * The plugin bootstrap file
5 *
6 * This file is read by WordPress to generate the plugin information in the plugin
7 * admin area. This file also includes all of the dependencies used by the plugin,
8 * registers the activation and deactivation functions, and defines a function
9 * that starts the plugin.
10 *
11 * @link http://rextheme.com/
12 * @since 7.3.6
13 * @package Wpvr
14 *
15 * @wordpress-plugin
16 * Plugin Name: WP VR
17 * Plugin URI: https://rextheme.com/wpvr/
18 * Description: WP VR - 360 Panorama and virtual tour creator for WordPress is a customized panaroma & virtual builder tool for WordPress Website.
19 * Version: 8.5.35
20 * Tested up to: 6.8.1
21 * Author: Rextheme
22 * Author URI: http://rextheme.com/
23 * License: GPL-2.0+
24 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
25 * Text Domain: wpvr
26 * Domain Path: /languages
27 */
28
29 // If this file is called directly, abort.
30 if (!defined('WPINC')) {
31 die;
32 }
33
34 require plugin_dir_path(__FILE__) . 'elementor/elementor.php';
35
36 if ( wp_get_theme('bricks')->exists() && 'bricks' === get_template()) {
37 require_once plugin_dir_path(__FILE__) . 'bricks/bricks.php';
38 }
39
40 /**
41 * Currently plugin version.
42 * Start at version 1.0.0 and use SemVer - https://semver.org
43 * Rename this for your plugin and update it as you release new versions.
44 */
45 define('WPVR_VERSION', '8.5.35');
46 define('WPVR_FILE', __FILE__);
47 define("WPVR_PLUGIN_DIR_URL", plugin_dir_url(__FILE__));
48 define("WPVR_PLUGIN_DIR_PATH", plugin_dir_path(__FILE__));
49 define("WPVR_PLUGIN_PUBLIC_DIR_URL", plugin_dir_url(__FILE__) . 'public/');
50 define('WPVR_BASE', plugin_basename(WPVR_FILE));
51 define('WPVR_DEV_MODE', false);
52 define('WPVR_JS_PATH', plugin_dir_url(__FILE__) . 'admin/js/');
53 define('WPVR_ASSET_PATH', plugin_dir_url(__FILE__) . 'admin/');
54 define( 'WPVR_WEBHOOK_URL', sanitize_url( 'https://rextheme.com/?mailmint=1&route=webhook&topic=contact&hash=bbd19901-6d42-4ae5-a7a8-01eb1013c553' ) );
55
56 /**
57 * The code that runs during plugin activation.
58 * This action is documented in includes/class-wpvr-activator.php
59 */
60 function activate_wpvr()
61 {
62 require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-activator.php';
63 Wpvr_Activator::activate();
64 }
65
66 /**
67 * The code that runs during plugin deactivation.
68 * This action is documented in includes/class-wpvr-deactivator.php
69 */
70 function deactivate_wpvr()
71 {
72 require_once plugin_dir_path(__FILE__) . 'includes/class-wpvr-deactivator.php';
73 Wpvr_Deactivator::deactivate();
74 }
75
76 register_activation_hook(__FILE__, 'activate_wpvr');
77 register_deactivation_hook(__FILE__, 'deactivate_wpvr');
78
79 /**
80 * The core plugin class that is used to define internationalization,
81 * admin-specific hooks, and public-facing site hooks.
82 */
83 require plugin_dir_path(__FILE__) . 'includes/class-wpvr.php';
84
85 /**
86 * Begins execution of the plugin.
87 *
88 * Since everything within the plugin is registered via hooks,
89 * then kicking off the plugin from this point in the file does
90 * not affect the page life cycle.
91 *
92 * @since 7.3.6
93 */
94 function run_wpvr()
95 {
96
97 $plugin = new Wpvr();
98 $plugin->run();
99
100 // black friday banner class initialization
101 new WPVR_Special_Occasion_Banner(
102 '4th_of_july_deal_2025',
103 '2025-07-02 00:00:01',
104 '2025-07-14 23:59:59'
105 );
106
107 // if (!defined('WPVR_PRO_VERSION') && 'no' === get_option('wpvr_sell_notification_bar', 'no')) {
108 // new WPVR_Notification_Bar();
109 // }
110
111
112 }
113 run_wpvr();
114
115
116 /**
117 * Array information checker
118 *
119 * @param mixed $needle
120 * @param mixed $haystack
121 * @param bool $strict
122 *
123 * @return bool
124 * @since 7.3.6
125 */
126 function wpvr_in_array_r($needle, $haystack, $strict = false)
127 {
128 foreach ($haystack as $item) {
129 if ((($strict ? $item === $needle : $item == $needle)) || is_array($item) && wpvr_in_array_r($needle, $item, $strict)) {
130 return true;
131 }
132 }
133 return false;
134 }
135
136
137 /**
138 * Initialize the plugin tracker
139 *
140 * @return void
141 * @since 7.3.6
142 */
143 function appsero_init_tracker_wpvr()
144 {
145 if (!class_exists('Appsero\Client')) {
146 require_once __DIR__ . '/appsero/src/Client.php';
147 }
148 $client = new Appsero\Client('cab9761e-b067-4824-9c71-042df5d58598', 'WP VR', __FILE__);
149
150 // Active insights
151 $client->insights()->init();
152 }
153
154 appsero_init_tracker_wpvr();
155
156
157 function wpvr_block()
158 {
159 wp_register_script(
160 'wpvr-block',
161 plugins_url('build/index.build.js', __FILE__),
162 array('wp-blocks', 'wp-element', 'wp-components', 'wp-editor')
163 );
164
165 if (is_admin()) {
166 wp_enqueue_style(
167 'gutyblocks/guty-block',
168 plugins_url('src/view.css', __FILE__),
169 array()
170 );
171 }
172
173
174 if (function_exists('register_block_type')) {
175 register_block_type('wpvr/wpvr-block', array(
176 'attributes' => array(
177 'id' => array(
178 'type' => 'string',
179 'default' => '0',
180 ),
181 'width' => array(
182 'type' => 'string',
183 'default' => '600',
184 ),
185 'width_unit' => array(
186 'type' => 'string',
187 'default' => 'px',
188 ),
189 'height' => array(
190 'type' => 'string',
191 'default' => '400',
192 ),
193 'height_unit' => array(
194 'type' => 'string',
195 'default' => 'px',
196 ),
197 'mobile_height' => array(
198 'type' => 'string',
199 'default' => '300',
200 ),
201 'mobile_height_unit' => array(
202 'type' => 'string',
203 'default' => 'px',
204 ),
205 'radius' => array(
206 'type' => 'string',
207 'default' => '0',
208 ),
209 'border_width' => array(
210 'type' => 'string',
211 'default' => '0px',
212 ),
213 'border_style' => array(
214 'type' => 'string',
215 'default' => 'none',
216 ),
217 'border_color' => array(
218 'type' => 'string',
219 'default' => 'none',
220 ),
221 'radius_unit' => array(
222 'type' => 'string',
223 'default' => 'px',
224 ),
225 'content' => array(
226 'type' => 'string',
227 'source' => 'html',
228 'default' => '<script> </script>'
229 ),
230 ),
231 'editor_script' => 'wpvr-block',
232 'render_callback' => 'wpvr_block_render',
233 ));
234 }
235 }
236
237 add_action('init', 'wpvr_block');
238
239 function wpvr_block_render($attributes)
240 {
241 if (isset($attributes['id'])) {
242 $id = $attributes['id'];
243 } else {
244 $id = 0;
245 }
246
247 $memberpress_active = defined('MEPR_VERSION');
248 $rcp_active = is_plugin_active( 'restrict-content-pro/restrict-content-pro.php' );
249
250 if (($memberpress_active || $rcp_active ) && apply_filters('is_wpvr_pro_active', false)) {
251
252 if (!is_user_logged_in()) {
253 return esc_html__('You need to log in to access this content.', 'wpvr');
254 }
255
256 $user_id = get_current_user_id();
257 $allowed_access = false;
258
259 // Get saved membership levels from post meta
260 $allowed_membership_levels = get_post_meta($id, '_wpvr_allowed_roles_levels', true);
261 if ( isset($allowed_membership_levels) && 'none' !== $allowed_membership_levels ) {
262 if (!is_array($allowed_membership_levels)) {
263 $allowed_membership_levels = array($allowed_membership_levels);
264 }
265
266 // Check MemberPress Access
267 if ($memberpress_active) {
268 $user = new MeprUser($user_id);
269 $active_memberships = $user->active_product_subscriptions();
270 if (array_intersect($allowed_membership_levels, $active_memberships) ) {
271 $allowed_access = true;
272 }
273 }
274
275 // Check Restrict Content Pro Access
276 if ($rcp_active) {
277 $user_rcp_memberships = rcp_get_customer_memberships($user_id);
278 foreach ($user_rcp_memberships as $membership) {
279 $rcp_access_level = array(
280 $membership->get_object_id()
281 );
282 if (array_intersect($allowed_membership_levels, $rcp_access_level) ) {
283 $allowed_access = true;
284 break;
285 }
286 }
287 }
288 } else {
289 // If no membership restriction is set, allow access by default
290 $allowed_access = true;
291 }
292
293 if (!$allowed_access) {
294 return esc_html__('You do not have access to this content.', 'wpvr');
295 }
296 }
297
298
299 if (isset($attributes['width'])) {
300 $width = $attributes['width'];
301 }
302 if (isset($attributes['width_unit'])) {
303 $width_unit = $attributes['width_unit'];
304 }
305 if (isset($attributes['height'])) {
306 $height = $attributes['height'];
307 }
308 if (isset($attributes['height_unit'])) {
309 $height_unit = $attributes['height_unit'];
310 }
311 if (isset($attributes['mobile_height'])) {
312 $mobile_height = $attributes['mobile_height'];
313 }
314 if (isset($attributes['mobile_height_unit'])) {
315 $mobile_height_unit = $attributes['mobile_height_unit'];
316 }
317 if (isset($attributes['radius']) && isset($attributes['radius_unit'])) {
318 $radius = $attributes['radius'] . $attributes['radius_unit'];
319 }
320 $border_style = '';
321 if (isset($attributes['border_width'], $attributes['border_style'], $attributes['border_color'])) {
322 $border_style = $attributes['border_width'] . 'px ' . $attributes['border_style'] . ' ' . $attributes['border_color'];
323 }
324
325 if (isset($attributes['className'])) {
326 $className = $attributes['className'];
327 } else {
328 $className = '';
329 }
330 $get_post = get_post_status($id);
331 if ($get_post !== 'publish') {
332 return esc_html__('Oops! It seems like this post isn\'t published yet. Stay tuned for updates!', 'wpvr');
333 }
334 if (post_password_required($id)) {
335 return get_the_password_form();
336 }
337 $postdata = get_post_meta($id, 'panodata', true);
338 $panoid = 'pano' . $id;
339 $panoid2 = 'pano2' . $id;
340 if (!isset($postdata) || empty($postdata)) {
341 return wp_kses(
342 __('Oops! It seems that you have not selected any tour yet. Please select a tour from the dropdown of WPVR block.<br>', 'wpvr'),
343 ['br' => []]
344 );
345 }
346 if (isset($postdata['streetviewdata'])) {
347 if (empty($width)) {
348 $width = '600px';
349 }
350 if (empty($height)) {
351 $height = '400px';
352 }
353 $streetviewurl = $postdata['streetviewurl'];
354 $html = '';
355 $html .= '<div class="vr-streetview ' . esc_attr( $className ) . '" style="text-align: center; max-width:100%; width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; height:' . esc_attr( $height ) . esc_attr( $height_unit ) . '; margin: 0 auto;">';
356 $html .= '<iframe src="' . esc_url( $streetviewurl ) . '" frameborder="0" style="border:0; width:100px; height:100%;" allowfullscreen=""></iframe>';
357 $html .= '</div>';
358
359 return $html;
360 }
361 $is_pro = apply_filters('is_wpvr_pro_active', false);
362
363 if (isset($postdata['vidid'])) {
364 if (empty($width)) {
365 $width = '600';
366 }
367 if (empty($height)) {
368 $height = '400';
369 }
370 $videourl = $postdata['vidurl'];
371
372 $videourl = $postdata['vidurl'];
373 $autoplay = 'off';
374 if (isset($postdata['autoplay'])) {
375 $autoplay = $postdata['autoplay'];
376 }
377 $loop = 'off';
378 if (isset($postdata['loop'])) {
379 $loop = $postdata['loop'];
380 }
381
382 if (strpos($videourl, 'youtube') > 0 || strpos($videourl, 'youtu') > 0) {
383 $explodeid = '';
384 $explodeid = explode("=", $videourl);
385 $foundid = '';
386 $muted = '&mute=1';
387
388 if ($autoplay == 'on') {
389 $autoplay = '&autoplay=1';
390 } else {
391 $autoplay = '';
392 }
393
394 if ($loop == 'on') {
395 $loop = '&loop=1';
396 } else {
397 $loop = '';
398 }
399
400 if (strpos($videourl, 'youtu') > 0) {
401 $explodeid = explode("/", $videourl);
402 $foundid = $explodeid[3] . '?' . $autoplay . $loop;
403 $expdata = $explodeid[3];
404 } else {
405 $foundid = $explodeid[1] . '?' . $autoplay . $loop;
406 $expdata = $explodeid[1];
407 }
408
409 $playlist = '&playlist=' . $expdata;
410 $playlist = str_replace("?feature=shared", "", $playlist);
411
412
413 $html = '';
414 $html .= '<div class="' . esc_attr($className) . '" style="text-align:center; max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height:' . esc_attr($height) . esc_attr($height_unit) . '; border-radius: ' . esc_attr($radius) . '; margin: 0 auto;">';
415
416 // Compatibility check script
417 $html .= '<script>
418 function wpvr_check_360_support() {
419 var support = {
420 supported: false,
421 fullySupported: false,
422 webgl: false,
423 orientation: false,
424 gyroscope: false,
425 touch: false,
426 browser: "unknown",
427 isMobile: false,
428 isIPhone: false,
429 details: []
430 };
431
432 support.isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
433 support.isIPhone = /iPhone/i.test(navigator.userAgent);
434 if (support.isMobile) support.details.push("Mobile device detected");
435 if (support.isIPhone) support.details.push("iPhone detected");
436
437 var ua = navigator.userAgent;
438 if (/^((?!chrome|android).)*safari/i.test(ua)) {
439 support.browser = "safari";
440 support.details.push("Safari browser detected");
441 } else if (ua.indexOf("Chrome") > -1) {
442 support.browser = "chrome";
443 support.details.push("Chrome browser detected");
444 } else if (ua.indexOf("Firefox") > -1) {
445 support.browser = "firefox";
446 support.details.push("Firefox browser detected");
447 } else if (ua.indexOf("MSIE") > -1 || ua.indexOf("Trident") > -1) {
448 support.browser = "ie";
449 support.details.push("Internet Explorer detected");
450 } else if (ua.indexOf("Edge") > -1 || ua.indexOf("Edg") > -1) {
451 support.browser = "edge";
452 support.details.push("Edge browser detected");
453 } else if (ua.indexOf("Opera") > -1 || ua.indexOf("OPR") > -1) {
454 support.browser = "opera";
455 support.details.push("Opera browser detected");
456 }
457
458 try {
459 var canvas = document.createElement("canvas");
460 support.webgl = !!(window.WebGLRenderingContext &&
461 (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")));
462 support.details.push(support.webgl ? "WebGL supported" : "WebGL not supported");
463 } catch (e) {
464 support.webgl = false;
465 support.details.push("WebGL detection error: " + e.message);
466 }
467
468 support.orientation = !!(window.DeviceOrientationEvent);
469 support.details.push(support.orientation ? "Device Orientation API supported" : "Device Orientation API not supported");
470
471 support.gyroscope = !!window.Gyroscope;
472 support.details.push(support.gyroscope ? "Gyroscope supported" : "Gyroscope not supported");
473
474 support.touch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
475 support.details.push(support.touch ? "Touch supported" : "Touch not supported");
476
477 support.supported = support.webgl;
478 support.fullySupported = support.webgl && ((support.isMobile && support.orientation) || !support.isMobile);
479
480 if (support.browser === "safari" && support.isIPhone) {
481 support.browserWarning = "iPhone has limited support for 360 videos in browser. The experience may not be optimal.";
482 support.fullySupported = false;
483 } else if (support.browser === "ie") {
484 support.browserWarning = "Internet Explorer has limited support for 360 videos.";
485 support.fullySupported = false;
486 } else if (!support.supported) {
487 support.browserWarning = "Your browser does not support 360° videos. Use Chrome or Firefox with WebGL.";
488 }
489
490 return support;
491 }
492 </script>';
493
494 $random_id = 'video-container-' . rand(10000, 99999);
495 $html .= '<div id="' . $random_id . '-container" style="position:relative; width:100%; height:100%;">';
496
497 // Compatibility check screen (initially hidden for all, will show only for iPhone)
498 $html .= '<div id="' . $random_id . '-compatibility-check" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:#f9f9f9; border-radius:' . esc_attr( $radius ) . ';">
499 <div style="margin-bottom:20px; text-align:center;">
500 <div class="wpvr-loading-spinner" style="border:5px solid #f3f3f3; border-top:5px solid #3498db; border-radius:50%; width:50px; height:50px; margin:0 auto 15px; animation:wpvr-spin 1s linear infinite;"></div>
501 <p style="margin:0;">Checking browser compatibility...</p>
502 </div>
503 </div>';
504
505 // Spinner animation
506 $html .= '<style>@keyframes wpvr-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>';
507
508 // Iframe (initial display set to block)
509 $html .= '<div id="' . $random_id . '-frame" class="' . esc_attr($className) . '" style="display:block; max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height:' . esc_attr($height) . esc_attr($height_unit) . '; border-radius: ' . esc_attr($radius) . '; margin: 0 auto;">';
510 $html .= '<iframe id="' . $random_id . '-iframe" src="https://www.youtube.com/embed/' . rawurlencode(sanitize_text_field($expdata)) . '?rel=0&modestbranding=1' . esc_attr($loop) . '&autohide=1' . esc_attr($muted) . '&showinfo=0&controls=1' . esc_attr($autoplay) . esc_attr($playlist) . '&enablejsapi=1" width="100%" height="100%" style="border-radius: ' . esc_attr($radius) . ';" frameborder="0" allowfullscreen allow="accelerometer; gyroscope; picture-in-picture"></iframe>';
511 $html .= '</div>';
512
513 // Permission request (mobile only)
514 $html .= '<div id="' . $random_id . '-permission-request" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:rgba(0,0,0,0.7); color:white; text-align:center; border-radius:' . $radius . ';">';
515 $html .= '<p style="font-size:16px; margin:0 20px 15px;">For the best 360° video experience on mobile</p>';
516 $html .= '<button id="' . $random_id . '-permission-button" style="padding:10px 15px; background-color:#0085ba; color:#fff; border:none; border-radius:4px; cursor:pointer;">Allow motion and orientation access</button>';
517 $html .= '</div>';
518
519 // Browser warning
520 $html .= '<div id="' . $random_id . '-browser-warning" style="position:absolute; top:0; left:0; width:100%; height:100%; display:none; flex-direction:column; justify-content:center; align-items:center; background-color:rgba(0,0,0,0.7); color:white; text-align:center; border-radius:' . $radius . ';">';
521 $html .= '<p id="' . $random_id . '-warning-text" style="font-size:16px; margin:0 20px 5px;"></p>';
522 $html .= '<p style="font-size:14px; margin:5px 20px 15px;">For the best experience, use Chrome or Firefox.</p>';
523 $html .= '<button id="' . $random_id . '-browser-continue" style="padding:10px 15px; background-color:#0085ba; color:#fff; border:none; border-radius:4px; cursor:pointer;">Continue Anyway</button>';
524 $html .= '</div>';
525
526 // Main script
527 $html .= '<script>
528 document.addEventListener("DOMContentLoaded", function() {
529 var supportInfo = wpvr_check_360_support();
530 var compatibilityCheck = document.getElementById("' . $random_id . '-compatibility-check");
531 var frameContainer = document.getElementById("' . $random_id . '-frame");
532 var warning = document.getElementById("' . $random_id . '-browser-warning");
533 var warningText = document.getElementById("' . $random_id . '-warning-text");
534 var continueBtn = document.getElementById("' . $random_id . '-browser-continue");
535
536 // Only show compatibility check and warning for iPhone
537 if (supportInfo.isIPhone) {
538 // Hide the iframe initially for iPhone
539 frameContainer.style.display = "none";
540
541 // Show compatibility check for iPhone
542 compatibilityCheck.style.display = "flex";
543
544 // After delay, hide compatibility check and show warning
545 setTimeout(function() {
546 compatibilityCheck.style.display = "none";
547 warningText.textContent = supportInfo.browserWarning || "Your browser may not fully support 360° videos.";
548 warning.style.display = "flex";
549
550 continueBtn.addEventListener("click", function() {
551 warning.style.display = "none";
552
553 if (supportInfo.fullySupported && supportInfo.isMobile) {
554 document.getElementById("' . $random_id . '-permission-request").style.display = "flex";
555 document.getElementById("' . $random_id . '-permission-button").addEventListener("click", function() {
556 requestDevicePermissions();
557 });
558 } else {
559 showVideo();
560 }
561 });
562 }, 1000);
563 } else {
564 // For non-iPhone devices, directly initialize the player
565 initializeYouTubePlayer();
566 }
567
568 function requestDevicePermissions() {
569 try {
570 if (typeof DeviceOrientationEvent !== "undefined" &&
571 typeof DeviceOrientationEvent.requestPermission === "function") {
572 DeviceOrientationEvent.requestPermission().then(function(response) {
573 if (response === "granted") {
574 if (typeof DeviceMotionEvent !== "undefined" &&
575 typeof DeviceMotionEvent.requestPermission === "function") {
576 DeviceMotionEvent.requestPermission().then(showVideo).catch(showVideo);
577 } else {
578 showVideo();
579 }
580 } else {
581 showVideo();
582 }
583 }).catch(showVideo);
584 } else {
585 showVideo();
586 }
587 } catch (e) {
588 showVideo();
589 }
590 }
591
592 function showVideo() {
593 document.getElementById("' . $random_id . '-permission-request").style.display = "none";
594 frameContainer.style.display = "block";
595 initializeYouTubePlayer();
596 }
597
598 function initializeYouTubePlayer() {
599 if (window.YT) {
600 initPlayer();
601 } else {
602 var tag = document.createElement("script");
603 tag.src = "https://www.youtube.com/iframe_api";
604 var firstScriptTag = document.getElementsByTagName("script")[0];
605 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
606 window.onYouTubeIframeAPIReady = initPlayer;
607 }
608
609 function initPlayer() {
610 new YT.Player("' . $random_id . '-iframe", {
611 events: {
612 "onReady": function(event) {}
613 }
614 });
615 }
616 }
617 });
618 </script>';
619
620 $html .= '</div>'; // Close container
621 $html .= '</div>'; // Close outer wrapper
622 } else {
623 $html = '';
624 $html .= '<div id="pano' . esc_attr($id) . '" class="pano-wrap ' . esc_attr($className) . '" style="max-width:100%; width:' . esc_attr($width) . esc_attr($width_unit) . '; height: ' . esc_attr($height) . esc_attr($height_unit) . '; border-radius:' . esc_attr($radius) . '; margin: 0 auto;">';
625 $html .= '<div style="width:100%; height:100%; border-radius: ' . esc_attr($radius) . ';">' . $postdata['panoviddata'] . '</div>';
626
627 $html .= '
628 <style>
629 .video-js {
630 border-radius:' . $radius . ';
631 }
632 .video-js canvas{
633 border-radius:' . $radius . ';
634 }
635 #pano' . $id . ' .vjs-poster {
636 border-radius: ' . $radius . ';
637 }
638 </style>
639
640 ';
641
642 // $html .= '<script>';
643 // $html .= 'videojs(' . $postdata['vidid'] . ', {';
644 // $html .= 'plugins: {';
645 // $html .= 'pannellum: {}';
646 // $html .= '}';
647 // $html .= '});';
648 // $html .= '</script>';
649 $html .= '</div>';
650
651 //video js vr setup //
652 $html .= '<script>';
653 $html .= '
654 (function (window, videojs) {
655 var player = window.player = videojs("' . $postdata['vidid'] . '");
656 player.mediainfo = player.mediainfo || {};
657 player.mediainfo.projection = "equirectangular";
658
659 // AUTO is the default and looks at mediainfo
660 var vr = window.vr = player.vr({ projection: "AUTO", debug: true, forceCardboard: false, antialias: false });
661 }(window, window.videojs));
662
663 ';
664 $html .= '</script>';
665 //video js vr end //
666 }
667 return $html;
668 }
669
670 $control = false;
671 if (isset($postdata['showControls'])) {
672 $control = $postdata['showControls'];
673 }
674
675 if ($control) {
676 if (isset($postdata['customcontrol'])) {
677 $custom_control = $postdata['customcontrol'];
678 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") {
679 $control = false;
680 }
681 }
682 }
683
684 $floor_plan_enable = 'off';
685 $floor_plan_image = '';
686 if (isset($postdata['floor_plan_tour_enabler']) && $postdata['floor_plan_tour_enabler'] == 'on') {
687 $floor_plan_enable = $postdata['floor_plan_tour_enabler'];
688 if (isset($postdata['floor_plan_attachment_url']) && !empty($postdata['floor_plan_attachment_url'])) {
689 $floor_plan_image = $postdata['floor_plan_attachment_url'];
690 }
691 }
692
693 $vrgallery = false;
694 if (isset($postdata['vrgallery'])) {
695 $vrgallery = $postdata['vrgallery'];
696 }
697
698 $vrgallery_title = false;
699 if (isset($postdata['vrgallery_title'])) {
700 $vrgallery_title = $postdata['vrgallery_title'];
701 }
702
703 $vrgallery_display = false;
704 if (isset($postdata['vrgallery_display'])) {
705 $vrgallery_display = $postdata['vrgallery_display'];
706 }
707 $vrgallery_icon_size = false;
708 if (isset($postdata['vrgallery_icon_size'])) {
709 $vrgallery_icon_size = $postdata['vrgallery_icon_size'];
710 }
711
712 $gyro = false;
713 $gyro_orientation = false;
714 if (isset($postdata['gyro'])) {
715 $gyro = $postdata['gyro'];
716 if (isset($postdata['deviceorientationcontrol'])) {
717 $gyro_orientation = $postdata['deviceorientationcontrol'];
718 }
719 }
720
721 $compass = false;
722 $audio_right = "5px";
723 if (isset($postdata['compass'])) {
724 $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
725 if ($compass) {
726 $audio_right = "60px";
727 }
728 }
729 $floor_map_right = "10px";
730 if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
731 $floor_map_right = "85px";
732 } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
733 $floor_map_right = "55px";
734 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
735 $floor_map_right = "25px";
736 }
737
738 //===explainer handle===//
739
740 //===explainer handle===//
741 $explainer_right = "10px";
742 if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
743 $explainer_right = "130px";
744 } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on' && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
745 $explainer_right = "100px";
746 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
747 $explainer_right = "60px";
748 } elseif ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
749 $explainer_right = "80px";
750 } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
751 $explainer_right = "55px";
752 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
753 $explainer_right = "30px";
754 } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
755 $explainer_right = "40px";
756 }
757 $enable_cardboard = '';
758 $is_cardboard = get_option('wpvr_cardboard_disable');
759 if (wpvr_isMobileDevice() && $is_cardboard == 'true') {
760 $enable_cardboard = 'enable-cardboard';
761 $audio_right = "73px";
762 if (isset($postdata['compass'])) {
763 $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
764 if ($compass) {
765 $audio_right = "130px";
766 }
767 }
768
769 $floor_map_right = "60px";
770 if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
771 $floor_map_right = "150px";
772 } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
773 $floor_map_right = "120px";
774 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
775 $floor_map_right = "90px";
776 }
777
778 //===explainer handle===//
779
780 $explainer_right = "65px";
781
782 if ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
783 $explainer_right = "150px";
784 } elseif ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
785 $explainer_right = "180px";
786 } elseif (isset($postdata['compass']) && $postdata['compass'] == true && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
787 $explainer_right = "150px";
788 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
789 $explainer_right = "120px";
790 } elseif (isset($postdata['compass']) && $postdata['compass'] == true) {
791 $explainer_right = "130px";
792 } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
793 $explainer_right = "90px";
794 } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
795 $explainer_right = "90px";
796 }
797 }
798
799 //===explainer handle===//
800
801 $mouseZoom = true;
802 if (isset($postdata['mouseZoom'])) {
803 if ($postdata['mouseZoom'] == "off") {
804 $mouseZoom = false;
805 } else {
806 $mouseZoom = true;
807 }
808 }
809
810 $draggable = true;
811 if (isset($postdata['draggable'])) {
812 $draggable = $postdata['draggable'] == 'on' || $postdata['draggable'] != null ? true : false;
813 if ($postdata['draggable'] === 'off') {
814 $draggable = false;
815 }
816 }
817 $diskeyboard = false;
818 if (isset($postdata['diskeyboard'])) {
819 $diskeyboard = $postdata['diskeyboard'] == 'off' || $postdata['diskeyboard'] == null ? false : true;
820 }
821
822 $keyboardzoom = true;
823 if (isset($postdata['keyboardzoom'])) {
824 $keyboardzoom = $postdata['keyboardzoom'];
825 }
826
827 $autoload = false;
828
829 if (isset($postdata['autoLoad'])) {
830 $autoload = $postdata['autoLoad'];
831 }
832
833 $default_scene = '';
834 if (isset($postdata['defaultscene'])) {
835 $default_scene = $postdata['defaultscene'];
836 }
837
838 $preview = '';
839 if (isset($postdata['preview'])) {
840 $preview = $postdata['preview'];
841 }
842
843 $autorotation = '';
844 if (isset($postdata["autoRotate"])) {
845 $autorotation = $postdata["autoRotate"];
846 }
847 $autorotationinactivedelay = '';
848 if (isset($postdata["autoRotateInactivityDelay"])) {
849 $autorotationinactivedelay = $postdata["autoRotateInactivityDelay"];
850 }
851 $autorotationstopdelay = '';
852 if (isset($postdata["autoRotateStopDelay"])) {
853 $autorotationstopdelay = $postdata["autoRotateStopDelay"];
854 }
855
856 $scene_fade_duration = '';
857 if (isset($postdata['scenefadeduration'])) {
858 $scene_fade_duration = $postdata['scenefadeduration'];
859 }
860
861 $panodata = array();
862 if (isset($postdata['panodata'])) {
863 $panodata = $postdata['panodata'];
864 }
865
866 $default_zoom_global = 100;
867 if (isset($postdata['hfov']) && $postdata['hfov'] != '') {
868 $default_zoom_global = $postdata['hfov'];
869 }
870
871 $min_zoom_global = 50;
872 if (isset($postdata['minHfov']) && $postdata['minHfov'] != '') {
873 $min_zoom_global = $postdata['minHfov'];
874 }
875
876 $max_zoom_global = 120;
877 if (isset($postdata['maxHfov']) && $postdata['maxHfov'] != '') {
878 $max_zoom_global = $postdata['maxHfov'];
879 }
880
881 $hotspoticoncolor = '#00b4ff';
882 $hotspotblink = 'on';
883 $default_data = array();
884 $default_data = array('firstScene' => $default_scene, 'sceneFadeDuration' => $scene_fade_duration, 'hfov' => $default_zoom_global, 'maxHfov' => $max_zoom_global, 'minHfov' => $min_zoom_global);
885 $scene_data = array();
886 if (is_array($panodata) && isset($panodata['scene-list'])) {
887 if (!empty($panodata['scene-list'])) {
888 foreach ($panodata['scene-list'] as $panoscenes) {
889 $scene_ititle = '';
890 if (isset($panoscenes["scene-ititle"])) {
891 $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]);
892 }
893
894 $scene_author = '';
895 if (isset($panoscenes["scene-author"])) {
896 $scene_author = sanitize_text_field($panoscenes["scene-author"]);
897 }
898
899 $scene_author_url = '';
900 if (isset($panoscenes["scene-author-url"])) {
901 $scene_author_url = sanitize_text_field($panoscenes["scene-author-url"]);
902 }
903
904 $scene_vaov = 180;
905 if (isset($panoscenes["scene-vaov"])) {
906 $scene_vaov = (float)$panoscenes["scene-vaov"];
907 }
908
909 $scene_haov = 360;
910 if (isset($panoscenes["scene-haov"])) {
911 $scene_haov = (float)$panoscenes["scene-haov"];
912 }
913
914 $scene_vertical_offset = 0;
915 if (isset($panoscenes["scene-vertical-offset"])) {
916 $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
917 }
918
919 $default_scene_pitch = null;
920 if (isset($panoscenes["scene-pitch"])) {
921 $default_scene_pitch = (float)$panoscenes["scene-pitch"];
922 }
923
924 $default_scene_yaw = null;
925 if (isset($panoscenes["scene-yaw"])) {
926 $default_scene_yaw = (float)$panoscenes["scene-yaw"];
927 }
928
929 $scene_max_pitch = '';
930 if (isset($panoscenes["scene-maxpitch"])) {
931 $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
932 }
933
934
935 $scene_min_pitch = '';
936 if (isset($panoscenes["scene-minpitch"])) {
937 $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
938 }
939
940
941 $scene_max_yaw = '';
942 if (isset($panoscenes["scene-maxyaw"])) {
943 $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
944 }
945
946
947 $scene_min_yaw = '';
948 if (isset($panoscenes["scene-minyaw"])) {
949 $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
950 }
951
952 $default_zoom = 100;
953 if (isset($panoscenes["scene-zoom"]) && $panoscenes["scene-zoom"] != '') {
954 $default_zoom = (int)$panoscenes["scene-zoom"];
955 } else {
956 if ($default_zoom_global != '') {
957 $default_zoom = (int)$default_zoom_global;
958 }
959 }
960
961
962 $max_zoom = 120;
963 if (isset($panoscenes["scene-maxzoom"]) && $panoscenes["scene-maxzoom"] != '') {
964 $max_zoom = (int)$panoscenes["scene-maxzoom"];
965 } else {
966 if ($max_zoom_global != '') {
967 $max_zoom = (int)$max_zoom_global;
968 }
969 }
970
971 $min_zoom = 120;
972 if (isset($panoscenes["scene-minzoom"]) && $panoscenes["scene-minzoom"] != '') {
973 $min_zoom = (int)$panoscenes["scene-minzoom"];
974 } else {
975 if ($min_zoom_global != '') {
976 $min_zoom = (int)$min_zoom_global;
977 }
978 }
979
980 $hotspot_datas = array();
981 if (isset($panoscenes['hotspot-list'])) {
982 $hotspot_datas = $panoscenes['hotspot-list'];
983 }
984
985 $hotspots = array();
986
987 foreach ($hotspot_datas as $hotspot_data) {
988 $status = get_option('wpvr_edd_license_status');
989 if ($status !== false && $status == 'valid') {
990
991 if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
992 $hotspot_data['hotspot-customclass'] = $hotspot_data["hotspot-customclass-pro"] . ' custom-' . $id . '-' . $panoscenes['scene-id'] . '-' . $hotspot_data['hotspot-title'];
993 }
994 if (isset($hotspot_data['hotspot-blink'])) {
995 $hotspotblink = $hotspot_data['hotspot-blink'];
996 }
997 }
998 $hotspot_scene_pitch = '';
999 if (isset($hotspot_data["hotspot-scene-pitch"])) {
1000 $hotspot_scene_pitch = $hotspot_data["hotspot-scene-pitch"];
1001 }
1002 $hotspot_scene_yaw = '';
1003 if (isset($hotspot_data["hotspot-scene-yaw"])) {
1004 $hotspot_scene_yaw = $hotspot_data["hotspot-scene-yaw"];
1005 }
1006
1007 $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"];
1008 $hotspot_content = '';
1009
1010 ob_start();
1011 do_action('wpvr_hotspot_content', $hotspot_data);
1012 $hotspot_content = ob_get_clean();
1013
1014 if (!$hotspot_content) {
1015 $hotspot_content = $hotspot_data["hotspot-content"];
1016 }
1017
1018 if (isset($hotspot_data["wpvr_url_open"][0])) {
1019 $wpvr_url_open = $hotspot_data["wpvr_url_open"][0];
1020 } else {
1021 $wpvr_url_open = "off";
1022 }
1023 $on_hover_content = preg_replace_callback(
1024 '/<p>\s*(<img[^>]*>)\s*<br>\s*<\/p>/i',
1025 function ($matches) {
1026 return $matches[1];
1027 },
1028 $hotspot_data['hotspot-hover'] ?? ''
1029 );
1030 $allowed_tags = [
1031 'a' => ['href' => [], 'title' => []],
1032 'img' => ['src' => [], 'alt' => [], 'title' => [], 'width' => [], 'height' => []],
1033 'br' => [],
1034 'em' => [],
1035 'strong' => [],
1036 'p' => [],
1037 'span' => ['style' => []],
1038 'b' => [],
1039 'i' => [],
1040 ];
1041 $on_hover_content = wp_kses($on_hover_content ?? '', $allowed_tags);
1042 $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1043 $hotspot_shape = 'round';
1044 if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
1045 $hotspot_shape = isset($hotspot_data["hotspot-shape"]) ? $hotspot_data["hotspot-shape"] : 'round';
1046 }
1047
1048 $hotspot_data_for_on_click=[];
1049 if('info' === $hotspot_type && !empty($on_click_content)){
1050 $hotspot_data_for_on_click = [
1051 'on_click_content' => $on_click_content,
1052 'tour_id' => $id,
1053 'scene_id' => $panoscenes['scene-id'],
1054 'hotspot_id' => $hotspot_data['hotspot-title'],
1055 ];
1056 } elseif('info' === $hotspot_type && !empty($hotspot_data["hotspot-url"])){
1057 $hotspot_data_for_on_click = [
1058 'on_click_content' => '',
1059 'tour_id' => $id,
1060 'scene_id' => $panoscenes['scene-id'],
1061 'hotspot_id' => $hotspot_data['hotspot-title'],
1062 ];
1063 }
1064
1065 $hotspot_info = array(
1066 'text' => $hotspot_data['hotspot-title'],
1067 'pitch' => $hotspot_data['hotspot-pitch'],
1068 'yaw' => $hotspot_data['hotspot-yaw'],
1069 'type' => $hotspot_type,
1070 'cssClass' => $hotspot_data['hotspot-customclass'],
1071 'URL' => $hotspot_data['hotspot-url'],
1072 "wpvr_url_open" => $wpvr_url_open,
1073 "clickHandlerArgs" => $hotspot_data_for_on_click,
1074 'createTooltipArgs' => $on_hover_content,
1075 "sceneId" => $hotspot_data["hotspot-scene"],
1076 "targetPitch" => (float)$hotspot_scene_pitch,
1077 "targetYaw" => (float)$hotspot_scene_yaw,
1078 'hotspot_type' => $hotspot_data['hotspot-type'],
1079 'hotspot_shape' => $hotspot_shape,
1080 );
1081
1082 $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1083
1084 if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1085 unset($hotspot_info["cssClass"]);
1086 }
1087 if (empty($hotspot_data["hotspot-scene"])) {
1088 unset($hotspot_info['targetPitch']);
1089 unset($hotspot_info['targetYaw']);
1090 }
1091 array_push($hotspots, $hotspot_info);
1092 }
1093
1094 $device_scene = $panoscenes['scene-attachment-url'];
1095 $mobile_media_resize = get_option('mobile_media_resize');
1096 $file_accessible = ini_get('allow_url_fopen');
1097 if ($mobile_media_resize == "true" && $device_scene) {
1098 if ($file_accessible == "1") {
1099 $image_info = getimagesize($device_scene);
1100 if ($image_info && $image_info[0] > 4096) {
1101 $src_to_id_for_mobile = '';
1102 $src_to_id_for_desktop = '';
1103 if (wpvr_isMobileDevice()) {
1104 $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1105 if ($src_to_id_for_mobile) {
1106 $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1107 if ($mobile_scene[3]) {
1108 $device_scene = $mobile_scene[0];
1109 }
1110 }
1111 } else {
1112 $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1113 if ($src_to_id_for_desktop) {
1114 $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1115 if ($desktop_scene && $desktop_scene[0]) {
1116 $device_scene = $desktop_scene[0];
1117 }
1118 }
1119 }
1120 }
1121 }
1122 }
1123
1124 $scene_info = array();
1125
1126 if ($panoscenes["scene-type"] == 'cubemap') {
1127 $pano_type = 'cubemap';
1128 $pano_attachment = array(
1129 $panoscenes["scene-attachment-url-face0"],
1130 $panoscenes["scene-attachment-url-face1"],
1131 $panoscenes["scene-attachment-url-face2"],
1132 $panoscenes["scene-attachment-url-face3"],
1133 $panoscenes["scene-attachment-url-face4"],
1134 $panoscenes["scene-attachment-url-face5"]
1135 );
1136
1137 $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);
1138 } else {
1139 $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);
1140 }
1141
1142
1143
1144 if (isset($panoscenes["ptyscene"])) {
1145 if ($panoscenes["ptyscene"] == "off") {
1146 unset($scene_info['pitch']);
1147 unset($scene_info['yaw']);
1148 }
1149 }
1150
1151 if (empty($panoscenes["scene-ititle"])) {
1152 unset($scene_info['title']);
1153 }
1154 if (empty($panoscenes["scene-author"])) {
1155 unset($scene_info['author']);
1156 }
1157 if (empty($panoscenes["scene-author-url"])) {
1158 unset($scene_info['authorURL']);
1159 }
1160
1161 if (empty($scene_vaov)) {
1162 unset($scene_info['vaov']);
1163 }
1164
1165 if (empty($scene_haov)) {
1166 unset($scene_info['haov']);
1167 }
1168
1169 if (empty($scene_vertical_offset)) {
1170 unset($scene_info['vOffset']);
1171 }
1172
1173 if (isset($panoscenes["cvgscene"])) {
1174 if ($panoscenes["cvgscene"] == "off") {
1175 unset($scene_info['maxPitch']);
1176 unset($scene_info['minPitch']);
1177 }
1178 }
1179 if (empty($panoscenes["scene-maxpitch"])) {
1180 unset($scene_info['maxPitch']);
1181 }
1182
1183 if (empty($panoscenes["scene-minpitch"])) {
1184 unset($scene_info['minPitch']);
1185 }
1186
1187 if (isset($panoscenes["chgscene"])) {
1188 if ($panoscenes["chgscene"] == "off") {
1189 unset($scene_info['maxYaw']);
1190 unset($scene_info['minYaw']);
1191 }
1192 }
1193 if (empty($panoscenes["scene-maxyaw"])) {
1194 unset($scene_info['maxYaw']);
1195 }
1196
1197 if (empty($panoscenes["scene-minyaw"])) {
1198 unset($scene_info['minYaw']);
1199 }
1200
1201 // if (isset($panoscenes["czscene"])) {
1202 // if ($panoscenes["czscene"] == "off") {
1203 // unset($scene_info['hfov']);
1204 // unset($scene_info['maxHfov']);
1205 // unset($scene_info['minHfov']);
1206 // }
1207 // }
1208
1209 $scene_array = array();
1210 $scene_array = array(
1211 $panoscenes['scene-id'] => $scene_info
1212 );
1213
1214 $scene_data[$panoscenes['scene-id']] = $scene_info;
1215 }
1216 }
1217 }
1218 $pano_id_array = array();
1219 $pano_id_array = array('panoid' => $panoid);
1220 $pano_response = array();
1221 $pano_response = array('autoLoad' => $autoload, 'showControls' => $control, '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);
1222 if (empty($autorotation)) {
1223 unset($pano_response['autoRotate']);
1224 unset($pano_response['autoRotateInactivityDelay']);
1225 unset($pano_response['autoRotateStopDelay']);
1226 }
1227 if (empty($autorotationinactivedelay)) {
1228 unset($pano_response['autoRotateInactivityDelay']);
1229 }
1230 if (empty($autorotationstopdelay)) {
1231 unset($pano_response['autoRotateStopDelay']);
1232 }
1233
1234 $response = array();
1235 $response = array($pano_id_array, $pano_response);
1236 if (!empty($response)) {
1237 $response = json_encode($response);
1238 }
1239 if (empty($width)) {
1240 $width = '600';
1241 }
1242 if (empty($height)) {
1243 $height = '400';
1244 }
1245 if ('fullwidth' == $width) {
1246 $width = "100%";
1247 }
1248
1249 $foreground_color = '#fff';
1250 $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1251 $rgb = wpvr_HTMLToRGB($hotspoticoncolor);
1252 $hsl = wpvr_RGBToHSL($rgb);
1253 if ($hsl->lightness > 200) {
1254 $foreground_color = '#000000';
1255 } else {
1256 $foreground_color = '#fff';
1257 }
1258
1259 $class = 'myclass';
1260 $html = 'test';
1261 $html = '';
1262 $html .= '<style>';
1263 if ($width == 'embed') {
1264 $html .= 'body{
1265 overflow: hidden;
1266 }';
1267 }
1268 $status = get_option('wpvr_edd_license_status');
1269 $status = get_option('wpvr_edd_license_status');
1270 if ($status !== false && $status == 'valid') {
1271 if (isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on') {
1272 $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
1273 }
1274 }
1275 if ($status !== false && $status == 'valid') {
1276 if (is_array($panodata) && isset($panodata['scene-list'])) {
1277 foreach ($panodata['scene-list'] as $panoscenes) {
1278
1279 foreach ($panoscenes['hotspot-list'] as $hotspot) {
1280 if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1281 $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1282 } else {
1283 $hotspoticoncolor = "#00b4ff";
1284 }
1285 $hotspot_border = '';
1286 if(isset($hotspot['hotspot-border']) && $hotspot['hotspot-border'] == 'on'){
1287 $border_width = $hotspot['hotspot-border-width'];
1288 $border_color = $hotspot['hotspot-border-color'];
1289 $border_style = $hotspot['hotspot-border-style'];
1290
1291 $hotspot_border = 'border: '.$border_width.'px '.$border_style.' '.$border_color.';';
1292 }
1293 $hotspot_background_color = 'background-color: ' . $hotspoticoncolor . ';';
1294 $hotspot_animation = ' animation: icon-pulse' . $panoid . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1295 '. $hotspot_border.'';
1296
1297
1298 $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1299 if (isset($hotspot["hotspot-customclass-pro"]) && $hotspot["hotspot-customclass-pro"] != 'none') {
1300 $border_radius = ' border-radius: 100%;';
1301 $hotspot_shape = isset($hotspot["hotspot-shape"]) ? $hotspot["hotspot-shape"] : 'round';
1302 if($hotspot_shape === 'square'){
1303 $border_radius = '';
1304 }
1305 if ($hotspot_shape === 'hexagon') {
1306 $border_radius = '';
1307 $hotspot_background_color = 'background-color: transparent;';
1308 $hotspot_animation = '';
1309 }
1310
1311 if(isset($hotspot['hotspot-custom-icon-color-value']) && !empty($hotspot['hotspot-custom-icon-color-value'])){
1312 $foreground_color = $hotspot['hotspot-custom-icon-color-value'];
1313 }
1314 $html .= '#' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1315 #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1316 #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1317 #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1318 #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1319 display: block !important;
1320 '.$hotspot_background_color.'
1321 color: ' . $foreground_color . ';
1322 '.$border_radius.'
1323 width: 30px;
1324 height: 30px;
1325 font-size: 16px;
1326 line-height: 30px;
1327 '.$hotspot_animation.'
1328 }';
1329 if($hotspot_shape === 'hexagon'){
1330
1331 $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' .hexagon-wrapper svg path {
1332 fill: ' . $hotspoticoncolor . ';
1333 }';
1334
1335 $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . '.pnlm-tooltip:after{
1336 content: "";
1337 position: absolute;
1338 left: 50%;
1339 top: 50%;
1340 transform: translate(-50%, -50%);
1341 width: 85%;
1342 height: 85%;
1343 animation: icon-pulse' . esc_attr( $panoid ) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1344 border-radius: 100%;
1345 z-index: -2;
1346 }';
1347
1348 }
1349 $html .= '#' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1350 #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1351 #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1352 #' . esc_attr( $panoid2) . ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ',
1353 #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1354 display: block !important;
1355 '.esc_attr( $hotspot_background_color).'
1356 color: ' . esc_attr( $foreground_color) . ';
1357 '.esc_attr( $border_radius).'
1358 width: 30px;
1359 height: 30px;
1360 font-size: 16px;
1361 line-height: 30px;
1362 '.esc_attr( $hotspot_animation).'
1363 }';
1364 }
1365 if (isset($hotspot['hotspot-blink'])) {
1366 $hotspotblink = $hotspot['hotspot-blink'];
1367 if ($hotspotblink == 'on') {
1368 $html .= '@-webkit-keyframes icon-pulse' . esc_attr( $panoid) . '-' . $panoscenes['scene-id'] . '-' . $hotspot['hotspot-title'] . ' {
1369 0% {
1370 box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);
1371 }
1372 100% {
1373 box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0]) . ', 0);
1374 }
1375 }
1376 @keyframes icon-pulse' . esc_attr( $panoid) . ' {
1377 0% {
1378 box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);)
1379 }
1380 100% {
1381 box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0] ). ', 0);
1382 }
1383 }';
1384 }
1385 }
1386 }
1387 }
1388 }
1389 }
1390
1391 $status = get_option('wpvr_edd_license_status');
1392 if ($status !== false && $status == 'valid') {
1393 if (!$gyro) {
1394 $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1395 display: none;
1396 }';
1397 }
1398 } else {
1399 $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1400 display: none;
1401 }';
1402 }
1403 $floor_plan_custom_color = isset($postdata['floor_plan_custom_color']) ? $postdata['floor_plan_custom_color'] : '#cca92c';
1404 $foreground_color_pointer = '#fff';
1405 if ($floor_plan_custom_color != '') {
1406 $pointer_pulse = wpvr_hex2rgb($floor_plan_custom_color);
1407 $floor_rgb = wpvr_HTMLToRGB($floor_plan_custom_color);
1408 $floor_hsl = wpvr_RGBToHSL($floor_rgb);
1409 if ($floor_hsl->lightness > 200) {
1410 $foreground_color_pointer = '#000000';
1411 }
1412 $html .= '
1413 .wpvr-floor-map .floor-plan-pointer.add-pulse:before {
1414 border: 17px solid ' . esc_attr( $floor_plan_custom_color ) . ';
1415 }
1416 @-webkit-keyframes pulse {
1417 0% {
1418 -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1419 }
1420 70% {
1421 -webkit-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1422 }
1423 100% {
1424 -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1425 }
1426 }
1427 @keyframes pulse {
1428 0% {
1429 -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1430 box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1431 }
1432 70% {
1433 -moz-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1434 box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1435 }
1436 100% {
1437 -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1438 box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1439 }
1440 }';
1441 }
1442 $html .= '</style>';
1443
1444 $scene_animation = isset($postdata['sceneAnimation']) ? $postdata['sceneAnimation'] : 'off';
1445
1446 if( $scene_animation === 'on'){
1447 $animation_type = isset($postdata['sceneAnimationName']) ? $postdata['sceneAnimationName'] : 'none';
1448 $animationDuration = isset($postdata['sceneAnimationTransitionDuration']) ? $postdata['sceneAnimationTransitionDuration'] : '500ms';
1449 $animationDelay = isset($postdata['sceneAnimationTransitionDelay']) ? $postdata['sceneAnimationTransitionDelay'] : '0ms';
1450 $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration, $animationDelay, $postdata,$id);
1451 $html .= $animation_css;
1452 }
1453
1454 if (wpvr_isMobileDevice()) {
1455 $html .= '<div id="master-container" class="wpvr-cardboard ' . esc_attr( $className ) . ' ' . esc_attr( $enable_cardboard ) . ' " style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; width: 100%; height: ' . esc_attr( $mobile_height ) . esc_attr( $mobile_height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr; border : ' . esc_attr( $border_style ) . ' ">';
1456 } else {
1457 $html .= '<div id="master-container" class="wpvr-cardboard ' . esc_attr( $className ) . ' ' . esc_attr( $enable_cardboard ) . '" style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '; width: 100%; height: ' . esc_attr( $height ) . esc_attr( $height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr; border : ' . esc_attr( $border_style ) . '">';
1458 }
1459 $status = get_option('wpvr_edd_license_status');
1460 $is_cardboard = get_option('wpvr_cardboard_disable');
1461 if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
1462 $html .= '<button class="fullscreen-button">';
1463 $html .= '<span class="expand">';
1464 $html .= '<i class="fa fa-expand" aria-hidden="true"></i>';
1465 $html .= '</span>';
1466
1467 $html .= '<span class="compress">';
1468 $html .= '<i class="fa fa-compress" aria-hidden="true"></i>';
1469 $html .= '</span>';
1470 $html .= '</button>';
1471 $html .= '<label class="wpvr-cardboard-switcher">
1472 <input type="checkbox" class="vr_mode_change' . $id . '" name="vr_mode_change" value="off">
1473 <span class="switcher-box">
1474 <span class="normal-mode-tooltip">Normal VR Mode</span>
1475 <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1476 <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"/>
1477 </svg>
1478 </span>
1479 </label>';
1480 }
1481
1482 if ($width == 'fullwidth') {
1483 if (wpvr_isMobileDevice()) {
1484 $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
1485 $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left cardboard-half" style="width: 49%!important; border-radius:' . esc_attr( $radius ). ' ;text-align:center; direction:ltr;" ><div id="center-pointer2' . esc_attr( $id ). '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1486 $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style="width: 100%; text-align:center; direction:ltr; border-radius:' . esc_attr( $radius ) . '" >';
1487 } else {
1488 $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';"><div id="center-pointer2' . esc_attr( $id ). '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1489 $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . esc_attr( $height ) . esc_attr( $height_unit ) . '; border-radius:' . esc_attr( $radius ) . '; direction:ltr;" >';
1490 }
1491 } else {
1492 if (wpvr_isMobileDevice()) {
1493 $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left cardboard-half" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';">
1494 <div id="center-pointer2' . esc_attr( $id ) . '" class="vr-pointer-container">
1495 <span class="center-pointer"></span>
1496 </div>
1497 </div>';
1498 $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style=" width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
1499 } else {
1500
1501 $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';"><div id="center-pointer2' . esc_attr( $id ) . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1502
1503 $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style="width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
1504 }
1505 }
1506 // Vr mode transction scene to scene
1507 if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
1508 $html .= '<div id="center-pointer' . esc_attr( $id ) . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
1509 }
1510
1511
1512 //===company logo===//
1513 if (isset($postdata['cpLogoSwitch'])) {
1514 $cpLogoImg = $postdata['cpLogoImg'];
1515 $cpLogoContent = $postdata['cpLogoContent'];
1516 if ($postdata['cpLogoSwitch'] == 'on') {
1517 $html .= '<div id="cp-logo-controls">';
1518 $html .= '<div class="cp-logo-ctrl" id="cp-logo">';
1519 if ($cpLogoImg) {
1520 $html .= '<img loading="lazy" src="' . esc_attr( $cpLogoImg ) . '" alt="Company Logo">';
1521 }
1522
1523 if ($cpLogoContent) {
1524 $html .= '<div class="cp-info">' . esc_attr( $cpLogoContent ) . '</div>';
1525 }
1526 $html .= '</div>';
1527 $html .= '</div>';
1528 }
1529 }
1530 //===company logo ends===//
1531
1532 //===Background Tour===//
1533 if (isset($postdata['bg_tour_enabler'])) {
1534
1535 $bg_tour_enabler = $postdata['bg_tour_enabler'];
1536 if ($bg_tour_enabler == 'on') {
1537 $bg_tour_navmenu = $postdata['bg_tour_navmenu'] ?? 'off';
1538 $bg_tour_title = $postdata['bg_tour_title'] ?? '';
1539 $bg_tour_subtitle = $postdata['bg_tour_subtitle'] ?? '';
1540
1541 if ($bg_tour_navmenu == 'on') {
1542 $menuLocations = get_nav_menu_locations();
1543 $menuID = $menuLocations['primary'];
1544 $primaryNav = wp_get_nav_menu_items($menuID);
1545
1546 if ($primaryNav) {
1547 $html .= '<div class="wpvr-navbar-container">';
1548 foreach ($primaryNav as $primaryNav_key => $primaryNav_value) {
1549 if ($primaryNav_value->menu_item_parent == "0") {
1550 $html .= '<li>';
1551 $html .= '<a href="' . esc_url( $primaryNav_value->url ) . '">' . esc_attr( $primaryNav_value->title ) . '</a>';
1552 $html .= '<ul class="wpvr-navbar-dropdown">';
1553 foreach ($primaryNav as $pm_key => $pm_value) {
1554 if ($pm_value->menu_item_parent == $primaryNav_value->ID) {
1555 $html .= '<li>';
1556 $html .= '<a href="' . esc_url( $pm_value->url ) . '">' . esc_attr( $pm_value->title ) . '</a>';
1557 $html .= '</li>';
1558 }
1559 }
1560 $html .= '</ul>';
1561 $html .= '</li>';
1562 }
1563 }
1564 $html .= '</div>';
1565 }
1566 }
1567
1568 $html .= '<div class="wpvr-home-content">';
1569 $html .= '<div class="wpvr-home-title">' . esc_attr( $bg_tour_title ) . '</div>';
1570 $html .= '<div class="wpvr-home-subtitle">' . esc_attr( $bg_tour_subtitle ) . '</div>';
1571 $html .= '</div>';
1572 }
1573 }
1574 //===Background Tour End===//
1575
1576 //===Custom Control===//
1577 if (isset($custom_control)) {
1578 if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $custom_control['gyroscopeSwitch'] == "on" || $custom_control['backToHomeSwitch'] == "on") {
1579 $html .= '<div id="zoom-in-out-controls' . esc_attr( $id ) . '" class="zoom-in-out-controls">';
1580
1581 if ($custom_control['backToHomeSwitch'] == "on") {
1582 $html .= '<div class="ctrl" id="backToHome' . esc_attr( $id ) . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . esc_attr( $custom_control['backToHomeColor'] ) . ';"></i></div>';
1583 }
1584
1585 if ($custom_control['panZoomInSwitch'] == "on") {
1586 $html .= '<div class="ctrl" id="zoom-in' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomInColor'] ) . ';"></i></div>';
1587 }
1588
1589 if ($custom_control['panZoomOutSwitch'] == "on") {
1590 $html .= '<div class="ctrl" id="zoom-out' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomOutColor'] ) . ';"></i></div>';
1591 }
1592
1593 if ($custom_control['gyroscopeSwitch'] == "on") {
1594 $html .= '<div class="ctrl" id="gyroscope' . esc_attr( $id ) . '"><i class="' . $custom_control['gyroscopeIcon'] . '" style="color:' . esc_attr( $custom_control['gyroscopeColor'] ) . ';"></i></div>';
1595 }
1596
1597 $html .= '</div>';
1598 }
1599 //===zoom in out Control===//
1600
1601 if ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on") {
1602
1603 //===Custom Control===//
1604 $html .= '<div class="controls" id="controls' . esc_attr( $id ) . '">';
1605
1606 if ($custom_control['panupSwitch'] == "on") {
1607 $html .= '<div class="ctrl pan-up" id="pan-up' . esc_attr( $id ) . '"><i class="' . $custom_control['panupIcon'] . '" style="color:' . esc_attr( $custom_control['panupColor'] ) . ';"></i></div>';
1608 }
1609
1610 if ($custom_control['panDownSwitch'] == "on") {
1611 $html .= '<div class="ctrl pan-down" id="pan-down' . esc_attr( $id ) . '"><i class="' . $custom_control['panDownIcon'] . '" style="color:' . esc_attr( $custom_control['panDownColor'] ) . ';"></i></div>';
1612 }
1613
1614 if ($custom_control['panLeftSwitch'] == "on") {
1615 $html .= '<div class="ctrl pan-left" id="pan-left' . esc_attr( $id ) . '"><i class="' . $custom_control['panLeftIcon'] . '" style="color:' . esc_attr( $custom_control['panLeftColor'] ) . ';"></i></div>';
1616 }
1617
1618 if ($custom_control['panRightSwitch'] == "on") {
1619 $html .= '<div class="ctrl pan-right" id="pan-right' . esc_attr( $id ) . '"><i class="' . $custom_control['panRightIcon'] . '" style="color:' . esc_attr( $custom_control['panRightColor'] ) . ';"></i></div>';
1620 }
1621
1622 if ($custom_control['panFullscreenSwitch'] == "on") {
1623 $html .= '<div class="ctrl fullscreen" id="fullscreen' . esc_attr( $id ) . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . esc_attr( $custom_control['panFullscreenColor'] ) . ';"></i></div>';
1624 }
1625 $html .= '</div>';
1626 }
1627
1628 //===explainer button===//
1629 $explainerControlSwitch = '';
1630 if (isset($custom_control['explainerSwitch'])) {
1631 $explainerControlSwitch = $custom_control['explainerSwitch'];
1632 }
1633 if ($custom_control['explainerSwitch'] == "on") {
1634 $explainer_style = empty($postdata['explainerContent']) || ( isset( $postdata['explainerSwitch'] ) && 'off' === $postdata['explainerSwitch'] )? 'pointer-events: none; opacity: 0.5;' : '';
1635 $html .= '<div class="explainer_button" id="explainer_button_' . esc_attr( $id ) . '" style="right:' . esc_attr( $explainer_right ) . '; ' . esc_attr( $explainer_style ) . '">';
1636 $html .= '<div class="ctrl" id="explainer_target_' . esc_attr( $id ) . '"><i class="' . $custom_control['explainerIcon'] . '" style="color:' . esc_attr( $custom_control['explainerColor'] ) . ';"></i></div>';
1637 $html .= '</div>';
1638 }
1639
1640 //===explainer button===//
1641
1642 }
1643 //===Custom Control===//
1644
1645 //===Scene navigation Control===//
1646 if (isset($postdata['scene_navigation']) && $postdata['scene_navigation'] === 'on') {
1647 $html .= '<style>
1648 #et-boc .et-l .pnlm-controls-container,
1649 .pnlm-controls-container{
1650 top: 33px;
1651 }
1652
1653 #et-boc .et-l .zoom-in-out-controls,
1654 .zoom-in-out-controls {
1655 top: 37px;
1656 }
1657 </style>';
1658 $html .= '<div id="custom-scene-navigation' . esc_attr( $id ) . '" class="custom-scene-navigation">
1659 <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>
1660 </div>
1661
1662 <div id="custom-scene-navigation-nav' . esc_attr( $id ) . '" class="custom-scene-navigation-nav">
1663 <ul></ul>
1664 </div>
1665 ';
1666 }
1667
1668 //===Scene navigation Control===//
1669
1670 //=====custom generic form=====//
1671 if (isset($postdata["genericform"]) && $postdata["genericform"] == 'on') {
1672 $shortcode_val = isset($postdata["genericformshortcode"]) && $postdata["genericformshortcode"] !== "" ? do_shortcode($postdata["genericformshortcode"]) : "No shortcode found";
1673 $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr( $id ) . '">';
1674 $html .= '<div class="ctrl" id="generic_form_target_' . esc_attr( $id ) . '"><i class="fab fa-wpforms" style="color:#f7fffb;"></i></div>';
1675 $html .= '</div>';
1676
1677 $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr( $id ) . '" style="display: none">';
1678 $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
1679 $html .= '<div class="generic-form-container">' . $shortcode_val . '</div>';
1680 $html .= '</div>';
1681 }
1682 //=====custom generic form=====//
1683
1684 //===Floor map button===//
1685 $status = get_option('wpvr_edd_license_status');
1686 if ($status !== false && 'valid' == $status && $is_pro) {
1687 if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
1688 $html .= '<div class="floor_map_button" id="floor_map_button_' . esc_attr( $id ) . '" style="right:' . esc_attr( $floor_map_right ) . '">';
1689 $html .= '<div class="ctrl" id="floor_map_target_' . esc_attr( $id ) . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1690 $html .= '</div>';
1691 }
1692 }
1693
1694 //===floor map button===//
1695 if ($vrgallery) {
1696 //===Carousal setup===//
1697 $size = '';
1698 if ($vrgallery_icon_size) {
1699 $size = 'vrg-icon-size-large';
1700 }
1701 $html .= '<div id="vrgcontrols' . esc_attr( $id ) . '" class="vrgcontrols">';
1702
1703 $html .= '<div class="vrgctrl' . esc_attr( $id ) . ' vrbounce ' . esc_attr( $size ) . '">';
1704 $html .= '</div>';
1705 $html .= '</div>';
1706
1707 $html .= '<div id="sccontrols' . esc_attr( $id ) . '" class="scene-gallery vrowl-carousel owl-theme">';
1708 if (isset($panodata["scene-list"])) {
1709 foreach ($panodata["scene-list"] as $panoscenes) {
1710 $scene_key = $panoscenes['scene-id'];
1711 if ($vrgallery_title == 'on') {
1712 $scene_key_title = $panoscenes['scene-ititle'];
1713 // $scene_key_title = $panoscenes['scene-id'];
1714 } else {
1715 $scene_key_title = "";
1716 }
1717
1718 if ($panoscenes['scene-type'] == 'cubemap') {
1719 $img_src_url = $panoscenes['scene-attachment-url-face0'];
1720 } else {
1721 $img_src_url = $panoscenes['scene-attachment-url'];
1722 }
1723
1724
1725 $src_to_id = attachment_url_to_postid($img_src_url);
1726 $thumbnail_array = wp_get_attachment_image_src($src_to_id, 'thumbnail');
1727 if ($thumbnail_array) {
1728 $thumbnail = $thumbnail_array[0];
1729 } else {
1730 $thumbnail = $img_src_url;
1731 }
1732 if( isset($postdata['tourLayout']['layout']) && 'layout1' !== $postdata['tourLayout']['layout']) {
1733 $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>';
1734 }else {
1735 $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>';
1736 }
1737 }
1738 }
1739 $html .= '</div>';
1740 $html .= '
1741 <div class="owl-nav wpvr_slider_nav">
1742 <button type="button" role="presentation" class="owl-prev wpvr_owl_prev">
1743 <div class="nav-btn prev-slide"><i class="fa fa-angle-left"></i></div>
1744 </button>
1745 <button type="button" role="presentation" class="owl-next wpvr_owl_next">
1746 <div class="nav-btn next-slide"><i class="fa fa-angle-right"></i></div>
1747 </button>
1748 </div>
1749 ';
1750 //===Carousal setup end===//
1751 }
1752
1753 $bg_music = isset($postdata['bg_music']) ? $postdata['bg_music'] : 'off';
1754 $bg_music_url = isset($postdata['bg_music_url']) ? $postdata['bg_music_url'] : '';
1755 $autoplay_bg_music = isset($postdata['autoplay_bg_music']) ? $postdata['autoplay_bg_music'] : 'off';
1756 $loop_bg_music = isset($postdata['loop_bg_music']) ? $postdata['loop_bg_music'] : 'off';
1757
1758 $bg_loop = ($loop_bg_music === 'on') ? 'loop' : '';
1759 $autoplay_attr = ($autoplay_bg_music === 'on') ? 'autoplay' : '';
1760 $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
1761 $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
1762
1763 if ($bg_music === 'on') {
1764 $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1765 $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 . '>
1766 <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
1767 Your browser does not support the audio element.
1768 </audio>';
1769 $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
1770 <i id="vr-volume' . esc_attr($id) . '" class="wpvrvolumeicon' . esc_attr($id) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
1771 </button>';
1772 $html .= '</div>';
1773 }
1774
1775 //===Explainer video section===//
1776 $explainerContent = "";
1777 if (isset($postdata['explainerContent'])) {
1778 $explainerContent = $postdata['explainerContent'];
1779 }
1780 $html .= '<div class="explainer" id="explainer' . esc_attr( $id ) . '" style="display: none">';
1781 $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
1782 $html .= '' . $explainerContent . '';
1783 $html .= '</div>';
1784 //===Explainer video section End===//
1785
1786 //===Floor plan section===//
1787 $floor_map_image = "";
1788 $floor_map_pointer = array();
1789 $floor_map_scene_id = '';
1790 $floor_plan_custom_color = '#cca92c';
1791
1792 if (isset($postdata['floor_plan_attachment_url'])) {
1793 $floor_map_image = $postdata['floor_plan_attachment_url'];
1794 $floor_map_pointer = $postdata['floor_plan_pointer_position'];
1795 $floor_map_scene_id = $postdata['floor_plan_data_list'];
1796 $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
1797 }
1798 $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
1799 $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
1800 $html .= '<img loading="lazy" src="' . $floor_map_image . '">';
1801
1802 foreach ($floor_map_pointer as $key => $pointer_position) {
1803 $html .= '<div class="floor-plan-pointer ui-draggable ui-draggable-handle" scene_id = "' . esc_attr( $floor_map_scene_id[$key]->value ) . '" id="' . esc_attr( $pointer_position->id ) . '" data-top="' . esc_attr( $pointer_position->data_top ) . '" data-left="' . esc_attr( $pointer_position->data_left ) . '" style="' . esc_attr( $pointer_position->style ) . '">
1804
1805 <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1806 <circle cx="12" cy="12" r="11.5" stroke="' . esc_attr( $floor_plan_custom_color ) . '"/>
1807 <circle cx="12" cy="12" r="5" fill="' . esc_attr( $foreground_color_pointer ) . '"/>
1808 </svg>
1809 <svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
1810 <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)"/>
1811 <defs>
1812 <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
1813 <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
1814 <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
1815 </linearGradient>
1816 </defs>
1817 </svg>
1818
1819 </div>';
1820 }
1821 $html .= '</div>';
1822 //===Floor plan section===//
1823
1824 $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
1825 $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
1826 $html .= '<div class="wpvr-hotspot-tweak-contents-flex">';
1827 $html .= '<div class="wpvr-hotspot-tweak-contents">';
1828 ob_start();
1829 do_action('wpvr_hotspot_tweak_contents', $scene_data);
1830 $hotspot_content = ob_get_clean();
1831 $html .= $hotspot_content;
1832 $html .= '</div>';
1833 $html .= '</div>';
1834 $html .= '</div>';
1835
1836 $html .= '<div class="custom-ifram-wrapper" style="display: none;">';
1837 $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
1838 $html .= '<div class="custom-ifram-flex">';
1839 $html .= '<div class="custom-ifram">';
1840 $html .= '</div>';
1841 $html .= '</div>';
1842 $html .= '</div>';
1843 $html .= '</div>';
1844 $html .= '</div>';
1845
1846
1847 if ("fullwidth" == $width) {
1848 $html .= '</div>';
1849 }
1850 if ($status !== false && 'valid' == $status && $is_pro) {
1851 $call_to_action = isset($postdata['calltoaction']) ? $postdata['calltoaction'] : 'off';
1852 if ('on' == $call_to_action) {
1853 $buttontext = isset($postdata['buttontext']) ? $postdata['buttontext'] : '';
1854 $buttonurl = isset($postdata['buttonurl']) ? $postdata['buttonurl'] : '';
1855 $cta_btn_style = isset($postdata['button_configuration']) ? $postdata['button_configuration'] : array();
1856
1857 $button_open_new_tab = isset($cta_btn_style['button_open_new_tab']) ? $cta_btn_style['button_open_new_tab'] : "off";
1858 $target = '_self';
1859 $button_position = isset($cta_btn_style['button_position']) ? $cta_btn_style['button_position'] : "";
1860 $background_color = isset($cta_btn_style['button_background_color']) ? $cta_btn_style['button_background_color'] : "";
1861 $color = isset($cta_btn_style['button_font_color']) ? $cta_btn_style['button_font_color'] : "";
1862 $font_size = isset($cta_btn_style['button_font_size']) ? $cta_btn_style['button_font_size'] : "";
1863 $font_weight = isset($cta_btn_style['button_font_weight']) ? $cta_btn_style['button_font_weight'] : "";
1864 $text_align = isset($cta_btn_style['button_alignment']) ? $cta_btn_style['button_alignment'] : "";
1865 $text_transform = isset($cta_btn_style['button_transform']) ? $cta_btn_style['button_transform'] : "";
1866 $font_style = isset($cta_btn_style['button_text_style']) ? $cta_btn_style['button_text_style'] : "";
1867 $text_decoration = isset($cta_btn_style['button_text_decoration']) ? $cta_btn_style['button_text_decoration'] : "";
1868 $line_height = isset($cta_btn_style['button_line_height']) ? $cta_btn_style['button_line_height'] : "";
1869 $letter_spacing = isset($cta_btn_style['button_letter_spacing']) ? $cta_btn_style['button_letter_spacing'] : "";
1870 $word_spacing = isset($cta_btn_style['button_word_spacing']) ? $cta_btn_style['button_word_spacing'] : "";
1871
1872 $border_width = isset($cta_btn_style['button_border_width']) ? $cta_btn_style['button_border_width'] : "";
1873 $border_style = isset($cta_btn_style['button_border_style']) ? $cta_btn_style['button_border_style'] : "";
1874 $border_color = isset($cta_btn_style['button_border_color']) ? $cta_btn_style['button_border_color'] : "";
1875 $border_radius = isset($cta_btn_style['button_border_radius']) ? $cta_btn_style['button_border_radius'] : "";
1876
1877 $button_pt = isset($cta_btn_style['button_pt']) ? $cta_btn_style['button_pt'] : "";
1878 $button_pr = isset($cta_btn_style['button_pr']) ? $cta_btn_style['button_pr'] : "";
1879 $button_pb = isset($cta_btn_style['button_pb']) ? $cta_btn_style['button_pb'] : "";
1880 $button_pl = isset($cta_btn_style['button_pl']) ? $cta_btn_style['button_pl'] : "";
1881
1882 if ($button_open_new_tab == 'on') {
1883 $target = '_blank';
1884 }
1885 $style = 'background-color: ' . esc_attr( $background_color ) . ';
1886 color: ' . esc_attr( $color ) . ';
1887 font-size: ' . esc_attr( $font_size ) . 'px;
1888 font-weight: ' . esc_attr( $font_weight ) . ';
1889 text-align: center;
1890 display: inline-block;
1891 text-transform: ' . esc_attr( $text_transform ) . ';
1892 font-style: ' . esc_attr( $font_style ) . ';
1893 text-decoration: ' . esc_attr( $text_decoration ) . ';
1894 line-height: ' . esc_attr( $line_height ) . ';
1895 letter-spacing: ' . esc_attr( $letter_spacing ) . 'px;
1896 word-spacing: ' . esc_attr( $word_spacing ) . 'px;
1897 border: ' . esc_attr( $border_width ) . 'px ' . esc_attr( $border_style ) . ' ' . esc_attr( $border_color ) . ';
1898 border-radius: ' . esc_attr( $border_radius ). 'px;
1899 padding: ' . esc_attr( $button_pt ) . 'px ' . esc_attr( $button_pr ) . 'px ' . esc_attr( $button_pb ) . 'px ' . esc_attr( $button_pl ) . 'px;
1900 ';
1901 $html .= '<div class="wpvr-call-to-action-button position-' . esc_attr( $text_align ) . '" style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '">
1902 <a href="' . esc_url( $buttonurl ) . '" style="' . esc_attr( $style ) . '" target="' . esc_attr( $target ) . '">' . esc_attr( $buttontext ) . '</a>
1903 </div>';
1904 }
1905 }
1906
1907 //script started
1908
1909 $html .= '<script>';
1910 if (isset($postdata['bg_music']) && $bg_music == 'on') {
1911 $html .= '
1912 var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
1913 var playing' . $id . ' = false;
1914 var autoplaySupported' . $id . ' = false;
1915 var alertShown' . $id . ' = false;
1916 var autoplayChecked' . $id . ' = false;
1917
1918 function playPause' . $id . '() {
1919 if (playing' . $id . ') {
1920 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1921 x' . $id . '.pause();
1922 jQuery("#audio_control' . $id . '").attr("data-play", "off");
1923 playing' . $id . ' = false;
1924 } else {
1925 x' . $id . '.muted = false;
1926 x' . $id . '.play().then(function() {
1927 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1928 jQuery("#audio_control' . $id . '").attr("data-play", "on");
1929 playing' . $id . ' = true;
1930 }).catch(function(e) {
1931 console.log("Play failed:", e);
1932 });
1933 }
1934 }
1935
1936 function audionEnd' . $id . '() {
1937 playing' . $id . ' = false;
1938 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1939 jQuery("#audio_control' . $id . '").attr("data-play", "off");
1940 }
1941
1942 x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
1943
1944 if ($autoplay_bg_music == 'on') {
1945 $html .= '
1946
1947 x' . $id . '.addEventListener("loadeddata", function() {
1948 if (!autoplayChecked' . $id . ') {
1949 checkAutoplayStatus' . $id . '();
1950 }
1951 });
1952
1953 x' . $id . '.addEventListener("canplay", function() {
1954 if (!autoplayChecked' . $id . ') {
1955 checkAutoplayStatus' . $id . '();
1956 }
1957 });
1958
1959 x' . $id . '.addEventListener("canplaythrough", function() {
1960 if (!autoplayChecked' . $id . ') {
1961 checkAutoplayStatus' . $id . '();
1962 }
1963 });
1964
1965 setTimeout(function() {
1966 if (!autoplayChecked' . $id . ') {
1967 checkAutoplayStatus' . $id . '();
1968 }
1969 }, 1000);
1970
1971 x' . $id . '.addEventListener("play", function() {
1972 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1973 jQuery("#audio_control' . $id . '").attr("data-play", "on");
1974 playing' . $id . ' = true;
1975 });
1976
1977 x' . $id . '.addEventListener("pause", function() {
1978 if (!playing' . $id . ') {
1979 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
1980 jQuery("#audio_control' . $id . '").attr("data-play", "off");
1981 }
1982 });
1983
1984 function checkAutoplayStatus' . $id . '() {
1985 autoplayChecked' . $id . ' = true;
1986
1987 x' . $id . '.muted = true;
1988 var playPromise = x' . $id . '.play();
1989
1990 if (playPromise !== undefined) {
1991 playPromise.then(function () {
1992 if (x' . $id . '.muted || x' . $id . '.volume === 0) {
1993 handleAutoplayBlocked' . $id . '();
1994 } else {
1995 autoplaySupported' . $id . ' = true;
1996 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
1997 jQuery("#audio_control' . $id . '").attr("data-play", "on");
1998 playing' . $id . ' = true;
1999 }
2000 }).catch(function () {
2001 handleAutoplayBlocked' . $id . '();
2002 });
2003 } else {
2004 setTimeout(function () {
2005 if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2006 handleAutoplayBlocked' . $id . '();
2007 } else {
2008 autoplaySupported' . $id . ' = true;
2009 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2010 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2011 playing' . $id . ' = true;
2012 }
2013 }, 300);
2014 }
2015 }
2016
2017 function handleAutoplayBlocked' . $id . '() {
2018 autoplaySupported' . $id . ' = false;
2019 if (!alertShown' . $id . ') {
2020 alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2021 alertShown' . $id . ' = true;
2022 }
2023
2024 x' . $id . '.pause();
2025 x' . $id . '.currentTime = 0;
2026 x' . $id . '.muted = true;
2027
2028 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2029 jQuery("#audio_control' . $id . '").attr("data-play", "off");
2030
2031 document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2032 document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2033 document.addEventListener("click", musicPlay' . $id . ', { once: true });
2034 }
2035
2036 function musicPlay' . $id . '() {
2037 x' . $id . '.muted = false;
2038 var playPromise = x' . $id . '.play();
2039
2040 if (playPromise !== undefined) {
2041 playPromise.then(function () {
2042 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2043 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2044 playing' . $id . ' = true;
2045 }).catch(function(e) {
2046 console.log("Play failed:", e);
2047 });
2048 } else {
2049 setTimeout(function () {
2050 if (!x' . $id . '.paused) {
2051 jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2052 jQuery("#audio_control' . $id . '").attr("data-play", "on");
2053 playing' . $id . ' = true;
2054 }
2055 }, 100);
2056 }
2057
2058 document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2059 document.removeEventListener("touchstart", musicPlay' . $id . ');
2060 document.removeEventListener("click", musicPlay' . $id . ');
2061 }
2062 ';
2063 }
2064 }
2065 $html .= 'jQuery(document).ready(function() {';
2066 $html .= 'var response = ' . $response . ';';
2067 $html .= 'var scenes = response[1];';
2068 $html .= 'if(scenes) {';
2069 $html .= 'var scenedata = scenes.scenes;';
2070 $html .= 'for(var i in scenedata) {';
2071 $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2072 $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2073 $html .= 'if(scenehotspot[i].type === "info") {';
2074 $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2075 $html .= '} else if(scenehotspot[i].type === "scene") {';
2076 $html .= ' scenehotspot[i]["clickHandlerArgs"] = scenehotspot[i]["text"];';
2077 $html .='if(wpvr_public.is_pro_active) {';
2078 $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspotscene;';
2079 $html .='}';
2080 $html .= '}';
2081 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2082 } else {
2083 $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2084 $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2085 $html .= '}';
2086 }
2087 $html .= '}';
2088 $html .= '}';
2089 $html .= '}';
2090 $html .= 'var panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2091
2092
2093 //===Dplicate mode only for vr mode===//
2094 $response2 = json_decode($response);
2095 $response2[1]->compass = false;
2096 $response2[1]->autoRotate = false;
2097 $response = json_encode($response2);
2098 $html .= 'var response_duplicate = ' . $response . ';';
2099 $html .= 'var scenes_duplicate = response_duplicate[1];';
2100
2101 $html .= 'if(scenes_duplicate) {';
2102 $html .= 'var scenedata = scenes_duplicate.scenes;';
2103 $html .= 'for(var i in scenedata) {';
2104 $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2105 $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2106 $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2107 $html .= 'scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2108 $html .= '}';
2109 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2110 } else {
2111 $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2112 $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2113 $html .= '}';
2114 }
2115 $html .= '}';
2116 $html .= '}';
2117 $html .= '}';
2118 $html .= 'var vr_mode = "off";';
2119 $status = get_option('wpvr_edd_license_status');
2120 if ($status !== false && 'valid' == $status && $is_pro) {
2121 $html .= 'var panoshow2' . $id . ' = pannellum.viewer("pano2' . $id . '", scenes_duplicate);';
2122
2123 // Show Cardboard Mode in Tour
2124 $html .= '
2125 var tim;
2126 var im = 0;
2127 var active_scene = "' . $default_scene . '";
2128 var c_time;
2129 c_time = new Date();
2130 var timer = c_time.getTime() + 2000;
2131 function panoShowCardBoardOnTrigger(data){
2132 if(scenes_duplicate) {
2133 var scenedata = scenes_duplicate.scenes;
2134 for(var i in scenedata) {
2135 if(active_scene === i) {
2136 var scenehotspot = scenedata[i].hotSpots;
2137 for(var j in scenehotspot) {
2138 var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2139 var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2140 var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2141 var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2142 var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2143 var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2144 if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2145 if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2146 jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2147 var getScene = scenehotspot[j].sceneId;
2148 if(scenehotspot[j].type == "scene"){
2149 panoshow' . $id . '.loadScene(getScene);
2150 panoshow2' . $id . '.loadScene(getScene);
2151 // var inside_current_time_object = new Date();
2152 // var inside_timer = inside_current_time_object.getTime();
2153 // if(inside_timer > timer) {
2154 // panoshow' . $id . '.loadScene(getScene);
2155 // panoshow2' . $id . '.loadScene(getScene);
2156 // jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2157 // }
2158 }else{
2159 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2160 }
2161 }
2162 else {
2163 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2164 c_time = new Date();
2165 timer = c_time.getTime() + 2000;
2166 }
2167 }
2168 else {
2169 c_time = new Date();
2170 timer = c_time.getTime() + 2000;
2171 }
2172 }
2173 }
2174 }
2175 }
2176 };
2177
2178 function vrDeviseOrientation(){
2179 var data = {
2180 pitch: panoshow' . $id . '.getPitch(),
2181 yaw: panoshow' . $id . '.getYaw(),
2182 };
2183 panoShowCardBoardOnTrigger(data);
2184 }
2185 ';
2186 $html .= '
2187
2188 function requestFullScreen(){
2189 var elem = document.getElementById("master-container");
2190 if (elem.requestFullscreen) {
2191 elem.requestFullscreen();
2192 } else if (elem.webkitRequestFullscreen) { /* Safari */
2193 elem.webkitRequestFullscreen();
2194 } else if (elem.msRequestFullscreen) { /* IE11 */
2195 elem.msRequestFullscreen();
2196 }
2197 }
2198 function requestExitFullscreen(){
2199 var elem = document.getElementById("master-container");
2200 if (document.exitFullscreen) {
2201 document.exitFullscreen();
2202 } else if (document.webkitExitFullscreen) { /* Safari */
2203 document.webkitExitFullscreen();
2204 } else if (document.msExitFullscreen) { /* IE11 */
2205 document.msExitFullscreen();
2206 }
2207 }
2208 jQuery(document).on("click",".fullscreen-button .expand",function() {
2209 jQuery(this).hide()
2210 jQuery(this).parent().find(".compress").show()
2211 requestFullScreen()
2212 screen.orientation.lock("landscape-primary")
2213 .then(function() {
2214 })
2215 .catch(function(error) {
2216 alert("Not Supported for this devise");
2217 });
2218
2219 });
2220 jQuery(document).on("click",".fullscreen-button .compress",function() {
2221 jQuery(this).hide()
2222 jQuery(this).parent().find(".expand").show()
2223 requestExitFullscreen()
2224 screen.orientation.unlock();
2225
2226 });
2227
2228 let onLoadAnalytics = false;
2229 let sceneLoadAnalytics = false;
2230 function storeAnalyticsData(data) {
2231 if(wpvr_public.is_pro_active) {
2232 jQuery.ajax({
2233 url: wpvrAnalyticsObj.ajaxUrl,
2234 type: "POST",
2235 data: {
2236 action: "store_scene_hotspot_data",
2237 scene_id: data.scene_id,
2238 tour_id: data.tour_id,
2239 type: data.type,
2240 hotspot_id: data.hotspot_id || "",
2241 user_agent: navigator.userAgent,
2242 device_type: getDeviceType() || "desktop",
2243 nonce: wpvrAnalyticsObj.nonce,
2244 },
2245 success: function (response) {
2246 console.log("Data stored successfully");
2247 },
2248 error: function (error) {
2249 console.log("Error in storing data");
2250 }
2251 });
2252 }
2253 }
2254
2255 function getDeviceType() {
2256 const userAgent = navigator.userAgent.toLowerCase();
2257
2258 if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)) {
2259 return "mobile";
2260 } else if (/tablet|ipad/i.test(userAgent)) {
2261 return "tablet";
2262 } else {
2263 return "desktop";
2264 }
2265 }
2266
2267 panoshow' . $id . '.on("scenechange", function(scene) {
2268 onLoadAnalytics = true;
2269 sceneLoadAnalytics = true;
2270 let scene_id = scene;
2271 let tour_id = ' . $id . ';
2272 let type = "scene";
2273 let hotspot_id = "";
2274 let user_agent = navigator.userAgent;
2275 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2276 storeAnalyticsData({
2277 scene_id: scene_id,
2278 tour_id: tour_id,
2279 type: type,
2280 hotspot_id: hotspot_id,
2281 user_agent: user_agent,
2282 device_type: device_type,
2283 });
2284 });
2285
2286 panoshow' . $id . '.on("load", function() {
2287 let scene_id = panoshow' . $id . '.getScene();
2288 let tour_id = ' . $id . ';
2289 let type = "scene";
2290 let hotspot_id = "";
2291 let user_agent = navigator.userAgent;
2292 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2293 if(!onLoadAnalytics && !sceneLoadAnalytics){
2294 storeAnalyticsData({
2295 scene_id: scene_id,
2296 tour_id: tour_id,
2297 type: type,
2298 hotspot_id: hotspot_id,
2299 user_agent: user_agent,
2300 device_type: device_type,
2301 });
2302 }
2303 });
2304
2305 function wpvrhotspotscene(hotSpotDiv, args) {
2306 onLoadAnalytics = true;
2307 let scene_id = panoshow' . $id . '.getScene();
2308 let tour_id = ' . $id . ';
2309 let type = "hotspot";
2310 let hotspot_id = args;
2311 let user_agent = navigator.userAgent;
2312 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2313 storeAnalyticsData({
2314 scene_id: scene_id,
2315 tour_id: tour_id,
2316 type: type,
2317 hotspot_id: hotspot_id,
2318 user_agent: user_agent,
2319 device_type: device_type
2320 });
2321 }
2322
2323 ';
2324
2325 $html .= '
2326 panoshow' . $id . '.on("scenechange", function (scene){
2327 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2328 active_scene = scene;
2329 });
2330 var compassBlock = "";
2331 var infoBlock = "";
2332 var getValue = "";
2333 jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2334
2335 jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2336 jQuery("#pano' . $id . ' .pnlm-load-button").trigger("click");
2337
2338 getValue = jQuery(this).val();
2339 var getParent = jQuery(this).parent().parent();
2340 var fullWidthParent = getParent.parent();
2341 var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2342 var panoInfo = getParent.find("#pano' . $id . ' .pnlm-panorama-info").css("display");
2343 if(compass == "block"){
2344 compassBlock = "block";
2345 }
2346 if(panoInfo == "block"){
2347 infoBlock = "block";
2348 }
2349 if (getValue == "off") {
2350 requestFullScreen()
2351 screen.orientation.lock("landscape-primary")
2352 .then(function() {
2353 })
2354 .catch(function(error) {
2355 alert("VR Glass Mode not supported in this device");
2356 });
2357 getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2358 // localStorage.setItem("vr_mode", "on");
2359 vr_mode = "on";
2360 jQuery(".vr-mode-title").show();
2361 jQuery(this).val("on");
2362 getParent.find("#pano2' . $id . '").css({
2363 "opacity": "1",
2364 "visibility": "visible",
2365 "position": "relative",
2366 });
2367 gyroSwitch = true;
2368 panoshow' . $id . '.startOrientation();
2369 panoshow2' . $id . '.startOrientation();
2370 panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
2371 panoshow2' . $id . '.setYaw(panoshow' . $id . '.getYaw(), 0);
2372 getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").hide();
2373 getParent.find("#pano' . $id . ' #controls' . $id . '").hide();
2374 getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").hide();
2375 getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
2376 getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").hide();
2377 getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").hide();
2378 getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
2379 getParent.find("#pano' . $id . ' #adcontrol' . $id . '").hide();
2380 getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
2381 getParent.find("#pano' . $id . ' #cp-logo-controls").hide();
2382
2383 getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
2384
2385 getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
2386 getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
2387
2388 getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2389 getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2390
2391 getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
2392 getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
2393 getParent.find("#pano' . $id . '").addClass("cardboard-half");
2394
2395 getParent.find("#center-pointer' . $id . '").show();
2396 getParent.find(".fullscreen-button").hide();
2397
2398
2399 if (window.DeviceOrientationEvent) {
2400 window.addEventListener("deviceorientation", vrDeviseOrientation);
2401 }
2402
2403 panoshow' . $id . '.on("mousemove", function (data){
2404 panoshow2' . $id . '.setPitch(data.pitch, 0);
2405 panoshow2' . $id . '.setYaw(data.yaw, 0);
2406 panoShowCardBoardOnTrigger(data);
2407
2408 });
2409 panoshow2' . $id . '.on("mousemove", function (data){
2410 panoshow2' . $id . '.setPitch(data.pitch, 0);
2411 panoshow' . $id . '.setYaw(data.yaw, 0);
2412 panoShowCardBoardOnTrigger(data);
2413
2414 });
2415
2416 panoshow' . $id . '.on("zoomchange", function (data){
2417 panoshow2' . $id . '.setHfov(data, 0);
2418 });
2419
2420 panoshow2' . $id . '.on("zoomchange", function (data){
2421 panoshow' . $id . '.setHfov(data, 0);
2422 });
2423
2424 panoshow' . $id . '.on("touchmove", function (data){
2425 panoshow' . $id . '.stopOrientation();
2426 panoshow2' . $id . '.stopOrientation();
2427 panoshow2' . $id . '.setPitch(data.pitch, 0);
2428 panoshow2' . $id . '.setYaw(data.yaw, 0);
2429 panoShowCardBoardOnTrigger(data);
2430
2431 });
2432
2433 panoshow2' . $id . '.on("touchmove", function (data){
2434 panoshow' . $id . '.stopOrientation();
2435 panoshow2' . $id . '.stopOrientation();
2436 panoshow' . $id . '.setPitch(data.pitch, 0);
2437 panoshow' . $id . '.setYaw(data.yaw, 0);
2438 panoShowCardBoardOnTrigger(data);
2439
2440 });
2441
2442 }
2443 else if(getValue == "on") {
2444 screen.orientation.unlock();
2445 requestExitFullscreen();
2446 // localStorage.setItem("vr_mode", "off");
2447 vr_mode = "off";
2448 jQuery(".vr-mode-title").hide();
2449 jQuery(this).val("off");
2450 getParent.find("#pano2' . $id . '").css({
2451 "opacity": "0",
2452 "visibility": "hidden",
2453 "position": "absolute",
2454 });
2455 panoshow' . $id . '.stopOrientation();
2456 panoshow2' . $id . '.stopOrientation();
2457 getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
2458 getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").show();
2459 getParent.find("#pano' . $id . ' #controls' . $id . '").show();
2460 getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").show();
2461 getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
2462 getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").show();
2463
2464 getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
2465 getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
2466 getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").show();
2467 getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
2468 getParent.find("#pano' . $id . ' #adcontrol' . $id . '").show();
2469 getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
2470 getParent.find("#pano' . $id . ' #cp-logo-controls").show();
2471 getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").show();
2472
2473 if(compassBlock == "block"){
2474 getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2475 getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2476 }
2477 if(infoBlock == "block"){
2478 getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
2479 getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
2480 }
2481
2482 getParent.find("#pano' . $id . '").removeClass("cardboard-half");
2483 getParent.find("#center-pointer' . $id . '").hide();
2484 getParent.find(".fullscreen-button").hide();
2485 panoshow' . $id . '.off("mousemove");
2486 panoshow' . $id . '.off("touchmove");
2487 panoshow2' . $id . '.off("mousemove");
2488 panoshow2' . $id . '.off("touchmove");
2489 if (window.DeviceOrientationEvent) {
2490 window.removeEventListener("deviceorientation", vrDeviseOrientation);
2491 }
2492 }
2493 });';
2494
2495 $html .= 'panoshow2' . $id . '.on("load", function (){
2496 // if(localStorage.getItem("vr_mode") == "off") {
2497 if( vr_mode == "off") {
2498 jQuery(".vr-mode-title").hide();
2499 }
2500 else {
2501 jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2502 jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2503 jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2504 jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2505 jQuery(".vr-mode-title").show();
2506 }
2507 });';
2508 }
2509
2510 $html .= 'jQuery("#pano' . $id . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
2511 var scene_id = jQuery(this).attr("scene_id");
2512 panoshow' . $id . '.loadScene(scene_id)
2513 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2514 jQuery(this).addClass("add-pulse")
2515 });';
2516
2517 if($scene_animation == 'on'){
2518 $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
2519 $html .= $animation_js;
2520 $html .= 'panoshow' . $id . '.on("load", function (scene){
2521 if (typeof changeScene === "function") {
2522 changeScene();
2523 } else {
2524 console.warn("changeScene function is not defined.");
2525 }
2526 });';
2527 }
2528
2529 $html .= '
2530 panoshow' . $id . '.on("mousemove", function (data){
2531 jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
2532 });
2533 ';
2534
2535
2536
2537 $status = get_option('wpvr_edd_license_status');
2538 if ($status !== false && 'valid' == $status && $is_pro) {
2539 $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2540 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2541 jQuery(".floor-plan-pointer").each(function(index ,element){
2542 var scene_id = jQuery(this).attr("scene_id");
2543 if( active_scene == scene_id ){
2544 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2545 jQuery(this).addClass("add-pulse")
2546 }
2547 });
2548
2549 });';
2550 $html .= 'panoshow' . $id . '.on("load", function (){
2551 if(jQuery(".floor-plan-pointer").length > 0){
2552 jQuery(".floor-plan-pointer").each(function(index ,element){
2553 var scene_id = jQuery(this).attr("scene_id");
2554 if( active_scene == scene_id ){
2555 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2556 jQuery(this).addClass("add-pulse")
2557 }
2558 });
2559 }
2560 });';
2561 }
2562
2563 if ($status !== false && 'valid' == $status && $is_pro) {
2564 $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
2565 $html .= '
2566 jQuery("#pano' . $id . ' .custom-scene-navigation").on("click",function(){
2567 jQuery("#custom-scene-navigation-nav' . $id . ' ul").empty()
2568 if(scenes){
2569 var scene_navigation_content_type = ' . "'" . $scene_navigation_content_type . "'" . ';
2570 var sceneList = scenes.scenes;
2571 var getScene = panoshow' . $id . '.getScene();
2572 for (const key in sceneList) {
2573 let title;
2574 if (scene_navigation_content_type === "scene_title") {
2575 if (sceneList[key].title) {
2576 title = sceneList[key].title;
2577
2578 }else{
2579 if(title == "" || title == undefined){
2580 if (sceneList[key].panorama) {
2581 title = getImageNameWithoutExtension(sceneList[key].panorama);
2582 }
2583 }
2584 }
2585 } else if (scene_navigation_content_type === "scene_image_name") {
2586 if (sceneList[key].panorama) {
2587 title = getImageNameWithoutExtension(sceneList[key].panorama);
2588 }
2589 } else {
2590 title = key;
2591 }
2592 if (sceneList.hasOwnProperty(key)) {
2593 if( key === getScene){
2594 jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list active\" scene_id= " + key + " >" + title + "</li>");
2595 }else{
2596 jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list\" scene_id= " + key + " >" + title + "</li>");
2597 }
2598 }
2599 }
2600 }
2601 jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
2602 });
2603 ';
2604
2605 $html .= 'function getImageNameWithoutExtension(imageUrl) {
2606 // Split the URL by "/"
2607 var parts = imageUrl.split("/");
2608
2609 // Get the last part which contains the image name
2610 var imageNameWithExtension = parts[parts.length - 1];
2611
2612 // Split the image name by period (.)
2613 var imageNameParts = imageNameWithExtension.split(".");
2614
2615 // Remove the last part (which is the extension) and join the remaining parts
2616 var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
2617
2618 // Return the image name without extension
2619 return imageNameWithoutExtension;
2620 }';
2621
2622
2623 $html .= '
2624 jQuery("#pano' . $id . ' #custom-scene-navigation-nav' . $id . ' ul").on("click", "li.scene-navigation-list", function() {
2625 if (scenes) {
2626 jQuery(this).siblings("li").removeClass("active");
2627 jQuery(this).addClass("active");
2628
2629 var scene_key = jQuery(this).attr("scene_id");
2630 panoshow' . $id . '.loadScene(scene_key);
2631 }
2632 });
2633 ';
2634 }
2635
2636 //Duplicate mode only for vr mode end===//
2637 $html .= 'panoshow' . $id . '.on("load", function (){
2638
2639 // if(localStorage.getItem("vr_mode") == "off") {
2640 if( vr_mode == "off") {
2641 jQuery(".vr-mode-title").hide();
2642 }
2643 else {
2644 jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2645 jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2646 jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2647 jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2648 jQuery(".vr-mode-title").show();
2649 }
2650
2651
2652 if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
2653 jQuery("#controls' . $id . '").css("bottom", "55px");
2654 }
2655 else {
2656 jQuery("#controls' . $id . '").css("bottom", "5px");
2657 }
2658 });';
2659
2660
2661 $html .= '
2662 if (scenes.autoRotate) {
2663 panoshow' . $id . '.on("load", function (){
2664 setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2665 });
2666 panoshow' . $id . '.on("scenechange", function (){
2667 setTimeout(function(){ panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0); }, 3000);
2668 });
2669 }
2670 ';
2671 $html .= 'var touchtime = 0;';
2672 if ($vrgallery) {
2673 if (isset($panodata["scene-list"])) {
2674 foreach ($panodata["scene-list"] as $panoscenes) {
2675 $scene_key = $panoscenes['scene-id'];
2676 $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
2677 $img_src_url = $panoscenes['scene-attachment-url'];
2678 // $html .= 'document.getElementById("' . $scene_key_gallery . '").addEventListener("click", function(e) { ';
2679 // $html .= 'if (touchtime == 0) {';
2680 // $html .= 'touchtime = new Date().getTime();';
2681 // $html .= '} else {';
2682 // $html .= 'if (((new Date().getTime()) - touchtime) < 800) {';
2683 // $html .= 'panoshow' . $id . '.loadScene("' . $scene_key . '");';
2684 // $html .= 'touchtime = 0;';
2685 // $html .= '} else {';
2686 // $html .= 'touchtime = new Date().getTime();';
2687 // $html .= '}';
2688 // $html .= '}';
2689 // $html .= '});';
2690 $html .= '
2691 jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
2692 panoshow' . $id . '.loadScene("' . $scene_key . '");
2693 });
2694 ';
2695 }
2696 }
2697 }
2698
2699
2700
2701 //===Custom Control===//
2702 if (isset($custom_control)) {
2703 if ($custom_control['panupSwitch'] == "on") {
2704 $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
2705 $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() + 10);';
2706 $html .= '});';
2707 }
2708
2709 if ($custom_control['panDownSwitch'] == "on") {
2710 $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
2711 $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() - 10);';
2712 $html .= '});';
2713 }
2714
2715 if ($custom_control['panLeftSwitch'] == "on") {
2716 $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
2717 $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() - 10);';
2718 $html .= '});';
2719 }
2720
2721 if ($custom_control['panRightSwitch'] == "on") {
2722 $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
2723 $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() + 10);';
2724 $html .= '});';
2725 }
2726
2727 if ($custom_control['panZoomInSwitch'] == "on") {
2728 $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
2729 $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() - 10);';
2730 $html .= '});';
2731 }
2732
2733 if ($custom_control['panZoomOutSwitch'] == "on") {
2734 $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
2735 $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() + 10);';
2736 $html .= '});';
2737 }
2738
2739 if ($custom_control['panFullscreenSwitch'] == "on") {
2740 $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
2741 $html .= 'panoshow' . $id . '.toggleFullscreen();';
2742 $html .= '});';
2743 }
2744
2745 if ($custom_control['backToHomeSwitch'] == "on") {
2746 $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
2747 $html .= 'panoshow' . $id . '.loadScene("' . $default_scene . '");';
2748 $html .= '});';
2749 }
2750
2751 if ($custom_control['gyroscopeSwitch'] == "on") {
2752 $html .= '
2753 var element = document.getElementById("gyroscope' . $id . '");
2754 var gyroSwitch = true;
2755 panoshow' . $id . '.on("load", function (){
2756 if(gyroSwitch == false) {
2757 panoshow' . $id . '.stopOrientation();
2758 element.children[0].style.color = "red";
2759 }
2760 else {
2761 panoshow' . $id . '.startOrientation();
2762 element.children[0].style.color = "' . $custom_control['gyroscopeColor'] . '";
2763 }
2764 });
2765 panoshow' . $id . '.on("scenechange", function (){
2766 if (panoshow' . $id . '.isOrientationActive()) {
2767 element.children[0].style.color = "' . $custom_control['gyroscopeColor'] . '";
2768 }
2769 else {
2770 element.children[0].style.color = "red";
2771 }
2772 });
2773
2774 panoshow' . $id . '.on("touchstart", function (){
2775 if (panoshow' . $id . '.isOrientationActive()) {
2776 gyroSwitch = true;
2777 element.children[0].style.color = "' . $custom_control['gyroscopeColor'] . '";
2778 }
2779 else {
2780 gyroSwitch = false;
2781 element.children[0].style.color = "red";
2782 }
2783 });
2784 ';
2785 $html .= 'document.getElementById("gyroscope' . $id . '").addEventListener("click", function(e) {';
2786 $html .= '
2787 var element = document.getElementById("gyroscope' . $id . '");
2788 if (panoshow' . $id . '.isOrientationActive()) {
2789
2790 panoshow' . $id . '.stopOrientation();
2791 gyroSwitch = false;
2792 element.children[0].style.color = "red";
2793 }
2794 else {
2795 panoshow' . $id . '.startOrientation();
2796 gyroSwitch = true;
2797 element.children[0].style.color = "' . $custom_control['gyroscopeColor'] . '";
2798 }
2799
2800 ';
2801 $html .= '});';
2802 }
2803 }
2804
2805 $angle_up = '<i class="fa fa-angle-up"></i>';
2806 $angle_down = '<i class="fa fa-angle-down"></i>';
2807 $sin_qout = "'";
2808
2809 //===Explainer Script===//
2810 $html .= '
2811 jQuery(document).on("click","#explainer_button_' . $id . '",function() {
2812 jQuery("#explainer' . $id . '").slideToggle();
2813 // jQuery(".explainer").slideToggle();
2814 });
2815
2816 jQuery(document).on("click",".close-explainer-video",function() {
2817 jQuery(this).parent(".explainer").hide();
2818 });
2819 jQuery(document).on("click","#pano' . $id . '",function(event) {
2820 var isActiveModal = event.target.closest(".custom-ifram-wrapper");
2821 var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
2822 if( isActiveModal == null && isForm == null){
2823 jQuery(".custom-ifram-wrapper").hide();
2824 jQuery(this).removeClass("show-modal");
2825 jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
2826 }else if(isForm != null){
2827 jQuery(this).addClass("show-modal");
2828 }
2829 });
2830
2831 ';
2832 //===Explainer Script End===//
2833
2834 //===generic form script===//
2835 if (isset($postdata["genericform"]) && $postdata["genericform"] == 'on') {
2836 $html .= '
2837 jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
2838 jQuery("#wpvr-generic-form' . $id . '").fadeToggle();
2839 });
2840
2841 jQuery(document).on("click",".close-generic-form",function() {
2842 jQuery(this).parent(".wpvr-generic-form").fadeOut()
2843 });
2844 ';
2845 }
2846 //===generic from script===//
2847
2848 //===Floor map Script===//
2849 $html .= '
2850 jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
2851 jQuery("#wpvr-floor-map' . $id . '").toggle().removeClass("fullwindow");
2852 });
2853
2854 jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
2855 jQuery(this).addClass("fullwindow");
2856 jQuery(this).parents(".pano-wrap").addClass("show-modal");
2857 });
2858
2859 jQuery(document).on("click",".close-floor-map-plan",function() {
2860 jQuery(this).parent(".wpvr-floor-map").hide();
2861 jQuery(this).parent(".wpvr-floor-map").removeClass("fullwindow");
2862 jQuery(this).parents(".pano-wrap").removeClass("show-modal");
2863 });
2864
2865 ';
2866 //===Floor map Script End===//
2867
2868 if ($vrgallery_display) {
2869 if (!$autoload) {
2870 $html .= '
2871 jQuery(document).ready(function($){
2872 jQuery("#sccontrols' . $id . '").hide();
2873 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2874 jQuery("#sccontrols' . $id . '").hide();
2875 jQuery(".wpvr_slider_nav").hide();
2876 });
2877 ';
2878
2879 $html .= '
2880 var slide' . $id . ' = "down";
2881 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2882
2883 if (slide' . $id . ' == "up") {
2884 jQuery(".vrgctrl' . $id . '").empty();
2885 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2886 slide' . $id . ' = "down";
2887 jQuery(".wpvr_slider_nav").slideToggle();
2888 jQuery("#sccontrols' . $id . '").slideToggle();
2889 }
2890 else {
2891 jQuery(".vrgctrl' . $id . '").empty();
2892 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2893 slide' . $id . ' = "up";
2894 jQuery(".wpvr_slider_nav").slideToggle();
2895 jQuery("#sccontrols' . $id . '").slideToggle();
2896 }
2897 });
2898 ';
2899 } else {
2900 $html .= '
2901 jQuery(document).ready(function($){
2902 jQuery("#sccontrols' . $id . '").show();
2903 jQuery(".wpvr_slider_nav").show();
2904 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2905 });
2906 ';
2907
2908 $html .= '
2909 var slide' . $id . ' = "down";
2910 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2911
2912 if (slide' . $id . ' == "up") {
2913 jQuery(".vrgctrl' . $id . '").empty();
2914 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2915 slide' . $id . ' = "down";
2916 }
2917 else {
2918 jQuery(".vrgctrl' . $id . '").empty();
2919 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2920 slide' . $id . ' = "up";
2921 }
2922 jQuery(".wpvr_slider_nav").slideToggle();
2923 jQuery("#sccontrols' . $id . '").slideToggle();
2924 });
2925 ';
2926 }
2927 } else {
2928 $html .= '
2929 jQuery(document).ready(function($){
2930 jQuery("#sccontrols' . $id . '").hide();
2931 jQuery(".wpvr_slider_nav").hide();
2932 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2933 });
2934 ';
2935
2936 $html .= '
2937 var slide' . $id . ' = "down";
2938 jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
2939
2940 if (slide' . $id . ' == "up") {
2941 jQuery(".vrgctrl' . $id . '").empty();
2942 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
2943 slide' . $id . ' = "down";
2944 }
2945 else {
2946 jQuery(".vrgctrl' . $id . '").empty();
2947 jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
2948 slide' . $id . ' = "up";
2949 }
2950 jQuery(".wpvr_slider_nav").slideToggle();
2951 jQuery("#sccontrols' . $id . '").slideToggle();
2952 });
2953 ';
2954 }
2955
2956 if (!$autoload) {
2957 $html .= '
2958
2959 jQuery(document).ready(function(){
2960 jQuery("#controls' . $id . '").hide();
2961 jQuery("#zoom-in-out-controls' . $id . '").hide();
2962 jQuery("#adcontrol' . $id . '").hide();
2963 jQuery("#explainer_button_' . $id . '").hide();
2964 jQuery("#generic_form_button_' . $id . '").hide();
2965 jQuery("#floor_map_button_' . $id . '").hide();
2966 jQuery("#vrgcontrols' . $id . '").hide();
2967 jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
2968 });
2969
2970 ';
2971
2972 if ($vrgallery_display) {
2973 $html .= 'var load_once = "true";';
2974 $html .= 'panoshow' . $id . '.on("load", function (){
2975 if (load_once == "true") {
2976 load_once = "false";
2977 jQuery("#sccontrols' . $id . '").slideToggle();
2978 jQuery(".wpvr_slider_nav").slideToggle();
2979 }
2980 });';
2981 }
2982
2983 $html .= 'panoshow' . $id . '.on("load", function (){
2984 jQuery("#controls' . $id . '").show();
2985 jQuery("#zoom-in-out-controls' . $id . '").show();
2986 jQuery("#adcontrol' . $id . '").show();
2987 jQuery("#explainer_button_' . $id . '").show();
2988 jQuery("#generic_form_button_' . $id . '").show();
2989 jQuery("#floor_map_button_' . $id . '").show();
2990 jQuery("#vrgcontrols' . $id . '").show();
2991 jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
2992 });';
2993 }
2994
2995 $previewText = $postdata['previewtext'] ?? 'Click To Load Panorama';
2996 if ($previewText) {
2997 $html .= '
2998 jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previewText. '")
2999 ';
3000 } else {
3001 $html .= '
3002 jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("Click To Load Panorama")
3003 ';
3004 }
3005
3006 $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3007 jQuery(this).attr("title", jQuery(this).text());
3008 });
3009 jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3010 jQuery(this).removeAttr("title");
3011 });';
3012 $html .= '});';
3013
3014
3015
3016 $html .= '</script>';
3017
3018 $tour_data = [];
3019 if(defined("WPVR_PRO_VERSION")){
3020 $tour_data = array(
3021 'explainerControlSwitch' => $explainerControlSwitch ?? false,
3022 'floor_plan_enable' => $floor_plan_enable ?? false,
3023 'floor_plan_image' => $floor_plan_image ?? '',
3024 'custom_control' => $custom_control ?? [],
3025 );
3026 }
3027
3028 return apply_filters('wpvr_generate_tour_layout_html', $html ,$postdata ,$id, $tour_data);
3029 }
3030
3031
3032 function wpvr_hex2rgb($colour)
3033 {
3034 if (isset($colour[0]) && $colour[0] == '#') {
3035 $colour = substr($colour, 1);
3036 }
3037 if (strlen($colour) == 6) {
3038 list($r, $g, $b) = array($colour[0] . $colour[1], $colour[2] . $colour[3], $colour[4] . $colour[5]);
3039 } elseif (strlen($colour) == 3) {
3040 list($r, $g, $b) = array($colour[0] . $colour[0], $colour[1] . $colour[1], $colour[2] . $colour[2]);
3041 } else {
3042 return false;
3043 }
3044 $r = hexdec($r);
3045 $g = hexdec($g);
3046 $b = hexdec($b);
3047 return array($r . ', ' . $g . ', ' . $b);
3048 }
3049
3050 function wpvr_HTMLToRGB($htmlCode)
3051 {
3052 $r = 0;
3053 $g = 0;
3054 $b = 0;
3055 if (isset($htmlCode[0]) && $htmlCode[0] == '#') {
3056 $htmlCode = substr($htmlCode, 1);
3057 }
3058
3059 if (strlen($htmlCode) == 3) {
3060 $htmlCode = $htmlCode[0] . $htmlCode[0] . $htmlCode[1] . $htmlCode[1] . $htmlCode[2] . $htmlCode[2];
3061 }
3062
3063 if (isset($htmlCode[0]) && isset($htmlCode[1])) {
3064 $r = hexdec($htmlCode[0] . $htmlCode[1]);
3065 }
3066 if (isset($htmlCode[2]) && isset($htmlCode[3])) {
3067 $g = hexdec($htmlCode[2] . $htmlCode[3]);
3068 }
3069 if (isset($htmlCode[4]) && isset($htmlCode[5])) {
3070 $b = hexdec($htmlCode[4] . $htmlCode[5]);
3071 }
3072
3073 return $b + ($g << 0x8) + ($r << 0x10);
3074 }
3075
3076 function wpvr_RGBToHSL($RGB)
3077 {
3078 $r = 0xFF & ($RGB >> 0x10);
3079 $g = 0xFF & ($RGB >> 0x8);
3080 $b = 0xFF & $RGB;
3081
3082 $r = ((float)$r) / 255.0;
3083 $g = ((float)$g) / 255.0;
3084 $b = ((float)$b) / 255.0;
3085
3086 $maxC = max($r, $g, $b);
3087 $minC = min($r, $g, $b);
3088
3089 $l = ($maxC + $minC) / 2.0;
3090
3091 if ($maxC == $minC) {
3092 $s = 0;
3093 $h = 0;
3094 } else {
3095 if ($l < .5) {
3096 $s = ($maxC - $minC) / ($maxC + $minC);
3097 } else {
3098 $s = ($maxC - $minC) / (2.0 - $maxC - $minC);
3099 }
3100 if ($r == $maxC) {
3101 $h = ($g - $b) / ($maxC - $minC);
3102 }
3103 if ($g == $maxC) {
3104 $h = 2.0 + ($b - $r) / ($maxC - $minC);
3105 }
3106 if ($b == $maxC) {
3107 $h = 4.0 + ($r - $g) / ($maxC - $minC);
3108 }
3109
3110 $h = $h / 6.0;
3111 }
3112
3113 $h = (int)round(255.0 * $h);
3114 $s = (int)round(255.0 * $s);
3115 $l = (int)round(255.0 * $l);
3116
3117 return (object) array('hue' => $h, 'saturation' => $s, 'lightness' => $l);
3118 }
3119
3120 add_action('rest_api_init', 'wpvr_rest_data_route');
3121 function wpvr_rest_data_route()
3122 {
3123 register_rest_route('wpvr/v1', '/panodata/', array(
3124 'methods' => 'GET',
3125 'callback' => 'wpvr_rest_data_set',
3126 'permission_callback' => 'wpvr_rest_route_permission'
3127 ));
3128 }
3129
3130 function wpvr_rest_route_permission()
3131 {
3132 return true;
3133 }
3134
3135 function wpvr_rest_data_set()
3136 {
3137 $query = new WP_Query(array(
3138 'post_type' => 'wpvr_item',
3139 'posts_per_page' => -1,
3140 ));
3141
3142 $wpvr_list = array();
3143 $list_none = array('value' => 0, 'label' => 'None');
3144 array_push($wpvr_list, $list_none);
3145 while ($query->have_posts()) {
3146 $query->the_post();
3147 $title = mb_convert_encoding(get_the_title(), 'UTF-8', 'HTML-ENTITIES');
3148 $post_id = get_the_ID();
3149 $title = $post_id . ' : ' . $title;
3150 $list_ob = array('value' => $post_id, 'label' => $title);
3151 array_push($wpvr_list, $list_ob);
3152 }
3153
3154 return $wpvr_list;
3155 }
3156
3157 function wpvr_isMobileDevice()
3158 {
3159 return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
3160 }
3161
3162 function wpvr_directory()
3163 {
3164 $upload = wp_upload_dir();
3165 $upload_dir = $upload['basedir'];
3166 $upload_dir_temp = $upload_dir . '/wpvr/temp/';
3167 if (!is_dir($upload_dir_temp)) {
3168 wp_mkdir_p($upload_dir_temp, 0700);
3169 }
3170 }
3171
3172 add_action('admin_init', 'wpvr_directory');
3173
3174
3175 function wpvr_add_role_cap()
3176 {
3177 $editor_active = get_option('wpvr_editor_active');
3178
3179 $author_active = get_option('wpvr_author_active');
3180
3181 $admin = get_role('administrator');
3182 $admin->add_cap('publish_wpvr_tour');
3183 $admin->add_cap('edit_wpvr_tours');
3184 $admin->add_cap('read_wpvr_tour');
3185 $admin->add_cap('edit_wpvr_tour');
3186 $admin->add_cap('edit_wpvr_tours');
3187 $admin->add_cap('publish_wpvr_tours');
3188 $admin->add_cap('publish_wpvr_tour');
3189 $admin->add_cap('delete_wpvr_tour');
3190 $admin->add_cap('edit_other_wpvr_tours');
3191 $admin->add_cap('delete_other_wpvr_tours');
3192
3193 if ($editor_active == "true") {
3194 $editor = get_role('editor');
3195 if ($editor) {
3196 $editor->add_cap('publish_wpvr_tour');
3197 $editor->add_cap('edit_wpvr_tours');
3198 $editor->add_cap('read_wpvr_tour');
3199 $editor->add_cap('edit_wpvr_tour');
3200 $editor->add_cap('edit_wpvr_tours');
3201 $editor->add_cap('publish_wpvr_tours');
3202 $editor->add_cap('publish_wpvr_tour');
3203 $editor->add_cap('delete_wpvr_tour');
3204 $editor->add_cap('edit_other_wpvr_tours');
3205 $editor->add_cap('delete_other_wpvr_tours');
3206 }
3207 } else {
3208 $editor = get_role('editor');
3209 if ($editor) {
3210 $editor->remove_cap('publish_wpvr_tour');
3211 $editor->remove_cap('edit_wpvr_tours');
3212 $editor->remove_cap('read_wpvr_tour');
3213 $editor->remove_cap('edit_wpvr_tour');
3214 $editor->remove_cap('edit_wpvr_tours');
3215 $editor->remove_cap('publish_wpvr_tours');
3216 $editor->remove_cap('publish_wpvr_tour');
3217 $editor->remove_cap('delete_wpvr_tour');
3218 $editor->remove_cap('edit_other_wpvr_tours');
3219 $editor->remove_cap('delete_other_wpvr_tours');
3220 }
3221 }
3222
3223 if ($author_active == "true") {
3224 $author = get_role('author');
3225 if ($author) {
3226 $author->add_cap('read_wpvr_tour');
3227 $author->add_cap('edit_wpvr_tour');
3228 $author->add_cap('edit_wpvr_tours');
3229 $author->add_cap('publish_wpvr_tours');
3230 $author->add_cap('publish_wpvr_tour');
3231 $author->add_cap('delete_wpvr_tour');
3232 }
3233 } else {
3234 $author = get_role('author');
3235 if ($author) {
3236 $author->remove_cap('read_wpvr_tour');
3237 $author->remove_cap('edit_wpvr_tour');
3238 $author->remove_cap('edit_wpvr_tours');
3239 $author->remove_cap('publish_wpvr_tours');
3240 $author->remove_cap('publish_wpvr_tour');
3241 $author->remove_cap('delete_wpvr_tour');
3242 }
3243 }
3244
3245 if(is_plugin_active( 'dokan-lite/dokan.php' ) || is_plugin_active( 'dokan-pro/dokan.php' )){
3246 $dokan_vendor_active = get_option('dokan_vendor_active');
3247
3248 if( 'true' === $dokan_vendor_active){
3249 $seller = get_role('seller');
3250 if ($seller) {
3251 $seller->add_cap('read_wpvr_tour');
3252 $seller->add_cap('edit_wpvr_tour');
3253 $seller->add_cap('edit_wpvr_tours');
3254 $seller->add_cap('publish_wpvr_tours');
3255 $seller->add_cap('publish_wpvr_tour');
3256 $seller->add_cap('delete_wpvr_tour');
3257 }
3258 } else{
3259 $seller = get_role('seller');
3260 if ($seller) {
3261 $seller->remove_cap('read_wpvr_tour');
3262 $seller->remove_cap('edit_wpvr_tour');
3263 $seller->remove_cap('edit_wpvr_tours');
3264 $seller->remove_cap('publish_wpvr_tours');
3265 $seller->remove_cap('publish_wpvr_tour');
3266 $seller->remove_cap('delete_wpvr_tour');
3267 }
3268 }
3269 }
3270
3271
3272 }
3273
3274 add_action('admin_init', 'wpvr_add_role_cap', 999);
3275
3276 function wpvr_role_management_from_post_type($args, $post_type)
3277 {
3278 if ('wpvr_item' !== $post_type) {
3279 return $args;
3280 }
3281
3282 $editor_active = get_option('wpvr_editor_active');
3283 $author_active = get_option('wpvr_author_active');
3284 $user = wp_get_current_user();
3285
3286 if ($editor_active == "true") {
3287 if (in_array('editor', (array) $user->roles)) {
3288 $args['show_in_menu'] = true;
3289 }
3290 }
3291
3292 if ($author_active == "true") {
3293 if (in_array('author', (array) $user->roles)) {
3294 $args['show_in_menu'] = true;
3295 }
3296 }
3297
3298 if(is_plugin_active( 'dokan-lite/dokan.php' ) || is_plugin_active( 'dokan-pro/dokan.php' )){
3299 $dokan_vendor_active = get_option('dokan_vendor_active');
3300 if( 'true' === $dokan_vendor_active){
3301 if (in_array('seller', (array) $user->roles)) {
3302 $args['show_in_menu'] = true;
3303 }
3304 }
3305
3306 }
3307
3308 return $args;
3309 }
3310 add_filter('register_post_type_args', 'wpvr_role_management_from_post_type', 10, 2);
3311
3312 function wpvr_cache_admin_notice()
3313 {
3314 $option = get_option('wpvr_warning');
3315 if (!$option) {
3316 ?>
3317 <div class="notice notice-warning" id="wpvr-warning" style="position: relative;">
3318 <p><?php _e('Since you have updated the plugin, please clear the browser cache for smooth functioning. Follow these steps if you are using <a href="https://support.google.com/accounts/answer/32050?co=GENIE.Platform%3DDesktop&hl=en" target="_blank">Google Chrome</a>, <a href="https://support.mozilla.org/en-US/kb/how-clear-firefox-cache" target="_blank">Mozilla Firefox</a>, <a href="https://clear-my-cache.com/en/apple-mac-os/safari.html" target="_blank">Safai</a> or <a href="https://support.microsoft.com/en-us/help/10607/microsoft-edge-view-delete-browser-history" target="_blank">Microsoft Edge</a>', 'wpvr'); ?></p>
3319 <button type="button" id="wpvr-dismissible" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button>
3320 </div>
3321 <?php
3322 }
3323 }
3324 // add_action('admin_notices', 'wpvr_cache_admin_notice');
3325
3326 //===Oxygen widget===//
3327 add_action('plugins_loaded', function () {
3328 if (!class_exists('OxyEl')) {
3329 return;
3330 }
3331 require_once __DIR__ . '/oxygen/oxy-manager.php';
3332 });
3333
3334 add_action('init', 'wpvr_mobile_media_handle');
3335 function wpvr_mobile_media_handle()
3336 {
3337 add_image_size('wpvr_mobile', 4096, 2048); //mobile
3338 }
3339
3340
3341 add_action(
3342 /**
3343 * @param $api \VisualComposer\Modules\Api\Factory
3344 */
3345 'vcv:api',
3346 function ($api) {
3347 $elementsToRegister = [
3348 'wpvrelement',
3349 ];
3350 $pluginBaseUrl = rtrim(plugins_url(basename(__DIR__)), '\\/');
3351 /** @var \VisualComposer\Modules\Elements\ApiController $elementsApi */
3352 $elementsApi = $api->elements;
3353 foreach ($elementsToRegister as $tag) {
3354 $manifestPath = __DIR__ . '/vc/' . $tag . '/manifest.json';
3355 $elementBaseUrl = $pluginBaseUrl . '/vc/' . $tag;
3356 $elementsApi->add($manifestPath, $elementBaseUrl);
3357 }
3358 }
3359 );
3360
3361 function wpvr_redirect_after_activation($plugin)
3362 {
3363 if ($plugin == plugin_basename(__FILE__)) {
3364 $url = admin_url('admin.php?page=wpvr-setup-wizard');
3365 $url = esc_url($url, FILTER_SANITIZE_URL);
3366 exit(wp_safe_redirect($url));
3367 }
3368 }
3369 //add_action('activated_plugin', 'wpvr_redirect_after_activation');
3370
3371 function replace_callback($matches)
3372 {
3373 foreach ($matches as $match) {
3374 return str_replace('<img', '<img decoding="async" ', $match);
3375 }
3376 }