PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.1.3
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.1.3
9.1.3 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 All 222 releases
← All changes | legacy/wpvr.php +193 -3123 9.0.09.1.3 View file →
@@ -7,8 +7,9 @@
7 7 die;
8 8 }
9 9
10 10 require WPVR_PLUGIN_LEGACY_DIR_PATH . 'elementor/elementor.php';
11 +require_once WPVR_PLUGIN_LEGACY_DIR_PATH . 'breakdance/breakdance.php';
11 12 if ( file_exists( dirname( WPVR_PLUGIN_LEGACY_DIR_PATH ) . '/vendor/autoload.php' ) ) {
12 13 require_once dirname( WPVR_PLUGIN_LEGACY_DIR_PATH ) . '/vendor/autoload.php';
13 14 } elseif ( file_exists( WPVR_PLUGIN_LEGACY_DIR_PATH . 'vendor/autoload.php' ) ) {
14 15 require_once WPVR_PLUGIN_LEGACY_DIR_PATH . 'vendor/autoload.php';
@@ -375,9 +376,13 @@
375 376 * @return string
376 377 * @since 9.0.0
377 378 */
378 379 function wpvr_render_scene_info_row( $html, $postdata, $id ) {
379 - $pano_id = 'pano' . absint( $id );
380 + if ( preg_match( '/id=[\'"](pano' . absint( $id ) . '(?:_\d+)?)[\'"]/', $html, $m ) ) {
381 + $pano_id = $m[1];
382 + } else {
383 + $pano_id = 'pano' . absint( $id );
384 + }
380 385 $pano_id_json = wp_json_encode( $pano_id );
381 386 $by_label = wp_json_encode( __( 'By', 'wpvr' ) );
382 387 $tour_layout = is_array( $postdata['tourLayout'] ?? null )
383 388 ? ( $postdata['tourLayout']['layout'] ?? 'default' )
@@ -383,9 +388,9 @@
383 388 ? ( $postdata['tourLayout']['layout'] ?? 'default' )
384 389 : ( $postdata['tourLayout'] ?? 'default' );
385 390 $is_classic_layout = wp_json_encode( 'layout1' !== $tour_layout );
386 391
387 - $html .= '<style id="wpvr-scene-info-' . esc_attr( $id ) . '">
392 + $html .= '<style id="wpvr-scene-info-' . esc_attr( $pano_id ) . '">
388 393 #' . esc_attr( $pano_id ) . ' .pnlm-panorama-info.wpvr-scene-info-row {
389 394 display: flex !important;
390 395 align-items: center !important;
391 396 justify-content: center !important;
@@ -481,9 +486,9 @@
481 486 padding-left: 7px !important;
482 487 }
483 488 }
484 489 </style>
485 - <script id="wpvr-scene-info-script-' . esc_attr( $id ) . '">
490 + <script id="wpvr-scene-info-script-' . esc_attr( $pano_id ) . '">
486 491 (function () {
487 492 var pano = document.getElementById(' . $pano_id_json . ');
488 493 var byLabel = ' . $by_label . ';
489 494
@@ -496,9 +501,9 @@
496 501 return;
497 502 }
498 503
499 504 var firstNode = author.firstChild;
500 - if (firstNode && firstNode.nodeType === 3) {
505 + if (firstNode ? firstNode.nodeType === 3 : false) {
501 506 var prefix = byLabel + " ";
502 507 if (firstNode.nodeValue.indexOf(prefix) === 0) {
503 508 firstNode.nodeValue = firstNode.nodeValue.slice(prefix.length);
504 509 }
@@ -524,10 +529,10 @@
524 529 }
525 530
526 531 var title = info.querySelector(".pnlm-title-box");
527 532 var author = info.querySelector(".pnlm-author-box");
528 - var hasTitle = !!(title && title.textContent.trim());
529 - var hasAuthor = !!(author && author.textContent.trim());
533 + var hasTitle = Boolean(title ? title.textContent.trim() : false);
534 + var hasAuthor = Boolean(author ? author.textContent.trim() : false);
530 535
531 536 if (hasTitle) {
532 537 title.setAttribute("title", title.textContent.trim());
533 538 } else if (title) {
@@ -637,9 +642,8 @@
637 642 array()
638 643 );
639 644 }
640 645
641 -
642 646 if (function_exists('register_block_type')) {
643 647 register_block_type('wpvr/wpvr-block', array(
644 648 'attributes' => array(
645 649 'id' => array(
@@ -673,11 +677,15 @@
673 677 'radius' => array(
674 678 'type' => 'string',
675 679 'default' => '0',
676 680 ),
681 + 'radius_unit' => array(
682 + 'type' => 'string',
683 + 'default' => 'px',
684 + ),
677 685 'border_width' => array(
678 686 'type' => 'string',
679 - 'default' => '0px',
687 + 'default' => '0',
680 688 ),
681 689 'border_style' => array(
682 690 'type' => 'string',
683 691 'default' => 'none',
@@ -683,19 +691,10 @@
683 691 'default' => 'none',
684 692 ),
685 693 'border_color' => array(
686 694 'type' => 'string',
687 - 'default' => 'none',
695 + 'default' => '',
688 696 ),
689 - 'radius_unit' => array(
690 - 'type' => 'string',
691 - 'default' => 'px',
692 - ),
693 - 'content' => array(
694 - 'type' => 'string',
695 - 'source' => 'html',
696 - 'default' => '<script> </script>'
697 - ),
698 697 ),
699 698 'editor_script' => 'wpvr-block',
700 699 'render_callback' => 'wpvr_block_render',
701 700 ));
@@ -705,3137 +704,100 @@
705 704 add_action('init', 'wpvr_block');
706 705
707 706 function wpvr_block_render($attributes)
708 707 {
709 - if (isset($attributes['id'])) {
710 - $id = $attributes['id'];
711 - } else {
712 - $id = 0;
708 + $id = isset($attributes['id']) ? (int) $attributes['id'] : 0;
709 + if (!$id) {
710 + return '<div class="wpvr-no-tour-selected">' . esc_html__('Please select a tour from the block settings panel.', 'wpvr') . '</div>';
713 711 }
714 712
715 - do_action('rex_wpvr_embadded_tour', $id);
716 -
717 - $memberpress_active = defined('MEPR_VERSION');
718 - $rcp_active = is_plugin_active( 'restrict-content-pro/restrict-content-pro.php' );
719 -
720 - if (($memberpress_active || $rcp_active ) && apply_filters('is_wpvr_pro_active', false)) {
721 -
722 - if (!is_user_logged_in()) {
723 - return esc_html__('You need to log in to access this content.', 'wpvr');
724 - }
725 -
726 - $user_id = get_current_user_id();
727 - $allowed_access = false;
728 -
729 - // Get saved membership levels from post meta
730 - $allowed_membership_levels = get_post_meta($id, '_wpvr_allowed_roles_levels', true);
731 - if ( isset($allowed_membership_levels) && 'none' !== $allowed_membership_levels ) {
732 - if (!is_array($allowed_membership_levels)) {
733 - $allowed_membership_levels = array($allowed_membership_levels);
734 - }
735 -
736 - // Check MemberPress Access
737 - if ($memberpress_active) {
738 - $user = new MeprUser($user_id);
739 - $active_memberships = $user->active_product_subscriptions();
740 - if (array_intersect($allowed_membership_levels, $active_memberships) ) {
741 - $allowed_access = true;
742 - }
743 - }
744 -
745 - // Check Restrict Content Pro Access
746 - if ($rcp_active) {
747 - $user_rcp_memberships = rcp_get_customer_memberships($user_id);
748 - foreach ($user_rcp_memberships as $membership) {
749 - $rcp_access_level = array(
750 - $membership->get_object_id()
751 - );
752 - if (array_intersect($allowed_membership_levels, $rcp_access_level) ) {
753 - $allowed_access = true;
754 - break;
755 - }
756 - }
757 - }
758 - } else {
759 - // If no membership restriction is set, allow access by default
760 - $allowed_access = true;
761 - }
762 -
763 - if (!$allowed_access) {
764 - return esc_html__('You do not have access to this content.', 'wpvr');
765 - }
766 - }
767 -
768 -
769 - if (isset($attributes['width'])) {
770 - $width = $attributes['width'];
771 - }
772 - if (isset($attributes['width_unit'])) {
773 - $width_unit = $attributes['width_unit'];
774 - }
775 - if (isset($attributes['height'])) {
776 - $height = $attributes['height'];
777 - }
778 - if (isset($attributes['height_unit'])) {
779 - $height_unit = $attributes['height_unit'];
780 - }
781 - if (isset($attributes['mobile_height'])) {
782 - $mobile_height = $attributes['mobile_height'];
783 - }
784 - if (isset($attributes['mobile_height_unit'])) {
785 - $mobile_height_unit = $attributes['mobile_height_unit'];
786 - }
787 - if (isset($attributes['radius']) && isset($attributes['radius_unit'])) {
788 - $radius = $attributes['radius'] . $attributes['radius_unit'];
789 - }
790 - $border_style = '';
791 - if (isset($attributes['border_width'], $attributes['border_style'], $attributes['border_color'])) {
792 - $border_style = $attributes['border_width'] . 'px ' . $attributes['border_style'] . ' ' . $attributes['border_color'];
793 - }
794 -
795 - if (isset($attributes['className'])) {
796 - $className = $attributes['className'];
713 + $width = isset($attributes['width']) ? $attributes['width'] : '600';
714 + if ('fullwidth' === $width) {
715 + $width_str = 'fullwidth';
797 716 } else {
798 - $className = '';
799 - }
800 - $get_post = get_post_status($id);
801 - if ($get_post !== 'publish') {
802 - return esc_html__('Oops! It seems like this post isn\'t published yet. Stay tuned for updates!', 'wpvr');
803 - }
804 - if (post_password_required($id)) {
805 - return get_the_password_form();
806 - }
807 - $postdata = get_post_meta($id, 'panodata', true);
808 - $postdata = is_array( $postdata ) ? wpvr_get_effective_panodata( $postdata ) : [];
809 - $panoid = 'pano' . $id;
810 - $panoid2 = 'pano2' . $id;
811 - if (!isset($postdata) || empty($postdata)) {
812 - return wp_kses(
813 - __('Oops! It seems that you have not selected any tour yet. Please select a tour from the dropdown of WPVR block.<br>', 'wpvr'),
814 - ['br' => []]
815 - );
816 - }
817 - if (isset($postdata['streetviewdata'])) {
818 - if (empty($width)) {
819 - $width = '600px';
820 - }
821 - if (empty($height)) {
822 - $height = '400px';
823 - }
824 - $streetviewurl = $postdata['streetviewurl'];
825 - $html = '';
826 - $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;">';
827 - $html .= '<iframe src="' . esc_url( $streetviewurl ) . '" frameborder="0" style="border:0; width:100px; height:100%;" allowfullscreen=""></iframe>';
828 - $html .= '</div>';
829 -
830 - return $html;
831 - }
832 - $is_pro = apply_filters('is_wpvr_pro_active', false);
833 -
834 - if (isset($postdata['vidid'])) {
835 - if (empty($width)) {
836 - $width = '600';
837 - }
838 - if (empty($height)) {
839 - $height = '400';
840 - }
841 - $videourl = $postdata['vidurl'];
842 -
843 - $videourl = $postdata['vidurl'];
844 - $autoplay = 'off';
845 - if (isset($postdata['autoplay'])) {
846 - $autoplay = $postdata['autoplay'];
847 - }
848 - $loop = 'off';
849 - if (isset($postdata['loop'])) {
850 - $loop = $postdata['loop'];
851 - }
852 -
853 - if (strpos($videourl, 'youtube') > 0 || strpos($videourl, 'youtu') > 0) {
854 - $explodeid = '';
855 - $explodeid = explode("=", $videourl);
856 - $foundid = '';
857 - $muted = '&mute=1';
858 -
859 - if ($autoplay == 'on') {
860 - $autoplay = '&autoplay=1';
861 - } else {
862 - $autoplay = '';
863 - }
864 -
865 - if ($loop == 'on') {
866 - $loop = '&loop=1';
867 - } else {
868 - $loop = '';
869 - }
870 -
871 - if (strpos($videourl, 'youtu') > 0) {
872 - $explodeid = explode("/", $videourl);
873 - $foundid = $explodeid[3] . '?' . $autoplay . $loop;
874 - $expdata = $explodeid[3];
875 - } else {
876 - $foundid = $explodeid[1] . '?' . $autoplay . $loop;
877 - $expdata = $explodeid[1];
878 - }
879 -
880 - $playlist = '&playlist=' . $expdata;
881 - $playlist = str_replace("?feature=shared", "", $playlist);
882 -
883 -
884 - $html = '';
885 - $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;">';
886 -
887 - // Compatibility check script
888 - $html .= '<script>
889 - function wpvr_check_360_support() {
890 - var support = {
891 - supported: false,
892 - fullySupported: false,
893 - webgl: false,
894 - orientation: false,
895 - gyroscope: false,
896 - touch: false,
897 - browser: "unknown",
898 - isMobile: false,
899 - isIPhone: false,
900 - details: []
901 - };
902 -
903 - support.isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
904 - support.isIPhone = /iPhone/i.test(navigator.userAgent);
905 - if (support.isMobile) support.details.push("Mobile device detected");
906 - if (support.isIPhone) support.details.push("iPhone detected");
907 -
908 - var ua = navigator.userAgent;
909 - if (/^((?!chrome|android).)*safari/i.test(ua)) {
910 - support.browser = "safari";
911 - support.details.push("Safari browser detected");
912 - } else if (ua.indexOf("Chrome") > -1) {
913 - support.browser = "chrome";
914 - support.details.push("Chrome browser detected");
915 - } else if (ua.indexOf("Firefox") > -1) {
916 - support.browser = "firefox";
917 - support.details.push("Firefox browser detected");
918 - } else if (ua.indexOf("MSIE") > -1 || ua.indexOf("Trident") > -1) {
919 - support.browser = "ie";
920 - support.details.push("Internet Explorer detected");
921 - } else if (ua.indexOf("Edge") > -1 || ua.indexOf("Edg") > -1) {
922 - support.browser = "edge";
923 - support.details.push("Edge browser detected");
924 - } else if (ua.indexOf("Opera") > -1 || ua.indexOf("OPR") > -1) {
925 - support.browser = "opera";
926 - support.details.push("Opera browser detected");
927 - }
928 -
929 - try {
930 - var canvas = document.createElement("canvas");
931 - support.webgl = !!(window.WebGLRenderingContext &&
932 - (canvas.getContext("webgl") || canvas.getContext("experimental-webgl")));
933 - support.details.push(support.webgl ? "WebGL supported" : "WebGL not supported");
934 - } catch (e) {
935 - support.webgl = false;
936 - support.details.push("WebGL detection error: " + e.message);
937 - }
938 -
939 - support.orientation = !!(window.DeviceOrientationEvent);
940 - support.details.push(support.orientation ? "Device Orientation API supported" : "Device Orientation API not supported");
941 -
942 - support.gyroscope = !!window.Gyroscope;
943 - support.details.push(support.gyroscope ? "Gyroscope supported" : "Gyroscope not supported");
944 -
945 - support.touch = "ontouchstart" in window || navigator.maxTouchPoints > 0;
946 - support.details.push(support.touch ? "Touch supported" : "Touch not supported");
947 -
948 - support.supported = support.webgl;
949 - support.fullySupported = support.webgl && ((support.isMobile && support.orientation) || !support.isMobile);
950 -
951 - if (support.browser === "safari" && support.isIPhone) {
952 - support.browserWarning = "iPhone has limited support for 360 videos in browser. The experience may not be optimal.";
953 - support.fullySupported = false;
954 - } else if (support.browser === "ie") {
955 - support.browserWarning = "Internet Explorer has limited support for 360 videos.";
956 - support.fullySupported = false;
957 - } else if (!support.supported) {
958 - support.browserWarning = "Your browser does not support 360° videos. Use Chrome or Firefox with WebGL.";
959 - }
960 -
961 - return support;
962 - }
963 - </script>';
964 -
965 - $random_id = 'video-container-' . rand(10000, 99999);
966 - $html .= '<div id="' . $random_id . '-container" style="position:relative; width:100%; height:100%;">';
967 -
968 - // Compatibility check screen (initially hidden for all, will show only for iPhone)
969 - $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 ) . ';">
970 - <div style="margin-bottom:20px; text-align:center;">
971 - <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>
972 - <p style="margin:0;">Checking browser compatibility...</p>
973 - </div>
974 - </div>';
975 -
976 - // Spinner animation
977 - $html .= '<style>@keyframes wpvr-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }</style>';
978 -
979 - // Iframe (initial display set to block)
980 - $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;">';
981 - $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>';
982 - $html .= '</div>';
983 -
984 - // Permission request (mobile only)
985 - $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:' . esc_attr( $radius ) . ';">';
986 - $html .= '<p style="font-size:16px; margin:0 20px 15px;">For the best 360° video experience on mobile</p>';
987 - $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>';
988 - $html .= '</div>';
989 -
990 - // Browser warning
991 - $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:' . esc_attr( $radius ) . ';">';
992 - $html .= '<p id="' . $random_id . '-warning-text" style="font-size:16px; margin:0 20px 5px;"></p>';
993 - $html .= '<p style="font-size:14px; margin:5px 20px 15px;">For the best experience, use Chrome or Firefox.</p>';
994 - $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>';
995 - $html .= '</div>';
996 -
997 - // Main script
998 - $html .= '<script>
999 - document.addEventListener("DOMContentLoaded", function() {
1000 - var supportInfo = wpvr_check_360_support();
1001 - var compatibilityCheck = document.getElementById("' . $random_id . '-compatibility-check");
1002 - var frameContainer = document.getElementById("' . $random_id . '-frame");
1003 - var warning = document.getElementById("' . $random_id . '-browser-warning");
1004 - var warningText = document.getElementById("' . $random_id . '-warning-text");
1005 - var continueBtn = document.getElementById("' . $random_id . '-browser-continue");
1006 -
1007 - // Only show compatibility check and warning for iPhone
1008 - if (supportInfo.isIPhone) {
1009 - // Hide the iframe initially for iPhone
1010 - frameContainer.style.display = "none";
1011 -
1012 - // Show compatibility check for iPhone
1013 - compatibilityCheck.style.display = "flex";
1014 -
1015 - // After delay, hide compatibility check and show warning
1016 - setTimeout(function() {
1017 - compatibilityCheck.style.display = "none";
1018 - warningText.textContent = supportInfo.browserWarning || "Your browser may not fully support 360° videos.";
1019 - warning.style.display = "flex";
1020 -
1021 - continueBtn.addEventListener("click", function() {
1022 - warning.style.display = "none";
1023 -
1024 - if (supportInfo.fullySupported && supportInfo.isMobile) {
1025 - document.getElementById("' . $random_id . '-permission-request").style.display = "flex";
1026 - document.getElementById("' . $random_id . '-permission-button").addEventListener("click", function() {
1027 - requestDevicePermissions();
1028 - });
1029 - } else {
1030 - showVideo();
1031 - }
1032 - });
1033 - }, 1000);
1034 - } else {
1035 - // For non-iPhone devices, directly initialize the player
1036 - initializeYouTubePlayer();
1037 - }
1038 -
1039 - function requestDevicePermissions() {
1040 - try {
1041 - if (typeof DeviceOrientationEvent !== "undefined" &&
1042 - typeof DeviceOrientationEvent.requestPermission === "function") {
1043 - DeviceOrientationEvent.requestPermission().then(function(response) {
1044 - if (response === "granted") {
1045 - if (typeof DeviceMotionEvent !== "undefined" &&
1046 - typeof DeviceMotionEvent.requestPermission === "function") {
1047 - DeviceMotionEvent.requestPermission().then(showVideo).catch(showVideo);
1048 - } else {
1049 - showVideo();
1050 - }
1051 - } else {
1052 - showVideo();
1053 - }
1054 - }).catch(showVideo);
1055 - } else {
1056 - showVideo();
1057 - }
1058 - } catch (e) {
1059 - showVideo();
1060 - }
1061 - }
1062 -
1063 - function showVideo() {
1064 - document.getElementById("' . $random_id . '-permission-request").style.display = "none";
1065 - frameContainer.style.display = "block";
1066 - initializeYouTubePlayer();
1067 - }
1068 -
1069 - function initializeYouTubePlayer() {
1070 - if (window.YT) {
1071 - initPlayer();
1072 - } else {
1073 - var tag = document.createElement("script");
1074 - tag.src = "https://www.youtube.com/iframe_api";
1075 - var firstScriptTag = document.getElementsByTagName("script")[0];
1076 - firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
1077 - window.onYouTubeIframeAPIReady = initPlayer;
1078 - }
1079 -
1080 - function initPlayer() {
1081 - new YT.Player("' . $random_id . '-iframe", {
1082 - events: {
1083 - "onReady": function(event) {}
1084 - }
1085 - });
1086 - }
1087 - }
1088 - });
1089 - </script>';
1090 -
1091 - $html .= '</div>'; // Close container
1092 - $html .= '</div>'; // Close outer wrapper
717 + $width_unit = isset($attributes['width_unit']) ? $attributes['width_unit'] : 'px';
718 + if (preg_match('/(px|%|vw|vh)$/', (string) $width)) {
719 + $width_str = $width;
1093 720 } else {
1094 - $html = '';
1095 - $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;">';
1096 - $html .= '<div style="width:100%; height:100%; border-radius: ' . esc_attr($radius) . ';">' . wp_kses(
1097 - $postdata['panoviddata'],
1098 - array(
1099 - 'video' => array(
1100 - 'id' => array(),
1101 - 'class' => array(),
1102 - 'src' => array(),
1103 - 'controls' => array(),
1104 - 'autoplay' => array(),
1105 - 'loop' => array(),
1106 - 'muted' => array(),
1107 - 'poster' => array(),
1108 - 'preload' => array(),
1109 - 'width' => array(),
1110 - 'height' => array(),
1111 - 'style' => array(),
1112 - 'playsinline' => array(),
1113 - 'crossorigin' => array(),
1114 - 'data-*' => true,
1115 - ),
1116 - 'source' => array(
1117 - 'src' => array(),
1118 - 'type' => array(),
1119 - ),
1120 - 'track' => array(
1121 - 'kind' => array(),
1122 - 'src' => array(),
1123 - 'srclang' => array(),
1124 - 'label' => array(),
1125 - 'default' => array(),
1126 - ),
1127 - 'div' => array(
1128 - 'id' => array(),
1129 - 'class' => array(),
1130 - 'style' => array(),
1131 - 'data-*' => true,
1132 - ),
1133 - 'span' => array(
1134 - 'id' => array(),
1135 - 'class' => array(),
1136 - 'style' => array(),
1137 - ),
1138 - 'button' => array(
1139 - 'id' => array(),
1140 - 'class' => array(),
1141 - 'style' => array(),
1142 - 'type' => array(),
1143 - 'title' => array(),
1144 - ),
1145 - )
1146 - ) . '</div>';
1147 -
1148 - $html .= '
1149 - <style>
1150 - .video-js {
1151 - border-radius:' . esc_attr($radius) . ';
1152 - }
1153 - .video-js canvas{
1154 - border-radius:' . esc_attr($radius) . ';
1155 - }
1156 - #pano' . esc_attr($id) . ' .vjs-poster {
1157 - border-radius: ' . esc_attr($radius) . ';
1158 - }
1159 - </style>
1160 -
1161 - ';
1162 -
1163 - // $html .= '<script>';
1164 - // $html .= 'videojs(' . $postdata['vidid'] . ', {';
1165 - // $html .= 'plugins: {';
1166 - // $html .= 'pannellum: {}';
1167 - // $html .= '}';
1168 - // $html .= '});';
1169 - // $html .= '</script>';
1170 - $html .= '</div>';
1171 -
1172 - //video js vr setup //
1173 - $html .= '<script>';
1174 - $html .= '
1175 - (function (window, videojs) {
1176 - var player = window.player = videojs("' . $postdata['vidid'] . '");
1177 - player.mediainfo = player.mediainfo || {};
1178 - player.mediainfo.projection = "equirectangular";
1179 -
1180 - // AUTO is the default and looks at mediainfo
1181 - var vr = window.vr = player.vr({ projection: "AUTO", debug: true, forceCardboard: false, antialias: false });
1182 - }(window, window.videojs));
1183 -
1184 - ';
1185 - $html .= '</script>';
1186 - //video js vr end //
721 + $width_str = $width . $width_unit;
1187 722 }
1188 - return $html;
1189 723 }
1190 724
1191 - $control = false;
1192 - if (isset($postdata['showControls'])) {
1193 - $control = $postdata['showControls'];
725 + $height = isset($attributes['height']) ? $attributes['height'] : '400';
726 + $height_unit = isset($attributes['height_unit']) ? $attributes['height_unit'] : 'px';
727 + if (!preg_match('/(px|%|vw|vh)$/', (string) $height)) {
728 + $height .= $height_unit;
1194 729 }
1195 730
1196 - if ($control) {
1197 - if (isset($postdata['customcontrol'])) {
1198 - $custom_control = wpvr_parse_custom_control($postdata['customcontrol']);
1199 - $custom_control = wp_parse_args($custom_control, array(
1200 - 'panupSwitch' => 'off',
1201 - 'panDownSwitch' => 'off',
1202 - 'panLeftSwitch' => 'off',
1203 - 'panRightSwitch' => 'off',
1204 - 'panZoomInSwitch' => 'off',
1205 - 'panZoomOutSwitch' => 'off',
1206 - 'panFullscreenSwitch' => 'off',
1207 - 'gyroscopeSwitch' => 'off',
1208 - 'backToHomeSwitch' => 'off',
1209 - 'explainerSwitch' => 'off',
1210 - ));
1211 - $gyro_enabled = isset($postdata['gyro']) && in_array($postdata['gyro'], array(true, 1, '1', 'on'), true);
1212 - $custom_control['gyroSwitch'] = $gyro_enabled ? 'on' : 'off';
1213 - $gyro_button_enabled = wpvr_isMobileDevice() && $custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on";
1214 - 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" || $gyro_button_enabled || $custom_control['backToHomeSwitch'] == "on") {
1215 - $control = false;
1216 - }
1217 - }
731 + $mobile_height = isset($attributes['mobile_height']) ? $attributes['mobile_height'] : '300';
732 + $mobile_height_unit = isset($attributes['mobile_height_unit']) ? $attributes['mobile_height_unit'] : 'px';
733 + if (!preg_match('/(px|%|vw|vh)$/', (string) $mobile_height)) {
734 + $mobile_height .= $mobile_height_unit;
1218 735 }
1219 736
1220 - $floor_plan_enable = 'off';
1221 - $floor_plan_image = '';
1222 - if (isset($postdata['floor_plan_tour_enabler']) && $postdata['floor_plan_tour_enabler'] == 'on') {
1223 - $floor_plan_enable = $postdata['floor_plan_tour_enabler'];
1224 - if (isset($postdata['floor_plan_attachment_url']) && !empty($postdata['floor_plan_attachment_url'])) {
1225 - $floor_plan_image = $postdata['floor_plan_attachment_url'];
1226 - }
737 + $radius = isset($attributes['radius']) ? $attributes['radius'] : '0';
738 + $radius_unit = isset($attributes['radius_unit']) ? $attributes['radius_unit'] : 'px';
739 + if (!preg_match('/(px|%|vw|vh)$/', (string) $radius)) {
740 + $radius .= $radius_unit;
1227 741 }
1228 742
1229 - $vrgallery = false;
1230 - if (isset($postdata['vrgallery'])) {
1231 - $vrgallery = $postdata['vrgallery'];
1232 - }
743 + $shortcode = sprintf(
744 + '[wpvr id="%d" width="%s" height="%s" mobile_height="%s" radius="%s"]',
745 + $id,
746 + esc_attr($width_str),
747 + esc_attr($height),
748 + esc_attr($mobile_height),
749 + esc_attr($radius)
750 + );
1233 751
1234 - $vrgallery_title = false;
1235 - if (isset($postdata['vrgallery_title'])) {
1236 - $vrgallery_title = $postdata['vrgallery_title'];
1237 - }
752 + $output = do_shortcode($shortcode);
1238 753
1239 - $vrgallery_display = false;
1240 - if (isset($postdata['vrgallery_display'])) {
1241 - $vrgallery_display = $postdata['vrgallery_display'];
754 + // Extract any <script> tags so they are not corrupted by wptexturize (which runs at priority 10 on the_content, after do_blocks at priority 9).
755 + $scripts = '';
756 + if (preg_match_all('/<script\b[^>]*>[\s\S]*?<\/script>/i', $output, $matches)) {
757 + $scripts = implode("\n", $matches[0]);
758 + $output = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $output);
1242 759 }
1243 - $vrgallery_icon_size = false;
1244 - if (isset($postdata['vrgallery_icon_size'])) {
1245 - $vrgallery_icon_size = $postdata['vrgallery_icon_size'];
1246 - }
1247 760
1248 - $gyro = false;
1249 - $gyro_orientation = false;
1250 - if (isset($postdata['gyro'])) {
1251 - $gyro = in_array($postdata['gyro'], array(true, 1, '1', 'on'), true);
1252 - if ($gyro && isset($postdata['deviceorientationcontrol'])) {
1253 - $gyro_orientation = in_array($postdata['deviceorientationcontrol'], array(true, 1, '1', 'on'), true);
1254 - }
1255 - }
1256 -
1257 - $compass = false;
1258 - $audio_right = "5px";
1259 - if (isset($postdata['compass'])) {
1260 - $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
1261 - if ($compass) {
1262 - $audio_right = "60px";
1263 - }
1264 - }
1265 - $floor_map_right = "25px";
1266 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
1267 - $floor_map_right = "85px";
1268 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
1269 - $floor_map_right = "55px";
1270 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
1271 - $floor_map_right = "25px";
1272 - }
1273 -
1274 - //===explainer handle===//
1275 -
1276 - //===explainer handle===//
1277 - $explainer_right = "10px";
1278 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1279 - $explainer_right = "130px";
1280 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on' && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1281 - $explainer_right = "100px";
1282 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1283 - $explainer_right = "55px";
1284 - } elseif ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
1285 - $explainer_right = "80px";
1286 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
1287 - $explainer_right = "55px";
1288 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
1289 - $explainer_right = "30px";
1290 - } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
1291 - $explainer_right = "70px";
1292 - }
1293 - $enable_cardboard = '';
1294 - $is_cardboard = get_option('wpvr_cardboard_disable');
1295 - if (wpvr_isMobileDevice() && $is_cardboard == 'true') {
1296 - $enable_cardboard = 'enable-cardboard';
1297 - $audio_right = "73px";
1298 - if (isset($postdata['compass'])) {
1299 - $compass = $postdata['compass'] == 'on' || $postdata['compass'] != null ? true : false;
1300 - if ($compass) {
1301 - $audio_right = "130px";
1302 - }
1303 - }
1304 -
1305 - $floor_map_right = "60px";
1306 - if ((isset($postdata['compass']) && $postdata['compass'] == 'on') && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
1307 - $floor_map_right = "150px";
1308 - } elseif (isset($postdata['compass']) && $postdata['compass'] == 'on') {
1309 - $floor_map_right = "120px";
1310 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
1311 - $floor_map_right = "90px";
1312 - }
1313 -
1314 - //===explainer handle===//
1315 -
1316 - $explainer_right = "65px";
1317 -
1318 - if ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on')) {
1319 - $explainer_right = "150px";
1320 - } elseif ((isset($postdata['compass']) && $postdata['compass'] == true) && (isset($postdata['bg_music']) && $postdata['bg_music'] == 'on') && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1321 - $explainer_right = "180px";
1322 - } elseif (isset($postdata['compass']) && $postdata['compass'] == true && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1323 - $explainer_right = "150px";
1324 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on" && ($floor_plan_enable == 'on' && !empty($floor_plan_image))) {
1325 - $explainer_right = "120px";
1326 - } elseif (isset($postdata['compass']) && $postdata['compass'] == true) {
1327 - $explainer_right = "130px";
1328 - } elseif (isset($postdata['bg_music']) && $postdata['bg_music'] == "on") {
1329 - $explainer_right = "90px";
1330 - } elseif ($floor_plan_enable == 'on' && !empty($floor_plan_image)) {
1331 - $explainer_right = "90px";
1332 - }
1333 - }
1334 -
1335 - //===explainer handle===//
1336 -
1337 - $mouseZoom = true;
1338 - if (isset($postdata['mouseZoom'])) {
1339 - if ($postdata['mouseZoom'] == "off") {
1340 - $mouseZoom = false;
761 + if (!empty($scripts)) {
762 + if (wp_doing_ajax() || (defined('REST_REQUEST') && REST_REQUEST)) {
763 + $output .= "\n" . $scripts;
1341 764 } else {
1342 - $mouseZoom = true;
765 + add_action('wp_footer', function() use ($scripts) {
766 + echo $scripts; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
767 + }, 20);
1343 768 }
1344 769 }
1345 770
1346 - $draggable = true;
1347 - if (isset($postdata['draggable'])) {
1348 - $draggable = $postdata['draggable'] == 'on' || $postdata['draggable'] != null ? true : false;
1349 - if ($postdata['draggable'] === 'off') {
1350 - $draggable = false;
1351 - }
771 + $border_css = '';
772 + if (!empty($attributes['border_width']) && !empty($attributes['border_style']) && 'none' !== $attributes['border_style']) {
773 + $border_width = rtrim((string) $attributes['border_width'], 'px') . 'px';
774 + $border_color = !empty($attributes['border_color']) ? $attributes['border_color'] : 'transparent';
775 + $border_css = 'border: ' . esc_attr($border_width . ' ' . $attributes['border_style'] . ' ' . $border_color) . ';';
1352 776 }
1353 - $diskeyboard = false;
1354 - if (isset($postdata['diskeyboard'])) {
1355 - $diskeyboard = $postdata['diskeyboard'] == 'off' || $postdata['diskeyboard'] == null ? false : true;
1356 - }
1357 777
1358 - $keyboardzoom = true;
1359 - if (isset($postdata['keyboardzoom'])) {
1360 - $keyboardzoom = $postdata['keyboardzoom'];
1361 - }
778 + $class_name = !empty($attributes['className']) ? ' ' . esc_attr($attributes['className']) : '';
1362 779
1363 - $autoload = false;
1364 -
1365 - if (isset($postdata['autoLoad'])) {
1366 - $autoload = $postdata['autoLoad'];
780 + if ('' !== $border_css || '' !== $class_name) {
781 + $wrapper_style = $border_css ? ' style="' . $border_css . ' display: inline-block; width: 100%; max-width: ' . esc_attr('fullwidth' === $width_str ? '100%' : $width_str) . ';"' : '';
782 + return '<div class="wpvr-block-wrapper' . $class_name . '"' . $wrapper_style . '>' . $output . '</div>';
1367 783 }
1368 784
1369 - $default_scene = '';
1370 - if (isset($postdata['defaultscene'])) {
1371 - $default_scene = $postdata['defaultscene'];
1372 - }
1373 -
1374 - $preview = '';
1375 - if (isset($postdata['preview'])) {
1376 - $preview = $postdata['preview'];
1377 - }
1378 -
1379 - $autorotation = '';
1380 - if (isset($postdata["autoRotate"])) {
1381 - $autorotation = $postdata["autoRotate"];
1382 - }
1383 - $autorotationinactivedelay = '';
1384 - if (isset($postdata["autoRotateInactivityDelay"])) {
1385 - $autorotationinactivedelay = $postdata["autoRotateInactivityDelay"];
1386 - }
1387 - $autorotationstopdelay = '';
1388 - if (isset($postdata["autoRotateStopDelay"])) {
1389 - $autorotationstopdelay = $postdata["autoRotateStopDelay"];
1390 - }
1391 -
1392 - $scene_fade_duration = '';
1393 - if (isset($postdata['scenefadeduration'])) {
1394 - $scene_fade_duration = $postdata['scenefadeduration'];
1395 - }
1396 -
1397 - $panodata = array();
1398 - if (isset($postdata['panodata'])) {
1399 - $panodata = $postdata['panodata'];
1400 - }
1401 -
1402 - $show_scene_info = ( $postdata['scene-info-enabled'] ?? 'on' ) !== 'off';
1403 - $tour_layout = is_array( $postdata['tourLayout'] ?? null )
1404 - ? ( $postdata['tourLayout']['layout'] ?? 'default' )
1405 - : ( $postdata['tourLayout'] ?? 'default' );
1406 - $is_classic_layout = 'layout1' !== $tour_layout;
1407 -
1408 - $default_zoom_global = 100;
1409 - if (isset($postdata['hfov']) && $postdata['hfov'] != '') {
1410 - $default_zoom_global = $postdata['hfov'];
1411 - }
1412 -
1413 - $min_zoom_global = 50;
1414 - if (isset($postdata['minHfov']) && $postdata['minHfov'] != '') {
1415 - $min_zoom_global = $postdata['minHfov'];
1416 - }
1417 -
1418 - $max_zoom_global = 120;
1419 - if (isset($postdata['maxHfov']) && $postdata['maxHfov'] != '') {
1420 - $max_zoom_global = $postdata['maxHfov'];
1421 - }
1422 -
1423 - $hotspoticoncolor = '#00b4ff';
1424 - $hotspotblink = 'on';
1425 - $default_data = array();
1426 - $default_data = array('firstScene' => $default_scene, 'sceneFadeDuration' => $scene_fade_duration, 'hfov' => $default_zoom_global, 'maxHfov' => $max_zoom_global, 'minHfov' => $min_zoom_global);
1427 - $scene_data = array();
1428 - if (is_array($panodata) && isset($panodata['scene-list'])) {
1429 - if (!empty($panodata['scene-list'])) {
1430 - foreach ($panodata['scene-list'] as $panoscenes) {
1431 - $scene_ititle = '';
1432 - if (isset($panoscenes["scene-ititle"])) {
1433 - $scene_ititle = esc_html($panoscenes["scene-ititle"]);
1434 - }
1435 -
1436 - $scene_author = '';
1437 - if (isset($panoscenes["scene-author"])) {
1438 - $scene_author = esc_html($panoscenes["scene-author"]);
1439 - }
1440 -
1441 - $scene_author_url = '';
1442 - if (isset($panoscenes["scene-author-url"])) {
1443 - $scene_author_url = sanitize_text_field($panoscenes["scene-author-url"]);
1444 - }
1445 -
1446 - $scene_vaov = 180;
1447 - if (isset($panoscenes["scene-vaov"])) {
1448 - $scene_vaov = (float)$panoscenes["scene-vaov"];
1449 - }
1450 -
1451 - $scene_haov = 360;
1452 - if (isset($panoscenes["scene-haov"])) {
1453 - $scene_haov = (float)$panoscenes["scene-haov"];
1454 - }
1455 -
1456 - $scene_vertical_offset = 0;
1457 - if (isset($panoscenes["scene-vertical-offset"])) {
1458 - $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
1459 - }
1460 -
1461 - $default_scene_pitch = null;
1462 - if (isset($panoscenes["scene-pitch"])) {
1463 - $default_scene_pitch = (float)$panoscenes["scene-pitch"];
1464 - }
1465 -
1466 - $default_scene_yaw = null;
1467 - if (isset($panoscenes["scene-yaw"])) {
1468 - $default_scene_yaw = (float)$panoscenes["scene-yaw"];
1469 - }
1470 -
1471 - $scene_max_pitch = '';
1472 - if (isset($panoscenes["scene-maxpitch"])) {
1473 - $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
1474 - }
1475 -
1476 -
1477 - $scene_min_pitch = '';
1478 - if (isset($panoscenes["scene-minpitch"])) {
1479 - $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
1480 - }
1481 -
1482 -
1483 - $scene_max_yaw = '';
1484 - if (isset($panoscenes["scene-maxyaw"])) {
1485 - $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
1486 - }
1487 -
1488 -
1489 - $scene_min_yaw = '';
1490 - if (isset($panoscenes["scene-minyaw"])) {
1491 - $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
1492 - }
1493 -
1494 - $default_zoom = 100;
1495 - if (isset($panoscenes["scene-zoom"]) && $panoscenes["scene-zoom"] != '') {
1496 - $default_zoom = (int)$panoscenes["scene-zoom"];
1497 - } else {
1498 - if ($default_zoom_global != '') {
1499 - $default_zoom = (int)$default_zoom_global;
1500 - }
1501 - }
1502 -
1503 -
1504 - $max_zoom = 120;
1505 - if (isset($panoscenes["scene-maxzoom"]) && $panoscenes["scene-maxzoom"] != '') {
1506 - $max_zoom = (int)$panoscenes["scene-maxzoom"];
1507 - } else {
1508 - if ($max_zoom_global != '') {
1509 - $max_zoom = (int)$max_zoom_global;
1510 - }
1511 - }
1512 -
1513 - $min_zoom = 120;
1514 - if (isset($panoscenes["scene-minzoom"]) && $panoscenes["scene-minzoom"] != '') {
1515 - $min_zoom = (int)$panoscenes["scene-minzoom"];
1516 - } else {
1517 - if ($min_zoom_global != '') {
1518 - $min_zoom = (int)$min_zoom_global;
1519 - }
1520 - }
1521 -
1522 - $hotspot_datas = array();
1523 - if (isset($panoscenes['hotspot-list'])) {
1524 - $hotspot_datas = $panoscenes['hotspot-list'];
1525 - }
1526 -
1527 - $hotspots = array();
1528 -
1529 - foreach ($hotspot_datas as $hotspot_data) {
1530 - $status = get_option('wpvr_edd_license_status');
1531 - if ($status !== false && $status == 'valid') {
1532 -
1533 - if (isset($hotspot_data["hotspot-customclass-pro"]) && $hotspot_data["hotspot-customclass-pro"] != 'none') {
1534 - $hotspot_data['hotspot-customclass'] = $hotspot_data["hotspot-customclass-pro"] . ' custom-' . $id . '-' . $panoscenes['scene-id'] . '-' . $hotspot_data['hotspot-title'];
1535 - }
1536 - if (isset($hotspot_data['hotspot-blink'])) {
1537 - $hotspotblink = $hotspot_data['hotspot-blink'];
1538 - }
1539 - }
1540 - $hotspot_scene_pitch = '';
1541 - if (isset($hotspot_data["hotspot-scene-pitch"])) {
1542 - $hotspot_scene_pitch = $hotspot_data["hotspot-scene-pitch"];
1543 - }
1544 - $hotspot_scene_yaw = '';
1545 - if (isset($hotspot_data["hotspot-scene-yaw"])) {
1546 - $hotspot_scene_yaw = $hotspot_data["hotspot-scene-yaw"];
1547 - }
1548 -
1549 - $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"];
1550 - $hotspot_content = '';
1551 -
1552 - ob_start();
1553 - do_action('wpvr_hotspot_content', $hotspot_data);
1554 - $hotspot_content = ob_get_clean();
1555 -
1556 - if (!$hotspot_content) {
1557 - $hotspot_content = $hotspot_data["hotspot-content"];
1558 - }
1559 -
1560 - if (isset($hotspot_data["wpvr_url_open"][0])) {
1561 - $wpvr_url_open = $hotspot_data["wpvr_url_open"][0];
1562 - } else {
1563 - $wpvr_url_open = "off";
1564 - }
1565 - $on_hover_content = preg_replace_callback(
1566 - '/<p>\s*(<img[^>]*>)\s*<br>\s*<\/p>/i',
1567 - function ($matches) {
1568 - return $matches[1];
1569 - },
1570 - $hotspot_data['hotspot-hover'] ?? ''
1571 - );
1572 -
1573 - if('fluent_form' !== $hotspot_data["hotspot-type"]){
1574 - $on_hover_content = sanitize_content_preserve_styles($on_hover_content ?? '');
1575 - $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1576 - $on_click_content = sanitize_content_preserve_styles($on_click_content ?? '');
1577 - }else{
1578 - $on_hover_content = $on_hover_content ?? '';
1579 - $on_click_content = $hotspot_content ?? '';
1580 - }
1581 -
1582 -
1583 - // Shape is independent of the optional custom icon in the
1584 - // new editor, so it must always be included in the public
1585 - // hotspot configuration.
1586 - $hotspot_shape = isset( $hotspot_data['hotspot-shape'] )
1587 - && in_array( $hotspot_data['hotspot-shape'], [ 'round', 'square', 'hexagon' ], true )
1588 - ? $hotspot_data['hotspot-shape']
1589 - : 'round';
1590 -
1591 - $hotspot_data_for_on_click=[];
1592 - if( ('info' === $hotspot_type || 'fluent_form' === $hotspot_data["hotspot-type"] ) && !empty($on_click_content)){
1593 - $hotspot_data_for_on_click = [
1594 - 'on_click_content' => $on_click_content,
1595 - 'tour_id' => $id,
1596 - 'scene_id' => $panoscenes['scene-id'],
1597 - 'hotspot_id' => sanitize_html_class($hotspot_data['hotspot-title']),
1598 - ];
1599 - } elseif('info' === $hotspot_type && !empty($hotspot_data["hotspot-url"])){
1600 - $hotspot_data_for_on_click = [
1601 - 'on_click_content' => '',
1602 - 'tour_id' => $id,
1603 - 'scene_id' => $panoscenes['scene-id'],
1604 - 'hotspot_id' => sanitize_html_class($hotspot_data['hotspot-title']),
1605 - ];
1606 - }
1607 -
1608 - $hotspot_info = array(
1609 - 'text' => esc_html(sanitize_text_field($hotspot_data['hotspot-title'])),
1610 - 'pitch' => $hotspot_data['hotspot-pitch'],
1611 - 'yaw' => $hotspot_data['hotspot-yaw'],
1612 - 'type' => $hotspot_type,
1613 - 'cssClass' => $hotspot_data['hotspot-customclass'],
1614 - 'URL' => $hotspot_data['hotspot-url'],
1615 - "wpvr_url_open" => $wpvr_url_open,
1616 - "clickHandlerArgs" => $hotspot_data_for_on_click,
1617 - 'createTooltipArgs' => !empty(trim($on_hover_content)) ? trim($on_hover_content) : '',
1618 - "sceneId" => $hotspot_data["hotspot-scene"],
1619 - "targetPitch" => (float)$hotspot_scene_pitch,
1620 - "targetYaw" => (float)$hotspot_scene_yaw,
1621 - 'hotspot_type' => $hotspot_data['hotspot-type'],
1622 - 'hotspot_shape' => $hotspot_shape,
1623 - );
1624 -
1625 - $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1626 -
1627 - if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1628 - unset($hotspot_info["cssClass"]);
1629 - }
1630 - if (empty($hotspot_data["hotspot-scene"])) {
1631 - unset($hotspot_info['targetPitch']);
1632 - unset($hotspot_info['targetYaw']);
1633 - }
1634 - array_push($hotspots, $hotspot_info);
1635 - }
1636 -
1637 - $device_scene = $panoscenes['scene-attachment-url'];
1638 - $mobile_media_resize = get_option('mobile_media_resize');
1639 - $file_accessible = ini_get('allow_url_fopen');
1640 - if ($mobile_media_resize == "true" && $device_scene) {
1641 - if ($file_accessible == "1") {
1642 - $image_info = getimagesize($device_scene);
1643 - if ($image_info && $image_info[0] > 4096) {
1644 - $src_to_id_for_mobile = '';
1645 - $src_to_id_for_desktop = '';
1646 - if (wpvr_isMobileDevice()) {
1647 - $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1648 - if ($src_to_id_for_mobile) {
1649 - $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1650 - if ($mobile_scene[3]) {
1651 - $device_scene = $mobile_scene[0];
1652 - }
1653 - }
1654 - } else {
1655 - $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1656 - if ($src_to_id_for_desktop) {
1657 - $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1658 - if ($desktop_scene && $desktop_scene[0]) {
1659 - $device_scene = $desktop_scene[0];
1660 - }
1661 - }
1662 - }
1663 - }
1664 - }
1665 - }
1666 -
1667 - $scene_info = array();
1668 -
1669 - if ($panoscenes["scene-type"] == 'cubemap') {
1670 - $pano_type = 'cubemap';
1671 - $pano_attachment = array(
1672 - $panoscenes["scene-attachment-url-face0"],
1673 - $panoscenes["scene-attachment-url-face1"],
1674 - $panoscenes["scene-attachment-url-face2"],
1675 - $panoscenes["scene-attachment-url-face3"],
1676 - $panoscenes["scene-attachment-url-face4"],
1677 - $panoscenes["scene-attachment-url-face5"]
1678 - );
1679 -
1680 - $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);
1681 - } else {
1682 - $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);
1683 - }
1684 -
1685 -
1686 -
1687 - if (isset($panoscenes["ptyscene"])) {
1688 - if ($panoscenes["ptyscene"] == "off") {
1689 - unset($scene_info['pitch']);
1690 - unset($scene_info['yaw']);
1691 - }
1692 - }
1693 -
1694 - if (!$show_scene_info || empty($panoscenes["scene-ititle"])) {
1695 - unset($scene_info['title']);
1696 - }
1697 - if (!$show_scene_info || empty($panoscenes["scene-author"])) {
1698 - unset($scene_info['author']);
1699 - }
1700 - if (!$show_scene_info || empty($panoscenes["scene-author-url"])) {
1701 - unset($scene_info['authorURL']);
1702 - }
1703 -
1704 - if (empty($scene_vaov)) {
1705 - unset($scene_info['vaov']);
1706 - }
1707 -
1708 - if (empty($scene_haov)) {
1709 - unset($scene_info['haov']);
1710 - }
1711 -
1712 - if (empty($scene_vertical_offset)) {
1713 - unset($scene_info['vOffset']);
1714 - }
1715 -
1716 - if (isset($panoscenes["cvgscene"])) {
1717 - if ($panoscenes["cvgscene"] == "off") {
1718 - unset($scene_info['maxPitch']);
1719 - unset($scene_info['minPitch']);
1720 - }
1721 - }
1722 - if (empty($panoscenes["scene-maxpitch"])) {
1723 - unset($scene_info['maxPitch']);
1724 - }
1725 -
1726 - if (empty($panoscenes["scene-minpitch"])) {
1727 - unset($scene_info['minPitch']);
1728 - }
1729 -
1730 - if (isset($panoscenes["chgscene"])) {
1731 - if ($panoscenes["chgscene"] == "off") {
1732 - unset($scene_info['maxYaw']);
1733 - unset($scene_info['minYaw']);
1734 - }
1735 - }
1736 - if (empty($panoscenes["scene-maxyaw"])) {
1737 - unset($scene_info['maxYaw']);
1738 - }
1739 -
1740 - if (empty($panoscenes["scene-minyaw"])) {
1741 - unset($scene_info['minYaw']);
1742 - }
1743 -
1744 - // if (isset($panoscenes["czscene"])) {
1745 - // if ($panoscenes["czscene"] == "off") {
1746 - // unset($scene_info['hfov']);
1747 - // unset($scene_info['maxHfov']);
1748 - // unset($scene_info['minHfov']);
1749 - // }
1750 - // }
1751 -
1752 - $scene_array = array();
1753 - $scene_array = array(
1754 - $panoscenes['scene-id'] => $scene_info
1755 - );
1756 -
1757 - $scene_data[$panoscenes['scene-id']] = $scene_info;
1758 - }
1759 - }
1760 - }
1761 - $pano_id_array = array();
1762 - $pano_id_array = array('panoid' => $panoid);
1763 - $pano_response = array();
1764 - $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);
1765 - if (empty($autorotation)) {
1766 - unset($pano_response['autoRotate']);
1767 - unset($pano_response['autoRotateInactivityDelay']);
1768 - unset($pano_response['autoRotateStopDelay']);
1769 - }
1770 - if (empty($autorotationinactivedelay)) {
1771 - unset($pano_response['autoRotateInactivityDelay']);
1772 - }
1773 - if (empty($autorotationstopdelay)) {
1774 - unset($pano_response['autoRotateStopDelay']);
1775 - }
1776 -
1777 - $response = array();
1778 - $response = array($pano_id_array, $pano_response);
1779 - if (!empty($response)) {
1780 - $response = json_encode($response);
1781 - }
1782 - if (empty($width)) {
1783 - $width = '600';
1784 - }
1785 - if (empty($height)) {
1786 - $height = '400';
1787 - }
1788 - if ('fullwidth' == $width) {
1789 - $width = "100%";
1790 - }
1791 -
1792 - $foreground_color = '#fff';
1793 - $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1794 - $rgb = wpvr_HTMLToRGB($hotspoticoncolor);
1795 - $hsl = wpvr_RGBToHSL($rgb);
1796 - if ($hsl->lightness > 200) {
1797 - $foreground_color = '#000000';
1798 - } else {
1799 - $foreground_color = '#fff';
1800 - }
1801 -
1802 - $class = 'myclass';
1803 - $html = 'test';
1804 - $html = '';
1805 - $html .= '<style>';
1806 - if ($width == 'embed') {
1807 - $html .= 'body{
1808 - overflow: hidden;
1809 - }';
1810 - }
1811 - $status = get_option('wpvr_edd_license_status');
1812 - if ($status !== false && $status == 'valid') {
1813 - if (isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on') {
1814 - $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
1815 - }
1816 - }
1817 - if ($status !== false && $status == 'valid') {
1818 - if (is_array($panodata) && isset($panodata['scene-list'])) {
1819 - foreach ($panodata['scene-list'] as $panoscenes) {
1820 -
1821 - foreach ($panoscenes['hotspot-list'] as $hotspot) {
1822 - if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1823 - $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1824 - } else {
1825 - $hotspoticoncolor = "#00b4ff";
1826 - }
1827 - $hotspot_border = '';
1828 - if(isset($hotspot['hotspot-border']) && $hotspot['hotspot-border'] == 'on'){
1829 - $border_width = $hotspot['hotspot-border-width'];
1830 - $border_color = $hotspot['hotspot-border-color'];
1831 - $border_style = $hotspot['hotspot-border-style'];
1832 -
1833 - $hotspot_border = 'border: '.$border_width.'px '.$border_style.' '.$border_color.';';
1834 - }
1835 - $hotspot_background_color = 'background-color: ' . $hotspoticoncolor . ';';
1836 - $hotspot_animation = ' animation: icon-pulse' . $panoid . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1837 - '. $hotspot_border.'';
1838 -
1839 -
1840 - $pulse_color = wpvr_hex2rgb($hotspoticoncolor);
1841 - if (isset($hotspot["hotspot-customclass-pro"]) && $hotspot["hotspot-customclass-pro"] != 'none') {
1842 - $border_radius = ' border-radius: 100%;';
1843 - $hotspot_shape = isset($hotspot["hotspot-shape"]) ? $hotspot["hotspot-shape"] : 'round';
1844 - if($hotspot_shape === 'square'){
1845 - $border_radius = '';
1846 - }
1847 - if ($hotspot_shape === 'hexagon') {
1848 - $border_radius = '';
1849 - $hotspot_background_color = 'background-color: transparent;';
1850 - $hotspot_animation = '';
1851 - }
1852 -
1853 - if(isset($hotspot['hotspot-custom-icon-color-value']) && !empty($hotspot['hotspot-custom-icon-color-value'])){
1854 - $foreground_color = $hotspot['hotspot-custom-icon-color-value'];
1855 - }
1856 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1857 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1858 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1859 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1860 - #' . esc_attr( $panoid ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' {
1861 - display: block !important;
1862 - '.$hotspot_background_color.'
1863 - color: ' . $foreground_color . ';
1864 - '.$border_radius.'
1865 - width: 30px;
1866 - height: 30px;
1867 - font-size: 16px;
1868 - line-height: 30px;
1869 - '.$hotspot_animation.'
1870 - }';
1871 - if($hotspot_shape === 'hexagon'){
1872 -
1873 - $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' .hexagon-wrapper svg path {
1874 - fill: ' . $hotspoticoncolor . ';
1875 - }';
1876 -
1877 - $html .= '#' . esc_attr( $panoid ) . ' .custom-' . esc_attr( $id ) . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . '.pnlm-tooltip:after{
1878 - content: "";
1879 - position: absolute;
1880 - left: 50%;
1881 - top: 50%;
1882 - transform: translate(-50%, -50%);
1883 - width: 85%;
1884 - height: 85%;
1885 - animation: icon-pulse' . esc_attr( $panoid ) . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' 1.5s infinite cubic-bezier(.25, 0, 0, 1);
1886 - border-radius: 100%;
1887 - z-index: -2;
1888 - }';
1889 -
1890 - }
1891 - $html .= '#' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fas.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1892 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fab.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1893 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.fa-solid.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1894 - #' . esc_attr( $panoid2) . ' div.pnlm-hotspot-base.fa.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ',
1895 - #' . esc_attr( $panoid2 ). ' div.pnlm-hotspot-base.far.custom-' . esc_attr( $id ). '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' {
1896 - display: block !important;
1897 - '.esc_attr( $hotspot_background_color).'
1898 - color: ' . esc_attr( $foreground_color) . ';
1899 - '.esc_attr( $border_radius).'
1900 - width: 30px;
1901 - height: 30px;
1902 - font-size: 16px;
1903 - line-height: 30px;
1904 - '.esc_attr( $hotspot_animation).'
1905 - }';
1906 - }
1907 - if (isset($hotspot['hotspot-blink'])) {
1908 - $hotspotblink = $hotspot['hotspot-blink'];
1909 - if ($hotspotblink == 'on') {
1910 - $html .= '@-webkit-keyframes icon-pulse' . esc_attr( $panoid) . '-' . $panoscenes['scene-id'] . '-' . sanitize_html_class($hotspot['hotspot-title']) . ' {
1911 - 0% {
1912 - box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);
1913 - }
1914 - 100% {
1915 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0]) . ', 0);
1916 - }
1917 - }
1918 - @keyframes icon-pulse' . esc_attr( $panoid) . ' {
1919 - 0% {
1920 - box-shadow: 0 0 0 0px rgba(' . esc_attr( $pulse_color[0]) . ', 1);)
1921 - }
1922 - 100% {
1923 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pulse_color[0] ). ', 0);
1924 - }
1925 - }';
1926 - }
1927 - }
1928 - }
1929 - }
1930 - }
1931 - }
1932 -
1933 - $status = get_option('wpvr_edd_license_status');
1934 - if ($status !== false && $status == 'valid') {
1935 - if (!$gyro) {
1936 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1937 - display: none;
1938 - }';
1939 - }
1940 - } else {
1941 - $html .= '#' . esc_attr( $panoid ). ' div.pnlm-orientation-button {
1942 - display: none;
1943 - }';
1944 - }
1945 - $floor_plan_custom_color = isset($postdata['floor_plan_custom_color']) ? $postdata['floor_plan_custom_color'] : '#cca92c';
1946 - $foreground_color_pointer = '#fff';
1947 - if ($floor_plan_custom_color != '') {
1948 - $pointer_pulse = wpvr_hex2rgb($floor_plan_custom_color);
1949 - $floor_rgb = wpvr_HTMLToRGB($floor_plan_custom_color);
1950 - $floor_hsl = wpvr_RGBToHSL($floor_rgb);
1951 - if ($floor_hsl->lightness > 200) {
1952 - $foreground_color_pointer = '#000000';
1953 - }
1954 - $html .= '
1955 - .wpvr-floor-map .floor-plan-pointer.add-pulse:before {
1956 - border: 17px solid ' . esc_attr( $floor_plan_custom_color ) . ';
1957 - }
1958 - @-webkit-keyframes pulse {
1959 - 0% {
1960 - -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1961 - }
1962 - 70% {
1963 - -webkit-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1964 - }
1965 - 100% {
1966 - -webkit-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1967 - }
1968 - }
1969 - @keyframes pulse {
1970 - 0% {
1971 - -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1972 - box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0.7);
1973 - }
1974 - 70% {
1975 - -moz-box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1976 - box-shadow: 0 0 0 10px rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1977 - }
1978 - 100% {
1979 - -moz-box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1980 - box-shadow: 0 0 0 0 rgba(' . esc_attr( $pointer_pulse[0] ) . ', 0);
1981 - }
1982 - }';
1983 - }
1984 - $html .= '</style>';
1985 -
1986 - $scene_animation = isset($postdata['sceneAnimation']) ? $postdata['sceneAnimation'] : 'off';
1987 - $scene_animation_enabled = in_array( $scene_animation, array( 'on', '1', 1, true ), true );
1988 -
1989 - if( $scene_animation_enabled && is_plugin_active( 'wpvr-pro/wpvr-pro.php' ) ) {
1990 - $animation_type = isset($postdata['sceneAnimationName']) ? $postdata['sceneAnimationName'] : 'none';
1991 - $animation_type = $animation_type === 'fade' ? 'fade_in' : $animation_type;
1992 - $animationDuration = isset($postdata['sceneAnimationTransitionDuration']) ? $postdata['sceneAnimationTransitionDuration'] : '500ms';
1993 - $animationDelay = isset($postdata['sceneAnimationTransitionDelay']) ? $postdata['sceneAnimationTransitionDelay'] : '0ms';
1994 - $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration, $animationDelay, $postdata,$id);
1995 - $html .= $animation_css;
1996 - }
1997 -
1998 - if (wpvr_isMobileDevice()) {
1999 - $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 ) . ' ">';
2000 - } else {
2001 - $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 ) . '">';
2002 - }
2003 - $status = get_option('wpvr_edd_license_status');
2004 - $is_cardboard = get_option('wpvr_cardboard_disable');
2005 - if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
2006 - $html .= '<button class="fullscreen-button">';
2007 - $html .= '<span class="expand">';
2008 - $html .= '<i class="fas fa-expand" aria-hidden="true"></i>';
2009 - $html .= '</span>';
2010 -
2011 - $html .= '<span class="compress">';
2012 - $html .= '<i class="fas fa-minimize" aria-hidden="true"></i>';
2013 - $html .= '</span>';
2014 - $html .= '</button>';
2015 - $html .= '<label class="wpvr-cardboard-switcher">
2016 - <input type="checkbox" class="vr_mode_change' . $id . '" name="vr_mode_change" value="off">
2017 - <span class="switcher-box">
2018 - <span class="normal-mode-tooltip">Normal VR Mode</span>
2019 - <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
2020 - <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"/>
2021 - </svg>
2022 - </span>
2023 - </label>';
2024 - }
2025 -
2026 - if ($width == 'fullwidth') {
2027 - if (wpvr_isMobileDevice()) {
2028 - $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
2029 - $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>';
2030 - $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 ) . '" >';
2031 - } else {
2032 - $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>';
2033 - $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;" >';
2034 - }
2035 - } else {
2036 - if (wpvr_isMobileDevice()) {
2037 - $html .= '<div id="pano2' . esc_attr( $id ) . '" class="pano-wrap pano-left cardboard-half" style="width: 49%; border-radius:' . esc_attr( $radius ) . ';">
2038 - <div id="center-pointer2' . esc_attr( $id ) . '" class="vr-pointer-container">
2039 - <span class="center-pointer"></span>
2040 - </div>
2041 - </div>';
2042 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style=" width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
2043 - } else {
2044 -
2045 - $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>';
2046 -
2047 - $html .= '<div id="pano' . esc_attr( $id ) . '" class="pano-wrap pano-right" style="width: 100%; border-radius:' . esc_attr( $radius ) . ';">';
2048 - }
2049 - }
2050 - // Vr mode transction scene to scene
2051 - if ($status !== false && 'valid' == $status && $is_pro && wpvr_isMobileDevice() && $is_cardboard == 'true') {
2052 - $html .= '<div id="center-pointer' . esc_attr( $id ) . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
2053 - }
2054 -
2055 -
2056 - //===company logo===//
2057 - if (isset($postdata['cpLogoSwitch'])) {
2058 - $cpLogoImg = $postdata['cpLogoImg'];
2059 - $cpLogoContent = $postdata['cpLogoContent'];
2060 - if ($postdata['cpLogoSwitch'] == 'on' && 'valid' == $status && $is_pro) {
2061 - $html .= '<div id="cp-logo-controls">';
2062 - $html .= '<div class="cp-logo-ctrl" id="cp-logo">';
2063 - if ($cpLogoImg) {
2064 - $html .= '<img loading="lazy" src="' . esc_attr( $cpLogoImg ) . '" alt="Company Logo">';
2065 - }
2066 -
2067 - if ($cpLogoContent) {
2068 - $html .= '<div class="cp-info">' . esc_html( $cpLogoContent ) . '</div>';
2069 - }
2070 - $html .= '</div>';
2071 - $html .= '</div>';
2072 - }
2073 - }
2074 - //===company logo ends===//
2075 -
2076 - //===Background Tour===//
2077 - if (isset($postdata['bg_tour_enabler'])) {
2078 -
2079 - $bg_tour_enabler = $postdata['bg_tour_enabler'];
2080 - if ($bg_tour_enabler == 'on') {
2081 - $bg_tour_navmenu = $postdata['bg_tour_navmenu'] ?? 'off';
2082 - $bg_tour_title = $postdata['bg_tour_title'] ?? '';
2083 - $bg_tour_subtitle = $postdata['bg_tour_subtitle'] ?? '';
2084 -
2085 - if ($bg_tour_navmenu == 'on') {
2086 - $menuLocations = get_nav_menu_locations();
2087 - $menuID = $menuLocations['primary'];
2088 - $primaryNav = wp_get_nav_menu_items($menuID);
2089 -
2090 - if ($primaryNav) {
2091 - $html .= '<div class="wpvr-navbar-container">';
2092 - foreach ($primaryNav as $primaryNav_key => $primaryNav_value) {
2093 - if ($primaryNav_value->menu_item_parent == "0") {
2094 - $html .= '<li>';
2095 - $html .= '<a href="' . esc_url( $primaryNav_value->url ) . '">' . esc_attr( $primaryNav_value->title ) . '</a>';
2096 - $html .= '<ul class="wpvr-navbar-dropdown">';
2097 - foreach ($primaryNav as $pm_key => $pm_value) {
2098 - if ($pm_value->menu_item_parent == $primaryNav_value->ID) {
2099 - $html .= '<li>';
2100 - $html .= '<a href="' . esc_url( $pm_value->url ) . '">' . esc_attr( $pm_value->title ) . '</a>';
2101 - $html .= '</li>';
2102 - }
2103 - }
2104 - $html .= '</ul>';
2105 - $html .= '</li>';
2106 - }
2107 - }
2108 - $html .= '</div>';
2109 - }
2110 - }
2111 -
2112 - if($is_pro && 'valid' == $status ){
2113 - $html .= '<div class="wpvr-home-content">';
2114 - $html .= '<div class="wpvr-home-title">' . $bg_tour_title . '</div>';
2115 - $html .= '<div class="wpvr-home-subtitle">' . $bg_tour_subtitle . '</div>';
2116 - $html .= '</div>';
2117 - }
2118 - }
2119 - }
2120 - //===Background Tour End===//
2121 -
2122 - //===Custom Control===//
2123 - if (isset($custom_control)) {
2124 - $gyro_button_enabled = wpvr_isMobileDevice() && $custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on";
2125 - if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $gyro_button_enabled || $custom_control['backToHomeSwitch'] == "on") {
2126 - $html .= '<div id="zoom-in-out-controls' . esc_attr( $id ) . '" class="zoom-in-out-controls">';
2127 -
2128 - if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
2129 - $html .= '<div class="ctrl" id="backToHome' . esc_attr( $id ) . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . esc_attr( $custom_control['backToHomeColor'] ) . ';"></i></div>';
2130 - }
2131 -
2132 - if ($custom_control['panZoomInSwitch'] == "on" && 'valid' == $status && $is_pro) {
2133 - $html .= '<div class="ctrl" id="zoom-in' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomInColor'] ) . ';"></i></div>';
2134 - }
2135 -
2136 - if ($custom_control['panZoomOutSwitch'] == "on" && 'valid' == $status && $is_pro) {
2137 - $html .= '<div class="ctrl" id="zoom-out' . esc_attr( $id ) . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . esc_attr( $custom_control['panZoomOutColor'] ) . ';"></i></div>';
2138 - }
2139 -
2140 - if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
2141 - $html .= '<div class="ctrl" id="gyroscope' . esc_attr( $id ) . '"><i class="' . $custom_control['gyroscopeIcon'] . '" style="color:' . esc_attr( $custom_control['gyroscopeColor'] ) . ';"></i></div>';
2142 - }
2143 -
2144 - $html .= '</div>';
2145 - }
2146 - //===zoom in out Control===//
2147 -
2148 - if ( ($custom_control['panupSwitch'] == "on" || $custom_control['panDownSwitch'] == "on" || $custom_control['panLeftSwitch'] == "on" || $custom_control['panRightSwitch'] == "on" || $custom_control['panFullscreenSwitch'] == "on" ) && 'valid' == $status && $is_pro) {
2149 -
2150 - //===Custom Control===//
2151 - $html .= '<div class="controls" id="controls' . esc_attr( $id ) . '">';
2152 -
2153 - if ($custom_control['panupSwitch'] == "on") {
2154 - $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>';
2155 - }
2156 -
2157 - if ($custom_control['panDownSwitch'] == "on") {
2158 - $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>';
2159 - }
2160 -
2161 - if ($custom_control['panLeftSwitch'] == "on") {
2162 - $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>';
2163 - }
2164 -
2165 - if ($custom_control['panRightSwitch'] == "on") {
2166 - $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>';
2167 - }
2168 -
2169 - if ($custom_control['panFullscreenSwitch'] == "on") {
2170 - $html .= '<div class="ctrl fullscreen" id="fullscreen' . esc_attr( $id ) . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . esc_attr( $custom_control['panFullscreenColor'] ) . ';"></i></div>';
2171 - }
2172 - $html .= '</div>';
2173 - }
2174 - }
2175 -
2176 - //===explainer button===//
2177 - $html .= wpvr_render_explainer_button(
2178 - isset( $custom_control ) ? $custom_control : null,
2179 - $postdata,
2180 - $is_pro,
2181 - $autoload,
2182 - $explainer_right,
2183 - $id
2184 - );
2185 - //===explainer button end===//
2186 -
2187 - //===Scene navigation Control===//
2188 - if (isset($postdata['scene_navigation']) && $postdata['scene_navigation'] === 'on' && 'valid' == $status && $is_pro) {
2189 - $scene_navigation_nav_class = 'custom-scene-navigation-nav' . ( $is_classic_layout ? ' wpvr-scene-navigation-nav--classic' : '' );
2190 - $html .= '<style>
2191 - #et-boc .et-l .pnlm-controls-container,
2192 - .pnlm-controls-container{
2193 - top: 33px;
2194 - }
2195 -
2196 - #et-boc .et-l .zoom-in-out-controls,
2197 - .zoom-in-out-controls {
2198 - top: 37px;
2199 - }
2200 - </style>';
2201 - $html .= '<div id="custom-scene-navigation' . esc_attr( $id ) . '" class="custom-scene-navigation">
2202 - <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>
2203 - </div>
2204 -
2205 - <div id="custom-scene-navigation-nav' . esc_attr( $id ) . '" class="' . esc_attr( $scene_navigation_nav_class ) . '">
2206 - <ul></ul>
2207 - </div>
2208 - ';
2209 - }
2210 -
2211 - //===Scene navigation Control===//
2212 -
2213 - /**
2214 - * Generic Form Handler
2215 - * Renders a generic form with modal functionality if enabled in post data
2216 - *
2217 - * @param array $postdata Array containing form configuration data
2218 - * @param string $id Unique identifier for the form instance
2219 - * @return string $html Generated HTML content
2220 - */
2221 -
2222 - // Check if generic form is enabled and validate the setting
2223 - if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on' && 'valid' == $status && $is_pro) {
2224 -
2225 - // Process shortcode with fallback handling
2226 - $shortcode_content = '';
2227 - if (isset($postdata["genericformshortcode"]) && !empty(trim($postdata["genericformshortcode"]))) {
2228 - $shortcode_content = do_shortcode( $postdata["genericformshortcode"] );
2229 - } else {
2230 - $shortcode_content = '<p class="error-message">No shortcode found.</p>';
2231 - }
2232 -
2233 - // Generate the form trigger button
2234 - $generic_form_icon = isset($postdata['genericformicon']) ? (string) $postdata['genericformicon'] : 'fab fa-wpforms';
2235 - $generic_form_icon = implode(' ', array_filter(array_map('sanitize_html_class', preg_split('/\s+/', $generic_form_icon))));
2236 - $generic_form_icon = $generic_form_icon ?: 'fab fa-wpforms';
2237 - $generic_form_icon_color = sanitize_hex_color($postdata['genericformiconcolor'] ?? '') ?: '#f7fffb';
2238 - $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr( $id ) . '">';
2239 - $html .= '<div class="generic-form-icon" title ="Generic Form" id="generic_form_target_' . esc_attr( $id ) . '"><i class="' . esc_attr( $generic_form_icon ) . '" style="color:' . esc_attr( $generic_form_icon_color ) . ';"></i></div>';
2240 - $html .= '</div>';
2241 -
2242 - // Generate the modal form container
2243 - $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr( $id ) . '" style="display: none">';
2244 - $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
2245 - $html .= '<div class="generic-form-container">' . $shortcode_content . '</div>';
2246 - $html .= '</div>';
2247 - }
2248 - //=====custom generic form=====//
2249 -
2250 - //===Floor map button===//
2251 - $status = get_option('wpvr_edd_license_status');
2252 - if ($status !== false && 'valid' == $status && $is_pro) {
2253 - if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
2254 - $html .= '<div class="floor_map_button" id="floor_map_button_' . esc_attr( $id ) . '" style="right:' . esc_attr( $floor_map_right ) . '">';
2255 - $html .= '<div class="ctrl" id="floor_map_target_' . esc_attr( $id ) . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
2256 - $html .= '</div>';
2257 - }
2258 - }
2259 -
2260 - //===floor map button===//
2261 - if ($vrgallery && 'valid' == $status && $is_pro ) {
2262 - //===Carousal setup===//
2263 - $size = '';
2264 - if ($vrgallery_icon_size) {
2265 - $size = 'vrg-icon-size-large';
2266 - }
2267 - $html .= '<div id="vrgcontrols' . esc_attr( $id ) . '" class="vrgcontrols">';
2268 -
2269 - $html .= '<div class="vrgctrl' . esc_attr( $id ) . ' vrbounce ' . esc_attr( $size ) . '">';
2270 - $html .= '</div>';
2271 - $html .= '</div>';
2272 -
2273 - $tour_layout = is_array( $postdata['tourLayout'] ?? null )
2274 - ? ( $postdata['tourLayout']['layout'] ?? 'default' )
2275 - : ( $postdata['tourLayout'] ?? 'default' );
2276 - $gallery_layout_class = 'layout1' === $tour_layout
2277 - ? 'wpvr-gallery--modern'
2278 - : 'wpvr-gallery--classic';
2279 -
2280 - $html .= '<div id="sccontrols' . esc_attr( $id ) . '" class="scene-gallery vrowl-carousel owl-theme ' . esc_attr( $gallery_layout_class ) . '">';
2281 - if (isset($panodata["scene-list"])) {
2282 - foreach ($panodata["scene-list"] as $panoscenes) {
2283 - $scene_key = $panoscenes['scene-id'];
2284 - if ($vrgallery_title == 'on') {
2285 - $scene_key_title = isset($panoscenes['scene-ititle']) ? esc_html($panoscenes['scene-ititle']) : '';
2286 - } else {
2287 - $scene_key_title = "";
2288 - }
2289 -
2290 - if ($panoscenes['scene-type'] == 'cubemap') {
2291 - $img_src_url = $panoscenes['scene-attachment-url-face0'];
2292 - } else {
2293 - $img_src_url = $panoscenes['scene-attachment-url'];
2294 - }
2295 -
2296 -
2297 - $src_to_id = attachment_url_to_postid($img_src_url);
2298 - $thumbnail_array = wp_get_attachment_image_src($src_to_id, 'thumbnail');
2299 - if ($thumbnail_array) {
2300 - $thumbnail = $thumbnail_array[0];
2301 - } else {
2302 - $thumbnail = $img_src_url;
2303 - }
2304 - if ( 'layout1' !== $tour_layout ) {
2305 - $html .= '<ul><li title="Double click to view scene"><span class="scene-title" title="' . esc_attr($scene_key_title) . '"> ' . $scene_key_title . '</span><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"></li></ul>';
2306 - }else {
2307 - $html .= '<ul><li title="Double click to view scene"><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $id . '" src="' . $thumbnail . '"><span class="scene-title" title="' . esc_attr($scene_key_title) . '">' . $scene_key_title . '</span></li></ul>';
2308 - }
2309 - }
2310 - }
2311 - $html .= '</div>';
2312 - $html .= '
2313 - <div class="owl-nav wpvr_slider_nav">
2314 - <button type="button" role="presentation" class="owl-prev wpvr_owl_prev">
2315 - <div class="nav-btn prev-slide"><i class="fa fa-angle-left"></i></div>
2316 - </button>
2317 - <button type="button" role="presentation" class="owl-next wpvr_owl_next">
2318 - <div class="nav-btn next-slide"><i class="fa fa-angle-right"></i></div>
2319 - </button>
2320 - </div>
2321 - ';
2322 - //===Carousal setup end===//
2323 - }
2324 -
2325 - $bg_music = isset($postdata['bg_music']) ? $postdata['bg_music'] : 'off';
2326 - $bg_music_url = isset($postdata['bg_music_url']) ? $postdata['bg_music_url'] : '';
2327 - $autoplay_bg_music = isset($postdata['autoplay_bg_music']) ? $postdata['autoplay_bg_music'] : 'off';
2328 - $loop_bg_music = isset($postdata['loop_bg_music']) ? $postdata['loop_bg_music'] : 'off';
2329 -
2330 - $bg_loop = ($loop_bg_music === 'on') ? 'loop' : '';
2331 - $autoplay_attr = ($autoplay_bg_music === 'on') ? 'autoplay' : '';
2332 - $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
2333 - $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
2334 -
2335 - if ($bg_music === 'on' && 'valid' == $status && $is_pro) {
2336 - $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
2337 - $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 . '>
2338 - <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
2339 - Your browser does not support the audio element.
2340 - </audio>';
2341 - $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
2342 - <i id="vr-volume' . esc_attr($id) . '" class="wpvrvolumeicon' . esc_attr($id) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
2343 - </button>';
2344 - $html .= '</div>';
2345 - }
2346 -
2347 - //===Explainer video section===//
2348 - $explainerContent = "";
2349 - if (isset($postdata['explainerContent'])) {
2350 - $explainerContent = wpvr_sanitize_iframe_only($postdata['explainerContent']);
2351 - }
2352 - $html .= '<div class="explainer" id="explainer' . esc_attr( $id ) . '" style="display: none">';
2353 - $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
2354 - $html .= '' . $explainerContent . '';
2355 - $html .= '</div>';
2356 - //===Explainer video section End===//
2357 -
2358 - //===Floor plan section===//
2359 - $floor_map_image = "";
2360 - $floor_map_pointer = array();
2361 - $floor_map_scene_id = '';
2362 - $floor_plan_custom_color = '#cca92c';
2363 - $floor_plan_direction_indicator = isset($postdata['floor_plan_direction_indicator']) ? $postdata['floor_plan_direction_indicator'] : 'on';
2364 -
2365 - if (isset($postdata['floor_plan_attachment_url'])) {
2366 - $floor_map_image = $postdata['floor_plan_attachment_url'];
2367 - $floor_map_pointer = $postdata['floor_plan_pointer_position'];
2368 - $floor_map_scene_id = $postdata['floor_plan_data_list'];
2369 - $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
2370 - }
2371 - $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
2372 - $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
2373 - $html .= '<img loading="lazy" src="' . $floor_map_image . '">';
2374 -
2375 - foreach ($floor_map_pointer as $key => $pointer_position) {
2376 - $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 ) . '">
2377 -
2378 - <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2379 - <circle cx="12" cy="12" r="11.5" stroke="' . esc_attr( $floor_plan_custom_color ) . '"/>
2380 - <circle cx="12" cy="12" r="5" fill="' . esc_attr( $foreground_color_pointer ) . '"/>
2381 - </svg>';
2382 -
2383 - // Only add the floor pointer flash SVG if floor_plan_direction_indicator is "on"
2384 - if ($floor_plan_direction_indicator === "on") {
2385 - $html .= '<svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
2386 - <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)"/>
2387 - <defs>
2388 - <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
2389 - <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
2390 - <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
2391 - </linearGradient>
2392 - </defs>
2393 - </svg>';
2394 - }
2395 - $html .= '</div>';
2396 - }
2397 - $html .= '</div>';
2398 - //===Floor plan section===//
2399 -
2400 - $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
2401 - $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
2402 - $html .= '<div class="wpvr-hotspot-tweak-contents-flex">';
2403 - $html .= '<div class="wpvr-hotspot-tweak-contents">';
2404 - ob_start();
2405 - do_action('wpvr_hotspot_tweak_contents', $scene_data);
2406 - $hotspot_content = ob_get_clean();
2407 - $html .= $hotspot_content;
2408 - $html .= '</div>';
2409 - $html .= '</div>';
2410 - $html .= '</div>';
2411 -
2412 - $html .= '<div class="custom-ifram-wrapper" style="display: none;">';
2413 - $html .= '<i class="fa fa-times cross" data-id="' . esc_attr( $id ) . '"></i>';
2414 - $html .= '<div class="custom-ifram-flex">';
2415 - $html .= '<div class="custom-ifram">';
2416 - $html .= '</div>';
2417 - $html .= '</div>';
2418 - $html .= '</div>';
2419 - $html .= '</div>';
2420 - $html .= '</div>';
2421 -
2422 -
2423 - if ("fullwidth" == $width) {
2424 - $html .= '</div>';
2425 - }
2426 - if ($status !== false && 'valid' == $status && $is_pro) {
2427 - $call_to_action = isset($postdata['calltoaction']) ? $postdata['calltoaction'] : 'off';
2428 - if ('on' == $call_to_action) {
2429 - $buttontext = isset($postdata['buttontext']) ? $postdata['buttontext'] : '';
2430 - $buttonurl = isset($postdata['buttonurl']) ? $postdata['buttonurl'] : '';
2431 - $cta_btn_style = isset($postdata['button_configuration']) ? $postdata['button_configuration'] : array();
2432 -
2433 - $button_open_new_tab = isset($cta_btn_style['button_open_new_tab']) ? $cta_btn_style['button_open_new_tab'] : "off";
2434 - $target = '_self';
2435 - $button_position = isset($cta_btn_style['button_position']) ? $cta_btn_style['button_position'] : "";
2436 - $background_color = isset($cta_btn_style['button_background_color']) ? $cta_btn_style['button_background_color'] : "";
2437 - $color = isset($cta_btn_style['button_font_color']) ? $cta_btn_style['button_font_color'] : "";
2438 - $font_size = isset($cta_btn_style['button_font_size']) ? $cta_btn_style['button_font_size'] : "";
2439 - $font_weight = isset($cta_btn_style['button_font_weight']) ? $cta_btn_style['button_font_weight'] : "";
2440 - $text_align = isset($cta_btn_style['button_alignment']) ? $cta_btn_style['button_alignment'] : "";
2441 - $text_transform = isset($cta_btn_style['button_transform']) ? $cta_btn_style['button_transform'] : "";
2442 - $font_style = isset($cta_btn_style['button_text_style']) ? $cta_btn_style['button_text_style'] : "";
2443 - $text_decoration = isset($cta_btn_style['button_text_decoration']) ? $cta_btn_style['button_text_decoration'] : "";
2444 - $line_height = isset($cta_btn_style['button_line_height']) ? $cta_btn_style['button_line_height'] : "";
2445 - $letter_spacing = isset($cta_btn_style['button_letter_spacing']) ? $cta_btn_style['button_letter_spacing'] : "";
2446 - $word_spacing = isset($cta_btn_style['button_word_spacing']) ? $cta_btn_style['button_word_spacing'] : "";
2447 -
2448 - $border_width = isset($cta_btn_style['button_border_width']) ? $cta_btn_style['button_border_width'] : "";
2449 - $border_style = isset($cta_btn_style['button_border_style']) ? $cta_btn_style['button_border_style'] : "";
2450 - $border_color = isset($cta_btn_style['button_border_color']) ? $cta_btn_style['button_border_color'] : "";
2451 - $border_radius = isset($cta_btn_style['button_border_radius']) ? $cta_btn_style['button_border_radius'] : "";
2452 -
2453 - $button_pt = isset($cta_btn_style['button_pt']) ? $cta_btn_style['button_pt'] : "";
2454 - $button_pr = isset($cta_btn_style['button_pr']) ? $cta_btn_style['button_pr'] : "";
2455 - $button_pb = isset($cta_btn_style['button_pb']) ? $cta_btn_style['button_pb'] : "";
2456 - $button_pl = isset($cta_btn_style['button_pl']) ? $cta_btn_style['button_pl'] : "";
2457 -
2458 - if ($button_open_new_tab == 'on') {
2459 - $target = '_blank';
2460 - }
2461 - $style = 'background-color: ' . esc_attr( $background_color ) . ';
2462 - color: ' . esc_attr( $color ) . ';
2463 - font-size: ' . esc_attr( $font_size ) . 'px;
2464 - font-weight: ' . esc_attr( $font_weight ) . ';
2465 - text-align: center;
2466 - display: inline-block;
2467 - text-transform: ' . esc_attr( $text_transform ) . ';
2468 - font-style: ' . esc_attr( $font_style ) . ';
2469 - text-decoration: ' . esc_attr( $text_decoration ) . ';
2470 - line-height: ' . esc_attr( $line_height ) . ';
2471 - letter-spacing: ' . esc_attr( $letter_spacing ) . 'px;
2472 - word-spacing: ' . esc_attr( $word_spacing ) . 'px;
2473 - border: ' . esc_attr( $border_width ) . 'px ' . esc_attr( $border_style ) . ' ' . esc_attr( $border_color ) . ';
2474 - border-radius: ' . esc_attr( $border_radius ). 'px;
2475 - padding: ' . esc_attr( $button_pt ) . 'px ' . esc_attr( $button_pr ) . 'px ' . esc_attr( $button_pb ) . 'px ' . esc_attr( $button_pl ) . 'px;
2476 - ';
2477 - $html .= '<div class="wpvr-call-to-action-button position-' . esc_attr( $text_align ) . '" style="max-width:' . esc_attr( $width ) . esc_attr( $width_unit ) . '">
2478 - <a href="' . esc_url( $buttonurl ) . '" style="' . esc_attr( $style ) . '" target="' . esc_attr( $target ) . '">' . esc_attr( $buttontext ) . '</a>
2479 - </div>';
2480 - }
2481 - }
2482 -
2483 - //script started
2484 -
2485 - $html .= '<script>';
2486 - if (isset($postdata['bg_music']) && $bg_music == 'on' && 'valid' == $status && $is_pro) {
2487 - $html .= '
2488 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
2489 -
2490 - var playing' . $id . ' = false;
2491 - var autoplaySupported' . $id . ' = false;
2492 - var alertShown' . $id . ' = false;
2493 - var autoplayChecked' . $id . ' = false;
2494 -
2495 - function playPause' . $id . '() {
2496 - if (playing' . $id . ') {
2497 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2498 - x' . $id . '.pause();
2499 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2500 - playing' . $id . ' = false;
2501 - } else {
2502 - x' . $id . '.muted = false;
2503 - x' . $id . '.play().then(function() {
2504 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2505 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2506 - playing' . $id . ' = true;
2507 - }).catch(function(e) {
2508 - console.log("Play failed:", e);
2509 - });
2510 - }
2511 - }
2512 -
2513 - function audionEnd' . $id . '() {
2514 - playing' . $id . ' = false;
2515 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2516 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2517 - }
2518 -
2519 - x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
2520 -
2521 - if ($autoplay_bg_music == 'on') {
2522 - $html .= '
2523 -
2524 - x' . $id . '.addEventListener("loadeddata", function() {
2525 - if (!autoplayChecked' . $id . ') {
2526 - checkAutoplayStatus' . $id . '();
2527 - }
2528 - });
2529 -
2530 - x' . $id . '.addEventListener("canplay", function() {
2531 - if (!autoplayChecked' . $id . ') {
2532 - checkAutoplayStatus' . $id . '();
2533 - }
2534 - });
2535 -
2536 - x' . $id . '.addEventListener("canplaythrough", function() {
2537 - if (!autoplayChecked' . $id . ') {
2538 - checkAutoplayStatus' . $id . '();
2539 - }
2540 - });
2541 -
2542 - setTimeout(function() {
2543 - if (!autoplayChecked' . $id . ') {
2544 - checkAutoplayStatus' . $id . '();
2545 - }
2546 - }, 1000);
2547 -
2548 - x' . $id . '.addEventListener("play", function() {
2549 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2550 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2551 - playing' . $id . ' = true;
2552 - });
2553 -
2554 - x' . $id . '.addEventListener("pause", function() {
2555 - if (!playing' . $id . ') {
2556 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2557 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2558 - }
2559 - });
2560 -
2561 - function checkAutoplayStatus' . $id . '() {
2562 - autoplayChecked' . $id . ' = true;
2563 -
2564 - x' . $id . '.muted = true;
2565 - var playPromise = x' . $id . '.play();
2566 -
2567 - if (playPromise !== undefined) {
2568 - playPromise.then(function () {
2569 - if (x' . $id . '.muted || x' . $id . '.volume === 0) {
2570 - handleAutoplayBlocked' . $id . '();
2571 - } else {
2572 - autoplaySupported' . $id . ' = true;
2573 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2574 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2575 - playing' . $id . ' = true;
2576 - }
2577 - }).catch(function () {
2578 - handleAutoplayBlocked' . $id . '();
2579 - });
2580 - } else {
2581 - setTimeout(function () {
2582 - if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2583 - handleAutoplayBlocked' . $id . '();
2584 - } else {
2585 - autoplaySupported' . $id . ' = true;
2586 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2587 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2588 - playing' . $id . ' = true;
2589 - }
2590 - }, 300);
2591 - }
2592 - }
2593 -
2594 - function handleAutoplayBlocked' . $id . '() {
2595 - autoplaySupported' . $id . ' = false;
2596 - if (!alertShown' . $id . ') {
2597 - alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2598 - alertShown' . $id . ' = true;
2599 - }
2600 -
2601 - x' . $id . '.pause();
2602 - x' . $id . '.currentTime = 0;
2603 - x' . $id . '.muted = true;
2604 -
2605 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2606 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2607 -
2608 - document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2609 - document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2610 - document.addEventListener("click", musicPlay' . $id . ', { once: true });
2611 - }
2612 -
2613 - function musicPlay' . $id . '() {
2614 - x' . $id . '.muted = false;
2615 - var playPromise = x' . $id . '.play();
2616 -
2617 - if (playPromise !== undefined) {
2618 - playPromise.then(function () {
2619 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2620 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2621 - playing' . $id . ' = true;
2622 - }).catch(function(e) {
2623 - console.log("Play failed:", e);
2624 - });
2625 - } else {
2626 - setTimeout(function () {
2627 - if (!x' . $id . '.paused) {
2628 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2629 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2630 - playing' . $id . ' = true;
2631 - }
2632 - }, 100);
2633 - }
2634 -
2635 - document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2636 - document.removeEventListener("touchstart", musicPlay' . $id . ');
2637 - document.removeEventListener("click", musicPlay' . $id . ');
2638 - }
2639 - ';
2640 - }
2641 - }
2642 - $html .= 'jQuery(document).ready(function() {';
2643 - $html .= 'var response = ' . $response . ';';
2644 - $html .= 'var scenes = response[1];';
2645 - $html .= 'if(scenes) {';
2646 - $html .= 'var scenedata = scenes.scenes;';
2647 - $html .= 'for(var i in scenedata) {';
2648 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2649 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2650 - $html .= 'if(scenehotspot[i].type === "info") {';
2651 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2652 - $html .= '} else if(scenehotspot[i].type === "scene") {';
2653 - $html .= ' scenehotspot[i]["clickHandlerArgs"] = scenehotspot[i]["text"];';
2654 - $status = get_option('wpvr_edd_license_status');
2655 - if ($status !== false && $status == 'valid') {
2656 - $html .='if(wpvr_public.is_pro_active) {';
2657 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = wpvrhotspotscene;';
2658 - $html .='}';
2659 - }
2660 - $html .= '}';
2661 - if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2662 - } else {
2663 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2664 - $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2665 - $html .= '}';
2666 - }
2667 - $html .= '}';
2668 - $html .= '}';
2669 - $html .= '}';
2670 - $html .= 'var panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2671 - $html .= '
2672 - window.wpvrViewers = window.wpvrViewers || {};
2673 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
2674 - document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2675 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
2676 - }));
2677 - ';
2678 - if ( (float) $scene_fade_duration > 0 ) {
2679 - $html .= '
2680 - panoshow' . $id . '.on("scenechange", function() {
2681 - var fadeImage = document.querySelector("#pano' . $id . ' .pnlm-render-container > .pnlm-fade-img");
2682 - if (fadeImage) {
2683 - fadeImage.style.opacity = "1";
2684 - void fadeImage.offsetWidth;
2685 - }
2686 - });';
2687 - }
2688 - $html .= '
2689 - if(!wpvr_public.is_pro_active || !wpvr_public.is_license_active) {
2690 - panoshow' . $id . '.on("load", function() {
2691 - jQuery(".pnlm-panorama-info").hide();
2692 - jQuery(".pnlm-compass").hide();
2693 - });
2694 -
2695 - panoshow' . $id . '.on("scenechange", function() {
2696 - jQuery(".pnlm-panorama-info").hide();
2697 - jQuery(".pnlm-compass").hide();
2698 - });
2699 - }';
2700 -
2701 - //===Dplicate mode only for vr mode===//
2702 - $response2 = json_decode($response);
2703 - $response2[1]->compass = false;
2704 - $response2[1]->autoRotate = false;
2705 - $response = json_encode($response2);
2706 - $html .= 'var response_duplicate = ' . $response . ';';
2707 - $html .= 'var scenes_duplicate = response_duplicate[1];';
2708 -
2709 - $html .= 'if(scenes_duplicate) {';
2710 - $html .= 'var scenedata = scenes_duplicate.scenes;';
2711 - $html .= 'for(var i in scenedata) {';
2712 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2713 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2714 - $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2715 - $html .= 'scenehotspot[i]["clickHandlerFunc"] = wpvrhotspot;';
2716 - $html .= '}';
2717 - if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2718 - } else {
2719 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2720 - $html .= 'scenehotspot[i]["createTooltipFunc"] = wpvrtooltip;';
2721 - $html .= '}';
2722 - }
2723 - $html .= '}';
2724 - $html .= '}';
2725 - $html .= '}';
2726 - $html .= 'var vr_mode = "off";';
2727 - $status = get_option('wpvr_edd_license_status');
2728 - if ($status !== false && 'valid' == $status && $is_pro) {
2729 - $html .= 'var panoshow2' . $id . ' = pannellum.viewer("pano2' . $id . '", scenes_duplicate);';
2730 - $html .= '
2731 - window.wpvrViewers = window.wpvrViewers || {};
2732 - window.wpvrViewers["pano2' . $id . '"] = panoshow2' . $id . ';
2733 - document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2734 - detail: { containerId: "pano2' . $id . '", viewer: panoshow2' . $id . ' }
2735 - }));
2736 - ';
2737 -
2738 - // Show Cardboard Mode in Tour
2739 - $html .= '
2740 - var tim;
2741 - var im = 0;
2742 - var active_scene = "' . $default_scene . '";
2743 - var c_time;
2744 - c_time = new Date();
2745 - var timer = c_time.getTime() + 2000;
2746 - function panoShowCardBoardOnTrigger(data){
2747 - if(scenes_duplicate) {
2748 - var scenedata = scenes_duplicate.scenes;
2749 - for(var i in scenedata) {
2750 - if(active_scene === i) {
2751 - var scenehotspot = scenedata[i].hotSpots;
2752 - for(var j in scenehotspot) {
2753 - var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2754 - var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2755 - var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2756 - var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2757 - var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2758 - var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2759 - if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2760 - if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2761 - jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2762 - var getScene = scenehotspot[j].sceneId;
2763 - if(scenehotspot[j].type == "scene"){
2764 - panoshow' . $id . '.loadScene(getScene);
2765 - panoshow2' . $id . '.loadScene(getScene);
2766 -// var inside_current_time_object = new Date();
2767 -// var inside_timer = inside_current_time_object.getTime();
2768 -// if(inside_timer > timer) {
2769 -// panoshow' . $id . '.loadScene(getScene);
2770 -// panoshow2' . $id . '.loadScene(getScene);
2771 -// jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2772 -// }
2773 - }else{
2774 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2775 - }
2776 - }
2777 - else {
2778 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2779 - c_time = new Date();
2780 - timer = c_time.getTime() + 2000;
2781 - }
2782 - }
2783 - else {
2784 - c_time = new Date();
2785 - timer = c_time.getTime() + 2000;
2786 - }
2787 - }
2788 - }
2789 - }
2790 - }
2791 - };
2792 -
2793 - function vrDeviseOrientation(){
2794 - var data = {
2795 - pitch: panoshow' . $id . '.getPitch(),
2796 - yaw: panoshow' . $id . '.getYaw(),
2797 - };
2798 - panoShowCardBoardOnTrigger(data);
2799 - }
2800 - ';
2801 - $html .= '
2802 -
2803 - function requestFullScreen(){
2804 - var elem = document.getElementById("master-container");
2805 - if (elem.requestFullscreen) {
2806 - elem.requestFullscreen();
2807 - } else if (elem.webkitRequestFullscreen) { /* Safari */
2808 - elem.webkitRequestFullscreen();
2809 - } else if (elem.msRequestFullscreen) { /* IE11 */
2810 - elem.msRequestFullscreen();
2811 - }
2812 - }
2813 - function requestExitFullscreen(){
2814 - var elem = document.getElementById("master-container");
2815 - if (document.exitFullscreen) {
2816 - document.exitFullscreen();
2817 - } else if (document.webkitExitFullscreen) { /* Safari */
2818 - document.webkitExitFullscreen();
2819 - } else if (document.msExitFullscreen) { /* IE11 */
2820 - document.msExitFullscreen();
2821 - }
2822 - }
2823 - jQuery(document).on("click",".fullscreen-button .expand",function() {
2824 - jQuery(this).hide()
2825 - jQuery(this).parent().find(".compress").show()
2826 - requestFullScreen()
2827 - screen.orientation.lock("landscape-primary")
2828 - .then(function() {
2829 - })
2830 - .catch(function(error) {
2831 - alert("Not Supported for this devise");
2832 - });
2833 -
2834 - });
2835 - jQuery(document).on("click",".fullscreen-button .compress",function() {
2836 - jQuery(this).hide()
2837 - jQuery(this).parent().find(".expand").show()
2838 - requestExitFullscreen()
2839 - screen.orientation.unlock();
2840 -
2841 - });
2842 -
2843 - let onLoadAnalytics = false;
2844 - let sceneLoadAnalytics = false;
2845 - function storeAnalyticsData(data) {
2846 - if(wpvr_public.is_pro_active) {
2847 - jQuery.ajax({
2848 - url: wpvrAnalyticsObj.ajaxUrl,
2849 - type: "POST",
2850 - data: {
2851 - action: "store_scene_hotspot_data",
2852 - scene_id: data.scene_id,
2853 - tour_id: data.tour_id,
2854 - type: data.type,
2855 - hotspot_id: data.hotspot_id || "",
2856 - user_agent: navigator.userAgent,
2857 - device_type: getDeviceType() || "desktop",
2858 - nonce: wpvrAnalyticsObj.nonce,
2859 - },
2860 - success: function (response) {
2861 - console.log("Data stored successfully");
2862 - },
2863 - error: function (error) {
2864 - console.log("Error in storing data");
2865 - }
2866 - });
2867 - }
2868 - }
2869 -
2870 - function getDeviceType() {
2871 - const userAgent = navigator.userAgent.toLowerCase();
2872 -
2873 - if (/mobile|android|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent)) {
2874 - return "mobile";
2875 - } else if (/tablet|ipad/i.test(userAgent)) {
2876 - return "tablet";
2877 - } else {
2878 - return "desktop";
2879 - }
2880 - }
2881 -
2882 - panoshow' . $id . '.on("scenechange", function(scene) {
2883 - onLoadAnalytics = true;
2884 - sceneLoadAnalytics = true;
2885 - let scene_id = scene;
2886 - let tour_id = ' . $id . ';
2887 - let type = "scene";
2888 - let hotspot_id = "";
2889 - let user_agent = navigator.userAgent;
2890 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2891 - storeAnalyticsData({
2892 - scene_id: scene_id,
2893 - tour_id: tour_id,
2894 - type: type,
2895 - hotspot_id: hotspot_id,
2896 - user_agent: user_agent,
2897 - device_type: device_type,
2898 - });
2899 - if(!wpvr_public.is_pro_active) {
2900 - jQuery(".pnlm-panorama-info").hide();
2901 - setTimeout(function() {
2902 - jQuery(".pnlm-panorama-info").each(function() {
2903 - jQuery(this).hide();
2904 - });
2905 - }, 500);
2906 - }
2907 - });
2908 -
2909 - panoshow' . $id . '.on("load", function() {
2910 - let scene_id = panoshow' . $id . '.getScene();
2911 - let tour_id = ' . $id . ';
2912 - let type = "scene";
2913 - let hotspot_id = "";
2914 - let user_agent = navigator.userAgent;
2915 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2916 - if(!onLoadAnalytics && !sceneLoadAnalytics){
2917 - storeAnalyticsData({
2918 - scene_id: scene_id,
2919 - tour_id: tour_id,
2920 - type: type,
2921 - hotspot_id: hotspot_id,
2922 - user_agent: user_agent,
2923 - device_type: device_type,
2924 - });
2925 - }
2926 - if(!wpvr_public.is_pro_active) {
2927 - jQuery(".pnlm-panorama-info").hide();
2928 - setTimeout(function() {
2929 - jQuery(".pnlm-panorama-info").each(function() {
2930 - jQuery(this).hide();
2931 - });
2932 - }, 500);
2933 - }
2934 - })
2935 -
2936 - function wpvrhotspotscene(hotSpotDiv, args) {
2937 - onLoadAnalytics = true;
2938 - let scene_id = panoshow' . $id . '.getScene();
2939 - let tour_id = ' . $id . ';
2940 - let type = "hotspot";
2941 - let hotspot_id = args;
2942 - let user_agent = navigator.userAgent;
2943 - let device_type = getDeviceType() ? getDeviceType() : "desktop";
2944 - storeAnalyticsData({
2945 - scene_id: scene_id,
2946 - tour_id: tour_id,
2947 - type: type,
2948 - hotspot_id: hotspot_id,
2949 - user_agent: user_agent,
2950 - device_type: device_type
2951 - });
2952 - }';
2953 -
2954 - $html .= '
2955 - panoshow' . $id . '.on("scenechange", function (scene){
2956 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2957 - active_scene = scene;
2958 - });
2959 - var compassBlock = "";
2960 - var infoBlock = "";
2961 - var getValue = "";
2962 - jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2963 -
2964 - jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2965 - jQuery("#pano' . $id . ' .pnlm-load-button").trigger("click");
2966 -
2967 - getValue = jQuery(this).val();
2968 - var getParent = jQuery(this).parent().parent();
2969 - var fullWidthParent = getParent.parent();
2970 - var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2971 - var panoInfo = getParent.find("#pano' . $id . ' .pnlm-panorama-info").css("display");
2972 - if(compass == "block"){
2973 - compassBlock = "block";
2974 - }
2975 - if(panoInfo == "block"){
2976 - infoBlock = "block";
2977 - }
2978 - if (getValue == "off") {
2979 - requestFullScreen()
2980 - screen.orientation.lock("landscape-primary")
2981 - .then(function() {
2982 - })
2983 - .catch(function(error) {
2984 - alert("VR Glass Mode not supported in this device");
2985 - });
2986 - getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2987 - // localStorage.setItem("vr_mode", "on");
2988 - vr_mode = "on";
2989 - jQuery(".vr-mode-title").show();
2990 - jQuery(this).val("on");
2991 - getParent.find("#pano2' . $id . '").css({
2992 - "opacity": "1",
2993 - "visibility": "visible",
2994 - "position": "relative",
2995 - });
2996 - gyroSwitch = true;
2997 - panoshow' . $id . '.startOrientation();
2998 - panoshow2' . $id . '.startOrientation();
2999 - panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
3000 - panoshow2' . $id . '.setYaw(panoshow' . $id . '.getYaw(), 0);
3001 - getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").hide();
3002 - getParent.find("#pano' . $id . ' #controls' . $id . '").hide();
3003 - getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").hide();
3004 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
3005 - getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").hide();
3006 - getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").hide();
3007 - getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
3008 - getParent.find("#pano' . $id . ' #adcontrol' . $id . '").hide();
3009 - getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
3010 - getParent.find("#pano' . $id . ' #cp-logo-controls").hide();
3011 -
3012 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
3013 -
3014 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
3015 - getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
3016 -
3017 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
3018 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
3019 -
3020 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
3021 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
3022 - getParent.find("#pano' . $id . '").addClass("cardboard-half");
3023 -
3024 - getParent.find("#center-pointer' . $id . '").show();
3025 - getParent.find(".fullscreen-button").hide();
3026 -
3027 -
3028 - if (window.DeviceOrientationEvent) {
3029 - window.addEventListener("deviceorientation", vrDeviseOrientation);
3030 - }
3031 -
3032 - panoshow' . $id . '.on("mousemove", function (data){
3033 - panoshow2' . $id . '.setPitch(data.pitch, 0);
3034 - panoshow2' . $id . '.setYaw(data.yaw, 0);
3035 - panoShowCardBoardOnTrigger(data);
3036 -
3037 - });
3038 - panoshow2' . $id . '.on("mousemove", function (data){
3039 - panoshow2' . $id . '.setPitch(data.pitch, 0);
3040 - panoshow' . $id . '.setYaw(data.yaw, 0);
3041 - panoShowCardBoardOnTrigger(data);
3042 -
3043 - });
3044 -
3045 - panoshow' . $id . '.on("zoomchange", function (data){
3046 - panoshow2' . $id . '.setHfov(data, 0);
3047 - });
3048 -
3049 - panoshow2' . $id . '.on("zoomchange", function (data){
3050 - panoshow' . $id . '.setHfov(data, 0);
3051 - });
3052 -
3053 - panoshow' . $id . '.on("touchmove", function (data){
3054 - panoshow' . $id . '.stopOrientation();
3055 - panoshow2' . $id . '.stopOrientation();
3056 - panoshow2' . $id . '.setPitch(data.pitch, 0);
3057 - panoshow2' . $id . '.setYaw(data.yaw, 0);
3058 - panoShowCardBoardOnTrigger(data);
3059 -
3060 - });
3061 -
3062 - panoshow2' . $id . '.on("touchmove", function (data){
3063 - panoshow' . $id . '.stopOrientation();
3064 - panoshow2' . $id . '.stopOrientation();
3065 - panoshow' . $id . '.setPitch(data.pitch, 0);
3066 - panoshow' . $id . '.setYaw(data.yaw, 0);
3067 - panoShowCardBoardOnTrigger(data);
3068 -
3069 - });
3070 -
3071 - }
3072 - else if(getValue == "on") {
3073 - screen.orientation.unlock();
3074 - requestExitFullscreen();
3075 - // localStorage.setItem("vr_mode", "off");
3076 - vr_mode = "off";
3077 - jQuery(".vr-mode-title").hide();
3078 - jQuery(this).val("off");
3079 - getParent.find("#pano2' . $id . '").css({
3080 - "opacity": "0",
3081 - "visibility": "hidden",
3082 - "position": "absolute",
3083 - });
3084 - panoshow' . $id . '.stopOrientation();
3085 - panoshow2' . $id . '.stopOrientation();
3086 - getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
3087 - getParent.find("#pano' . $id . ' #zoom-in-out-controls' . $id . '").show();
3088 - getParent.find("#pano' . $id . ' #controls' . $id . '").show();
3089 - getParent.find("#pano' . $id . ' #explainer_button_' . $id . '").show();
3090 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
3091 - getParent.find("#pano' . $id . ' #floor_map_button_' . $id . '").show();
3092 -
3093 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
3094 - getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
3095 - getParent.find("#pano' . $id . ' #vrgcontrols' . $id . '").show();
3096 - getParent.find("#pano' . $id . ' #sccontrols' . $id . '").hide();
3097 - getParent.find("#pano' . $id . ' #adcontrol' . $id . '").show();
3098 - getParent.find("#pano' . $id . ' .owl-nav.wpvr_slider_nav").hide();
3099 - getParent.find("#pano' . $id . ' #cp-logo-controls").show();
3100 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").show();
3101 -
3102 - if(compassBlock == "block"){
3103 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
3104 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
3105 - }
3106 - if(infoBlock == "block"){
3107 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
3108 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
3109 - }
3110 -
3111 - getParent.find("#pano' . $id . '").removeClass("cardboard-half");
3112 - getParent.find("#center-pointer' . $id . '").hide();
3113 - getParent.find(".fullscreen-button").hide();
3114 - panoshow' . $id . '.off("mousemove");
3115 - panoshow' . $id . '.off("touchmove");
3116 - panoshow2' . $id . '.off("mousemove");
3117 - panoshow2' . $id . '.off("touchmove");
3118 - if (window.DeviceOrientationEvent) {
3119 - window.removeEventListener("deviceorientation", vrDeviseOrientation);
3120 - }
3121 - }
3122 - });';
3123 -
3124 - $html .= 'panoshow2' . $id . '.on("load", function (){
3125 -// if(localStorage.getItem("vr_mode") == "off") {
3126 - if( vr_mode == "off") {
3127 - jQuery(".vr-mode-title").hide();
3128 - }
3129 - else {
3130 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3131 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3132 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
3133 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
3134 - jQuery(".vr-mode-title").show();
3135 - }
3136 - });';
3137 - }
3138 -
3139 - $html .= 'jQuery("#pano' . $id . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
3140 - var scene_id = jQuery(this).attr("scene_id");
3141 - panoshow' . $id . '.loadScene(scene_id)
3142 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
3143 - jQuery(this).addClass("add-pulse")
3144 - });';
3145 -
3146 - if ($scene_animation_enabled && is_plugin_active('wpvr-pro/wpvr-pro.php') ) {
3147 - $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
3148 - if (!empty($animation_js)) {
3149 - $html .= $animation_js;
3150 - $html .= 'panoshow' . $id . '.on("load", function (scene){
3151 - if (typeof changeScene === "function") {
3152 - changeScene();
3153 - } else {
3154 - console.warn("changeScene function is not defined.");
3155 - }
3156 - });';
3157 - }
3158 - }
3159 -
3160 -
3161 - $html .= '
3162 - panoshow' . $id . '.on("mousemove", function (data){
3163 - jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
3164 - });
3165 -';
3166 -
3167 -
3168 -
3169 - $status = get_option('wpvr_edd_license_status');
3170 - if ($status !== false && 'valid' == $status && $is_pro) {
3171 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
3172 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
3173 - jQuery(".floor-plan-pointer").each(function(index ,element){
3174 - var scene_id = jQuery(this).attr("scene_id");
3175 - if( active_scene == scene_id ){
3176 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
3177 - jQuery(this).addClass("add-pulse")
3178 - }
3179 - });
3180 -
3181 - });';
3182 - $html .= 'panoshow' . $id . '.on("load", function (){
3183 - if(jQuery(".floor-plan-pointer").length > 0){
3184 - jQuery(".floor-plan-pointer").each(function(index ,element){
3185 - var scene_id = jQuery(this).attr("scene_id");
3186 - if( active_scene == scene_id ){
3187 - jQuery(".floor-plan-pointer").removeClass("add-pulse")
3188 - jQuery(this).addClass("add-pulse")
3189 - }
3190 - });
3191 - }
3192 - });';
3193 - }
3194 -
3195 - if ($status !== false && 'valid' == $status && $is_pro) {
3196 - $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
3197 - $html .= '
3198 - jQuery("#pano' . $id . ' .custom-scene-navigation").on("click",function(){
3199 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").empty()
3200 - if(scenes){
3201 - var scene_navigation_content_type = ' . "'" . $scene_navigation_content_type . "'" . ';
3202 - var sceneList = scenes.scenes;
3203 - var getScene = panoshow' . $id . '.getScene();
3204 - for (const key in sceneList) {
3205 - let title;
3206 - if (scene_navigation_content_type === "scene_title") {
3207 - if (sceneList[key].title) {
3208 - title = sceneList[key].title;
3209 -
3210 - }else{
3211 - if(title == "" || title == undefined){
3212 - if (sceneList[key].panorama) {
3213 - title = getImageNameWithoutExtension(sceneList[key].panorama);
3214 - }
3215 - }
3216 - }
3217 - } else if (scene_navigation_content_type === "scene_image_name") {
3218 - if (sceneList[key].panorama) {
3219 - title = getImageNameWithoutExtension(sceneList[key].panorama);
3220 - }
3221 - } else {
3222 - title = key;
3223 - }
3224 - if (sceneList.hasOwnProperty(key)) {
3225 - if( key === getScene){
3226 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list active\" scene_id= " + key + " >" + title + "</li>");
3227 - }else{
3228 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").append("<li class=\"scene-navigation-list\" scene_id= " + key + " >" + title + "</li>");
3229 - }
3230 - }
3231 - }
3232 - }
3233 - jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
3234 - });
3235 - ';
3236 -
3237 - $html .= 'function getImageNameWithoutExtension(imageUrl) {
3238 - // Split the URL by "/"
3239 - var parts = imageUrl.split("/");
3240 -
3241 - // Get the last part which contains the image name
3242 - var imageNameWithExtension = parts[parts.length - 1];
3243 -
3244 - // Split the image name by period (.)
3245 - var imageNameParts = imageNameWithExtension.split(".");
3246 -
3247 - // Remove the last part (which is the extension) and join the remaining parts
3248 - var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
3249 -
3250 - // Return the image name without extension
3251 - return imageNameWithoutExtension;
3252 - }';
3253 -
3254 -
3255 - $html .= '
3256 - jQuery("#pano' . $id . ' #custom-scene-navigation-nav' . $id . ' ul").on("click", "li.scene-navigation-list", function() {
3257 - if (scenes) {
3258 - jQuery(this).siblings("li").removeClass("active");
3259 - jQuery(this).addClass("active");
3260 -
3261 - var scene_key = jQuery(this).attr("scene_id");
3262 - panoshow' . $id . '.loadScene(scene_key);
3263 - }
3264 - });
3265 - ';
3266 - }
3267 -
3268 - //Duplicate mode only for vr mode end===//
3269 - $html .= 'panoshow' . $id . '.on("load", function (){
3270 -
3271 -// if(localStorage.getItem("vr_mode") == "off") {
3272 - if( vr_mode == "off") {
3273 - jQuery(".vr-mode-title").hide();
3274 - }
3275 - else {
3276 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3277 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3278 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
3279 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
3280 - jQuery(".vr-mode-title").show();
3281 - }
3282 -
3283 -
3284 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3285 - jQuery("#controls' . $id . '").css("bottom", "80px");
3286 - }
3287 - else {
3288 - jQuery("#controls' . $id . '").css("bottom", "5px");
3289 - }
3290 - });';
3291 -
3292 -
3293 - $html .= '
3294 - if (scenes.autoRotate) {
3295 - var wpvrAutoRotateTimer' . $id . ' = null;
3296 - var wpvrAutoRotateStopDelay' . $id . ' = parseInt(scenes.autoRotateStopDelay, 10) || 0;
3297 - var wpvrScheduleAutoRotate' . $id . ' = function () {
3298 - clearTimeout(wpvrAutoRotateTimer' . $id . ');
3299 - if (wpvrAutoRotateStopDelay' . $id . ' > 0) {
3300 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
3301 - panoshow' . $id . '.stopAutoRotate();
3302 - }, wpvrAutoRotateStopDelay' . $id . ');
3303 - } else {
3304 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
3305 - panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0);
3306 - }, 3000);
3307 - }
3308 - };
3309 - panoshow' . $id . '.on("load", wpvrScheduleAutoRotate' . $id . ');
3310 - panoshow' . $id . '.on("scenechange", wpvrScheduleAutoRotate' . $id . ');
3311 - }
3312 - ';
3313 - $html .= 'var touchtime = 0;';
3314 - if ($vrgallery) {
3315 - if (isset($panodata["scene-list"])) {
3316 - foreach ($panodata["scene-list"] as $panoscenes) {
3317 - $scene_key = $panoscenes['scene-id'];
3318 - $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
3319 - $img_src_url = $panoscenes['scene-attachment-url'];
3320 - // $html .= 'document.getElementById("' . $scene_key_gallery . '").addEventListener("click", function(e) { ';
3321 - // $html .= 'if (touchtime == 0) {';
3322 - // $html .= 'touchtime = new Date().getTime();';
3323 - // $html .= '} else {';
3324 - // $html .= 'if (((new Date().getTime()) - touchtime) < 800) {';
3325 - // $html .= 'panoshow' . $id . '.loadScene("' . $scene_key . '");';
3326 - // $html .= 'touchtime = 0;';
3327 - // $html .= '} else {';
3328 - // $html .= 'touchtime = new Date().getTime();';
3329 - // $html .= '}';
3330 - // $html .= '}';
3331 - // $html .= '});';
3332 - $html .= '
3333 - jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
3334 - panoshow' . $id . '.loadScene("' . $scene_key . '");
3335 - });
3336 - ';
3337 - }
3338 - }
3339 -
3340 - $html .= '
3341 - var owlGallery' . $id . ' = jQuery("#sccontrols' . $id . '").owlCarousel({
3342 - items: 1,
3343 - loop: true,
3344 - nav: false,
3345 - dots: false,
3346 - margin: 5,
3347 - stagePadding: 30
3348 - });
3349 - jQuery("#pano' . $id . '").on("click", ".wpvr_owl_prev", function() {
3350 - owlGallery' . $id . '.trigger("prev.owl.carousel");
3351 - });
3352 - jQuery("#pano' . $id . '").on("click", ".wpvr_owl_next", function() {
3353 - owlGallery' . $id . '.trigger("next.owl.carousel");
3354 - });
3355 - ';
3356 - }
3357 -
3358 -
3359 -
3360 - //===Custom Control===//
3361 - if (isset($custom_control)) {
3362 - if ($custom_control['panupSwitch'] == "on" && $status == 'valid' && $is_pro) {
3363 - $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
3364 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() + 10);';
3365 - $html .= '});';
3366 - }
3367 -
3368 - if ($custom_control['panDownSwitch'] == "on" && $status == 'valid' && $is_pro) {
3369 - $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
3370 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() - 10);';
3371 - $html .= '});';
3372 - }
3373 -
3374 - if ($custom_control['panLeftSwitch'] == "on" && $status == 'valid' && $is_pro) {
3375 - $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
3376 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() - 10);';
3377 - $html .= '});';
3378 - }
3379 -
3380 - if ($custom_control['panRightSwitch'] == "on" && $status == 'valid' && $is_pro) {
3381 - $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
3382 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() + 10);';
3383 - $html .= '});';
3384 - }
3385 -
3386 - if ($custom_control['panZoomInSwitch'] == "on") {
3387 - $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
3388 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() - 10);';
3389 - $html .= '});';
3390 - }
3391 -
3392 - if ($custom_control['panZoomOutSwitch'] == "on") {
3393 - $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
3394 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() + 10);';
3395 - $html .= '});';
3396 - }
3397 -
3398 - if ($custom_control['panFullscreenSwitch'] == "on" && $status == 'valid' && $is_pro) {
3399 - $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
3400 - $html .= 'panoshow' . $id . '.toggleFullscreen();';
3401 - $html .= '});';
3402 - $html .= '(function() {';
3403 - $html .= 'function wpvrFsChange' . $id . '() {';
3404 - $html .= 'var fsIcon = document.querySelector("#fullscreen' . $id . ' i");';
3405 - $html .= 'if (!fsIcon) return;';
3406 - $html .= 'if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {';
3407 - $html .= 'fsIcon.classList.remove("fa-expand"); fsIcon.classList.add("fa-minimize");';
3408 - $html .= '} else {';
3409 - $html .= 'fsIcon.classList.remove("fa-minimize"); fsIcon.classList.add("fa-expand");';
3410 - $html .= '}';
3411 - $html .= '}';
3412 - $html .= 'document.addEventListener("fullscreenchange", wpvrFsChange' . $id . ');';
3413 - $html .= 'document.addEventListener("webkitfullscreenchange", wpvrFsChange' . $id . ');';
3414 - $html .= 'document.addEventListener("mozfullscreenchange", wpvrFsChange' . $id . ');';
3415 - $html .= 'document.addEventListener("MSFullscreenChange", wpvrFsChange' . $id . ');';
3416 - $html .= '})();';
3417 - }
3418 -
3419 - if ($custom_control['backToHomeSwitch'] == "on" && $status == 'valid' && $is_pro) {
3420 - $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
3421 - $html .= 'panoshow' . $id . '.loadScene("' . $default_scene . '");';
3422 - $html .= '});';
3423 - }
3424 -
3425 - if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
3426 - $html .= '
3427 - (function() {
3428 - var gyroButton = document.getElementById("gyroscope' . $id . '");
3429 - var gyroIcon = gyroButton ? gyroButton.querySelector("i") : null;
3430 - var activeColor = ' . wp_json_encode($custom_control['gyroscopeColor']) . ';
3431 - var permissionGranted = false;
3432 -
3433 - if (!gyroButton || !gyroIcon) {
3434 - return;
3435 - }
3436 -
3437 - function updateGyroscopeState() {
3438 - gyroIcon.style.color = panoshow' . $id . '.isOrientationActive()
3439 - ? activeColor
3440 - : "red";
3441 - }
3442 -
3443 - function startGyroscope() {
3444 - if (!panoshow' . $id . '.isOrientationSupported()) {
3445 - updateGyroscopeState();
3446 - return;
3447 - }
3448 -
3449 - panoshow' . $id . '.startOrientation();
3450 - window.setTimeout(updateGyroscopeState, 0);
3451 - }
3452 -
3453 - function requestGyroscopePermission() {
3454 - var orientationEvent = window.DeviceOrientationEvent;
3455 - if (orientationEvent) {
3456 - if (typeof orientationEvent.requestPermission === "function") {
3457 - if (!permissionGranted) {
3458 - orientationEvent.requestPermission()
3459 - .then(function(state) {
3460 - permissionGranted = state === "granted";
3461 - if (permissionGranted) {
3462 - startGyroscope();
3463 - } else {
3464 - updateGyroscopeState();
3465 - }
3466 - })
3467 - .catch(updateGyroscopeState);
3468 - return;
3469 - }
3470 - }
3471 - }
3472 -
3473 - startGyroscope();
3474 - }
3475 -
3476 - panoshow' . $id . '.on("load", updateGyroscopeState);
3477 - panoshow' . $id . '.on("scenechange", updateGyroscopeState);
3478 -
3479 - gyroButton.addEventListener("click", function() {
3480 - if (panoshow' . $id . '.isOrientationActive()) {
3481 - panoshow' . $id . '.stopOrientation();
3482 - updateGyroscopeState();
3483 - return;
3484 - }
3485 -
3486 - requestGyroscopePermission();
3487 - });
3488 - })();';
3489 - }
3490 - }
3491 -
3492 - $angle_up = '<i class="fa fa-angle-up"></i>';
3493 - $angle_down = '<i class="fa fa-angle-down"></i>';
3494 - $sin_qout = "'";
3495 -
3496 - //===Explainer Script===//
3497 - $html .= '
3498 - jQuery(document).on("click","#explainer_button_' . $id . '",function() {
3499 - jQuery("#explainer' . $id . '").slideToggle(function(){
3500 - var $explainerVideoId = jQuery("#explainer' . $id . '");
3501 - var $explainerVideoIframe = $explainerVideoId.find("iframe");
3502 - var explainerVideoIframSrc = $explainerVideoIframe.attr("src");
3503 - $explainerVideoIframe.attr("src", "");
3504 - $explainerVideoIframe.attr("src", explainerVideoIframSrc);
3505 - });
3506 - });
3507 -
3508 - jQuery(document).on("click", ".close-explainer-video", function() {
3509 - var $explainer = jQuery(this).parent(".explainer");
3510 - var $iframe = $explainer.find("iframe");
3511 - var src = $iframe.attr("src");
3512 - $iframe.attr("src", "");
3513 - $explainer.hide();
3514 - $iframe.attr("src", src);
3515 - });
3516 -
3517 - jQuery(document).on("click","#pano' . $id . '",function(event) {
3518 - var isActiveModal = event.target.closest(".custom-ifram-wrapper");
3519 - var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
3520 - var isHotspot = event.target.closest(".pnlm-hotspot-base");
3521 - if( isActiveModal == null && isForm == null && isHotspot == null){
3522 - jQuery(".custom-ifram-wrapper .custom-ifram").empty();
3523 - jQuery(".custom-ifram-wrapper").hide();
3524 - jQuery(this).removeClass("show-modal");
3525 - jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
3526 - }else if(isForm != null){
3527 - jQuery(this).addClass("show-modal");
3528 - }
3529 - });
3530 -
3531 - ';
3532 - //===Explainer Script End===//
3533 -
3534 - //===generic form script===//
3535 - if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
3536 - $html .= '
3537 - jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
3538 - jQuery("#wpvr-generic-form' . $id . '").fadeToggle();
3539 - });
3540 -
3541 - jQuery(document).on("click",".close-generic-form",function() {
3542 - jQuery(this).parent(".wpvr-generic-form").fadeOut()
3543 - });
3544 - ';
3545 - }
3546 -
3547 - //===generic from script===//
3548 -
3549 - //===Floor map Script===//
3550 - $html .= '
3551 - jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
3552 - jQuery("#wpvr-floor-map' . $id . '").toggle().removeClass("fullwindow");
3553 - });
3554 -
3555 - jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
3556 - jQuery(this).addClass("fullwindow");
3557 - jQuery(this).parents(".pano-wrap").addClass("show-modal");
3558 - });
3559 -
3560 - jQuery(document).on("click",".close-floor-map-plan",function() {
3561 - jQuery(this).parent(".wpvr-floor-map").hide();
3562 - jQuery(this).parent(".wpvr-floor-map").removeClass("fullwindow");
3563 - jQuery(this).parents(".pano-wrap").removeClass("show-modal");
3564 - });
3565 -
3566 - ';
3567 - //===Floor map Script End===//
3568 -
3569 - if ($vrgallery_display) {
3570 - if (!$autoload) {
3571 - $html .= '
3572 - jQuery(document).ready(function($){
3573 - jQuery("#sccontrols' . $id . '").hide();
3574 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3575 - jQuery("#sccontrols' . $id . '").hide();
3576 - jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3577 - });
3578 - ';
3579 -
3580 - $html .= '
3581 - var slide' . $id . ' = "down";
3582 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3583 -
3584 - if (slide' . $id . ' == "up") {
3585 - jQuery(".vrgctrl' . $id . '").empty();
3586 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3587 - slide' . $id . ' = "down";
3588 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3589 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3590 - if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3591 - if (jQuery(this).is(":visible")) {
3592 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3593 - "display": "flex",
3594 - "justify-content": "center",
3595 - "align-items": "center",
3596 - "gap": "15px"
3597 - });
3598 - }
3599 - }
3600 - if (jQuery(".bricks-is-frontend").length) {
3601 - if (jQuery(this).is(":visible")) {
3602 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3603 - "display": "flex",
3604 - "justify-content": "center",
3605 - "align-items": "center"
3606 - });
3607 - }
3608 - }
3609 - });
3610 - }
3611 - else {
3612 - jQuery(".vrgctrl' . $id . '").empty();
3613 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3614 - slide' . $id . ' = "up";
3615 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3616 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3617 - if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3618 - if (jQuery(this).is(":visible")) {
3619 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3620 - "display": "flex",
3621 - "justify-content": "center",
3622 - "align-items": "center",
3623 - "gap": "15px"
3624 - });
3625 - }
3626 - }
3627 - if (jQuery(".bricks-is-frontend").length) {
3628 - if (jQuery(this).is(":visible")) {
3629 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3630 - "display": "flex",
3631 - "justify-content": "center",
3632 - "align-items": "center"
3633 - });
3634 - }
3635 - }
3636 - });
3637 - }
3638 - });
3639 - ';
3640 - } else {
3641 - $html .= '
3642 - jQuery(document).ready(function($){
3643 - jQuery("#sccontrols' . $id . '").show();
3644 - jQuery("#pano' . $id . ' .wpvr_slider_nav").show();
3645 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3646 - });
3647 - ';
3648 -
3649 - $html .= '
3650 - var slide' . $id . ' = "down";
3651 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3652 -
3653 - if (slide' . $id . ' == "up") {
3654 - jQuery(".vrgctrl' . $id . '").empty();
3655 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3656 - slide' . $id . ' = "down";
3657 - }
3658 - else {
3659 - jQuery(".vrgctrl' . $id . '").empty();
3660 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3661 - slide' . $id . ' = "up";
3662 - }
3663 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3664 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3665 - if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3666 - if (jQuery(this).is(":visible")) {
3667 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3668 - "display": "flex",
3669 - "justify-content": "center",
3670 - "align-items": "center",
3671 - "gap": "15px"
3672 - });
3673 - }
3674 - }
3675 - if (jQuery(".bricks-is-frontend").length) {
3676 - if (jQuery(this).is(":visible")) {
3677 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3678 - "display": "flex",
3679 - "justify-content": "center",
3680 - "align-items": "center"
3681 - });
3682 - }
3683 - }
3684 - });
3685 - });
3686 - ';
3687 - }
3688 - } else {
3689 - $html .= '
3690 - jQuery(document).ready(function($){
3691 - jQuery("#sccontrols' . $id . '").hide();
3692 - jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3693 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3694 - });
3695 - ';
3696 -
3697 - $html .= '
3698 - var slide' . $id . ' = "down";
3699 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3700 -
3701 - if (slide' . $id . ' == "up") {
3702 - jQuery(".vrgctrl' . $id . '").empty();
3703 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3704 - slide' . $id . ' = "down";
3705 - }
3706 - else {
3707 - jQuery(".vrgctrl' . $id . '").empty();
3708 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3709 - slide' . $id . ' = "up";
3710 - }
3711 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3712 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3713 - if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3714 - if (jQuery(this).is(":visible")) {
3715 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3716 - "display": "flex",
3717 - "justify-content": "center",
3718 - "align-items": "center",
3719 - "gap": "15px"
3720 - });
3721 - }
3722 - }
3723 - if (jQuery(".bricks-is-frontend").length) {
3724 - if (jQuery(this).is(":visible")) {
3725 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3726 - "display": "flex",
3727 - "justify-content": "center",
3728 - "align-items": "center"
3729 - });
3730 - }
3731 - }
3732 - });
3733 - });
3734 - ';
3735 - }
3736 -
3737 - if (!$autoload) {
3738 - $html .= '
3739 -
3740 - jQuery(document).ready(function(){
3741 - jQuery("#controls' . $id . '").hide();
3742 - jQuery("#zoom-in-out-controls' . $id . '").hide();
3743 - jQuery("#adcontrol' . $id . '").hide();
3744 - jQuery("#explainer_button_' . $id . '").hide();
3745 - jQuery("#generic_form_button_' . $id . '").hide();
3746 - jQuery("#floor_map_button_' . $id . '").hide();
3747 - jQuery("#vrgcontrols' . $id . '").hide();
3748 - jQuery("#cp-logo-controls").hide();
3749 - jQuery(".custom-scene-navigation").hide();
3750 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
3751 - });
3752 -
3753 - ';
3754 -
3755 - if ($vrgallery_display) {
3756 - $html .= 'var load_once = "true";';
3757 - $html .= 'panoshow' . $id . '.on("load", function (){
3758 - if (load_once == "true") {
3759 - load_once = "false";
3760 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3761 - if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3762 - if (jQuery(this).is(":visible")) {
3763 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css("display", "flex");
3764 - }
3765 - }
3766 - if (jQuery(".bricks-is-frontend").length) {
3767 - if (jQuery(this).is(":visible")) {
3768 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3769 - "display": "flex",
3770 - "justify-content": "center",
3771 - "align-items": "center"
3772 - });
3773 - }
3774 - }
3775 - });
3776 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3777 - }
3778 - });';
3779 - }
3780 -
3781 - $html .= 'panoshow' . $id . '.on("load", function (){
3782 - jQuery("#controls' . $id . '").show();
3783 - jQuery("#zoom-in-out-controls' . $id . '").show();
3784 - jQuery("#adcontrol' . $id . '").show();
3785 - jQuery("#explainer_button_' . $id . '").show();
3786 - jQuery("#generic_form_button_' . $id . '").show();
3787 - jQuery("#floor_map_button_' . $id . '").show();
3788 - jQuery("#vrgcontrols' . $id . '").show();
3789 - jQuery("#cp-logo-controls").show();
3790 - jQuery(".custom-scene-navigation").show();
3791 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
3792 - });';
3793 - }
3794 -
3795 - $previewText = $postdata['previewtext'] ?? 'Click To Load Panorama';
3796 - if ($previewText) {
3797 - $html .= '
3798 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previewText. '")
3799 - ';
3800 - } else {
3801 - $html .= '
3802 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("Click To Load Panorama")
3803 - ';
3804 - }
3805 -
3806 - $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3807 - jQuery(this).attr("title", jQuery(this).text());
3808 - });
3809 - jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3810 - jQuery(this).removeAttr("title");
3811 - });';
3812 - $html .= '});';
3813 - $html .= '</script>';
3814 -
3815 - $tour_data = [];
3816 - if(defined("WPVR_PRO_VERSION")){
3817 - $tour_data = array(
3818 - 'explainerControlSwitch' => (
3819 - isset( $postdata['explainerSwitch'] )
3820 - && in_array( $postdata['explainerSwitch'], array( true, 1, '1', 'on' ), true )
3821 - ) ? 'on' : 'off',
3822 - 'floor_plan_enable' => $floor_plan_enable ?? false,
3823 - 'floor_plan_image' => $floor_plan_image ?? '',
3824 - 'custom_control' => $custom_control ?? [],
3825 - );
3826 - }
3827 - return apply_filters('wpvr_generate_tour_layout_html', $html ,$postdata ,$id, $tour_data);
785 + return $output;
3828 786 }
3829 787
3830 -function sanitize_content_preserve_styles($content) {
788 +function sanitize_content_preserve_styles($content, $allow_forms = false) {
3831 789 // Decode HTML entities first (in case content was encoded in database)
3832 790 $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
3833 791
3834 - // Escape <script> blocks to display as text instead of removing them
3835 - $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
3836 - return esc_html($matches[0]); // Convert to plain text
3837 - }, $content);
792 + // Escape or strip <script> blocks
793 + if ($allow_forms) {
794 + $content = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $content);
795 + } else {
796 + $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
797 + return esc_html($matches[0]); // Convert to plain text
798 + }, $content);
799 + }
3838 800
3839 801 // Strip dangerous URL-based attributes
3840 802 $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*(javascript|vbscript|data|about):/i', '$1=""', $content);
3841 803
@@ -3848,11 +810,16 @@
3848 810 // Handle unquoted event handlers
3849 811 return ' ' . esc_html($matches[1]) . '=' . esc_html($matches[2]);
3850 812 }, $content);
3851 813
3852 - // Remove all unsafe embedded/interactive elements except iframe
3853 - $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
3854 - $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
814 + // Remove unsafe embedded/interactive elements
815 + if ($allow_forms) {
816 + $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base)\b[^>]*>/i', '', $content);
817 + $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base)>/i', '', $content);
818 + } else {
819 + $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
820 + $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
821 + }
3855 822
3856 823 // Clean style attributes safely
3857 824 $content = preg_replace_callback('/style\s*=\s*["\']([^"\']*)["\']/', function($matches) {
3858 825 $style = $matches[1];
@@ -3873,10 +840,16 @@
3873 840 $css = preg_replace('/-moz-binding\s*:/i', '', $css);
3874 841 return '<style>' . esc_html($css) . '</style>';
3875 842 }, $content);
3876 843
3877 - // Allow iframes from safe sources only (e.g., YouTube, Vimeo)
844 + // Allow iframes and styles from safe sources only
3878 845 $allowed_tags = wp_kses_allowed_html('post');
846 + $allowed_tags['style'] = [
847 + 'type' => true,
848 + 'id' => true,
849 + 'class' => true,
850 + 'media' => true,
851 + ];
3879 852 $allowed_tags['iframe'] = [
3880 853 'src' => true,
3881 854 'width' => true,
3882 855 'height' => true,
@@ -3904,8 +877,72 @@
3904 877 'srcset' => true,
3905 878 'sizes' => true,
3906 879 ];
3907 880
881 + if ($allow_forms) {
882 + $form_attributes = [
883 + 'id' => true,
884 + 'class' => true,
885 + 'style' => true,
886 + 'name' => true,
887 + 'value' => true,
888 + 'type' => true,
889 + 'placeholder' => true,
890 + 'action' => true,
891 + 'method' => true,
892 + 'target' => true,
893 + 'enctype' => true,
894 + 'disabled' => true,
895 + 'readonly' => true,
896 + 'required' => true,
897 + 'checked' => true,
898 + 'selected' => true,
899 + 'multiple' => true,
900 + 'size' => true,
901 + 'rows' => true,
902 + 'cols' => true,
903 + 'maxlength' => true,
904 + 'minlength' => true,
905 + 'min' => true,
906 + 'max' => true,
907 + 'step' => true,
908 + 'pattern' => true,
909 + 'autocomplete' => true,
910 + 'autofocus' => true,
911 + 'for' => true,
912 + 'data-*' => true,
913 + 'data-form_id' => true,
914 + 'data-form_instance' => true,
915 + 'data-name' => true,
916 + 'data-type' => true,
917 + 'aria-invalid' => true,
918 + 'aria-required' => true,
919 + 'aria-label' => true,
920 + 'aria-describedby' => true,
921 + 'aria-labelledby' => true,
922 + ];
923 + $allowed_tags['form'] = $form_attributes;
924 + $allowed_tags['input'] = $form_attributes;
925 + $allowed_tags['button'] = $form_attributes;
926 + $allowed_tags['textarea'] = $form_attributes;
927 + $allowed_tags['select'] = $form_attributes;
928 + $allowed_tags['option'] = $form_attributes;
929 + $allowed_tags['optgroup'] = $form_attributes;
930 + $allowed_tags['label'] = $form_attributes;
931 + $allowed_tags['fieldset'] = $form_attributes;
932 + $allowed_tags['legend'] = $form_attributes;
933 + if (!isset($allowed_tags['div'])) {
934 + $allowed_tags['div'] = [];
935 + }
936 + $allowed_tags['div']['data-*'] = true;
937 + $allowed_tags['div']['data-form_id'] = true;
938 + $allowed_tags['div']['data-form_instance'] = true;
939 + if (!isset($allowed_tags['span'])) {
940 + $allowed_tags['span'] = [];
941 + }
942 + $allowed_tags['span']['data-*'] = true;
943 + }
944 +
3908 945 // Apply wp_kses() to keep only allowed tags/attributes
3909 946 $content = wp_kses($content, $allowed_tags);
3910 947
3911 948 // Finally, validate iframe src for security (allow https only, block javascript: etc.)
@@ -4020,15 +1057,22 @@
4020 1057 }
4021 1058
4022 1059 function wpvr_rest_route_permission()
4023 1060 {
4024 - return true;
1061 + $post_type_obj = get_post_type_object( 'wpvr_item' );
1062 + $edit_cap = $post_type_obj ? $post_type_obj->cap->edit_posts : 'edit_wpvr_tours';
1063 + return current_user_can( $edit_cap ) || current_user_can( 'edit_posts' );
4025 1064 }
4026 1065
4027 1066 function wpvr_rest_data_set()
4028 1067 {
1068 + $post_type_obj = get_post_type_object( 'wpvr_item' );
1069 + $edit_cap = $post_type_obj ? $post_type_obj->cap->edit_posts : 'edit_wpvr_tours';
1070 + $post_status = current_user_can( $edit_cap ) ? array( 'publish', 'draft', 'private' ) : 'publish';
1071 +
4029 1072 $query = new WP_Query(array(
4030 - 'post_type' => 'wpvr_item',
1073 + 'post_type' => 'wpvr_item',
1074 + 'post_status' => $post_status,
4031 1075 'posts_per_page' => -1,
4032 1076 ));
4033 1077
4034 1078 $wpvr_list = array();
@@ -4041,8 +1085,9 @@
4041 1085 $title = $post_id . ' : ' . $title;
4042 1086 $list_ob = array('value' => $post_id, 'label' => $title);
4043 1087 array_push($wpvr_list, $list_ob);
4044 1088 }
1089 + wp_reset_postdata();
4045 1090
4046 1091 return $wpvr_list;
4047 1092 }
4048 1093
@@ -4238,9 +1283,9 @@
4238 1283 function ($api) {
4239 1284 $elementsToRegister = [
4240 1285 'wpvrelement',
4241 1286 ];
4242 - $pluginBaseUrl = rtrim(plugins_url(basename(__DIR__)), '\\/');
1287 + $pluginBaseUrl = rtrim(WPVR_PLUGIN_DIR_URL, '\\/');
4243 1288 /** @var \VisualComposer\Modules\Elements\ApiController $elementsApi */
4244 1289 $elementsApi = $api->elements;
4245 1290 foreach ($elementsToRegister as $tag) {
4246 1291 $manifestPath = __DIR__ . '/vc/' . $tag . '/manifest.json';
@@ -4351,5 +1396,30 @@
4351 1396 }
4352 1397 }
4353 1398
4354 1399 return wp_kses( $content, $allowed_tags );
1400 +}
1401 +
1402 +add_filter('fluentform/form_vars_for_JS', 'wpvr_fluent_form_register_inline_vars', 10, 2);
1403 +/**
1404 + * Register Fluent Forms JS vars safely via WordPress script API.
1405 + * Prevents raw script tag concatenation in HTML while ensuring form handlers initialize.
1406 + *
1407 + * @param array $vars Form configuration variables from Fluent Forms.
1408 + * @param object $form Fluent Form database record.
1409 + * @return array
1410 + */
1411 +function wpvr_fluent_form_register_inline_vars($vars, $form) {
1412 + if (!empty($vars['form_instance'])) {
1413 + $inline_js = 'window.fluent_form_' . esc_js($vars['form_instance']) . ' = ' . wp_json_encode($vars) . ';';
1414 + if (wp_script_is('fluent-form-submission', 'done') || wp_doing_ajax()) {
1415 + if (function_exists('wp_print_inline_script_tag')) {
1416 + wp_print_inline_script_tag($inline_js);
1417 + } else {
1418 + echo '<script type="text/javascript">' . $inline_js . '</script>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1419 + }
1420 + } else {
1421 + wp_add_inline_script('fluent-form-submission', $inline_js, 'before');
1422 + }
1423 + }
1424 + return $vars;
4355 1425 }