PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.2.0
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.2.0
9.2.0 9.1.4 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 All 224 releases
← All changes | legacy/admin/classes/class-wpvr-scene.php +1059 -681 9.0.2 → 9.2.0 View file →
@@ -114,16 +114,28 @@
114 114 <?php $this->render_default_repeater_item(); ?>
115 115 </div>
116 116 <!-- Empty repeater end -->
117 117
118 - <?php $s = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
119 - foreach ($postdata['panodata']["scene-list"] as $pano_scene) { ?>
118 + <?php
119 + if ( ! empty( $postdata['panodata']["scene-list"] ) && is_array( $postdata['panodata']["scene-list"] ) ) {
120 + $s = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
121 + $default_scene = $postdata['defaultscene'] ?? ($firstvalue['scene-id'] ?? '');
122 + foreach ($postdata['panodata']["scene-list"] as $pano_scene) {
123 + if ( ! is_array( $pano_scene ) ) {
124 + continue;
125 + }
126 + if ( ! isset( $pano_scene['dscene'] ) ) {
127 + $pano_scene['dscene'] = ( ! empty( $default_scene ) && ( $pano_scene['scene-id'] ?? '' ) === $default_scene ) ? 'on' : 'off';
128 + }
129 + $is_active = ( ( $pano_scene['scene-id'] ?? '' ) === ( $firstvalue['scene-id'] ?? '' ) );
130 + ?>
120 131
121 - <div data-repeater-item class="single-scene rex-pano-tab <?php if($pano_scene['scene-id'] == $firstvalue['scene-id']) { echo esc_attr('active'); }; ?>" data-title="1" id="scene-<?php echo esc_attr( $s ); ?>">
132 + <div data-repeater-item class="single-scene rex-pano-tab <?php if($is_active) { echo esc_attr('active'); }; ?>" data-title="1" id="scene-<?php echo esc_attr( $s ); ?>">
122 133 <?php $this->render_repeater_item_with_panodata($pano_scene, $s); ?>
123 134 </div>
124 135
125 - <?php $s++; } ?>
136 + <?php $s++; }
137 + } ?>
126 138 </div>
127 139 <?php
128 140 // ob_end_flush();
129 141 }
@@ -141,18 +153,26 @@
141 153 {
142 154 ob_start();
143 155 ?>
144 156 <ul>
145 - <?php $i = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
146 - foreach ($postdata['panodata']["scene-list"] as $pano_scene) { ?>
157 + <?php
158 + if ( ! empty( $postdata['panodata']["scene-list"] ) && is_array( $postdata['panodata']["scene-list"] ) ) {
159 + $i = 1; $firstvalue = reset($postdata['panodata']["scene-list"]);
160 + foreach ($postdata['panodata']["scene-list"] as $pano_scene) {
161 + if ( ! is_array( $pano_scene ) ) {
162 + continue;
163 + }
164 + $is_active = ( ( $pano_scene['scene-id'] ?? '' ) === ( $firstvalue['scene-id'] ?? '' ) );
165 + ?>
147 166
148 - <li class="<?php if ($pano_scene['scene-id'] == $firstvalue['scene-id']) {echo 'active';};?>">
167 + <li class="<?php if ($is_active) {echo 'active';};?>">
149 168 <span data-index="<?php echo esc_attr( $i ); ?>" data-href="#scene-<?php echo esc_attr( $i ); ?>">
150 169 <i class="fa fa-image"></i>
151 170 </span>
152 171 </li>
153 172
154 - <?php $i++; } ?>
173 + <?php $i++; }
174 + } ?>
155 175 <li class="add" data-repeater-create><span><i class="fa fa-plus-circle"></i></span></li>
156 176 </ul>
157 177 <?php
158 178 ob_end_flush();
@@ -888,10 +908,10 @@
888 908 if (isset($postdata['scenefadeduration'])) {
889 909 $scene_fade_duration = $postdata['scenefadeduration'];
890 910 }
891 911
892 - $panodata = '';
893 - if (isset($postdata['panodata'])) {
912 + $panodata = array();
913 + if (isset($postdata['panodata']) && is_array($postdata['panodata'])) {
894 914 $panodata = $postdata['panodata'];
895 915 }
896 916
897 917 $hotspoticoncolor = '#00b4ff';
@@ -902,9 +922,10 @@
902 922 } else {
903 923 $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration);
904 924 }
905 925
906 - $scene_data = array();
926 + $scene_data = array();
927 + $mobile_media_resize = get_option('mobile_media_resize');
907 928
908 929 if (!empty($panodata["scene-list"])) {
909 930 foreach ($panodata["scene-list"] as $panoscenes) {
910 931 $scene_ititle = '';
@@ -1031,10 +1052,18 @@
1031 1052 ob_start();
1032 1053 do_action('wpvr_hotspot_content', $hotspot_data);
1033 1054 $hotspot_content = ob_get_clean();
1034 1055
1035 - if (!$hotspot_content) {
1036 - $hotspot_content = $hotspot_data["hotspot-content"];
1056 + $is_fluent_form = isset($hotspot_data["hotspot-type"]) && 'fluent_form' === $hotspot_data["hotspot-type"];
1057 +
1058 + if ($is_fluent_form) {
1059 + if (!empty($hotspot_content)) {
1060 + $hotspot_content = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $hotspot_content);
1061 + }
1062 + } else {
1063 + if (!$hotspot_content) {
1064 + $hotspot_content = $hotspot_data["hotspot-content"] ?? '';
1065 + }
1037 1066 }
1038 1067
1039 1068 $hotspot_url = $this->normalize_hotspot_external_url($hotspot_data["hotspot-url"] ?? '');
1040 1069
@@ -1054,16 +1083,11 @@
1054 1083 $hotspot_data['hotspot-hover'] ?? ''
1055 1084 );
1056 1085
1057 1086
1058 - if('fluent_form' !== $hotspot_data["hotspot-type"]){
1059 - $on_hover_content = $this->sanitize_content_preserve_styles($on_hover_content ?? '');
1060 - $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1061 - $on_click_content = $this->sanitize_content_preserve_styles($on_click_content ?? '');
1062 - }else{
1063 - $on_hover_content = $on_hover_content ?? '';
1064 - $on_click_content = $hotspot_content ?? '';
1065 - }
1087 + $on_hover_content = $this->sanitize_content_preserve_styles($on_hover_content ?? '', false);
1088 + $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1089 + $on_click_content = $this->sanitize_content_preserve_styles($on_click_content ?? '', $is_fluent_form);
1066 1090
1067 1091 // Shape is independent of the optional custom icon in the
1068 1092 // new editor, so it must always be included in the public
1069 1093 // hotspot configuration.
@@ -1115,41 +1139,134 @@
1115 1139 }
1116 1140 }
1117 1141 $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1118 1142
1119 - if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1120 - unset($hotspot_info["cssClass"]);
1143 + $is_sticker = ( ( $hotspot_data['hotspot-type'] ?? '' ) === 'sticker' );
1144 + if ( $is_sticker ) {
1145 + $custom_class_pro = ! empty( $hotspot_data['hotspot-customclass'] ) && $hotspot_data['hotspot-customclass'] !== 'none'
1146 + ? ' ' . $hotspot_data['hotspot-customclass']
1147 + : '';
1148 + $hotspot_info['cssClass'] = 'wpvr-hs-custom wpvr-hs-sticker' . $custom_class_pro;
1149 + $hotspot_info['scale'] = true;
1150 + $hotspot_info['stickerTemplate'] = $hotspot_data['hotspot-sticker-template'] ?? 'social_proof';
1151 + $hotspot_info['stickerReviewText'] = $hotspot_data['hotspot-sticker-review-text'] ?? 'The support is super responsive and responds without worries to our requests and needs! Big up to the entire RexTheme team!';
1152 + $hotspot_info['stickerClientName'] = $hotspot_data['hotspot-sticker-client-name'] ?? 'Elena R.';
1153 + $hotspot_info['stickerClientAvatar'] = $hotspot_data['hotspot-sticker-client-avatar'] ?? '';
1154 + $hotspot_info['stickerRating'] = isset( $hotspot_data['hotspot-sticker-rating'] ) ? (int) $hotspot_data['hotspot-sticker-rating'] : 5;
1155 + $is_separate_icon = ( $hotspot_data['hotspot-sticker-template'] ?? '' ) === 'button_with_separate_icon';
1156 + $is_add_to_cart = ( $hotspot_data['hotspot-sticker-template'] ?? '' ) === 'add_to_cart';
1157 + $is_social_share = ( $hotspot_data['hotspot-sticker-template'] ?? '' ) === 'social_share';
1158 + $hotspot_info['stickerBgColor'] = $hotspot_data['hotspot-sticker-bg-color'] ?? '#201b2c';
1159 + $hotspot_info['stickerBgOpacity'] = isset( $hotspot_data['hotspot-sticker-bg-opacity'] ) ? (float) $hotspot_data['hotspot-sticker-bg-opacity'] : ( ( $is_separate_icon || $is_add_to_cart || $is_social_share ) ? 75 : 95 );
1160 + $hotspot_info['stickerBlur'] = isset( $hotspot_data['hotspot-sticker-blur'] ) ? (float) $hotspot_data['hotspot-sticker-blur'] : 12;
1161 + $hotspot_info['stickerBrightness'] = isset( $hotspot_data['hotspot-sticker-brightness'] ) ? (float) $hotspot_data['hotspot-sticker-brightness'] : 100;
1162 + $hotspot_info['stickerTextColor'] = $hotspot_data['hotspot-sticker-text-color'] ?? '#ffffff';
1163 + $hotspot_info['stickerBorderColor'] = $hotspot_data['hotspot-sticker-border-color'] ?? ( ( $is_separate_icon || $is_add_to_cart || $is_social_share ) ? '#40355a' : '#3a3051' );
1164 + $default_radius = $is_separate_icon ? 135 : ( ( $is_add_to_cart || $is_social_share ) ? 15 : 20 );
1165 + $hotspot_info['stickerBorderRadius'] = $hotspot_data['hotspot-sticker-border-radius'] ?? [
1166 + 'topLeft' => $default_radius,
1167 + 'topRight' => $default_radius,
1168 + 'bottomRight' => $default_radius,
1169 + 'bottomLeft' => $default_radius,
1170 + ];
1171 + $hotspot_info['stickerPadding'] = $hotspot_data['hotspot-sticker-padding'] ?? [
1172 + 'top' => 21,
1173 + 'right' => 21,
1174 + 'bottom' => 21,
1175 + 'left' => 21,
1176 + ];
1177 + $hotspot_info['stickerStarColor'] = $hotspot_data['hotspot-sticker-star-color'] ?? '#EF991F';
1178 + // Text before button (for add_to_cart)
1179 + $hotspot_info['stickerPrefixText'] = $hotspot_data['hotspot-sticker-prefix-text'] ?? '$1,090 -';
1180 + $hotspot_info['stickerSubText'] = $hotspot_data['hotspot-sticker-sub-text'] ?? 'Ready to ship';
1181 + // Discount button, add to cart & social share sticker fields
1182 + $hotspot_info['stickerBtnText'] = $hotspot_data['hotspot-sticker-btn-text'] ?? ( $is_social_share ? 'SHARE EXPERIENCE' : ( $is_add_to_cart ? 'ADD TO CART' : ( $is_separate_icon ? 'Limited “Midnight Horizon” Edition' : 'GET 20% OFF NOW' ) ) );
1183 + $hotspot_info['stickerBtnColor'] = $hotspot_data['hotspot-sticker-btn-color'] ?? ( $is_social_share ? '#201a2b' : ( $is_add_to_cart ? '#3f04fe' : ( $is_separate_icon ? '#ffffff' : '#EF991F' ) ) );
1184 + $hotspot_info['stickerBtnTextColor'] = $hotspot_data['hotspot-sticker-btn-text-color'] ?? ( ( $is_add_to_cart || $is_social_share ) ? '#ffffff' : '#000000' );
1185 + $hotspot_info['stickerBtnIconColor'] = $hotspot_data['hotspot-sticker-btn-icon-color'] ?? '#000000';
1186 + $hotspot_info['stickerBtnUrl'] = $hotspot_data['hotspot-sticker-btn-url'] ?? '';
1187 + $hotspot_info['stickerBtnNewTab'] = $hotspot_data['hotspot-sticker-btn-new-tab'] ?? 'off';
1188 + $hotspot_info['stickerMainBg'] = $hotspot_data['hotspot-sticker-main-bg'] ?? ( $hotspot_data['hotspot-sticker-card-bg'] ?? 'on' );
1189 + $hotspot_info['stickerCardBg'] = $hotspot_info['stickerMainBg'];
1190 + $hotspot_info['stickerBtnBg'] = $hotspot_data['hotspot-sticker-btn-bg'] ?? 'on';
1191 + $hotspot_info['stickerBtnWidth'] = isset( $hotspot_data['hotspot-sticker-btn-width'] ) && $hotspot_data['hotspot-sticker-btn-width'] !== '' ? $hotspot_data['hotspot-sticker-btn-width'] : ( $is_social_share ? 222 : ( $is_add_to_cart ? 163 : ( $is_separate_icon ? 356 : '' ) ) );
1192 + $hotspot_info['stickerBtnHeight'] = isset( $hotspot_data['hotspot-sticker-btn-height'] ) && $hotspot_data['hotspot-sticker-btn-height'] !== '' ? $hotspot_data['hotspot-sticker-btn-height'] : ( ( $is_social_share || $is_add_to_cart || $is_separate_icon ) ? 60 : '' );
1193 + $hotspot_info['stickerBtnRadius'] = isset( $hotspot_data['hotspot-sticker-btn-radius'] ) && $hotspot_data['hotspot-sticker-btn-radius'] !== '' ? (float) $hotspot_data['hotspot-sticker-btn-radius'] : ( $is_separate_icon ? 30 : 10 );
1194 + $hotspot_info['stickerBtnBorder'] = isset( $hotspot_data['hotspot-sticker-btn-border'] ) && $hotspot_data['hotspot-sticker-btn-border'] !== '' ? (float) $hotspot_data['hotspot-sticker-btn-border'] : ( $is_social_share ? 1 : 0 );
1195 + $hotspot_info['stickerBtnBorderColor'] = $hotspot_data['hotspot-sticker-btn-border-color'] ?? ( $is_social_share ? '#3a3051' : ( ( $is_add_to_cart || $is_separate_icon ) ? '#ffffff' : '#EF991F' ) );
1196 + $hotspot_info['stickerBtnTextSize'] = isset( $hotspot_data['hotspot-sticker-btn-text-size'] ) && $hotspot_data['hotspot-sticker-btn-text-size'] !== '' ? (float) $hotspot_data['hotspot-sticker-btn-text-size'] : 18;
1197 + $hotspot_info['stickerBtnTextWeight'] = $hotspot_data['hotspot-sticker-btn-text-weight'] ?? ( ( $is_social_share || $is_add_to_cart || $is_separate_icon ) ? '600' : '700' );
1198 + $hotspot_info['stickerBtnIcon'] = ( $is_add_to_cart || $is_social_share ) ? 'none' : ( $hotspot_data['hotspot-sticker-btn-icon'] ?? 'fas fa-tag' );
1199 + // Button with separate icon fields
1200 + $hotspot_info['stickerIconBoxBgColor'] = $hotspot_data['hotspot-sticker-icon-box-bg-color'] ?? '#ffffff';
1201 + $hotspot_info['stickerIconBoxRadius'] = isset( $hotspot_data['hotspot-sticker-icon-box-radius'] ) && $hotspot_data['hotspot-sticker-icon-box-radius'] !== '' ? (float) $hotspot_data['hotspot-sticker-icon-box-radius'] : 30;
1202 + $hotspot_info['stickerIconBoxBorder'] = isset( $hotspot_data['hotspot-sticker-icon-box-border'] ) && $hotspot_data['hotspot-sticker-icon-box-border'] !== '' ? (float) $hotspot_data['hotspot-sticker-icon-box-border'] : 0;
1203 + $hotspot_info['stickerIconBoxBorderColor'] = $hotspot_data['hotspot-sticker-icon-box-border-color'] ?? '#ffffff';
1204 + $hotspot_info['stickerIconBoxSize'] = isset( $hotspot_data['hotspot-sticker-icon-box-size'] ) && $hotspot_data['hotspot-sticker-icon-box-size'] !== '' ? (float) $hotspot_data['hotspot-sticker-icon-box-size'] : 60;
1205 + // Social share sticker fields
1206 + $hotspot_info['stickerSocialColor'] = $hotspot_data['hotspot-sticker-social-color'] ?? '#ffffff';
1207 + $hotspot_info['stickerSocialSize'] = isset( $hotspot_data['hotspot-sticker-social-size'] ) && $hotspot_data['hotspot-sticker-social-size'] !== '' ? (float) $hotspot_data['hotspot-sticker-social-size'] : 20;
1208 + $hotspot_info['stickerSocialGap'] = isset( $hotspot_data['hotspot-sticker-social-gap'] ) && $hotspot_data['hotspot-sticker-social-gap'] !== '' ? (float) $hotspot_data['hotspot-sticker-social-gap'] : 16;
1209 + $hotspot_info['stickerSocialLinks'] = isset( $hotspot_data['hotspot-sticker-social-links'] ) ? ( is_array( $hotspot_data['hotspot-sticker-social-links'] ) ? $hotspot_data['hotspot-sticker-social-links'] : json_decode( (string) $hotspot_data['hotspot-sticker-social-links'], true ) ) : [
1210 + [ 'id' => '1', 'icon' => 'fab fa-linkedin-in', 'customSvg' => '', 'url' => 'https://linkedin.com', 'openNewTab' => 'on' ],
1211 + [ 'id' => '2', 'icon' => 'fab fa-facebook-f', 'customSvg' => '', 'url' => 'https://facebook.com', 'openNewTab' => 'on' ],
1212 + [ 'id' => '3', 'icon' => 'fab fa-instagram', 'customSvg' => '', 'url' => 'https://instagram.com', 'openNewTab' => 'on' ],
1213 + [ 'id' => '4', 'icon' => 'fab fa-dribbble', 'customSvg' => '', 'url' => 'https://dribbble.com', 'openNewTab' => 'on' ],
1214 + ];
1215 + $hotspot_info['stickerShowPlaceholderText'] = $hotspot_data['hotspot-sticker-show-placeholder-text'] ?? 'on';
1216 + } else {
1217 + if ( isset( $hotspot_data['hotspot-scale'] ) && ( $hotspot_data['hotspot-scale'] === 'on' || $hotspot_data['hotspot-scale'] === true ) ) {
1218 + $hotspot_info['scale'] = true;
1219 + }
1220 + if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1221 + unset($hotspot_info["cssClass"]);
1222 + }
1121 1223 }
1122 1224 array_push($hotspots, $hotspot_info);
1123 1225 }
1124 1226
1125 - $device_scene = $panoscenes['scene-attachment-url'];
1126 - $mobile_media_resize = get_option('mobile_media_resize');
1127 - $file_accessible = ini_get('allow_url_fopen');
1128 - if ($mobile_media_resize == "true" && $device_scene ) {
1129 - if ($file_accessible == "1") {
1130 - $image_info = getimagesize($device_scene);
1131 - if ( isset($image_info[0]) && $image_info[0] > 4096) {
1132 - $src_to_id_for_mobile = '';
1133 - $src_to_id_for_desktop = '';
1134 - if (wpvr_isMobileDevice()) {
1135 - $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1136 - if ($src_to_id_for_mobile) {
1137 - $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1138 - if ($mobile_scene[3]) {
1139 - $device_scene = $mobile_scene[0];
1140 - }
1227 + $device_scene = $panoscenes['scene-attachment-url'];
1228 + $mobile_scene_url = '';
1229 + $desktop_scene_url = $device_scene;
1230 +
1231 + if ($mobile_media_resize == "true" && !empty($device_scene)) {
1232 + $attachment_id = !empty($panoscenes['scene-attachment-id'])
1233 + ? (int) $panoscenes['scene-attachment-id']
1234 + : $this->get_attachment_id_by_url($device_scene);
1235 +
1236 + if ($attachment_id) {
1237 + $image_width = 0;
1238 + $image_meta = wp_get_attachment_metadata($attachment_id);
1239 +
1240 + if (isset($image_meta['width'])) {
1241 + $image_width = (int) $image_meta['width'];
1242 + } elseif (function_exists('get_attached_file')) {
1243 + // Local file fallback only if attachment metadata is missing (no network request)
1244 + $file_path = get_attached_file($attachment_id);
1245 + if ($file_path && file_exists($file_path)) {
1246 + $image_info = @getimagesize($file_path);
1247 + if (isset($image_info[0])) {
1248 + $image_width = (int) $image_info[0];
1141 1249 }
1142 - } else {
1143 - $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1144 - if ($src_to_id_for_desktop) {
1145 - $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1146 - if (isset($desktop_scene[0])) {
1147 - $device_scene = $desktop_scene[0];
1148 - }
1149 - }
1150 1250 }
1151 1251 }
1252 +
1253 + if ($image_width > 4096) {
1254 + $mobile_scene = wp_get_attachment_image_src($attachment_id, 'wpvr_mobile');
1255 + if (!empty($mobile_scene[3])) { // is_intermediate verifies resized image exists
1256 + $mobile_scene_url = $mobile_scene[0];
1257 + }
1258 +
1259 + $desktop_scene = wp_get_attachment_image_src($attachment_id, 'full');
1260 + if (isset($desktop_scene[0])) {
1261 + $desktop_scene_url = $desktop_scene[0];
1262 + $device_scene = $desktop_scene[0];
1263 + }
1264 +
1265 + if (wpvr_isMobileDevice() && !empty($mobile_scene_url)) {
1266 + $device_scene = $mobile_scene_url;
1267 + }
1268 + }
1152 1269 }
1153 1270 }
1154 1271
1155 1272 $scene_info = array();
@@ -1166,8 +1283,13 @@
1166 1283
1167 1284 $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);
1168 1285 } else {
1169 1286 $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);
1287 + if (!empty($mobile_scene_url)) {
1288 + $scene_info['mobile_panorama'] = $mobile_scene_url;
1289 + $scene_info['desktop_panorama'] = $desktop_scene_url;
1290 + $scene_info['desktop_width'] = $image_width;
1291 + }
1170 1292 }
1171 1293
1172 1294
1173 1295 if (isset($panoscenes["ptyscene"])) {
@@ -1293,14 +1415,21 @@
1293 1415 if(isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on'){
1294 1416 $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
1295 1417 }
1296 1418 }
1297 - $panoid2 = 'pano2'.$id;
1419 + $pano_suffix = (strpos($panoid, 'pano') === 0) ? substr($panoid, 4) : (string) $panoid;
1420 + $panoid2 = 'pano2' . $pano_suffix;
1421 + $master_container_id = ($panoid === 'pano' . $id) ? 'master-container' : ('master-container-' . $pano_suffix);
1298 1422 $status = get_option('wpvr_edd_license_status');
1299 - if ($status !== false && $status == 'valid') {
1423 + if ($status !== false && $status == 'valid' && ! empty( $panodata['scene-list'] ) && is_array( $panodata['scene-list'] )) {
1300 1424 foreach ($panodata['scene-list'] as $panoscenes){
1301 -
1425 + if ( empty( $panoscenes['hotspot-list'] ) || ! is_array( $panoscenes['hotspot-list'] ) ) {
1426 + continue;
1427 + }
1302 1428 foreach($panoscenes['hotspot-list'] as $hotspot){
1429 + if ( ( $hotspot['hotspot-type'] ?? '' ) === 'sticker' ) {
1430 + continue;
1431 + }
1303 1432 if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1304 1433 $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1305 1434 } else {
1306 1435 $hotspoticoncolor = "#00b4ff";
@@ -1495,16 +1624,24 @@
1495 1624 $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration,$animationDelay,$postdata,$id);
1496 1625 $html .= $animation_css;
1497 1626 }
1498 1627
1628 + $container_width = $width;
1629 + $container_height = $height;
1630 + $container_mobile_height = $mobile_height;
1631 +
1499 1632 if ($width == 'fullwidth') {
1500 - $width = "100%";
1633 + $container_width = "100%";
1634 + } elseif ($width == 'embed') {
1635 + $container_width = "100%";
1636 + $container_height = "100%";
1637 + $container_mobile_height = "100%";
1501 1638 }
1502 1639
1503 1640 if (wpvr_isMobileDevice()) {
1504 - $html .= '<div id="master-container" class="wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $width . '; width: 100%; height: ' . $mobile_height . '; border-radius:' . $radius . '; direction:ltr; ">';
1641 + $html .= '<div id="' . $master_container_id . '" class="wpvr-master-container wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $container_width . '; width: 100%; height: ' . $container_mobile_height . '; border-radius:' . $radius . '; direction:ltr; ">';
1505 1642 } else {
1506 - $html .= '<div id="master-container" class="wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $width . '; width: 100%; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr; ">';
1643 + $html .= '<div id="' . $master_container_id . '" class="wpvr-master-container wpvr-cardboard '.$enable_cardboard.'" style="max-width:' . $container_width . '; width: 100%; height: ' . $container_height . '; border-radius:' . $radius . '; direction:ltr; ">';
1507 1644 }
1508 1645 $is_pro = apply_filters('is_wpvr_pro_active',false);
1509 1646 $status = get_option('wpvr_edd_license_status');
1510 1647 $is_cardboard = get_option('wpvr_cardboard_disable');
@@ -1522,9 +1659,9 @@
1522 1659 if($width == "embed"){
1523 1660 $embed_mode = "vr-embade-mode";
1524 1661 }
1525 1662 $html .= '<label class="wpvr-cardboard-switcher '.$embed_mode.'">
1526 - <input type="checkbox" class="vr_mode_change' . $id . '" name="vr_mode_change" value="off">
1663 + <input type="checkbox" class="vr_mode_change' . $pano_suffix . '" name="vr_mode_change" value="off">
1527 1664 <span class="switcher-box">
1528 1665 <span class="normal-mode-tooltip">Normal VR Mode</span>
1529 1666 <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1530 1667 <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"/>
@@ -1536,43 +1673,43 @@
1536 1673
1537 1674 if ($width == 'fullwidth') {
1538 1675 if (wpvr_isMobileDevice()) {
1539 1676 $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
1540 - $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left cardboard-half" style="width: 49%!important; border-radius:' . $radius . ' text-align:center; direction:ltr;" ><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1541 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%; text-align:center; direction:ltr; border-radius:' . $radius . '" >';
1677 + $html .= '<div id="' . $panoid2 . '" class="pano-wrap pano-left cardboard-half pano2' . $id . '" style="width: 49%!important; border-radius:' . $radius . ' text-align:center; direction:ltr;" ><div id="center-pointer2' . $pano_suffix . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1678 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style="width: 100%; text-align:center; direction:ltr; border-radius:' . $radius . '" >';
1542 1679 } else {
1543 - $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1680 + $html .= '<div id="' . $panoid2 . '" class="pano-wrap pano-left pano2' . $id . '" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $pano_suffix . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1544 1681 if ($radius) {
1545 - $html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr;" >';
1682 + $html .= '<div id="' . $panoid . '" class="pano-wrap vrfullwidth pano' . $id . '" style=" text-align:center; height: ' . $height . '; border-radius:' . $radius . '; direction:ltr;" >';
1546 1683 } else {
1547 - $html .= '<div id="pano' . $id . '" class="pano-wrap vrfullwidth" style=" text-align:center; height: ' . $height . '; direction:ltr;" >';
1684 + $html .= '<div id="' . $panoid . '" class="pano-wrap vrfullwidth pano' . $id . '" style=" text-align:center; height: ' . $height . '; direction:ltr;" >';
1548 1685 }
1549 1686 }
1550 1687 } elseif ($width == 'embed') {
1551 1688 $html .= '<div class="cardboard-vrembed vrembed">';
1552 - $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style=" width: 49%!important; text-align:center; direction:ltr;" ><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1553 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" text-align:center; direction:ltr;" >';
1689 + $html .= '<div id="' . $panoid2 . '" class="pano-wrap pano-left pano2' . $id . '" style=" width: 49%!important; text-align:center; direction:ltr;" ><div id="center-pointer2' . $pano_suffix . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1690 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style="width: 100%; height: 100%; text-align:center; direction:ltr;" >';
1554 1691 } else {
1555 1692 if (wpvr_isMobileDevice()) {
1556 - $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left cardboard-half" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1693 + $html .= '<div id="' . $panoid2 . '" class="pano-wrap pano-left cardboard-half pano2' . $id . '" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $pano_suffix . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1557 1694 if ($radius) {
1558 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" width: 100%; border-radius:' . $radius . ';">';
1695 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style=" width: 100%; border-radius:' . $radius . ';">';
1559 1696 } else {
1560 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style=" width: 100%; ">';
1697 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style=" width: 100%; ">';
1561 1698 }
1562 1699 } else {
1563 - $html .= '<div id="pano2' . $id . '" class="pano-wrap pano-left" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $id . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1700 + $html .= '<div id="' . $panoid2 . '" class="pano-wrap pano-left pano2' . $id . '" style="width: 49%; border-radius:' . $radius . '"><div id="center-pointer2' . $pano_suffix . '" class="vr-pointer-container"><span class="center-pointer"></span></div></div>';
1564 1701
1565 1702 if ($radius) {
1566 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%; border-radius:' . $radius . ';">';
1703 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style="width: 100%; border-radius:' . $radius . ';">';
1567 1704 } else {
1568 - $html .= '<div id="pano' . $id . '" class="pano-wrap pano-right" style="width: 100%;">';
1705 + $html .= '<div id="' . $panoid . '" class="pano-wrap pano-right pano' . $id . '" style="width: 100%;">';
1569 1706 }
1570 1707 }
1571 1708 }
1572 1709 // Vr mode transction scene to scene
1573 1710 if ($status !== false && 'valid' == $status && $is_pro) {
1574 - $html .= '<div id="center-pointer' . $id . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
1711 + $html .= '<div id="center-pointer' . $pano_suffix . '" class="vr-pointer-container" style="display:none"><span class="center-pointer"></span></div>';
1575 1712 }
1576 1713 $social_logo_top = '';
1577 1714 //===company logo===//
1578 1715 if (isset($postdata['cpLogoSwitch'])) {
@@ -1609,14 +1746,14 @@
1609 1746 $generic_form_icon = isset($postdata['genericformicon']) ? (string) $postdata['genericformicon'] : 'fab fa-wpforms';
1610 1747 $generic_form_icon = implode(' ', array_filter(array_map('sanitize_html_class', preg_split('/\s+/', $generic_form_icon))));
1611 1748 $generic_form_icon = $generic_form_icon ?: 'fab fa-wpforms';
1612 1749 $generic_form_icon_color = sanitize_hex_color($postdata['genericformiconcolor'] ?? '') ?: '#f7fffb';
1613 - $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr($id) . '">';
1614 - $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>';
1750 + $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr($pano_suffix) . '">';
1751 + $html .= '<div class="generic-form-icon" title ="Generic Form" id="generic_form_target_' . esc_attr($pano_suffix) . '"><i class="' . esc_attr($generic_form_icon) . '" style="color:' . esc_attr($generic_form_icon_color) . ';"></i></div>';
1615 1752 $html .= '</div>';
1616 1753
1617 1754 // Generate the modal form container
1618 - $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr($id) . '" style="display: none">';
1755 + $html .= '<div class="wpvr-generic-form" id="wpvr-generic-form' . esc_attr($pano_suffix) . '" style="display: none">';
1619 1756 $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
1620 1757 $html .= '<div class="generic-form-container">' . $shortcode_content . '</div>';
1621 1758 $html .= '</div>';
1622 1759 }
@@ -1669,23 +1806,23 @@
1669 1806 //===Custom Control===//
1670 1807 if (isset($custom_control)) {
1671 1808 $gyro_button_enabled = wpvr_isMobileDevice() && $custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on";
1672 1809 if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $gyro_button_enabled || $custom_control['backToHomeSwitch'] == "on") {
1673 - $html .= '<div id="zoom-in-out-controls' . $id . '" class="zoom-in-out-controls">';
1810 + $html .= '<div id="zoom-in-out-controls' . $pano_suffix . '" class="zoom-in-out-controls">';
1674 1811
1675 1812 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
1676 - $html .= '<div class="ctrl" id="backToHome' . $id . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . $custom_control['backToHomeColor'] . ';"></i></div>';
1813 + $html .= '<div class="ctrl" id="backToHome' . $pano_suffix . '"><i class="' . $custom_control['backToHomeIcon'] . '" style="color:' . $custom_control['backToHomeColor'] . ';"></i></div>';
1677 1814 }
1678 1815
1679 1816 if ($custom_control['panZoomInSwitch'] == "on" && 'valid' == $status && $is_pro) {
1680 - $html .= '<div class="ctrl" id="zoom-in' . $id . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . $custom_control['panZoomInColor'] . ';"></i></div>';
1817 + $html .= '<div class="ctrl" id="zoom-in' . $pano_suffix . '"><i class="' . $custom_control['panZoomInIcon'] . '" style="color:' . $custom_control['panZoomInColor'] . ';"></i></div>';
1681 1818 }
1682 1819
1683 1820 if ($custom_control['panZoomOutSwitch'] == "on" && 'valid' == $status && $is_pro) {
1684 - $html .= '<div class="ctrl" id="zoom-out' . $id . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . $custom_control['panZoomOutColor'] . ';"></i></div>';
1821 + $html .= '<div class="ctrl" id="zoom-out' . $pano_suffix . '"><i class="' . $custom_control['panZoomOutIcon'] . '" style="color:' . $custom_control['panZoomOutColor'] . ';"></i></div>';
1685 1822 }
1686 1823 if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
1687 - $html .= '<div class="ctrl" id="gyroscope' . $id . '" ><i class="' . $custom_control['gyroscopeIcon'] . '" style="color:' . $custom_control['gyroscopeColor'] . ';"></i></div>';
1824 + $html .= '<div class="ctrl" id="gyroscope' . $pano_suffix . '" ><i class="' . $custom_control['gyroscopeIcon'] . '" style="color:' . $custom_control['gyroscopeColor'] . ';"></i></div>';
1688 1825 }
1689 1826 $html .= '</div>';
1690 1827 }
1691 1828 //===zoom in out Control===//
@@ -1691,28 +1828,28 @@
1691 1828 //===zoom in out Control===//
1692 1829
1693 1830 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) {
1694 1831 //===Custom Control===//
1695 - $html .= '<div class="controls" id="controls' . $id . '">';
1832 + $html .= '<div class="controls" id="controls' . $pano_suffix . '">';
1696 1833
1697 1834 if ($custom_control['panupSwitch'] == "on") {
1698 - $html .= '<div class="ctrl pan-up" id="pan-up' . $id . '"><i class="' . $custom_control['panupIcon'] . '" style="color:' . $custom_control['panupColor'] . ';"></i></div>';
1835 + $html .= '<div class="ctrl pan-up" id="pan-up' . $pano_suffix . '"><i class="' . $custom_control['panupIcon'] . '" style="color:' . $custom_control['panupColor'] . ';"></i></div>';
1699 1836 }
1700 1837
1701 1838 if ($custom_control['panDownSwitch'] == "on") {
1702 - $html .= '<div class="ctrl pan-down" id="pan-down' . $id . '"><i class="' . $custom_control['panDownIcon'] . '" style="color:' . $custom_control['panDownColor'] . ';"></i></div>';
1839 + $html .= '<div class="ctrl pan-down" id="pan-down' . $pano_suffix . '"><i class="' . $custom_control['panDownIcon'] . '" style="color:' . $custom_control['panDownColor'] . ';"></i></div>';
1703 1840 }
1704 1841
1705 1842 if ($custom_control['panLeftSwitch'] == "on") {
1706 - $html .= '<div class="ctrl pan-left" id="pan-left' . $id . '"><i class="' . $custom_control['panLeftIcon'] . '" style="color:' . $custom_control['panLeftColor'] . ';"></i></div>';
1843 + $html .= '<div class="ctrl pan-left" id="pan-left' . $pano_suffix . '"><i class="' . $custom_control['panLeftIcon'] . '" style="color:' . $custom_control['panLeftColor'] . ';"></i></div>';
1707 1844 }
1708 1845
1709 1846 if ($custom_control['panRightSwitch'] == "on") {
1710 - $html .= '<div class="ctrl pan-right" id="pan-right' . $id . '"><i class="' . $custom_control['panRightIcon'] . '" style="color:' . $custom_control['panRightColor'] . ';"></i></div>';
1847 + $html .= '<div class="ctrl pan-right" id="pan-right' . $pano_suffix . '"><i class="' . $custom_control['panRightIcon'] . '" style="color:' . $custom_control['panRightColor'] . ';"></i></div>';
1711 1848 }
1712 1849
1713 1850 if ($custom_control['panFullscreenSwitch'] == "on") {
1714 - $html .= '<div class="ctrl fullscreen" id="fullscreen' . $id . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . $custom_control['panFullscreenColor'] . ';"></i></div>';
1851 + $html .= '<div class="ctrl fullscreen" id="fullscreen' . $pano_suffix . '"><i class="' . $custom_control['panFullscreenIcon'] . '" style="color:' . $custom_control['panFullscreenColor'] . ';"></i></div>';
1715 1852 }
1716 1853 $html .= '</div>';
1717 1854 }
1718 1855 }
@@ -1724,20 +1861,19 @@
1724 1861 $postdata,
1725 1862 $is_pro,
1726 1863 $autoload,
1727 1864 $explainer_right,
1728 - $id
1865 + $pano_suffix
1729 1866 );
1730 1867 //===explainer button end===//
1731 1868
1732 1869 //===Floor map button===//
1733 1870 $status = get_option('wpvr_edd_license_status');
1734 - if ($status !== false && 'valid' == $status && $is_pro){
1735 - if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
1736 - $html .= '<div class="floor_map_button" id="floor_map_button_' . $id . '" style="right:'.$floor_map_right.'">';
1737 - $html .= '<div class="ctrl" id="floor_map_target_' . $id . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1738 - $html .= '</div>';
1739 - }
1871 + $has_floor_plan = ( $status !== false && 'valid' == $status && $is_pro && 'on' == $floor_plan_enable && ! empty( $floor_plan_image ) );
1872 + if ( $has_floor_plan ) {
1873 + $html .= '<div class="floor_map_button" id="floor_map_button_' . $pano_suffix . '" style="right:'.$floor_map_right.'">';
1874 + $html .= '<div class="ctrl" id="floor_map_target_' . $pano_suffix . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1875 + $html .= '</div>';
1740 1876 }
1741 1877 //===floor map button===//
1742 1878
1743 1879 if ($vrgallery && 'valid' == $status && $is_pro ) {
@@ -1745,11 +1881,11 @@
1745 1881 $size = '';
1746 1882 if($vrgallery_icon_size){
1747 1883 $size = 'vrg-icon-size-large';
1748 1884 }
1749 - $html .= '<div id="vrgcontrols' . $id . '" class="vrgcontrols">';
1885 + $html .= '<div id="vrgcontrols' . $pano_suffix . '" class="vrgcontrols">';
1750 1886
1751 - $html .= '<div class="vrgctrl' . $id . ' vrbounce '.$size.'">';
1887 + $html .= '<div class="vrgctrl' . $pano_suffix . ' vrbounce '.$size.'">';
1752 1888 $html .= '</div>';
1753 1889 $html .= '</div>';
1754 1890
1755 1891 $gallery_layout_class = isset($postdata['tourLayout']['layout']) && 'layout1' === $postdata['tourLayout']['layout']
@@ -1754,9 +1890,9 @@
1754 1890
1755 1891 $gallery_layout_class = isset($postdata['tourLayout']['layout']) && 'layout1' === $postdata['tourLayout']['layout']
1756 1892 ? 'wpvr-gallery--modern'
1757 1893 : 'wpvr-gallery--classic';
1758 - $html .= '<div id="sccontrols' . $id . '" class="scene-gallery vrowl-carousel ' . esc_attr($gallery_layout_class) . '">';
1894 + $html .= '<div id="sccontrols' . $pano_suffix . '" class="scene-gallery vrowl-carousel ' . esc_attr($gallery_layout_class) . '">';
1759 1895 if (isset($panodata["scene-list"])) {
1760 1896 foreach ($panodata["scene-list"] as $panoscenes) {
1761 1897 $scene_key = $panoscenes['scene-id'];
1762 1898
@@ -1780,11 +1916,11 @@
1780 1916 $thumbnail = $img_src_url;
1781 1917 }
1782 1918
1783 1919 if( isset($postdata['tourLayout']['layout']) && 'layout1' !== $postdata['tourLayout']['layout']) {
1784 - $html .= '<ul><li title="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>';
1920 + $html .= '<ul><li title="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_' . $pano_suffix . '" src="' . $thumbnail . '"></li></ul>';
1785 1921 }else {
1786 - $html .= '<ul><li title="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>';
1922 + $html .= '<ul><li title="Click to view scene"><img loading="lazy" class="scctrl" id="' . $scene_key . '_gallery_' . $pano_suffix . '" src="' . $thumbnail . '"><span class="scene-title" title="' . esc_attr($scene_key_title) . '">' . $scene_key_title . '</span></li></ul>';
1787 1923 }
1788 1924 }
1789 1925 }
1790 1926
@@ -1815,15 +1951,15 @@
1815 1951 $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
1816 1952 $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
1817 1953
1818 1954 if ($bg_music === 'on' && 'valid' == $status && $is_pro) {
1819 - $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1820 - $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 . '>
1955 + $html .= '<div id="adcontrol' . esc_attr( $pano_suffix ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1956 + $html .= '<audio id="vrAudio' . esc_attr($pano_suffix) . '" class="vrAudioDefault" data-autoplay="' . esc_attr($autoplay_bg_music) . '" onended="audionEnd' . esc_attr($pano_suffix) . '()" ' . $autoplay_attr . ' ' . $audio_muted_attr . ' ' . $bg_loop . '>
1821 1957 <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
1822 1958 Your browser does not support the audio element.
1823 1959 </audio>';
1824 - $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
1825 - <i id="vr-volume' . esc_attr($id) . '" class="wpvrvolumeicon' . esc_attr($id) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
1960 + $html .= '<button onclick="playPause' . esc_attr($pano_suffix) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($pano_suffix) . '">
1961 + <i id="vr-volume' . esc_attr($pano_suffix) . '" class="wpvrvolumeicon' . esc_attr($pano_suffix) . ' fas ' . esc_attr($audio_icon_class) . '" style="color:#fff;"></i>
1826 1962 </button>';
1827 1963 $html .= '</div>';
1828 1964 }
1829 1965 //===Explainer video section===//
@@ -1830,9 +1966,9 @@
1830 1966 $explainerContent = "";
1831 1967 if (isset($postdata['explainerContent'])) {
1832 1968 $explainerContent = $this->wpvr_sanitize_iframe_only($postdata['explainerContent']);
1833 1969 }
1834 - $html .= '<div class="explainer" id="explainer' . $id . '" style="display: none">';
1970 + $html .= '<div class="explainer" id="explainer' . $pano_suffix . '" style="display: none">';
1835 1971 $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
1836 1972 $html .= '' . $explainerContent . '';
1837 1973 $html .= '</div>';
1838 1974 //===Explainer video section End===//
@@ -1850,13 +1986,13 @@
1850 1986 .zoom-in-out-controls {
1851 1987 top: 37px;
1852 1988 }
1853 1989 </style>';
1854 - $html .= '<div id="custom-scene-navigation' . $id . '" class="custom-scene-navigation">
1990 + $html .= '<div id="custom-scene-navigation' . $pano_suffix . '" class="custom-scene-navigation">
1855 1991 <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>
1856 1992 </div>
1857 1993
1858 - <div id="custom-scene-navigation-nav' . $id . '" class="' . esc_attr( $scene_navigation_nav_class ) . '">
1994 + <div id="custom-scene-navigation-nav' . $pano_suffix . '" class="' . esc_attr( $scene_navigation_nav_class ) . '">
1859 1995 <ul></ul>
1860 1996 </div>
1861 1997 ';
1862 1998 }
@@ -1864,9 +2000,9 @@
1864 2000
1865 2001
1866 2002 if( 'embed' === $width){
1867 2003 if(WPVR_Helper::is_enable_social_share($postdata) === 'on'){
1868 - $html .= '<div id="wpvr-social-share-bg-box'.$id.'" class="wpvr-social-share-bg-box" style="top:'.$social_logo_top.'">
2004 + $html .= '<div id="wpvr-social-share-bg-box'.$pano_suffix.'" class="wpvr-social-share-bg-box" style="top:'.$social_logo_top.'">
1869 2005 <span class="share-btn-svg"><svg fill="none" viewBox="0 0 24 24" width="24" height="24" ><path fill="#1F1CF4" d="M18.4 2.4a3.2 3.2 0 00-3.2 3.2 3.2 3.2 0 00.075.67L8.01 9.901A3.2 3.2 0 005.6 8.8a3.2 3.2 0 101.325 6.112 3.2 3.2 0 001.086-.812l7.261 3.632a3.2 3.2 0 101.803-2.242c-.415.189-.786.466-1.085.81l-7.261-3.63A3.2 3.2 0 008.8 12a3.2 3.2 0 00-.075-.667L15.991 7.7a3.2 3.2 0 002.41 1.1 3.2 3.2 0 100-6.4z"/></svg></span>
1870 2006 <nav class="wpvr-share-nav">
1871 2007 '.WPVR_Helper::social_media_share_links_display_in_embed(home_url().'/?embed_page='. $id).'
1872 2008 </nav>
@@ -1873,45 +2009,88 @@
1873 2009 </div>';
1874 2010 }
1875 2011 }
1876 2012 //===Floor plan section===//
1877 - $floor_map_image = "";
1878 - $floor_map_pointer = array();
1879 - $floor_map_scene_id = '';
1880 - $floor_plan_custom_color = '#cca92c';
1881 - $floor_plan_direction_indicator = isset($postdata['floor_plan_direction_indicator']) ? $postdata['floor_plan_direction_indicator'] : 'on';
2013 + if ( $has_floor_plan ) {
2014 + $floor_map_image = $floor_plan_image;
2015 + $floor_map_pointer = isset($postdata['floor_plan_pointer_position']) && is_array($postdata['floor_plan_pointer_position']) ? $postdata['floor_plan_pointer_position'] : array();
2016 + $floor_map_scene_id = isset($postdata['floor_plan_data_list']) && is_array($postdata['floor_plan_data_list']) ? $postdata['floor_plan_data_list'] : array();
2017 + $floor_plan_custom_color = isset($postdata['floor_plan_custom_color']) && ! empty($postdata['floor_plan_custom_color']) ? $postdata['floor_plan_custom_color'] : '#cca92c';
2018 + $floor_plan_direction_indicator = isset($postdata['floor_plan_direction_indicator']) ? $postdata['floor_plan_direction_indicator'] : 'on';
1882 2019
1883 - if (isset($postdata['floor_plan_attachment_url'])) {
1884 - $floor_map_image = $postdata['floor_plan_attachment_url'];
1885 - $floor_map_pointer = $postdata['floor_plan_pointer_position'];
1886 - $floor_map_scene_id = $postdata['floor_plan_data_list'];
1887 - $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
1888 - }
1889 - $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
1890 - $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
1891 - $html .= '<img loading="lazy" src="'.$floor_map_image.'">';
1892 - foreach($floor_map_pointer as $key=> $pointer_position){
1893 - $html .= '<div class="floor-plan-pointer ui-draggable ui-draggable-handle" scene_id = "'.$floor_map_scene_id[$key]->value.'" id="'.$pointer_position->id.'" data-top="'.$pointer_position->data_top.'" data-left="'.$pointer_position->data_left.'" style="'.$pointer_position->style.'">
1894 - <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1895 - <circle cx="12" cy="12" r="11.5" stroke="'.$floor_plan_custom_color.'"/>
1896 - <circle cx="12" cy="12" r="5" fill="'.$foreground_color_pointer.'"/>
1897 - </svg>';
1898 -
1899 - // Only add the floor pointer flash SVG if floor_plan_direction_indicator is "on"
1900 - if ($floor_plan_direction_indicator === "on") {
1901 - $html .= '<svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
1902 - <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)"/>
1903 - <defs>
1904 - <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
1905 - <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
1906 - <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
1907 - </linearGradient>
1908 - </defs>
1909 - </svg>';
2020 + $media_alt = '';
2021 + $attachment_id = attachment_url_to_postid( $floor_map_image );
2022 +
2023 + if ( $attachment_id ) {
2024 + $media_alt = sanitize_text_field( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) );
2025 + }
2026 +
2027 + if ( ! empty( $media_alt ) ) {
2028 + $floor_map_alt = $media_alt;
2029 + } else {
2030 + $tour_title = sanitize_text_field( get_the_title( $id ) );
2031 +
2032 + $floor_map_alt = ! empty( $tour_title )
2033 + /* translators: %s: tour title */
2034 + ? sprintf( __( '%s - Floor Plan', 'wpvr' ), $tour_title )
2035 + : __( 'Floor Plan', 'wpvr' );
2036 + }
2037 +
2038 + $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $pano_suffix . '" style="display: none">';
2039 + $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
2040 + $html .= '<img loading="lazy" src="' . esc_url( $floor_map_image ) . '" alt="' . esc_attr( $floor_map_alt ) . '">';
2041 + foreach ( $floor_map_pointer as $key => $pointer_position ) {
2042 + $pointer_id = '';
2043 + $data_top = '';
2044 + $data_left = '';
2045 + $style = '';
2046 +
2047 + if ( is_object( $pointer_position ) ) {
2048 + $pointer_id = isset( $pointer_position->id ) ? (string) $pointer_position->id : '';
2049 + $data_top = isset( $pointer_position->data_top ) ? (string) $pointer_position->data_top : '';
2050 + $data_left = isset( $pointer_position->data_left ) ? (string) $pointer_position->data_left : '';
2051 + $style = isset( $pointer_position->style ) ? (string) $pointer_position->style : '';
2052 + } elseif ( is_array( $pointer_position ) ) {
2053 + $pointer_id = isset( $pointer_position['id'] ) ? (string) $pointer_position['id'] : '';
2054 + $data_top = isset( $pointer_position['data_top'] ) ? (string) $pointer_position['data_top'] : '';
2055 + $data_left = isset( $pointer_position['data_left'] ) ? (string) $pointer_position['data_left'] : '';
2056 + $style = isset( $pointer_position['style'] ) ? (string) $pointer_position['style'] : '';
2057 + }
2058 +
2059 + $scene_id_val = '';
2060 + if ( isset( $floor_map_scene_id[ $key ] ) ) {
2061 + $scene_item = $floor_map_scene_id[ $key ];
2062 + if ( is_object( $scene_item ) && isset( $scene_item->value ) ) {
2063 + $scene_id_val = (string) $scene_item->value;
2064 + } elseif ( is_array( $scene_item ) && isset( $scene_item['value'] ) ) {
2065 + $scene_id_val = (string) $scene_item['value'];
2066 + } elseif ( is_scalar( $scene_item ) ) {
2067 + $scene_id_val = (string) $scene_item;
1910 2068 }
2069 + }
2070 +
2071 + $html .= '<div class="floor-plan-pointer ui-draggable ui-draggable-handle" scene_id="' . esc_attr( $scene_id_val ) . '" id="' . esc_attr( $pointer_id ) . '" data-top="' . esc_attr( $data_top ) . '" data-left="' . esc_attr( $data_left ) . '" style="' . esc_attr( $style ) . '">
2072 + <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2073 + <circle cx="12" cy="12" r="11.5" stroke="' . esc_attr( $floor_plan_custom_color ) . '"/>
2074 + <circle cx="12" cy="12" r="5" fill="' . esc_attr( $foreground_color_pointer ) . '"/>
2075 + </svg>';
2076 +
2077 + // Only add the floor pointer flash SVG if floor_plan_direction_indicator is "on"
2078 + if ( $floor_plan_direction_indicator === 'on' ) {
2079 + $html .= '<svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
2080 + <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)"/>
2081 + <defs>
2082 + <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
2083 + <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
2084 + <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
2085 + </linearGradient>
2086 + </defs>
2087 + </svg>';
2088 + }
2089 + $html .= '</div>';
2090 + }
1911 2091 $html .= '</div>';
1912 2092 }
1913 - $html .= '</div>';
1914 2093 //===Floor plan section===//
1915 2094
1916 2095 $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
1917 2096 $html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>';
@@ -1991,9 +2170,10 @@
1991 2170 border: '.$border_width.'px '.$border_style.' '.$border_color.';
1992 2171 border-radius: '.$border_radius.'px;
1993 2172 padding: '.$button_pt.'px '.$button_pr.'px '.$button_pb.'px '.$button_pl.'px;
1994 2173 ';
1995 - $html .= '<div class="wpvr-call-to-action-button position-'.$text_align.'" style="max-width:' . $width.'">
2174 + $cta_width = ( $width === 'fullwidth' || $width === 'embed' ) ? '100%' : $width;
2175 + $html .= '<div class="wpvr-call-to-action-button position-'.$text_align.'" style="max-width:' . $cta_width . '">
1996 2176 <a href="'.$buttonurl.'" style="'.$style.'" target="'.$target.'">'.$buttontext.'</a>
1997 2177 </div>';
1998 2178
1999 2179 }
@@ -2003,26 +2183,26 @@
2003 2183 //script started
2004 2184 $html .= '<script>';
2005 2185 if (isset($postdata['bg_music']) && $bg_music == 'on' && 'valid' == $status && $is_pro) {
2006 2186 $html .= '
2007 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
2008 - var playing' . $id . ' = false;
2009 - var autoplaySupported' . $id . ' = false;
2010 - var alertShown' . $id . ' = false;
2011 - var autoplayChecked' . $id . ' = false;
2187 + var x' . $pano_suffix . ' = document.getElementById("vrAudio' . $pano_suffix . '");
2188 + var playing' . $pano_suffix . ' = false;
2189 + var autoplaySupported' . $pano_suffix . ' = false;
2190 + var alertShown' . $pano_suffix . ' = false;
2191 + var autoplayChecked' . $pano_suffix . ' = false;
2012 2192
2013 - function playPause' . $id . '() {
2014 - if (playing' . $id . ') {
2015 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2016 - x' . $id . '.pause();
2017 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2018 - playing' . $id . ' = false;
2193 + function playPause' . $pano_suffix . '() {
2194 + if (playing' . $pano_suffix . ') {
2195 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2196 + x' . $pano_suffix . '.pause();
2197 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "off");
2198 + playing' . $pano_suffix . ' = false;
2019 2199 } else {
2020 - x' . $id . '.muted = false;
2021 - x' . $id . '.play().then(function() {
2022 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2023 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2024 - playing' . $id . ' = true;
2200 + x' . $pano_suffix . '.muted = false;
2201 + x' . $pano_suffix . '.play().then(function() {
2202 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2203 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2204 + playing' . $pano_suffix . ' = true;
2025 2205 }).catch(function(e) {
2026 2206 console.log("Play failed:", e);
2027 2207 });
2028 2208 }
@@ -2027,133 +2207,139 @@
2027 2207 });
2028 2208 }
2029 2209 }
2030 2210
2031 - function audionEnd' . $id . '() {
2032 - playing' . $id . ' = false;
2033 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2034 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2211 + function audionEnd' . $pano_suffix . '() {
2212 + playing' . $pano_suffix . ' = false;
2213 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2214 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "off");
2035 2215 }
2036 2216
2037 - x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
2217 + x' . $pano_suffix . '.addEventListener("ended", audionEnd' . $pano_suffix . ');';
2038 2218
2039 2219 if ($autoplay_bg_music == 'on') {
2040 2220 $html .= '
2041 2221
2042 - x' . $id . '.addEventListener("loadeddata", function() {
2043 - if (!autoplayChecked' . $id . ') {
2044 - checkAutoplayStatus' . $id . '();
2222 + x' . $pano_suffix . '.addEventListener("loadeddata", function() {
2223 + if (!autoplayChecked' . $pano_suffix . ') {
2224 + checkAutoplayStatus' . $pano_suffix . '();
2045 2225 }
2046 2226 });
2047 2227
2048 - x' . $id . '.addEventListener("canplay", function() {
2049 - if (!autoplayChecked' . $id . ') {
2050 - checkAutoplayStatus' . $id . '();
2228 + x' . $pano_suffix . '.addEventListener("canplay", function() {
2229 + if (!autoplayChecked' . $pano_suffix . ') {
2230 + checkAutoplayStatus' . $pano_suffix . '();
2051 2231 }
2052 2232 });
2053 2233
2054 - x' . $id . '.addEventListener("canplaythrough", function() {
2055 - if (!autoplayChecked' . $id . ') {
2056 - checkAutoplayStatus' . $id . '();
2234 + x' . $pano_suffix . '.addEventListener("canplaythrough", function() {
2235 + if (!autoplayChecked' . $pano_suffix . ') {
2236 + checkAutoplayStatus' . $pano_suffix . '();
2057 2237 }
2058 2238 });
2059 2239
2060 2240 setTimeout(function() {
2061 - if (!autoplayChecked' . $id . ') {
2062 - checkAutoplayStatus' . $id . '();
2241 + if (!autoplayChecked' . $pano_suffix . ') {
2242 + checkAutoplayStatus' . $pano_suffix . '();
2063 2243 }
2064 2244 }, 1000);
2065 2245
2066 - x' . $id . '.addEventListener("play", function() {
2067 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2068 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2069 - playing' . $id . ' = true;
2246 + x' . $pano_suffix . '.addEventListener("play", function() {
2247 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2248 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2249 + playing' . $pano_suffix . ' = true;
2070 2250 });
2071 2251
2072 - x' . $id . '.addEventListener("pause", function() {
2073 - if (!playing' . $id . ') {
2074 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2075 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2252 + x' . $pano_suffix . '.addEventListener("pause", function() {
2253 + if (!playing' . $pano_suffix . ') {
2254 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2255 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "off");
2076 2256 }
2077 2257 });
2078 2258
2079 - function checkAutoplayStatus' . $id . '() {
2080 - autoplayChecked' . $id . ' = true;
2259 + function checkAutoplayStatus' . $pano_suffix . '() {
2260 + autoplayChecked' . $pano_suffix . ' = true;
2081 2261
2082 - x' . $id . '.muted = true;
2083 - var playPromise = x' . $id . '.play();
2262 + x' . $pano_suffix . '.muted = true;
2263 + var playPromise = x' . $pano_suffix . '.play();
2084 2264
2085 2265 if (playPromise !== undefined) {
2086 2266 playPromise.then(function () {
2087 - if (x' . $id . '.muted || x' . $id . '.volume === 0) {
2088 - handleAutoplayBlocked' . $id . '();
2267 + if (x' . $pano_suffix . '.muted || x' . $pano_suffix . '.volume === 0) {
2268 + handleAutoplayBlocked' . $pano_suffix . '();
2089 2269 } else {
2090 - autoplaySupported' . $id . ' = true;
2091 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2092 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2093 - playing' . $id . ' = true;
2270 + autoplaySupported' . $pano_suffix . ' = true;
2271 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2272 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2273 + playing' . $pano_suffix . ' = true;
2094 2274 }
2095 2275 }).catch(function () {
2096 - handleAutoplayBlocked' . $id . '();
2276 + handleAutoplayBlocked' . $pano_suffix . '();
2097 2277 });
2098 2278 } else {
2099 2279 setTimeout(function () {
2100 - if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2101 - handleAutoplayBlocked' . $id . '();
2280 + if (x' . $pano_suffix . '.paused || x' . $pano_suffix . '.currentTime === 0) {
2281 + handleAutoplayBlocked' . $pano_suffix . '();
2102 2282 } else {
2103 - autoplaySupported' . $id . ' = true;
2104 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2105 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2106 - playing' . $id . ' = true;
2283 + autoplaySupported' . $pano_suffix . ' = true;
2284 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2285 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2286 + playing' . $pano_suffix . ' = true;
2107 2287 }
2108 2288 }, 300);
2109 2289 }
2110 2290 }
2111 2291
2112 - function handleAutoplayBlocked' . $id . '() {
2113 - autoplaySupported' . $id . ' = false;
2114 - if (!alertShown' . $id . ') {
2292 + function handleAutoplayBlocked' . $pano_suffix . '() {
2293 + autoplaySupported' . $pano_suffix . ' = false;
2294 + if (!alertShown' . $pano_suffix . ') {
2115 2295 alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2116 - alertShown' . $id . ' = true;
2296 + alertShown' . $pano_suffix . ' = true;
2117 2297 }
2118 2298
2119 - x' . $id . '.pause();
2120 - x' . $id . '.currentTime = 0;
2121 - x' . $id . '.muted = true;
2299 + x' . $pano_suffix . '.pause();
2300 + x' . $pano_suffix . '.currentTime = 0;
2301 + x' . $pano_suffix . '.muted = true;
2122 2302
2123 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2124 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2303 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2304 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "off");
2125 2305
2126 - document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2127 - document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2128 - document.addEventListener("click", musicPlay' . $id . ', { once: true });
2306 + var musicTriggerElem = document.getElementById("' . $panoid . '");
2307 + if (musicTriggerElem) {
2308 + musicTriggerElem.addEventListener("click", musicPlay' . $pano_suffix . ');
2309 + }
2310 + document.addEventListener("touchstart", musicPlay' . $pano_suffix . ', { once: true });
2311 + document.addEventListener("click", musicPlay' . $pano_suffix . ', { once: true });
2129 2312 }
2130 2313
2131 - function musicPlay' . $id . '() {
2132 - x' . $id . '.muted = false;
2133 - var playPromise = x' . $id . '.play();
2314 + function musicPlay' . $pano_suffix . '() {
2315 + x' . $pano_suffix . '.muted = false;
2316 + var playPromise = x' . $pano_suffix . '.play();
2134 2317
2135 2318 if (playPromise !== undefined) {
2136 2319 playPromise.then(function () {
2137 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2138 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2139 - playing' . $id . ' = true;
2320 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2321 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2322 + playing' . $pano_suffix . ' = true;
2140 2323 }).catch(function(e) {
2141 2324 console.log("Play failed:", e);
2142 2325 });
2143 2326 } else {
2144 2327 setTimeout(function () {
2145 - if (!x' . $id . '.paused) {
2146 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2147 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2148 - playing' . $id . ' = true;
2328 + if (!x' . $pano_suffix . '.paused) {
2329 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2330 + jQuery("#audio_control' . $pano_suffix . '").attr("data-play", "on");
2331 + playing' . $pano_suffix . ' = true;
2149 2332 }
2150 2333 }, 100);
2151 2334 }
2152 2335
2153 - document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2154 - document.removeEventListener("touchstart", musicPlay' . $id . ');
2155 - document.removeEventListener("click", musicPlay' . $id . ');
2336 + var musicTriggerElem = document.getElementById("' . $panoid . '");
2337 + if (musicTriggerElem) {
2338 + musicTriggerElem.removeEventListener("click", musicPlay' . $pano_suffix . ');
2339 + }
2340 + document.removeEventListener("touchstart", musicPlay' . $pano_suffix . ');
2341 + document.removeEventListener("click", musicPlay' . $pano_suffix . ');
2156 2342 }
2157 2343 ';
2158 2344 }
2159 2345 }
@@ -2160,29 +2346,75 @@
2160 2346 $html .= '(function ($) {';
2161 2347 $html .= 'jQuery(document).ready(function() {';
2162 2348 $html .= 'var response = ' . $response . ';';
2163 2349 $html .= 'var scenes = response[1];';
2350 + $html .= 'function wpvrResolveDevicePanorama(scenesConfig) {';
2351 + $html .= ' if (!scenesConfig || !scenesConfig.scenes) return;';
2352 + $html .= ' var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);';
2353 + $html .= ' var isSmallScreen = (window.innerWidth <= 768);';
2354 + $html .= ' if (typeof window.wpvrMaxTexture === "undefined") {';
2355 + $html .= ' window.wpvrMaxTexture = 16384;';
2356 + $html .= ' try {';
2357 + $html .= ' var testCanvas = document.createElement("canvas");';
2358 + $html .= ' var gl = testCanvas.getContext("webgl") || testCanvas.getContext("experimental-webgl");';
2359 + $html .= ' if (gl) {';
2360 + $html .= ' window.wpvrMaxTexture = gl.getParameter(gl.MAX_TEXTURE_SIZE) || 16384;';
2361 + $html .= ' var ext = gl.getExtension("WEBGL_lose_context");';
2362 + $html .= ' if (ext) { ext.loseContext(); }';
2363 + $html .= ' }';
2364 + $html .= ' } catch (e) {}';
2365 + $html .= ' }';
2366 + $html .= ' var maxTexture = window.wpvrMaxTexture;';
2367 + $html .= ' for (var scId in scenesConfig.scenes) {';
2368 + $html .= ' if (!scenesConfig.scenes.hasOwnProperty(scId)) continue;';
2369 + $html .= ' var sc = scenesConfig.scenes[scId];';
2370 + $html .= ' if (!sc) continue;';
2371 + $html .= ' var exceedsGpu = sc.desktop_width && (sc.desktop_width > maxTexture);';
2372 + $html .= ' if (isMobile || isSmallScreen || exceedsGpu) {';
2373 + $html .= ' if (sc.mobile_panorama) {';
2374 + $html .= ' sc.panorama = sc.mobile_panorama;';
2375 + $html .= ' }';
2376 + $html .= ' } else if (sc.desktop_panorama) {';
2377 + $html .= ' sc.panorama = sc.desktop_panorama;';
2378 + $html .= ' }';
2379 + $html .= ' }';
2380 + $html .= '}';
2381 + $html .= 'wpvrResolveDevicePanorama(scenes);';
2164 2382 $html .= 'if(scenes) {';
2165 2383 $html .= 'var scenedata = scenes.scenes;';
2166 - $html .= 'for(var i in scenedata) {';
2167 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2168 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2169 - $html .= 'if(scenehotspot[i].type === "info") {';
2170 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };';
2171 - $html .= '} else if(scenehotspot[i].type === "scene") {';
2172 - $html .= ' scenehotspot[i]["clickHandlerArgs"] = scenehotspot[i]["text"];';
2384 + $html .= 'for(var scId in scenedata) {';
2385 + $html .= 'if(!scenedata.hasOwnProperty(scId)) continue;';
2386 + $html .= 'var scenehotspot = scenedata[scId].hotSpots;';
2387 + $html .= 'if(scenehotspot && scenehotspot.length) {';
2388 + $html .= 'for(var hIdx = 0; hIdx < scenehotspot.length; hIdx++) {';
2389 + $html .= 'if(scenehotspot[hIdx].type === "info") {';
2390 + $html .= ' scenehotspot[hIdx]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };';
2391 + $html .= '} else if(scenehotspot[hIdx].type === "scene") {';
2392 + $html .= ' scenehotspot[hIdx]["clickHandlerArgs"] = scenehotspot[hIdx]["text"] || "";';
2173 2393 $status = get_option('wpvr_edd_license_status');
2174 2394 if ($status !== false && $status == 'valid') {
2175 - $html .='if(typeof wpvr_public !== "undefined" && wpvr_public.is_pro_active) {';
2176 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = function(div, args) { if (typeof wpvrhotspotscene === "function") { wpvrhotspotscene(div, args); } else if (typeof window.wpvrhotspotscene === "function") { window.wpvrhotspotscene(div, args); } };';
2395 + $html .='if(typeof wpvr_public !== "undefined") {';
2396 + $html .='if(wpvr_public.is_pro_active) {';
2397 + $html .= ' scenehotspot[hIdx]["clickHandlerFunc"] = function(div, args) { if (typeof wpvrhotspotscene' . $pano_suffix . ' === "function") { wpvrhotspotscene' . $pano_suffix . '(div, args); } else if (typeof wpvrhotspotscene === "function") { wpvrhotspotscene(div, args); } else if (typeof window.wpvrhotspotscene === "function") { window.wpvrhotspotscene(div, args); } };';
2177 2398 $html .='}';
2399 + $html .='}';
2178 2400 }
2179 2401 $html .= '}';
2180 2402
2403 + $html .= 'if(scenehotspot[hIdx].hotspot_type === "sticker" || scenehotspot[hIdx].type === "sticker" || scenehotspot[hIdx].stickerTemplate) {';
2404 + $html .= ' (function(hs) {';
2405 + $html .= ' hs["createTooltipFunc"] = function(div) {';
2406 + $html .= ' if (typeof window.wpvrRenderStickerHotspot === "function") {';
2407 + $html .= ' window.wpvrRenderStickerHotspot(div, hs);';
2408 + $html .= ' }';
2409 + $html .= ' };';
2410 + $html .= ' })(scenehotspot[hIdx]);';
2411 + $html .= '}';
2412 +
2181 2413 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2182 2414 } else {
2183 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2184 - $html .= 'scenehotspot[i]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };';
2415 + $html .= 'else if(scenehotspot[hIdx]["createTooltipArgs"] != "") {';
2416 + $html .= ' scenehotspot[hIdx]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };';
2185 2417 $html .= '}';
2186 2418 }
2187 2419
2188 2420 $html .= '}';
@@ -2187,24 +2419,25 @@
2187 2419
2188 2420 $html .= '}';
2189 2421 $html .= '}';
2190 2422 $html .= '}';
2191 - $html .= 'var panoshow' . $id . ';';
2192 - $html .= 'var panoshow2' . $id . ';';
2193 - $html .= 'function initWPVRViewer' . $id . '() {';
2194 - $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer' . $id . ', 50); return; }';
2195 - $html .= 'panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2423 + $html .= '}';
2424 + $html .= 'var panoshow' . $pano_suffix . ';';
2425 + $html .= 'var panoshow2' . $pano_suffix . ';';
2426 + $html .= 'function initWPVRViewer' . $pano_suffix . '() {';
2427 + $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer' . $pano_suffix . ', 50); return; }';
2428 + $html .= 'panoshow' . $pano_suffix . ' = pannellum.viewer(response[0]["panoid"], scenes);';
2196 2429 $html .= '
2197 2430 window.wpvrViewers = window.wpvrViewers || {};
2198 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
2431 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
2199 2432 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2200 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
2433 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
2201 2434 }));
2202 2435 ';
2203 2436 if ( (float) $scene_fade_duration > 0 ) {
2204 2437 $html .= '
2205 - panoshow' . $id . '.on("scenechange", function() {
2206 - var fadeImage = document.querySelector("#pano' . $id . ' .pnlm-render-container > .pnlm-fade-img");
2438 + panoshow' . $pano_suffix . '.on("scenechange", function() {
2439 + var fadeImage = document.querySelector("#' . $panoid . ' .pnlm-render-container > .pnlm-fade-img");
2207 2440 if (fadeImage) {
2208 2441 fadeImage.style.opacity = "1";
2209 2442 void fadeImage.offsetWidth;
2210 2443 }
@@ -2212,20 +2445,20 @@
2212 2445 }
2213 2446 $html .= '
2214 2447
2215 2448 if(typeof wpvr_public === "undefined" || !wpvr_public.is_pro_active || !wpvr_public.is_license_active) {
2216 - panoshow' . $id . '.on("load", function() {
2449 + panoshow' . $pano_suffix . '.on("load", function() {
2217 2450 jQuery(".pnlm-panorama-info").hide();
2218 2451 jQuery(".pnlm-compass").hide();
2219 2452 });
2220 2453
2221 - panoshow' . $id . '.on("scenechange", function() {
2454 + panoshow' . $pano_suffix . '.on("scenechange", function() {
2222 2455 jQuery(".pnlm-panorama-info").hide();
2223 2456 jQuery(".pnlm-compass").hide();
2224 2457 });
2225 2458 }';
2226 2459 $html .= '}';
2227 - $html .= 'initWPVRViewer' . $id . '();';
2460 + $html .= 'initWPVRViewer' . $pano_suffix . '();';
2228 2461 //===Dplicate mode only for vr mode===//
2229 2462 $response2 = json_decode($response);
2230 2463 $response2[1]->compass = false;
2231 2464 $response2[1]->autoRotate = false;
@@ -2231,43 +2464,57 @@
2231 2464 $response2[1]->autoRotate = false;
2232 2465 $response = json_encode($response2);
2233 2466 $html .= 'var response_duplicate = ' . $response . ';';
2234 2467 $html .= 'var scenes_duplicate = response_duplicate[1];';
2468 + $html .= 'wpvrResolveDevicePanorama(scenes_duplicate);';
2235 2469
2236 2470 $html .= 'if(scenes_duplicate) {';
2237 2471 $html .= 'var scenedata = scenes_duplicate.scenes;';
2238 - $html .= 'for(var i in scenedata) {';
2239 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2240 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2241 - $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2242 - $html .= 'scenehotspot[i]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };';
2472 + $html .= 'for(var scId in scenedata) {';
2473 + $html .= 'if(!scenedata.hasOwnProperty(scId)) continue;';
2474 + $html .= 'var scenehotspot = scenedata[scId].hotSpots;';
2475 + $html .= 'if(scenehotspot && scenehotspot.length) {';
2476 + $html .= 'for(var hIdx = 0; hIdx < scenehotspot.length; hIdx++) {';
2477 + $html .= 'if(scenehotspot[hIdx]["clickHandlerArgs"] != "") {';
2478 + $html .= 'scenehotspot[hIdx]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };';
2243 2479 $html .= '}';
2480 + $html .= 'if(scenehotspot[hIdx].hotspot_type === "sticker" || scenehotspot[hIdx].type === "sticker" || scenehotspot[hIdx].stickerTemplate) {';
2481 + $html .= ' (function(hs) {';
2482 + $html .= ' hs["createTooltipFunc"] = function(div) {';
2483 + $html .= ' if (typeof window.wpvrRenderStickerHotspot === "function") {';
2484 + $html .= ' window.wpvrRenderStickerHotspot(div, hs);';
2485 + $html .= ' }';
2486 + $html .= ' };';
2487 + $html .= ' })(scenehotspot[hIdx]);';
2488 + $html .= '}';
2489 +
2244 2490 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2245 2491 } else {
2246 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2247 - $html .= 'scenehotspot[i]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };';
2492 + $html .= 'else if(scenehotspot[hIdx]["createTooltipArgs"] != "") {';
2493 + $html .= ' scenehotspot[hIdx]["createTooltipFunc"] = function(div, args) { if (typeof window.wpvrtooltip === "function") { window.wpvrtooltip(div, args); } };';
2248 2494 $html .= '}';
2249 2495 }
2250 2496 $html .= '}';
2251 2497 $html .= '}';
2252 2498 $html .= '}';
2499 + $html .= '}';
2253 2500
2254 2501 $is_pro = apply_filters('is_wpvr_pro_active',false);
2255 2502 $status = get_option('wpvr_edd_license_status');
2256 2503 $html .= 'var vr_mode = "off";';
2257 2504 if ($status !== false && 'valid' == $status && $is_pro) {
2258 - $html .= 'function initWPVRViewer2' . $id . '() {';
2259 - $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer2' . $id . ', 50); return; }';
2260 - $html .= 'panoshow2' . $id . ' = pannellum.viewer("pano2' . $id . '", scenes_duplicate);';
2505 + $html .= 'function initWPVRViewer2' . $pano_suffix . '() {';
2506 + $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer2' . $pano_suffix . ', 50); return; }';
2507 + $html .= 'panoshow2' . $pano_suffix . ' = pannellum.viewer("' . $panoid2 . '", scenes_duplicate);';
2261 2508 $html .= '
2262 2509 window.wpvrViewers = window.wpvrViewers || {};
2263 - window.wpvrViewers["pano2' . $id . '"] = panoshow2' . $id . ';
2510 + window.wpvrViewers["' . $panoid2 . '"] = panoshow2' . $pano_suffix . ';
2264 2511 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2265 - detail: { containerId: "pano2' . $id . '", viewer: panoshow2' . $id . ' }
2512 + detail: { containerId: "' . $panoid2 . '", viewer: panoshow2' . $pano_suffix . ' }
2266 2513 }));
2267 2514 ';
2268 2515 $html .= '}';
2269 - $html .= 'initWPVRViewer2' . $id . '();';
2516 + $html .= 'initWPVRViewer2' . $pano_suffix . '();';
2270 2517 // Show Cardboard Mode in Tour
2271 2518 $html .= '
2272 2519 var tim;
2273 2520 var im = 0;
@@ -2280,43 +2527,45 @@
2280 2527 var scenedata = scenes_duplicate.scenes;
2281 2528 for(var i in scenedata) {
2282 2529 if(active_scene === i) {
2283 2530 var scenehotspot = scenedata[i].hotSpots;
2284 - for(var j in scenehotspot) {
2285 - var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2286 - var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2287 - var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2288 - var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2289 - var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2290 - var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2291 - if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2292 - if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2293 - jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2294 - var getScene = scenehotspot[j].sceneId;
2295 - if(scenehotspot[j].type == "scene"){
2296 - panoshow' . $id . '.loadScene(getScene);
2297 - panoshow2' . $id . '.loadScene(getScene);
2298 -// var inside_current_time_object = new Date();
2299 -// var inside_timer = inside_current_time_object.getTime();
2300 -// if(inside_timer > timer) {
2301 -// panoshow' . $id . '.loadScene(getScene);
2302 -// panoshow2' . $id . '.loadScene(getScene);
2303 -// jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2304 -// }
2305 - }else{
2306 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2531 + if(scenehotspot && scenehotspot.length) {
2532 + for(var j = 0; j < scenehotspot.length; j++) {
2533 + var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2534 + var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2535 + var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2536 + var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2537 + if(Math.round(data.pitch) > minusFivePitch) {
2538 + if(Math.round(data.pitch) < plusFivePitch) {
2539 + if(Math.round(data.yaw) > minusFiveYaw) {
2540 + if(Math.round(data.yaw) < plusFiveYaw) {
2541 + jQuery(".center-pointer").addClass("wpvr-pluse-effect");
2542 + var getScene = scenehotspot[j].sceneId;
2543 + if(scenehotspot[j].type == "scene"){
2544 + panoshow' . $pano_suffix . '.loadScene(getScene);
2545 + panoshow2' . $pano_suffix . '.loadScene(getScene);
2546 + }else{
2547 + jQuery(".center-pointer").removeClass("wpvr-pluse-effect");
2548 + }
2549 + } else {
2550 + jQuery(".center-pointer").removeClass("wpvr-pluse-effect");
2551 + c_time = new Date();
2552 + timer = c_time.getTime() + 2000;
2553 + }
2554 + } else {
2555 + jQuery(".center-pointer").removeClass("wpvr-pluse-effect");
2556 + c_time = new Date();
2557 + timer = c_time.getTime() + 2000;
2558 + }
2559 + } else {
2560 + c_time = new Date();
2561 + timer = c_time.getTime() + 2000;
2307 2562 }
2308 - }
2309 - else {
2310 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2563 + } else {
2311 2564 c_time = new Date();
2312 2565 timer = c_time.getTime() + 2000;
2313 2566 }
2314 2567 }
2315 - else {
2316 - c_time = new Date();
2317 - timer = c_time.getTime() + 2000;
2318 - }
2319 2568 }
2320 2569 }
2321 2570 }
2322 2571 }
@@ -2322,26 +2571,28 @@
2322 2571 }
2323 2572 };
2324 2573 function vrDeviseOrientation(){
2325 2574 var data = {
2326 - pitch: panoshow' . $id . '.getPitch(),
2327 - yaw: panoshow' . $id . '.getYaw(),
2575 + pitch: panoshow' . $pano_suffix . '.getPitch(),
2576 + yaw: panoshow' . $pano_suffix . '.getYaw(),
2328 2577 };
2329 2578 panoShowCardBoardOnTrigger(data);
2330 2579 }';
2331 2580 $html .= '
2332 2581 function requestFullScreen(){
2333 - var elem = document.getElementById("master-container");
2334 - if (elem.requestFullscreen) {
2335 - elem.requestFullscreen();
2336 - } else if (elem.webkitRequestFullscreen) { /* Safari */
2337 - elem.webkitRequestFullscreen();
2338 - } else if (elem.msRequestFullscreen) { /* IE11 */
2339 - elem.msRequestFullscreen();
2340 - }
2582 + var elem = document.getElementById("' . $master_container_id . '") || document.getElementById("master-container");
2583 + if (elem) {
2584 + if (elem.requestFullscreen) {
2585 + elem.requestFullscreen();
2586 + } else if (elem.webkitRequestFullscreen) { /* Safari */
2587 + elem.webkitRequestFullscreen();
2588 + } else if (elem.msRequestFullscreen) { /* IE11 */
2589 + elem.msRequestFullscreen();
2590 + }
2591 + }
2341 2592 }
2342 2593 function requestExitFullscreen(){
2343 - var elem = document.getElementById("master-container");
2594 + var elem = document.getElementById("' . $master_container_id . '") || document.getElementById("master-container");
2344 2595 if (document.exitFullscreen) {
2345 2596 document.exitFullscreen();
2346 2597 } else if (document.webkitExitFullscreen) { /* Safari */
2347 2598 document.webkitExitFullscreen();
@@ -2363,29 +2614,33 @@
2363 2614 let onLoadAnalytics = false;
2364 2615 let sceneLoadAnalytics = false;
2365 2616
2366 2617 function storeAnalyticsData(data) {
2367 - if (typeof wpvrAnalyticsObj !== "undefined" && typeof wpvr_public !== "undefined" && wpvr_public.is_pro_active) {
2368 - jQuery.ajax({
2369 - url: wpvrAnalyticsObj.ajaxUrl,
2370 - type: "POST",
2371 - data: {
2372 - action: "store_scene_hotspot_data",
2373 - scene_id: data.scene_id,
2374 - tour_id: data.tour_id,
2375 - type: data.type,
2376 - hotspot_id: data.hotspot_id || "",
2377 - user_agent: navigator.userAgent,
2378 - device_type: getDeviceType() || "desktop",
2379 - nonce: wpvrAnalyticsObj.nonce,
2380 - },
2381 - success: function (response) {
2382 - console.log("Data stored successfully");
2383 - },
2384 - error: function (error) {
2385 - console.log("Error in storing data");
2618 + if (typeof wpvrAnalyticsObj !== "undefined") {
2619 + if (typeof wpvr_public !== "undefined") {
2620 + if (wpvr_public.is_pro_active) {
2621 + jQuery.ajax({
2622 + url: wpvrAnalyticsObj.ajaxUrl,
2623 + type: "POST",
2624 + data: {
2625 + action: "store_scene_hotspot_data",
2626 + scene_id: data.scene_id,
2627 + tour_id: data.tour_id,
2628 + type: data.type,
2629 + hotspot_id: data.hotspot_id || "",
2630 + user_agent: navigator.userAgent,
2631 + device_type: getDeviceType() || "desktop",
2632 + nonce: wpvrAnalyticsObj.nonce,
2633 + },
2634 + success: function (response) {
2635 + console.log("Data stored successfully");
2636 + },
2637 + error: function (error) {
2638 + console.log("Error in storing data");
2639 + }
2640 + });
2386 2641 }
2387 - });
2642 + }
2388 2643 } else {
2389 2644 console.warn("Analytics object not available or pro not active");
2390 2645 }
2391 2646 }
@@ -2398,9 +2653,9 @@
2398 2653 } else {
2399 2654 return "desktop";
2400 2655 }
2401 2656 }
2402 - panoshow' . $id . '.on("scenechange", function(scene) {
2657 + panoshow' . $pano_suffix . '.on("scenechange", function(scene) {
2403 2658 onLoadAnalytics = true;
2404 2659 sceneLoadAnalytics = true;
2405 2660 let scene_id = scene;
2406 2661 let tour_id = ' . $id . ';
@@ -2416,29 +2671,31 @@
2416 2671 user_agent: user_agent,
2417 2672 device_type: device_type,
2418 2673 });
2419 2674 });
2420 - panoshow' . $id . '.on("load", function() {
2421 - let scene_id = panoshow' . $id . '.getScene();
2675 + panoshow' . $pano_suffix . '.on("load", function() {
2676 + let scene_id = panoshow' . $pano_suffix . '.getScene();
2422 2677 let tour_id = ' . $id . ';
2423 2678 let type = "scene";
2424 2679 let hotspot_id = "";
2425 2680 let user_agent = navigator.userAgent;
2426 2681 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2427 - if(!onLoadAnalytics && !sceneLoadAnalytics) {
2428 - storeAnalyticsData({
2429 - scene_id: scene_id,
2430 - tour_id: tour_id,
2431 - type: type,
2432 - hotspot_id: hotspot_id,
2433 - user_agent: user_agent,
2434 - device_type: device_type,
2435 - });
2682 + if(!onLoadAnalytics) {
2683 + if(!sceneLoadAnalytics) {
2684 + storeAnalyticsData({
2685 + scene_id: scene_id,
2686 + tour_id: tour_id,
2687 + type: type,
2688 + hotspot_id: hotspot_id,
2689 + user_agent: user_agent,
2690 + device_type: device_type,
2691 + });
2692 + }
2436 2693 }
2437 2694 });
2438 - function wpvrhotspotscene(hotSpotDiv, args) {
2695 + function wpvrhotspotscene' . $pano_suffix . '(hotSpotDiv, args) {
2439 2696 onLoadAnalytics = true;
2440 - let scene_id = panoshow' . $id . '.getScene();
2697 + let scene_id = panoshow' . $pano_suffix . '.getScene();
2441 2698 let tour_id = ' . $id . ';
2442 2699 let type = "hotspot";
2443 2700 let hotspot_id = args;
2444 2701 let user_agent = navigator.userAgent;
@@ -2451,27 +2708,28 @@
2451 2708 user_agent: user_agent,
2452 2709 device_type: device_type
2453 2710 });
2454 2711 }
2712 + var wpvrhotspotscene = wpvrhotspotscene' . $pano_suffix . ';
2455 2713 ';
2456 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2714 + $html .= 'panoshow' . $pano_suffix . '.on("scenechange", function (scene){
2457 2715 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2458 2716 active_scene = scene;
2459 2717 // if(localStorage.getItem("vr_mode") == "on") {
2460 2718 if(vr_mode == "on") {
2461 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2462 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2719 + jQuery("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2720 + jQuery("#' . $panoid . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2463 2721 }
2464 2722 });
2465 2723 var compassBlock = "";
2466 2724 var infoBlock = "";
2467 - jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2468 - jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2469 - jQuery("#pano' . $id . ' .pnlm-load-button").trigger("click");
2725 + jQuery(document).on("click",".vr_mode_change' . $pano_suffix . '",function (){
2726 + jQuery("#' . $panoid2 . ' .pnlm-load-button").trigger("click");
2727 + jQuery("#' . $panoid . ' .pnlm-load-button").trigger("click");
2470 2728 var getValue = jQuery(this).val();
2471 2729 var getParent = jQuery(this).parent().parent();
2472 - var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2473 - var panoInfo = getParent.find("#pano' . $id . ' .pnlm-panorama-info").css("display");
2730 + var compass = getParent.find("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2731 + var panoInfo = getParent.find("#' . $panoid . ' .pnlm-panorama-info").css("display");
2474 2732 if(compass == "block"){
2475 2733 compassBlock = "block";
2476 2734 }
2477 2735 if(panoInfo == "block"){
@@ -2486,79 +2744,79 @@
2486 2744 // localStorage.setItem("vr_mode", "on");
2487 2745 vr_mode = "on";
2488 2746 jQuery(".vr-mode-title").show();
2489 2747 jQuery(this).val("on");
2490 - getParent.find("#pano2' . $id . '").css({
2748 + getParent.find("#' . $panoid2 . '").css({
2491 2749 "opacity": "1",
2492 2750 "visibility": "visible",
2493 2751 "position": "relative",
2494 2752 });
2495 2753 gyroSwitch = true;
2496 - panoshow' . $id . '.startOrientation();
2497 - panoshow2' . $id . '.startOrientation();
2498 - panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
2499 - panoshow2' . $id . '.setYaw(panoshow' . $id . '.getYaw(), 0);
2754 + panoshow' . $pano_suffix . '.startOrientation();
2755 + panoshow2' . $pano_suffix . '.startOrientation();
2756 + panoshow2' . $pano_suffix . '.setPitch(panoshow' . $pano_suffix . '.getPitch(), 0);
2757 + panoshow2' . $pano_suffix . '.setYaw(panoshow' . $pano_suffix . '.getYaw(), 0);
2500 2758 getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2501 - getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").hide();
2502 - getParent.find("#pano' .$id. ' #controls'.$id.'").hide();
2503 - getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").hide();
2504 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
2505 - getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").hide();
2506 - getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").hide();
2507 - getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2508 - getParent.find("#pano' .$id. ' #adcontrol'.$id.'").hide();
2509 - getParent.find("#pano' .$id. ' .wpvr_slider_nav").hide();
2510 - getParent.find("#pano' .$id. ' #cp-logo-controls").hide();
2511 - getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").hide();
2512 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
2513 - getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
2514 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2515 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2516 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
2517 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
2518 - getParent.find("#pano' . $id . '").addClass("cardboard-half");
2519 - getParent.find("#center-pointer' . $id . '").show();
2759 + getParent.find("#' . $panoid . ' #zoom-in-out-controls' . $pano_suffix . '").hide();
2760 + getParent.find("#' . $panoid . ' #controls' . $pano_suffix . '").hide();
2761 + getParent.find("#' . $panoid . ' #explainer_button_' . $pano_suffix . '").hide();
2762 + getParent.find("#' . $panoid . ' #generic_form_button_' . $pano_suffix . '").hide();
2763 + getParent.find("#' . $panoid . ' #floor_map_button_' . $pano_suffix . '").hide();
2764 + getParent.find("#' . $panoid . ' #vrgcontrols' . $pano_suffix . '").hide();
2765 + getParent.find("#' . $panoid . ' #sccontrols' . $pano_suffix . '").hide();
2766 + getParent.find("#' . $panoid . ' #adcontrol' . $pano_suffix . '").hide();
2767 + getParent.find("#' . $panoid . ' .wpvr_slider_nav").hide();
2768 + getParent.find("#' . $panoid . ' #cp-logo-controls").hide();
2769 + getParent.find("#' . $panoid . ' #wpvr-social-share-bg-box' . $pano_suffix . '").hide();
2770 + getParent.find("#' . $panoid2 . ' .pnlm-controls-container").hide();
2771 + getParent.find("#' . $panoid . ' .pnlm-controls-container").hide();
2772 + getParent.find("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2773 + getParent.find("#' . $panoid . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2774 + getParent.find("#' . $panoid2 . ' .pnlm-panorama-info").hide();
2775 + getParent.find("#' . $panoid . ' .pnlm-panorama-info").hide();
2776 + getParent.find("#' . $panoid . '").addClass("cardboard-half");
2777 + getParent.find("#center-pointer' . $pano_suffix . '").show();
2520 2778 getParent.find(".fullscreen-button").hide();
2521 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
2779 + getParent.find("#' . $panoid . ' #custom-scene-navigation' . $pano_suffix . '").hide();
2522 2780 if (window.DeviceOrientationEvent) {
2523 2781 window.addEventListener("deviceorientation", vrDeviseOrientation);
2524 2782 }
2525 - panoshow' . $id . '.on("zoomchange", function (data){
2526 - panoshow2' . $id . '.setHfov(data, 0);
2783 + panoshow' . $pano_suffix . '.on("zoomchange", function (data){
2784 + panoshow2' . $pano_suffix . '.setHfov(data, 0);
2527 2785 });
2528 - panoshow2' . $id . '.on("zoomchange", function (data){
2529 - panoshow' . $id . '.setHfov(data, 0);
2786 + panoshow2' . $pano_suffix . '.on("zoomchange", function (data){
2787 + panoshow' . $pano_suffix . '.setHfov(data, 0);
2530 2788 });
2531 - jQuery(document).on("click","#pano2' . $id . '",function(event) {
2532 - panoshow' . $id . '.startOrientation();
2533 - panoshow2' . $id . '.startOrientation();
2789 + jQuery(document).on("click","#' . $panoid2 . '",function(event) {
2790 + panoshow' . $pano_suffix . '.startOrientation();
2791 + panoshow2' . $pano_suffix . '.startOrientation();
2534 2792 });
2535 - jQuery(document).on("click","#pano' . $id . '",function(event) {
2536 - panoshow' . $id . '.startOrientation();
2537 - panoshow2' . $id . '.startOrientation();
2793 + jQuery(document).on("click","#' . $panoid . '",function(event) {
2794 + panoshow' . $pano_suffix . '.startOrientation();
2795 + panoshow2' . $pano_suffix . '.startOrientation();
2538 2796 });
2539 - panoshow' . $id . '.on("mousemove", function (data){
2540 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2541 - panoshow2' . $id . '.setYaw(data.yaw, 0);
2797 + panoshow' . $pano_suffix . '.on("mousemove", function (data){
2798 + panoshow2' . $pano_suffix . '.setPitch(data.pitch, 0);
2799 + panoshow2' . $pano_suffix . '.setYaw(data.yaw, 0);
2542 2800 panoShowCardBoardOnTrigger(data);
2543 2801 });
2544 - panoshow2' . $id . '.on("mousemove", function (data){
2545 - panoshow' . $id . '.setPitch(data.pitch, 0);
2546 - panoshow' . $id . '.setYaw(data.yaw, 0);
2802 + panoshow2' . $pano_suffix . '.on("mousemove", function (data){
2803 + panoshow' . $pano_suffix . '.setPitch(data.pitch, 0);
2804 + panoshow' . $pano_suffix . '.setYaw(data.yaw, 0);
2547 2805 panoShowCardBoardOnTrigger(data);
2548 2806 });
2549 - panoshow' . $id . '.on("touchmove", function (data){
2550 - panoshow' . $id . '.stopOrientation();
2551 - panoshow2' . $id . '.stopOrientation();
2552 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2553 - panoshow2' . $id . '.setYaw(data.yaw, 0);
2807 + panoshow' . $pano_suffix . '.on("touchmove", function (data){
2808 + panoshow' . $pano_suffix . '.stopOrientation();
2809 + panoshow2' . $pano_suffix . '.stopOrientation();
2810 + panoshow2' . $pano_suffix . '.setPitch(data.pitch, 0);
2811 + panoshow2' . $pano_suffix . '.setYaw(data.yaw, 0);
2554 2812 panoShowCardBoardOnTrigger(data);
2555 2813 });
2556 - panoshow2' . $id . '.on("touchmove", function (data){
2557 - panoshow' . $id . '.stopOrientation();
2558 - panoshow2' . $id . '.stopOrientation();
2559 - panoshow' . $id . '.setPitch(data.pitch, 0);
2560 - panoshow' . $id . '.setYaw(data.yaw, 0);
2814 + panoshow2' . $pano_suffix . '.on("touchmove", function (data){
2815 + panoshow' . $pano_suffix . '.stopOrientation();
2816 + panoshow2' . $pano_suffix . '.stopOrientation();
2817 + panoshow' . $pano_suffix . '.setPitch(data.pitch, 0);
2818 + panoshow' . $pano_suffix . '.setYaw(data.yaw, 0);
2561 2819 panoShowCardBoardOnTrigger(data);
2562 2820 });
2563 2821 } else if(getValue == "on") {
2564 2822 screen.orientation.unlock();
@@ -2566,66 +2824,66 @@
2566 2824 // localStorage.setItem("vr_mode", "off");
2567 2825 vr_mode = "off";
2568 2826 jQuery(".vr-mode-title").hide();
2569 2827 jQuery(this).val("off");
2570 - getParent.find("#pano2' . $id . '").css({
2828 + getParent.find("#' . $panoid2 . '").css({
2571 2829 "opacity": "0",
2572 2830 "visibility": "hidden",
2573 2831 "position": "absolute",
2574 2832 });
2575 2833 getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
2576 - getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").show();
2577 - getParent.find("#pano' .$id. ' #controls'.$id.'").show();
2578 - getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").show();
2579 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
2580 - getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").show();
2581 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
2582 - getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
2583 - getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").show();
2584 - getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2585 - getParent.find("#pano' .$id. ' #adcontrol'.$id.'").show();
2586 - getParent.find("#pano' .$id. ' .wpvr_slider_nav").hide();
2587 - getParent.find("#pano' .$id. ' #cp-logo-controls").show();
2588 - getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").show();
2589 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").show();
2834 + getParent.find("#' . $panoid . ' #zoom-in-out-controls' . $pano_suffix . '").show();
2835 + getParent.find("#' . $panoid . ' #controls' . $pano_suffix . '").show();
2836 + getParent.find("#' . $panoid . ' #explainer_button_' . $pano_suffix . '").show();
2837 + getParent.find("#' . $panoid . ' #generic_form_button_' . $pano_suffix . '").show();
2838 + getParent.find("#' . $panoid . ' #floor_map_button_' . $pano_suffix . '").show();
2839 + getParent.find("#' . $panoid2 . ' .pnlm-controls-container").show();
2840 + getParent.find("#' . $panoid . ' .pnlm-controls-container").show();
2841 + getParent.find("#' . $panoid . ' #vrgcontrols' . $pano_suffix . '").show();
2842 + getParent.find("#' . $panoid . ' #sccontrols' . $pano_suffix . '").hide();
2843 + getParent.find("#' . $panoid . ' #adcontrol' . $pano_suffix . '").show();
2844 + getParent.find("#' . $panoid . ' .wpvr_slider_nav").hide();
2845 + getParent.find("#' . $panoid . ' #cp-logo-controls").show();
2846 + getParent.find("#' . $panoid . ' #wpvr-social-share-bg-box' . $pano_suffix . '").show();
2847 + getParent.find("#' . $panoid . ' #custom-scene-navigation' . $pano_suffix . '").show();
2590 2848 if(compassBlock == "block"){
2591 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2592 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2849 + getParent.find("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2850 + getParent.find("#' . $panoid . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2593 2851 }
2594 2852 if(infoBlock == "block"){
2595 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
2596 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
2853 + getParent.find("#' . $panoid2 . ' .pnlm-panorama-info").show();
2854 + getParent.find("#' . $panoid . ' .pnlm-panorama-info").show();
2597 2855 }
2598 - getParent.find("#pano' . $id . '").removeClass("cardboard-half");
2599 - getParent.find("#center-pointer' . $id . '").hide();
2856 + getParent.find("#' . $panoid . '").removeClass("cardboard-half");
2857 + getParent.find("#center-pointer' . $pano_suffix . '").hide();
2600 2858 getParent.find(".fullscreen-button").hide();
2601 - panoshow' . $id . '.off("mousemove");
2602 - panoshow' . $id . '.off("touchmove");
2603 - panoshow2' . $id . '.off("mousemove");
2604 - panoshow2' . $id . '.off("touchmove");
2859 + panoshow' . $pano_suffix . '.off("mousemove");
2860 + panoshow' . $pano_suffix . '.off("touchmove");
2861 + panoshow2' . $pano_suffix . '.off("mousemove");
2862 + panoshow2' . $pano_suffix . '.off("touchmove");
2605 2863 if (window.DeviceOrientationEvent) {
2606 2864 window.removeEventListener("deviceorientation", vrDeviseOrientation);
2607 2865 }
2608 2866 }
2609 2867 });';
2610 - $html .= 'panoshow2' . $id . '.on("load", function (){
2868 + $html .= 'panoshow2' . $pano_suffix . '.on("load", function (){
2611 2869 // if(localStorage.getItem("vr_mode") == "off") {
2612 2870 if( vr_mode == "off") {
2613 2871 jQuery(".vr-mode-title").hide();
2614 2872 }
2615 2873 else {
2616 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2617 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2618 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2619 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
2874 + jQuery("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2875 + jQuery("#' . $panoid . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2876 + jQuery("#' . $panoid2 . ' .pnlm-panorama-info").hide();
2877 + jQuery("#' . $panoid . ' .pnlm-panorama-info").hide();
2620 2878 jQuery(".vr-mode-title").show();
2621 2879 }
2622 2880 });';
2623 2881 }
2624 2882 //=== end Dplicate mode only for vr mode===//
2625 - $html .= 'jQuery("#pano' . $id . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
2883 + $html .= 'jQuery("#' . $panoid . ' .wpvr-floor-map .floor-plan-pointer").on("click",function(){
2626 2884 var scene_id = jQuery(this).attr("scene_id");
2627 - panoshow' . $id . '.loadScene(scene_id)
2885 + panoshow' . $pano_suffix . '.loadScene(scene_id)
2628 2886 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2629 2887 jQuery(this).addClass("add-pulse")
2630 2888 });';
2631 2889 if ($scene_animation_enabled && is_plugin_active('wpvr-pro/wpvr-pro.php')) {
@@ -2635,9 +2893,9 @@
2635 2893 $animationDelay = $postdata['sceneAnimationTransitionDelay'] ?? '0ms';
2636 2894 $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
2637 2895 if (!empty($animation_js)) {
2638 2896 $html .= $animation_js;
2639 - $html .= 'panoshow' . $id . '.on("load", function (scene){
2897 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (scene){
2640 2898 if (typeof changeScene === "function") {
2641 2899 changeScene();
2642 2900 } else {
2643 2901 console.warn("changeScene function is not defined.");
@@ -2645,15 +2903,15 @@
2645 2903 });';
2646 2904 }
2647 2905 }
2648 2906
2649 - $html .= 'panoshow' . $id . '.on("mousemove", function (data){
2907 + $html .= 'panoshow' . $pano_suffix . '.on("mousemove", function (data){
2650 2908 jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
2651 2909 });
2652 2910 ';
2653 2911 $status = get_option('wpvr_edd_license_status');
2654 2912 if ($status !== false && 'valid' == $status && $is_pro){
2655 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2913 + $html .= 'panoshow' . $pano_suffix . '.on("scenechange", function (scene){
2656 2914 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2657 2915 jQuery(".floor-plan-pointer").each(function(index ,element){
2658 2916 var scene_id = jQuery(this).attr("scene_id");
2659 2917 if( active_scene == scene_id ){
@@ -2661,9 +2919,9 @@
2661 2919 jQuery(this).addClass("add-pulse")
2662 2920 }
2663 2921 });
2664 2922 });';
2665 - $html .= 'panoshow' . $id . '.on("load", function (){
2923 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
2666 2924 if(jQuery(".floor-plan-pointer").length > 0){
2667 2925 jQuery(".floor-plan-pointer").each(function(index ,element){
2668 2926 var scene_id = jQuery(this).attr("scene_id");
2669 2927 if( active_scene == scene_id ){
@@ -2675,14 +2933,14 @@
2675 2933 });';
2676 2934 }
2677 2935 if ($status !== false && 'valid' == $status && $is_pro){
2678 2936 $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
2679 - $html .= 'jQuery("#pano' . $id . ' .custom-scene-navigation").on("click", function() {
2680 - jQuery("#custom-scene-navigation-nav' . $id . ' ul").empty();
2937 + $html .= 'jQuery("#' . $panoid . ' .custom-scene-navigation").on("click", function() {
2938 + jQuery("#custom-scene-navigation-nav' . $pano_suffix . ' ul").empty();
2681 2939 if (scenes) {
2682 2940 var scene_navigation_content_type = "' . $scene_navigation_content_type . '";
2683 2941 var sceneList = scenes.scenes;
2684 - var getScene = panoshow' . $id . '.getScene();
2942 + var getScene = panoshow' . $pano_suffix . '.getScene();
2685 2943 for (const key in sceneList) {
2686 2944 let title;
2687 2945 if (scene_navigation_content_type === "scene_title") {
2688 2946 if (sceneList[key].title) {
@@ -2701,9 +2959,9 @@
2701 2959 } else {
2702 2960 title = key;
2703 2961 }
2704 2962 if (sceneList.hasOwnProperty(key)) {
2705 - let ulElement = document.querySelector("#custom-scene-navigation-nav' . $id . ' ul");
2963 + let ulElement = document.querySelector("#custom-scene-navigation-nav' . $pano_suffix . ' ul");
2706 2964 if (ulElement) {
2707 2965 let liElement = document.createElement("li");
2708 2966 liElement.className = "scene-navigation-list" + (key === getScene ? " active" : "");
2709 2967 liElement.setAttribute("scene_id", key);
@@ -2711,9 +2969,9 @@
2711 2969 ulElement.appendChild(liElement);
2712 2970 }
2713 2971 }
2714 2972 }
2715 - jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
2973 + jQuery("#custom-scene-navigation-nav' . $pano_suffix . '").toggleClass("visible");
2716 2974 }
2717 2975 });';
2718 2976 $html .='function getImageNameWithoutExtension(imageUrl) {
2719 2977 // Split the URL by "/"
@@ -2726,70 +2984,70 @@
2726 2984 var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
2727 2985 // Return the image name without extension
2728 2986 return imageNameWithoutExtension;
2729 2987 }';
2730 - $html .= 'jQuery("#pano' . $id . ' #custom-scene-navigation-nav' . $id . ' ul").on("click", "li.scene-navigation-list", function() {
2988 + $html .= 'jQuery("#' . $panoid . ' #custom-scene-navigation-nav' . $pano_suffix . ' ul").on("click", "li.scene-navigation-list", function() {
2731 2989 if (scenes) {
2732 2990 jQuery(this).siblings("li").removeClass("active");
2733 2991 jQuery(this).addClass("active");
2734 2992 var scene_key = jQuery(this).attr("scene_id");
2735 - panoshow' . $id . '.loadScene(scene_key);
2993 + panoshow' . $pano_suffix . '.loadScene(scene_key);
2736 2994 }
2737 2995 });';
2738 2996 }
2739 2997 $html .= 'const node = document.querySelector(".add-pulse");
2740 - panoshow' . $id . '.on("compasschange", function (data){
2998 + panoshow' . $pano_suffix . '.on("compasschange", function (data){
2741 2999 // const node = document.querySelector(".add-pulse");
2742 3000 // node.style.transform = data;
2743 3001 // jQuery(".add-pulse").css({"transform":data});
2744 3002 });';
2745 - $html .= 'panoshow' . $id . '.on("load", function (){
3003 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
2746 3004 // if(localStorage.getItem("vr_mode") == "off") {
2747 3005 if(vr_mode == "off") {
2748 3006 jQuery(".vr-mode-title").hide();
2749 3007 } else {
2750 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2751 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2752 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2753 - jQuery("#pano' . $id . ' .pnlm-panorama-info").hide();
3008 + jQuery("#' . $panoid2 . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3009 + jQuery("#' . $panoid . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
3010 + jQuery("#' . $panoid2 . ' .pnlm-panorama-info").hide();
3011 + jQuery("#' . $panoid . ' .pnlm-panorama-info").hide();
2754 3012 jQuery(".vr-mode-title").show();
2755 3013 }
2756 3014 setTimeout(() => {
2757 3015 window.dispatchEvent(new Event("resize"));
2758 3016 }, 200);
2759 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
2760 - jQuery("#controls' . $id . '").css("bottom", "80px");
3017 + if (jQuery("#' . $panoid . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3018 + jQuery("#controls' . $pano_suffix . '").css("bottom", "80px");
2761 3019 }
2762 3020 else {
2763 - jQuery("#controls' . $id . '").css("bottom", "5px");
3021 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
2764 3022 }
2765 3023 });';
2766 - $html .= 'panoshow' . $id . '.on("render", function (){
3024 + $html .= 'panoshow' . $pano_suffix . '.on("render", function (){
2767 3025 window.dispatchEvent(new Event("resize"));
2768 3026 });';
2769 3027 $html .= 'if (scenes.autoRotate) {
2770 - var wpvrAutoRotateTimer' . $id . ' = null;
2771 - var wpvrAutoRotateStopDelay' . $id . ' = parseInt(scenes.autoRotateStopDelay, 10) || 0;
2772 - var wpvrScheduleAutoRotate' . $id . ' = function () {
2773 - clearTimeout(wpvrAutoRotateTimer' . $id . ');
2774 - if (wpvrAutoRotateStopDelay' . $id . ' > 0) {
2775 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
2776 - panoshow' . $id . '.stopAutoRotate();
2777 - }, wpvrAutoRotateStopDelay' . $id . ');
3028 + var wpvrAutoRotateTimer' . $pano_suffix . ' = null;
3029 + var wpvrAutoRotateStopDelay' . $pano_suffix . ' = parseInt(scenes.autoRotateStopDelay, 10) || 0;
3030 + var wpvrScheduleAutoRotate' . $pano_suffix . ' = function () {
3031 + clearTimeout(wpvrAutoRotateTimer' . $pano_suffix . ');
3032 + if (wpvrAutoRotateStopDelay' . $pano_suffix . ' > 0) {
3033 + wpvrAutoRotateTimer' . $pano_suffix . ' = setTimeout(function () {
3034 + panoshow' . $pano_suffix . '.stopAutoRotate();
3035 + }, wpvrAutoRotateStopDelay' . $pano_suffix . ');
2778 3036 } else {
2779 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
2780 - panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0);
3037 + wpvrAutoRotateTimer' . $pano_suffix . ' = setTimeout(function () {
3038 + panoshow' . $pano_suffix . '.startAutoRotate(scenes.autoRotate, 0);
2781 3039 }, 3000);
2782 3040 }
2783 3041 };
2784 - panoshow' . $id . '.on("load", wpvrScheduleAutoRotate' . $id . ');
2785 - panoshow' . $id . '.on("scenechange", wpvrScheduleAutoRotate' . $id . ');
3042 + panoshow' . $pano_suffix . '.on("load", wpvrScheduleAutoRotate' . $pano_suffix . ');
3043 + panoshow' . $pano_suffix . '.on("scenechange", wpvrScheduleAutoRotate' . $pano_suffix . ');
2786 3044 }';
2787 3045 $html .= 'var touchtime = 0;';
2788 3046 $html .= '
2789 - var wpvrHotspotRoot' . $id . ' = document.getElementById("pano' . $id . '");
2790 - if (wpvrHotspotRoot' . $id . ') {
2791 - wpvrHotspotRoot' . $id . '.addEventListener("click", function (event) {
3047 + var wpvrHotspotRoot' . $pano_suffix . ' = document.getElementById("' . $panoid . '");
3048 + if (wpvrHotspotRoot' . $pano_suffix . ') {
3049 + wpvrHotspotRoot' . $pano_suffix . '.addEventListener("click", function (event) {
2792 3050 var hotspot = event.target.closest(".pnlm-hotspot-base");
2793 3051
2794 3052 if (!hotspot) {
2795 3053 return;
@@ -2794,8 +3052,13 @@
2794 3052 if (!hotspot) {
2795 3053 return;
2796 3054 }
2797 3055
3056 + // Social share icons navigate independently using their own links and targets.
3057 + if (hotspot.querySelector(".wpvr-sticker-card--social-share")) {
3058 + return;
3059 + }
3060 +
2798 3061 var hotspotLink = hotspot.closest("a[href]");
2799 3062 if (!hotspotLink) {
2800 3063 hotspotLink = hotspot.querySelector("a[href]");
2801 3064 }
@@ -2820,11 +3083,11 @@
2820 3083 if (isset($panodata["scene-list"])) {
2821 3084 foreach ($panodata["scene-list"] as $panoscenes) {
2822 3085 $scene_key = $panoscenes['scene-id'];
2823 3086 $gallery_scene_ids[] = (string) $scene_key;
2824 - $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
3087 + $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $pano_suffix;
2825 3088 $html .= 'jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
2826 - panoshow' . $id . '.loadScene("' . $scene_key . '");
3089 + panoshow' . $pano_suffix . '.loadScene(' . wp_json_encode( (string) $scene_key ) . ');
2827 3090 });';
2828 3091 }
2829 3092 }
2830 3093
@@ -2852,22 +3115,22 @@
2852 3115 stagePadding: 0
2853 3116 }';
2854 3117
2855 3118 $html .= '
2856 - var wpvrGallery' . $id . ' = jQuery("#sccontrols' . $id . '");
2857 - var wpvrGalleryRoot' . $id . ' = jQuery("#pano' . $id . '");
2858 - var wpvrGalleryScenes' . $id . ' = ' . wp_json_encode(array_values($gallery_scene_ids)) . ';
2859 - var wpvrGalleryResizeTimer' . $id . ';
2860 - var wpvrGalleryVisibilityTimer' . $id . ';
2861 - var wpvrGalleryObserver' . $id . ';
3119 + var wpvrGallery' . $pano_suffix . ' = jQuery("#sccontrols' . $pano_suffix . '");
3120 + var wpvrGalleryRoot' . $pano_suffix . ' = jQuery("#' . $panoid . '");
3121 + var wpvrGalleryScenes' . $pano_suffix . ' = ' . wp_json_encode(array_values($gallery_scene_ids)) . ';
3122 + var wpvrGalleryResizeTimer' . $pano_suffix . ';
3123 + var wpvrGalleryVisibilityTimer' . $pano_suffix . ';
3124 + var wpvrGalleryObserver' . $pano_suffix . ';
2862 3125
2863 - function wpvrPrepareSceneNavigation' . $id . '() {
2864 - var navigationDisabled = wpvrGalleryScenes' . $id . '.length < 2;
2865 - var previousButtons = wpvrGalleryRoot' . $id . '.find(".wpvr_owl_prev");
2866 - var nextButtons = wpvrGalleryRoot' . $id . '.find(".wpvr_owl_next");
3126 + function wpvrPrepareSceneNavigation' . $pano_suffix . '() {
3127 + var navigationDisabled = wpvrGalleryScenes' . $pano_suffix . '.length < 2;
3128 + var previousButtons = wpvrGalleryRoot' . $pano_suffix . '.find(".wpvr_owl_prev");
3129 + var nextButtons = wpvrGalleryRoot' . $pano_suffix . '.find(".wpvr_owl_next");
2867 3130
2868 - wpvrGallery' . $id . '.removeClass("owl-theme");
2869 - wpvrGalleryRoot' . $id . '.find(".wpvr_slider_nav").removeClass("owl-nav");
3131 + wpvrGallery' . $pano_suffix . '.removeClass("owl-theme");
3132 + wpvrGalleryRoot' . $pano_suffix . '.find(".wpvr_slider_nav").removeClass("owl-nav");
2870 3133 previousButtons
2871 3134 .removeClass("owl-prev")
2872 3135 .prop("disabled", navigationDisabled)
2873 3136 .toggleClass("disabled", navigationDisabled);
@@ -2876,76 +3139,76 @@
2876 3139 .prop("disabled", navigationDisabled)
2877 3140 .toggleClass("disabled", navigationDisabled);
2878 3141 }
2879 3142
2880 - function wpvrRefreshGallery' . $id . '() {
2881 - wpvrPrepareSceneNavigation' . $id . '();
3143 + function wpvrRefreshGallery' . $pano_suffix . '() {
3144 + wpvrPrepareSceneNavigation' . $pano_suffix . '();
2882 3145
2883 - if (!wpvrGallery' . $id . '.length || !wpvrGallery' . $id . '.hasClass("owl-loaded") || !wpvrGallery' . $id . '.is(":visible")) {
3146 + if (!wpvrGallery' . $pano_suffix . '.length || !wpvrGallery' . $pano_suffix . '.hasClass("owl-loaded") || !wpvrGallery' . $pano_suffix . '.is(":visible")) {
2884 3147 return;
2885 3148 }
2886 3149
2887 - if (wpvrGallery' . $id . '.css("display") === "flex") {
2888 - wpvrGallery' . $id . '.css("display", "block");
3150 + if (wpvrGallery' . $pano_suffix . '.css("display") === "flex") {
3151 + wpvrGallery' . $pano_suffix . '.css("display", "block");
2889 3152 }
2890 - wpvrGallery' . $id . '.trigger("refresh.owl.carousel");
2891 - wpvrUpdateGalleryNavigation' . $id . '(panoshow' . $id . '.getScene());
3153 + wpvrGallery' . $pano_suffix . '.trigger("refresh.owl.carousel");
3154 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2892 3155 }
2893 3156
2894 - function wpvrGallerySceneIndex' . $id . '(sceneId) {
2895 - return wpvrGalleryScenes' . $id . '.indexOf(String(sceneId));
3157 + function wpvrGallerySceneIndex' . $pano_suffix . '(sceneId) {
3158 + return wpvrGalleryScenes' . $pano_suffix . '.indexOf(String(sceneId));
2896 3159 }
2897 3160
2898 - function wpvrUpdateGalleryNavigation' . $id . '(sceneId) {
2899 - var currentIndex = wpvrGallerySceneIndex' . $id . '(sceneId);
2900 - var activeThumbnailId = String(sceneId) + "_gallery_' . $id . '";
2901 - var thumbnails = wpvrGallery' . $id . '.find("img.scctrl");
3161 + function wpvrUpdateGalleryNavigation' . $pano_suffix . '(sceneId) {
3162 + var currentIndex = wpvrGallerySceneIndex' . $pano_suffix . '(sceneId);
3163 + var activeThumbnailId = String(sceneId) + "_gallery_' . $pano_suffix . '";
3164 + var thumbnails = wpvrGallery' . $pano_suffix . '.find("img.scctrl");
2902 3165 var activeThumbnail = thumbnails.filter(function () {
2903 3166 return this.id === activeThumbnailId;
2904 3167 });
2905 3168
2906 - wpvrPrepareSceneNavigation' . $id . '();
3169 + wpvrPrepareSceneNavigation' . $pano_suffix . '();
2907 3170 thumbnails.removeClass("wpvr-active-thumbnail");
2908 - wpvrGallery' . $id . '.find(".owl-item").removeClass("clicked");
3171 + wpvrGallery' . $pano_suffix . '.find(".owl-item").removeClass("clicked");
2909 3172 activeThumbnail.addClass("wpvr-active-thumbnail");
2910 3173 activeThumbnail.closest(".owl-item").addClass("clicked");
2911 3174
2912 3175 if (currentIndex >= 0) {
2913 - if (wpvrGallery' . $id . '.hasClass("owl-loaded")) {
2914 - wpvrGallery' . $id . '.trigger("to.owl.carousel", [currentIndex, 300, true]);
2915 - window.setTimeout(wpvrPrepareSceneNavigation' . $id . ', 0);
3176 + if (wpvrGallery' . $pano_suffix . '.hasClass("owl-loaded")) {
3177 + wpvrGallery' . $pano_suffix . '.trigger("to.owl.carousel", [currentIndex, 300, true]);
3178 + window.setTimeout(wpvrPrepareSceneNavigation' . $pano_suffix . ', 0);
2916 3179 }
2917 3180 }
2918 3181 }
2919 3182
2920 - function wpvrLoadAdjacentGalleryScene' . $id . '(direction) {
2921 - var currentIndex = wpvrGallerySceneIndex' . $id . '(panoshow' . $id . '.getScene());
3183 + function wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(direction) {
3184 + var currentIndex = wpvrGallerySceneIndex' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2922 3185
2923 - if (currentIndex < 0 || wpvrGalleryScenes' . $id . '.length < 2) {
3186 + if (currentIndex < 0 || wpvrGalleryScenes' . $pano_suffix . '.length < 2) {
2924 3187 return;
2925 3188 }
2926 3189
2927 - var targetIndex = (currentIndex + direction + wpvrGalleryScenes' . $id . '.length) % wpvrGalleryScenes' . $id . '.length;
2928 - panoshow' . $id . '.loadScene(wpvrGalleryScenes' . $id . '[targetIndex]);
3190 + var targetIndex = (currentIndex + direction + wpvrGalleryScenes' . $pano_suffix . '.length) % wpvrGalleryScenes' . $pano_suffix . '.length;
3191 + panoshow' . $pano_suffix . '.loadScene(wpvrGalleryScenes' . $pano_suffix . '[targetIndex]);
2929 3192 }
2930 3193
2931 3194 if (jQuery.fn.owlCarousel) {
2932 - if (wpvrGallery' . $id . '.length) {
2933 - if (!wpvrGallery' . $id . '.hasClass("owl-loaded")) {
2934 - wpvrGallery' . $id . '.owlCarousel(' . $gallery_options . ');
3195 + if (wpvrGallery' . $pano_suffix . '.length) {
3196 + if (!wpvrGallery' . $pano_suffix . '.hasClass("owl-loaded")) {
3197 + wpvrGallery' . $pano_suffix . '.owlCarousel(' . $gallery_options . ');
2935 3198 }
2936 3199 }
2937 3200 }
2938 3201
2939 - wpvrGalleryRoot' . $id . '
2940 - .off("click.wpvrGalleryRefresh' . $id . '", "#vrgcontrols' . $id . '")
2941 - .on("click.wpvrGalleryRefresh' . $id . '", "#vrgcontrols' . $id . '", function () {
2942 - wpvrPrepareSceneNavigation' . $id . '();
2943 - window.setTimeout(wpvrRefreshGallery' . $id . ', 450);
3202 + wpvrGalleryRoot' . $pano_suffix . '
3203 + .off("click.wpvrGalleryRefresh' . $pano_suffix . '", "#vrgcontrols' . $pano_suffix . '")
3204 + .on("click.wpvrGalleryRefresh' . $pano_suffix . '", "#vrgcontrols' . $pano_suffix . '", function () {
3205 + wpvrPrepareSceneNavigation' . $pano_suffix . '();
3206 + window.setTimeout(wpvrRefreshGallery' . $pano_suffix . ', 450);
2944 3207 });
2945 3208
2946 - if (wpvrGalleryRoot' . $id . '.length) {
2947 - wpvrGalleryRoot' . $id . '[0].addEventListener("click", function (event) {
3209 + if (wpvrGalleryRoot' . $pano_suffix . '.length) {
3210 + wpvrGalleryRoot' . $pano_suffix . '[0].addEventListener("click", function (event) {
2948 3211 var navigationButton = event.target.closest(".wpvr_owl_prev, .wpvr_owl_next");
2949 3212
2950 3213 if (!navigationButton) {
2951 3214 return;
@@ -2950,9 +3213,9 @@
2950 3213 if (!navigationButton) {
2951 3214 return;
2952 3215 }
2953 3216
2954 - if (!wpvrGalleryRoot' . $id . '[0].contains(navigationButton)) {
3217 + if (!wpvrGalleryRoot' . $pano_suffix . '[0].contains(navigationButton)) {
2955 3218 return;
2956 3219 }
2957 3220
2958 3221 event.preventDefault();
@@ -2958,29 +3221,29 @@
2958 3221 event.preventDefault();
2959 3222 event.stopImmediatePropagation();
2960 3223
2961 3224 if (navigationButton.classList.contains("wpvr_owl_prev")) {
2962 - wpvrLoadAdjacentGalleryScene' . $id . '(-1);
3225 + wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(-1);
2963 3226 } else {
2964 - wpvrLoadAdjacentGalleryScene' . $id . '(1);
3227 + wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(1);
2965 3228 }
2966 3229 }, true);
2967 3230 }
2968 3231
2969 3232 jQuery(window)
2970 - .off("resize.wpvrGallery' . $id . '")
2971 - .on("resize.wpvrGallery' . $id . '", function () {
2972 - window.clearTimeout(wpvrGalleryResizeTimer' . $id . ');
2973 - wpvrGalleryResizeTimer' . $id . ' = window.setTimeout(wpvrRefreshGallery' . $id . ', 100);
3233 + .off("resize.wpvrGallery' . $pano_suffix . '")
3234 + .on("resize.wpvrGallery' . $pano_suffix . '", function () {
3235 + window.clearTimeout(wpvrGalleryResizeTimer' . $pano_suffix . ');
3236 + wpvrGalleryResizeTimer' . $pano_suffix . ' = window.setTimeout(wpvrRefreshGallery' . $pano_suffix . ', 100);
2974 3237 });
2975 3238
2976 3239 if (window.MutationObserver) {
2977 - if (wpvrGallery' . $id . '.length) {
2978 - wpvrGalleryObserver' . $id . ' = new MutationObserver(function () {
2979 - window.clearTimeout(wpvrGalleryVisibilityTimer' . $id . ');
2980 - wpvrGalleryVisibilityTimer' . $id . ' = window.setTimeout(wpvrRefreshGallery' . $id . ', 50);
3240 + if (wpvrGallery' . $pano_suffix . '.length) {
3241 + wpvrGalleryObserver' . $pano_suffix . ' = new MutationObserver(function () {
3242 + window.clearTimeout(wpvrGalleryVisibilityTimer' . $pano_suffix . ');
3243 + wpvrGalleryVisibilityTimer' . $pano_suffix . ' = window.setTimeout(wpvrRefreshGallery' . $pano_suffix . ', 50);
2981 3244 });
2982 - wpvrGalleryObserver' . $id . '.observe(wpvrGallery' . $id . '[0], {
3245 + wpvrGalleryObserver' . $pano_suffix . '.observe(wpvrGallery' . $pano_suffix . '[0], {
2983 3246 attributes: true,
2984 3247 attributeFilter: ["style"]
2985 3248 });
2986 3249 }
@@ -2985,15 +3248,15 @@
2985 3248 });
2986 3249 }
2987 3250 }
2988 3251
2989 - panoshow' . $id . '.on("scenechange", function (sceneId) {
2990 - wpvrUpdateGalleryNavigation' . $id . '(sceneId);
3252 + panoshow' . $pano_suffix . '.on("scenechange", function (sceneId) {
3253 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(sceneId);
2991 3254 });
2992 3255
2993 - window.setTimeout(wpvrRefreshGallery' . $id . ', 0);
3256 + window.setTimeout(wpvrRefreshGallery' . $pano_suffix . ', 0);
2994 3257 window.setTimeout(function () {
2995 - wpvrUpdateGalleryNavigation' . $id . '(panoshow' . $id . '.getScene());
3258 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2996 3259 }, 0);
2997 3260 ';
2998 3261 }
2999 3262 //===Custom Control===//
@@ -2998,44 +3261,44 @@
2998 3261 }
2999 3262 //===Custom Control===//
3000 3263 if (isset($custom_control)) {
3001 3264 if ($custom_control['panupSwitch'] == "on" && 'valid' == $status && $is_pro) {
3002 - $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
3003 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() + 10);';
3265 + $html .= 'document.getElementById("pan-up' . $pano_suffix . '").addEventListener("click", function(e) {';
3266 + $html .= 'panoshow' . $pano_suffix . '.setPitch(panoshow' . $pano_suffix . '.getPitch() + 10);';
3004 3267 $html .= '});';
3005 3268 }
3006 3269 if ($custom_control['panDownSwitch'] == "on" && 'valid' == $status && $is_pro) {
3007 - $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
3008 - $html .= 'panoshow' . $id . '.setPitch(panoshow' . $id . '.getPitch() - 10);';
3270 + $html .= 'document.getElementById("pan-down' . $pano_suffix . '").addEventListener("click", function(e) {';
3271 + $html .= 'panoshow' . $pano_suffix . '.setPitch(panoshow' . $pano_suffix . '.getPitch() - 10);';
3009 3272 $html .= '});';
3010 3273 }
3011 3274 if ($custom_control['panLeftSwitch'] == "on" && 'valid' == $status && $is_pro) {
3012 - $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
3013 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() - 10);';
3275 + $html .= 'document.getElementById("pan-left' . $pano_suffix . '").addEventListener("click", function(e) {';
3276 + $html .= 'panoshow' . $pano_suffix . '.setYaw(panoshow' . $pano_suffix . '.getYaw() - 10);';
3014 3277 $html .= '});';
3015 3278 }
3016 3279 if ($custom_control['panRightSwitch'] == "on" && 'valid' == $status && $is_pro) {
3017 - $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
3018 - $html .= 'panoshow' . $id . '.setYaw(panoshow' . $id . '.getYaw() + 10);';
3280 + $html .= 'document.getElementById("pan-right' . $pano_suffix . '").addEventListener("click", function(e) {';
3281 + $html .= 'panoshow' . $pano_suffix . '.setYaw(panoshow' . $pano_suffix . '.getYaw() + 10);';
3019 3282 $html .= '});';
3020 3283 }
3021 3284 if ($custom_control['panZoomInSwitch'] == "on") {
3022 - $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
3023 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() - 10);';
3285 + $html .= 'document.getElementById("zoom-in' . $pano_suffix . '").addEventListener("click", function(e) {';
3286 + $html .= 'panoshow' . $pano_suffix . '.setHfov(panoshow' . $pano_suffix . '.getHfov() - 10);';
3024 3287 $html .= '});';
3025 3288 }
3026 3289 if ($custom_control['panZoomOutSwitch'] == "on") {
3027 - $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
3028 - $html .= 'panoshow' . $id . '.setHfov(panoshow' . $id . '.getHfov() + 10);';
3290 + $html .= 'document.getElementById("zoom-out' . $pano_suffix . '").addEventListener("click", function(e) {';
3291 + $html .= 'panoshow' . $pano_suffix . '.setHfov(panoshow' . $pano_suffix . '.getHfov() + 10);';
3029 3292 $html .= '});';
3030 3293 }
3031 3294 if ($custom_control['panFullscreenSwitch'] == "on" && 'valid' == $status && $is_pro) {
3032 - $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
3033 - $html .= 'panoshow' . $id . '.toggleFullscreen();';
3295 + $html .= 'document.getElementById("fullscreen' . $pano_suffix . '").addEventListener("click", function(e) {';
3296 + $html .= 'panoshow' . $pano_suffix . '.toggleFullscreen();';
3034 3297 $html .= '});';
3035 3298 $html .= '(function() {';
3036 - $html .= 'function wpvrFsChange' . $id . '() {';
3037 - $html .= 'var fsIcon = document.querySelector("#fullscreen' . $id . ' i");';
3299 + $html .= 'function wpvrFsChange' . $pano_suffix . '() {';
3300 + $html .= 'var fsIcon = document.querySelector("#fullscreen' . $pano_suffix . ' i");';
3038 3301 $html .= 'if (!fsIcon) return;';
3039 3302 $html .= 'if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {';
3040 3303 $html .= 'fsIcon.classList.remove("fa-expand"); fsIcon.classList.add("fa-minimize");';
3041 3304 $html .= '} else {';
@@ -3041,23 +3304,23 @@
3041 3304 $html .= '} else {';
3042 3305 $html .= 'fsIcon.classList.remove("fa-minimize"); fsIcon.classList.add("fa-expand");';
3043 3306 $html .= '}';
3044 3307 $html .= '}';
3045 - $html .= 'document.addEventListener("fullscreenchange", wpvrFsChange' . $id . ');';
3046 - $html .= 'document.addEventListener("webkitfullscreenchange", wpvrFsChange' . $id . ');';
3047 - $html .= 'document.addEventListener("mozfullscreenchange", wpvrFsChange' . $id . ');';
3048 - $html .= 'document.addEventListener("MSFullscreenChange", wpvrFsChange' . $id . ');';
3308 + $html .= 'document.addEventListener("fullscreenchange", wpvrFsChange' . $pano_suffix . ');';
3309 + $html .= 'document.addEventListener("webkitfullscreenchange", wpvrFsChange' . $pano_suffix . ');';
3310 + $html .= 'document.addEventListener("mozfullscreenchange", wpvrFsChange' . $pano_suffix . ');';
3311 + $html .= 'document.addEventListener("MSFullscreenChange", wpvrFsChange' . $pano_suffix . ');';
3049 3312 $html .= '})();';
3050 3313 }
3051 3314 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
3052 - $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
3053 - $html .= 'panoshow' . $id . '.loadScene("' . $default_scene . '");';
3315 + $html .= 'document.getElementById("backToHome' . $pano_suffix . '").addEventListener("click", function(e) {';
3316 + $html .= 'panoshow' . $pano_suffix . '.loadScene(' . wp_json_encode( (string) $default_scene ) . ');';
3054 3317 $html .= '});';
3055 3318 }
3056 3319 if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
3057 3320 $html .= '
3058 3321 (function() {
3059 - var gyroButton = document.getElementById("gyroscope' . $id . '");
3322 + var gyroButton = document.getElementById("gyroscope' . $pano_suffix . '");
3060 3323 var gyroIcon = gyroButton ? gyroButton.querySelector("i") : null;
3061 3324 var activeColor = ' . wp_json_encode($custom_control['gyroscopeColor']) . ';
3062 3325 var permissionGranted = false;
3063 3326
@@ -3065,20 +3328,20 @@
3065 3328 return;
3066 3329 }
3067 3330
3068 3331 function updateGyroscopeState() {
3069 - gyroIcon.style.color = panoshow' . $id . '.isOrientationActive()
3332 + gyroIcon.style.color = panoshow' . $pano_suffix . '.isOrientationActive()
3070 3333 ? activeColor
3071 3334 : "red";
3072 3335 }
3073 3336
3074 3337 function startGyroscope() {
3075 - if (!panoshow' . $id . '.isOrientationSupported()) {
3338 + if (!panoshow' . $pano_suffix . '.isOrientationSupported()) {
3076 3339 updateGyroscopeState();
3077 3340 return;
3078 3341 }
3079 3342
3080 - panoshow' . $id . '.startOrientation();
3343 + panoshow' . $pano_suffix . '.startOrientation();
3081 3344 window.setTimeout(updateGyroscopeState, 0);
3082 3345 }
3083 3346
3084 3347 function requestGyroscopePermission() {
@@ -3103,14 +3366,14 @@
3103 3366
3104 3367 startGyroscope();
3105 3368 }
3106 3369
3107 - panoshow' . $id . '.on("load", updateGyroscopeState);
3108 - panoshow' . $id . '.on("scenechange", updateGyroscopeState);
3370 + panoshow' . $pano_suffix . '.on("load", updateGyroscopeState);
3371 + panoshow' . $pano_suffix . '.on("scenechange", updateGyroscopeState);
3109 3372
3110 3373 gyroButton.addEventListener("click", function() {
3111 - if (panoshow' . $id . '.isOrientationActive()) {
3112 - panoshow' . $id . '.stopOrientation();
3374 + if (panoshow' . $pano_suffix . '.isOrientationActive()) {
3375 + panoshow' . $pano_suffix . '.stopOrientation();
3113 3376 updateGyroscopeState();
3114 3377 return;
3115 3378 }
3116 3379
@@ -3125,15 +3388,15 @@
3125 3388
3126 3389 //===Explainer Script===//
3127 3390
3128 3391 if ($autoplay_bg_music == 'on') {
3129 - $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
3130 - jQuery("#explainer' . $id . '").slideToggle();
3131 - playing' . $id . ' = false;
3132 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
3133 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up");
3134 - jQuery("#vr-volume' . $id . '").addClass("fas fa-volume-mute");
3135 - x' . $id . '.pause();
3392 + $html .= 'jQuery(document).on("click","#explainer_button_' . $pano_suffix . '",function() {
3393 + jQuery("#explainer' . $pano_suffix . '").slideToggle();
3394 + playing' . $pano_suffix . ' = false;
3395 + var x' . $pano_suffix . ' = document.getElementById("vrAudio' . $pano_suffix . '");
3396 + jQuery("#vr-volume' . $pano_suffix . '").removeClass("fas fa-volume-up");
3397 + jQuery("#vr-volume' . $pano_suffix . '").addClass("fas fa-volume-mute");
3398 + x' . $pano_suffix . '.pause();
3136 3399 });
3137 3400 jQuery(document).on("click",".close-explainer-video",function() {
3138 3401 jQuery(this).parent(".explainer").hide();
3139 3402 var el_src = jQuery(".vr-iframe").attr("src");
@@ -3139,11 +3402,11 @@
3139 3402 var el_src = jQuery(".vr-iframe").attr("src");
3140 3403 jQuery(".vr-iframe").attr("src", el_src);
3141 3404 });';
3142 3405 } else {
3143 - $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
3144 - jQuery("#explainer' . $id . '").slideToggle(function(){
3145 - var $explainerVideoId = jQuery("#explainer' . $id . '");
3406 + $html .= 'jQuery(document).on("click","#explainer_button_' . $pano_suffix . '",function() {
3407 + jQuery("#explainer' . $pano_suffix . '").slideToggle(function(){
3408 + var $explainerVideoId = jQuery("#explainer' . $pano_suffix . '");
3146 3409 var $explainerVideoIframe = $explainerVideoId.find("iframe");
3147 3410 var explainerVideoIframSrc = $explainerVideoIframe.attr("src");
3148 3411 $explainerVideoIframe.attr("src", "");
3149 3412 $explainerVideoIframe.attr("src", explainerVideoIframSrc);
@@ -3159,12 +3422,16 @@
3159 3422 });';
3160 3423 }
3161 3424
3162 3425 $html .= '
3163 - jQuery(document).on("click","#pano' . $id . '",function(event) {
3426 + jQuery(document).on("click","#' . $panoid . '",function(event) {
3427 + var isCross = event.target.closest(".cross");
3164 3428 var isActiveModal = event.target.closest(".custom-ifram-wrapper");
3165 - var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
3429 + var isForm = event.target.closest(".wpvr-hotspot-tweak-contents-wrapper");
3166 3430 var isHotspot = event.target.closest(".pnlm-hotspot-base");
3431 + if(isCross != null){
3432 + return;
3433 + }
3167 3434 if(isForm != null){
3168 3435 jQuery(this).addClass("show-modal");
3169 3436 }else if(isActiveModal == null){
3170 3437 if(isHotspot == null){
@@ -3170,9 +3437,9 @@
3170 3437 if(isHotspot == null){
3171 3438 jQuery(".custom-ifram-wrapper .custom-ifram").empty();
3172 3439 jQuery(".custom-ifram-wrapper").hide();
3173 3440 jQuery(this).removeClass("show-modal");
3174 - jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
3441 + jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide();
3175 3442 }
3176 3443 }
3177 3444 });';
3178 3445
@@ -3180,10 +3447,10 @@
3180 3447
3181 3448 //===generic form script===//
3182 3449 if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
3183 3450 $html .= '
3184 - jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
3185 - jQuery("#wpvr-generic-form' . $id . '").fadeToggle();
3451 + jQuery(document).on("click","#generic_form_button_' . $pano_suffix . '",function() {
3452 + jQuery("#wpvr-generic-form' . $pano_suffix . '").fadeToggle();
3186 3453 });
3187 3454
3188 3455 jQuery(document).on("click",".close-generic-form",function() {
3189 3456 jQuery(this).parent(".wpvr-generic-form").fadeOut()
@@ -3192,12 +3459,12 @@
3192 3459 }
3193 3460 //===generic from script===//
3194 3461
3195 3462 //===Floor map Script===//
3196 - $html .= 'jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
3197 - jQuery("#wpvr-floor-map' . $id . '").toggle().removeClass("fullwindow");
3463 + $html .= 'jQuery(document).on("click","#floor_map_button_' . $pano_suffix . '",function() {
3464 + jQuery("#wpvr-floor-map' . $pano_suffix . '").toggle().removeClass("fullwindow");
3198 3465 });
3199 - jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
3466 + jQuery(document).on("dblclick","#wpvr-floor-map' . $pano_suffix . '",function(){
3200 3467 jQuery(this).addClass("fullwindow");
3201 3468 jQuery(this).parents(".pano-wrap").addClass("show-modal");
3202 3469 });
3203 3470 jQuery(document).on("click",".close-floor-map-plan",function() {
@@ -3210,24 +3477,24 @@
3210 3477 if ($vrgallery_display) {
3211 3478
3212 3479 if (!$autoload) {
3213 3480 $html .= 'jQuery(document).ready(function($){
3214 - jQuery("#sccontrols' . $id . '").hide();
3215 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3216 - jQuery("#sccontrols' . $id . '").hide();
3217 - jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3481 + jQuery("#sccontrols' . $pano_suffix . '").hide();
3482 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3483 + jQuery("#sccontrols' . $pano_suffix . '").hide();
3484 + jQuery("#' . $panoid . ' .wpvr_slider_nav").hide();
3218 3485 });';
3219 - $html .= 'var slide' . $id . ' = "down";
3220 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3221 - if (slide' . $id . ' == "up") {
3222 - jQuery(".vrgctrl' . $id . '").empty();
3223 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3224 - slide' . $id . ' = "down";
3225 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3226 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3486 + $html .= 'var slide' . $pano_suffix . ' = "down";
3487 + jQuery(document).on("click","#vrgcontrols' . $pano_suffix . '",function() {
3488 + if (slide' . $pano_suffix . ' == "up") {
3489 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3490 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3491 + slide' . $pano_suffix . ' = "down";
3492 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3493 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3227 3494 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3228 3495 if (jQuery(this).is(":visible")) {
3229 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3496 + jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3230 3497 "display": "flex",
3231 3498 "justify-content": "center",
3232 3499 "align-items": "center",
3233 3500 "gap": "15px"
@@ -3235,9 +3502,9 @@
3235 3502 }
3236 3503 }
3237 3504 if (jQuery(".bricks-is-frontend").length) {
3238 3505 if (jQuery(this).is(":visible")) {
3239 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3506 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3240 3507 "display": "flex",
3241 3508 "justify-content": "center",
3242 3509 "align-items": "center"
3243 3510 });
@@ -3245,16 +3512,16 @@
3245 3512 }
3246 3513 });
3247 3514 }
3248 3515 else {
3249 - jQuery(".vrgctrl' . $id . '").empty();
3250 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3251 - slide' . $id . ' = "up";
3252 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3253 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3516 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3517 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3518 + slide' . $pano_suffix . ' = "up";
3519 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3520 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3254 3521 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3255 3522 if (jQuery(this).is(":visible")) {
3256 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3523 + jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3257 3524 "display": "flex",
3258 3525 "justify-content": "center",
3259 3526 "align-items": "center",
3260 3527 "gap": "15px"
@@ -3262,9 +3529,9 @@
3262 3529 }
3263 3530 }
3264 3531 if (jQuery(".bricks-is-frontend").length) {
3265 3532 if (jQuery(this).is(":visible")) {
3266 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3533 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3267 3534 "display": "flex",
3268 3535 "justify-content": "center",
3269 3536 "align-items": "center"
3270 3537 });
@@ -3274,28 +3541,28 @@
3274 3541 }
3275 3542 });';
3276 3543 } else {
3277 3544 $html .= 'jQuery(document).ready(function($){
3278 - jQuery("#sccontrols' . $id . '").show();
3279 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3280 - jQuery("#pano' . $id . ' .wpvr_slider_nav").show();
3545 + jQuery("#sccontrols' . $pano_suffix . '").show();
3546 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3547 + jQuery("#' . $panoid . ' .wpvr_slider_nav").show();
3281 3548 });';
3282 - $html .= 'var slide' . $id . ' = "down";
3283 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3284 - if (slide' . $id . ' == "up") {
3285 - jQuery(".vrgctrl' . $id . '").empty();
3286 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3287 - slide' . $id . ' = "down";
3549 + $html .= 'var slide' . $pano_suffix . ' = "down";
3550 + jQuery(document).on("click","#vrgcontrols' . $pano_suffix . '",function() {
3551 + if (slide' . $pano_suffix . ' == "up") {
3552 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3553 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3554 + slide' . $pano_suffix . ' = "down";
3288 3555 } else {
3289 - jQuery(".vrgctrl' . $id . '").empty();
3290 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3291 - slide' . $id . ' = "up";
3556 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3557 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3558 + slide' . $pano_suffix . ' = "up";
3292 3559 }
3293 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3294 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3560 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3561 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3295 3562 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3296 3563 if (jQuery(this).is(":visible")) {
3297 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3564 + jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3298 3565 "display": "flex",
3299 3566 "justify-content": "center",
3300 3567 "align-items": "center",
3301 3568 "gap": "15px"
@@ -3303,9 +3570,9 @@
3303 3570 }
3304 3571 }
3305 3572 if (jQuery(".bricks-is-frontend").length) {
3306 3573 if (jQuery(this).is(":visible")) {
3307 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3574 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3308 3575 "display": "flex",
3309 3576 "justify-content": "center",
3310 3577 "align-items": "center"
3311 3578 });
@@ -3315,29 +3582,29 @@
3315 3582 });';
3316 3583 }
3317 3584 } else {
3318 3585 $html .= 'jQuery(document).ready(function($){
3319 - jQuery("#sccontrols' . $id . '").hide();
3320 - jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3321 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3586 + jQuery("#sccontrols' . $pano_suffix . '").hide();
3587 + jQuery("#' . $panoid . ' .wpvr_slider_nav").hide();
3588 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3322 3589 });';
3323 - $html .= 'var slide' . $id . ' = "down";
3324 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3325 - if (slide' . $id . ' == "up") {
3326 - jQuery(".vrgctrl' . $id . '").empty();
3327 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3328 - slide' . $id . ' = "down";
3590 + $html .= 'var slide' . $pano_suffix . ' = "down";
3591 + jQuery(document).on("click","#vrgcontrols' . $pano_suffix . '",function() {
3592 + if (slide' . $pano_suffix . ' == "up") {
3593 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3594 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3595 + slide' . $pano_suffix . ' = "down";
3329 3596 }
3330 3597 else {
3331 - jQuery(".vrgctrl' . $id . '").empty();
3332 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3333 - slide' . $id . ' = "up";
3598 + jQuery(".vrgctrl' . $pano_suffix . '").empty();
3599 + jQuery(".vrgctrl' . $pano_suffix . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3600 + slide' . $pano_suffix . ' = "up";
3334 3601 }
3335 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3336 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3602 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3603 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3337 3604 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3338 3605 if (jQuery(this).is(":visible")) {
3339 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3606 + jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3340 3607 "display": "flex",
3341 3608 "justify-content": "center",
3342 3609 "align-items": "center",
3343 3610 "gap": "15px"
@@ -3345,9 +3612,9 @@
3345 3612 }
3346 3613 }
3347 3614 if (jQuery(".bricks-is-frontend").length) {
3348 3615 if (jQuery(this).is(":visible")) {
3349 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3616 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3350 3617 "display": "flex",
3351 3618 "justify-content": "center",
3352 3619 "align-items": "center"
3353 3620 });
@@ -3357,33 +3624,33 @@
3357 3624 });';
3358 3625 }
3359 3626 if (!$autoload) {
3360 3627 $html .= 'jQuery(document).ready(function(){
3361 - jQuery("#controls' . $id . '").hide();
3362 - jQuery("#zoom-in-out-controls' . $id . '").hide();
3363 - jQuery("#adcontrol' . $id . '").hide();
3364 - jQuery("#explainer_button_' . $id . '").hide();
3365 - jQuery("#generic_form_button_' . $id . '").hide();
3366 - jQuery("#floor_map_button_' . $id . '").hide();
3367 - jQuery("#vrgcontrols' . $id . '").hide();
3628 + jQuery("#controls' . $pano_suffix . '").hide();
3629 + jQuery("#zoom-in-out-controls' . $pano_suffix . '").hide();
3630 + jQuery("#adcontrol' . $pano_suffix . '").hide();
3631 + jQuery("#explainer_button_' . $pano_suffix . '").hide();
3632 + jQuery("#generic_form_button_' . $pano_suffix . '").hide();
3633 + jQuery("#floor_map_button_' . $pano_suffix . '").hide();
3634 + jQuery("#vrgcontrols' . $pano_suffix . '").hide();
3368 3635 jQuery("#cp-logo-controls").hide();
3369 3636 jQuery(".custom-scene-navigation").hide();
3370 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
3637 + jQuery("#' . $panoid . '").find(".pnlm-panorama-info").hide();
3371 3638 });';
3372 3639 if ($vrgallery_display) {
3373 - $html .= 'var load_once = "true";';
3374 - $html .= 'panoshow' . $id . '.on("load", function (){
3375 - if (load_once == "true") {
3376 - load_once = "false";
3377 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3640 + $html .= 'var load_once' . $pano_suffix . ' = "true";';
3641 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
3642 + if (load_once' . $pano_suffix . ' == "true") {
3643 + load_once' . $pano_suffix . ' = "false";
3644 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3378 3645 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3379 3646 if (jQuery(this).is(":visible")) {
3380 - jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css("display", "flex");
3647 + jQuery(".elementor-edit-mode .elementor-widget-container .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css("display", "flex");
3381 3648 }
3382 3649 }
3383 3650 if (jQuery(".bricks-is-frontend").length) {
3384 3651 if (jQuery(this).is(":visible")) {
3385 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3652 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3386 3653 "display": "flex",
3387 3654 "justify-content": "center",
3388 3655 "align-items": "center"
3389 3656 });
@@ -3389,23 +3656,23 @@
3389 3656 });
3390 3657 }
3391 3658 }
3392 3659 });
3393 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3660 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3394 3661 }
3395 3662 });';
3396 3663 }
3397 - $html .= 'panoshow' . $id . '.on("load", function (){
3398 - jQuery("#controls' . $id . '").show();
3399 - jQuery("#zoom-in-out-controls' . $id . '").show();
3400 - jQuery("#adcontrol' . $id . '").show();
3401 - jQuery("#explainer_button_' . $id . '").show();
3402 - jQuery("#generic_form_button_' . $id . '").show();
3403 - jQuery("#floor_map_button_' . $id . '").show();
3404 - jQuery("#vrgcontrols' . $id . '").show();
3664 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
3665 + jQuery("#controls' . $pano_suffix . '").show();
3666 + jQuery("#zoom-in-out-controls' . $pano_suffix . '").show();
3667 + jQuery("#adcontrol' . $pano_suffix . '").show();
3668 + jQuery("#explainer_button_' . $pano_suffix . '").show();
3669 + jQuery("#generic_form_button_' . $pano_suffix . '").show();
3670 + jQuery("#floor_map_button_' . $pano_suffix . '").show();
3671 + jQuery("#vrgcontrols' . $pano_suffix . '").show();
3405 3672 jQuery("#cp-logo-controls").show();
3406 3673 jQuery(".custom-scene-navigation").show();
3407 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
3674 + jQuery("#' . $panoid . '").find(".pnlm-panorama-info").show();
3408 3675 });';
3409 3676 }
3410 3677
3411 3678 //==Old code working properly==//
@@ -3419,31 +3686,29 @@
3419 3686 var pano_id;
3420 3687 var element_id = this.id;
3421 3688 element_id = element_id.split("-");
3422 3689 element_id = element_id[3];
3423 - jQuery("#elementor-tab-content-"+element_id).find("#master-container").children("div").eq(1).addClass("awwww");
3690 + jQuery("#elementor-tab-content-"+element_id).find("#' . $master_container_id . '").children("div").eq(1).addClass("awwww");
3424 3691 var pano_id = jQuery(".awwww").attr("id");
3425 - jQuery("#elementor-tab-content-"+element_id).find("#master-container").children("div").eq(1).removeClass("awwww");;
3692 + jQuery("#elementor-tab-content-"+element_id).find("#' . $master_container_id . '").children("div").eq(1).removeClass("awwww");;
3426 3693 if (pano_id != undefined) {
3427 - pano_id = pano_id.split("o");
3428 - pano_id = pano_id[1];
3429 - if (pano_id == "' . $id . '") {
3430 - jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3431 - jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3432 - panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);
3694 + if (pano_id == "' . $panoid . '") {
3695 + jQuery("#' . $panoid . '").children(".pnlm-render-container").remove();
3696 + jQuery("#' . $panoid . '").children(".pnlm-ui").remove();
3697 + panoshow' . $pano_suffix . ' = pannellum.viewer(response[0]["panoid"], scenes);
3433 3698 window.wpvrViewers = window.wpvrViewers || {};
3434 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
3699 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
3435 3700 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
3436 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
3701 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
3437 3702 }));
3438 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '")
3703 + jQuery("#' . $panoid . '").children(".pnlm-ui").find(".pnlm-load-button p").text(' . wp_json_encode( (string) $previeword ) . ')
3439 3704 setTimeout(function() {
3440 - // panoshow' . $id . '.loadScene("' . $default_scene . '");
3705 + // panoshow' . $pano_suffix . '.loadScene("' . $default_scene . '");
3441 3706 window.dispatchEvent(new Event("resize"));
3442 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3443 - jQuery("#controls' . $id . '").css("bottom", "55px");
3707 + if (jQuery("#' . $panoid . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3708 + jQuery("#controls' . $pano_suffix . '").css("bottom", "55px");
3444 3709 } else {
3445 - jQuery("#controls' . $id . '").css("bottom", "5px");
3710 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
3446 3711 }
3447 3712 }, 200);
3448 3713 }
3449 3714 }
@@ -3448,30 +3713,30 @@
3448 3713 }
3449 3714 }
3450 3715 });';
3451 3716 $html .= 'jQuery(".geodir-tab-head dd, #vr-tour-tab").click(function(){
3452 - jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3453 - jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3454 - panoshow' . $id . ' = pannellum.viewer(response[0]["panoid"], scenes);
3717 + jQuery("#' . $panoid . '").children(".pnlm-render-container").remove();
3718 + jQuery("#' . $panoid . '").children(".pnlm-ui").remove();
3719 + panoshow' . $pano_suffix . ' = pannellum.viewer(response[0]["panoid"], scenes);
3455 3720 window.wpvrViewers = window.wpvrViewers || {};
3456 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
3721 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
3457 3722 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
3458 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
3723 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
3459 3724 }));
3460 3725 setTimeout(function() {
3461 - panoshow' . $id . '.loadScene("' . $default_scene . '");
3726 + panoshow' . $pano_suffix . '.loadScene(' . wp_json_encode( (string) $default_scene ) . ');
3462 3727 window.dispatchEvent(new Event("resize"));
3463 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3464 - jQuery("#controls' . $id . '").css("bottom", "55px");
3728 + if (jQuery("#' . $panoid . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3729 + jQuery("#controls' . $pano_suffix . '").css("bottom", "55px");
3465 3730 }
3466 3731 else {
3467 - jQuery("#controls' . $id . '").css("bottom", "5px");
3732 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
3468 3733 }
3469 3734 }, 200);
3470 3735 });';
3471 3736 if (isset($previeword) && $previeword != '') {
3472 3737 $html .= '
3473 - jQuery("#pano' . $id . '").children(".pnlm-ui").find(".pnlm-load-button p").text("' . $previeword . '")
3738 + jQuery("#' . $panoid . '").children(".pnlm-ui").find(".pnlm-load-button p").text(' . wp_json_encode( (string) $previeword ) . ')
3474 3739 ';
3475 3740 }
3476 3741 if ($default_global_zoom != '' || $max_global_zoom != '' || $min_global_zoom != '') {
3477 3742 $html .= 'jQuery(".globalzoom").val("on").change();';
@@ -3476,12 +3741,12 @@
3476 3741 if ($default_global_zoom != '' || $max_global_zoom != '' || $min_global_zoom != '') {
3477 3742 $html .= 'jQuery(".globalzoom").val("on").change();';
3478 3743 }
3479 3744
3480 - $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3745 + $html .= 'jQuery("#' . $panoid . ' .pnlm-title-box").on("mouseenter", function(){
3481 3746 jQuery(this).attr("title", jQuery(this).text());
3482 3747 });
3483 - jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3748 + jQuery("#' . $panoid . ' .pnlm-title-box").on("mouseleave", function(){
3484 3749 jQuery(this).removeAttr("title");
3485 3750 });';
3486 3751 $html .= '});';
3487 3752 $html .= '})(jQuery);';
@@ -3511,16 +3776,20 @@
3511 3776 }
3512 3777
3513 3778 }
3514 3779
3515 -private function sanitize_content_preserve_styles($content) {
3780 +private function sanitize_content_preserve_styles($content, $allow_forms = false) {
3516 3781 // Decode HTML entities first (in case content was encoded in database)
3517 3782 $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
3518 3783
3519 - // Escape <script> blocks to display as text instead of removing them
3520 - $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
3521 - return esc_html($matches[0]); // Convert to plain text
3522 - }, $content);
3784 + // Escape or strip <script> blocks
3785 + if ($allow_forms) {
3786 + $content = preg_replace('/<script\b[^>]*>[\s\S]*?<\/script>/i', '', $content);
3787 + } else {
3788 + $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
3789 + return esc_html($matches[0]); // Convert to plain text
3790 + }, $content);
3791 + }
3523 3792
3524 3793 // Strip dangerous URL-based attributes
3525 3794 $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*(javascript|vbscript|data|about):/i', '$1=""', $content);
3526 3795
@@ -3533,11 +3802,16 @@
3533 3802 // Handle unquoted event handlers
3534 3803 return ' ' . esc_html($matches[1]) . '=' . esc_html($matches[2]);
3535 3804 }, $content);
3536 3805
3537 - // Remove all unsafe embedded/interactive elements except iframe
3538 - $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
3539 - $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
3806 + // Remove unsafe embedded/interactive elements
3807 + if ($allow_forms) {
3808 + $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base)\b[^>]*>/i', '', $content);
3809 + $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base)>/i', '', $content);
3810 + } else {
3811 + $content = preg_replace('/<(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)\b[^>]*>/i', '', $content);
3812 + $content = preg_replace('/<\/(object|embed|applet|frame|frameset|meta|link|base|form|input|button|textarea|select|option)>/i', '', $content);
3813 + }
3540 3814
3541 3815 // Clean style attributes safely
3542 3816 $content = preg_replace_callback('/style\s*=\s*["\']([^"\']*)["\']/', function($matches) {
3543 3817 $style = $matches[1];
@@ -3558,10 +3832,16 @@
3558 3832 $css = preg_replace('/-moz-binding\s*:/i', '', $css);
3559 3833 return '<style>' . esc_html($css) . '</style>';
3560 3834 }, $content);
3561 3835
3562 - // Allow iframes from safe sources only (e.g., YouTube, Vimeo)
3836 + // Allow iframes and styles from safe sources only
3563 3837 $allowed_tags = wp_kses_allowed_html('post');
3838 + $allowed_tags['style'] = [
3839 + 'type' => true,
3840 + 'id' => true,
3841 + 'class' => true,
3842 + 'media' => true,
3843 + ];
3564 3844 $allowed_tags['iframe'] = [
3565 3845 'src' => true,
3566 3846 'width' => true,
3567 3847 'height' => true,
@@ -3589,8 +3869,72 @@
3589 3869 'srcset' => true,
3590 3870 'sizes' => true,
3591 3871 ];
3592 3872
3873 + if ($allow_forms) {
3874 + $form_attributes = [
3875 + 'id' => true,
3876 + 'class' => true,
3877 + 'style' => true,
3878 + 'name' => true,
3879 + 'value' => true,
3880 + 'type' => true,
3881 + 'placeholder' => true,
3882 + 'action' => true,
3883 + 'method' => true,
3884 + 'target' => true,
3885 + 'enctype' => true,
3886 + 'disabled' => true,
3887 + 'readonly' => true,
3888 + 'required' => true,
3889 + 'checked' => true,
3890 + 'selected' => true,
3891 + 'multiple' => true,
3892 + 'size' => true,
3893 + 'rows' => true,
3894 + 'cols' => true,
3895 + 'maxlength' => true,
3896 + 'minlength' => true,
3897 + 'min' => true,
3898 + 'max' => true,
3899 + 'step' => true,
3900 + 'pattern' => true,
3901 + 'autocomplete' => true,
3902 + 'autofocus' => true,
3903 + 'for' => true,
3904 + 'data-*' => true,
3905 + 'data-form_id' => true,
3906 + 'data-form_instance' => true,
3907 + 'data-name' => true,
3908 + 'data-type' => true,
3909 + 'aria-invalid' => true,
3910 + 'aria-required' => true,
3911 + 'aria-label' => true,
3912 + 'aria-describedby' => true,
3913 + 'aria-labelledby' => true,
3914 + ];
3915 + $allowed_tags['form'] = $form_attributes;
3916 + $allowed_tags['input'] = $form_attributes;
3917 + $allowed_tags['button'] = $form_attributes;
3918 + $allowed_tags['textarea'] = $form_attributes;
3919 + $allowed_tags['select'] = $form_attributes;
3920 + $allowed_tags['option'] = $form_attributes;
3921 + $allowed_tags['optgroup'] = $form_attributes;
3922 + $allowed_tags['label'] = $form_attributes;
3923 + $allowed_tags['fieldset'] = $form_attributes;
3924 + $allowed_tags['legend'] = $form_attributes;
3925 + if (!isset($allowed_tags['div'])) {
3926 + $allowed_tags['div'] = [];
3927 + }
3928 + $allowed_tags['div']['data-*'] = true;
3929 + $allowed_tags['div']['data-form_id'] = true;
3930 + $allowed_tags['div']['data-form_instance'] = true;
3931 + if (!isset($allowed_tags['span'])) {
3932 + $allowed_tags['span'] = [];
3933 + }
3934 + $allowed_tags['span']['data-*'] = true;
3935 + }
3936 +
3593 3937 // Apply wp_kses() to keep only allowed tags/attributes
3594 3938 $content = wp_kses($content, $allowed_tags);
3595 3939
3596 3940 // Finally, validate iframe src for security (allow https only, block javascript: etc.)
@@ -3622,7 +3966,41 @@
3622 3966 return 'https://' . $url;
3623 3967 }
3624 3968
3625 3969 return $url;
3970 +}
3971 +
3972 +/**
3973 + * Get attachment ID from URL with in-memory static cache and WordPress object cache.
3974 + *
3975 + * @param string $url Image URL.
3976 + * @return int Attachment ID or 0.
3977 + */
3978 +private function get_attachment_id_by_url($url)
3979 +{
3980 + static $memory_cache = array();
3981 +
3982 + if (empty($url) || !is_string($url)) {
3983 + return 0;
3984 + }
3985 +
3986 + if (isset($memory_cache[$url])) {
3987 + return $memory_cache[$url];
3988 + }
3989 +
3990 + $cache_key = 'wpvr_att_id_' . md5($url);
3991 + $cached_id = wp_cache_get($cache_key, 'wpvr');
3992 + if (false !== $cached_id) {
3993 + $memory_cache[$url] = (int) $cached_id;
3994 + return (int) $cached_id;
3995 + }
3996 +
3997 + $attachment_id = attachment_url_to_postid($url);
3998 + $attachment_id = $attachment_id ? (int) $attachment_id : 0;
3999 +
4000 + wp_cache_set($cache_key, $attachment_id, 'wpvr', HOUR_IN_SECONDS);
4001 + $memory_cache[$url] = $attachment_id;
4002 +
4003 + return $attachment_id;
3626 4004 }
3627 4005
3628 4006 }