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 +1032 -699 9.0.3 → 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,9 +1083,8 @@
1054 1083 $hotspot_data['hotspot-hover'] ?? ''
1055 1084 );
1056 1085
1057 1086
1058 - $is_fluent_form = isset($hotspot_data["hotspot-type"]) && 'fluent_form' === $hotspot_data["hotspot-type"];
1059 1087 $on_hover_content = $this->sanitize_content_preserve_styles($on_hover_content ?? '', false);
1060 1088 $on_click_content = preg_replace_callback('/<img[^>]*>/', "replace_callback", $hotspot_content ?? '');
1061 1089 $on_click_content = $this->sanitize_content_preserve_styles($on_click_content ?? '', $is_fluent_form);
1062 1090
@@ -1111,41 +1139,134 @@
1111 1139 }
1112 1140 }
1113 1141 $hotspot_info['URL'] = ($hotspot_data['hotspot-type'] === 'fluent_form' || $hotspot_data['hotspot-type'] === 'wc_product') ? '' : $hotspot_info['URL'];
1114 1142
1115 - if ($hotspot_data["hotspot-customclass"] == 'none' || $hotspot_data["hotspot-customclass"] == '') {
1116 - 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 + }
1117 1223 }
1118 1224 array_push($hotspots, $hotspot_info);
1119 1225 }
1120 1226
1121 - $device_scene = $panoscenes['scene-attachment-url'];
1122 - $mobile_media_resize = get_option('mobile_media_resize');
1123 - $file_accessible = ini_get('allow_url_fopen');
1124 - if ($mobile_media_resize == "true" && $device_scene ) {
1125 - if ($file_accessible == "1") {
1126 - $image_info = getimagesize($device_scene);
1127 - if ( isset($image_info[0]) && $image_info[0] > 4096) {
1128 - $src_to_id_for_mobile = '';
1129 - $src_to_id_for_desktop = '';
1130 - if (wpvr_isMobileDevice()) {
1131 - $src_to_id_for_mobile = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1132 - if ($src_to_id_for_mobile) {
1133 - $mobile_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'wpvr_mobile');
1134 - if ($mobile_scene[3]) {
1135 - $device_scene = $mobile_scene[0];
1136 - }
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];
1137 1249 }
1138 - } else {
1139 - $src_to_id_for_desktop = attachment_url_to_postid($panoscenes['scene-attachment-url']);
1140 - if ($src_to_id_for_desktop) {
1141 - $desktop_scene = wp_get_attachment_image_src($src_to_id_for_mobile, 'full');
1142 - if (isset($desktop_scene[0])) {
1143 - $device_scene = $desktop_scene[0];
1144 - }
1145 - }
1146 1250 }
1147 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 + }
1148 1269 }
1149 1270 }
1150 1271
1151 1272 $scene_info = array();
@@ -1162,8 +1283,13 @@
1162 1283
1163 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);
1164 1285 } else {
1165 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 + }
1166 1292 }
1167 1293
1168 1294
1169 1295 if (isset($panoscenes["ptyscene"])) {
@@ -1289,14 +1415,21 @@
1289 1415 if(isset($postdata['customcss_enable']) && $postdata['customcss_enable'] == 'on'){
1290 1416 $html .= isset($postdata['customcss']) ? $postdata['customcss'] : '';
1291 1417 }
1292 1418 }
1293 - $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);
1294 1422 $status = get_option('wpvr_edd_license_status');
1295 - if ($status !== false && $status == 'valid') {
1423 + if ($status !== false && $status == 'valid' && ! empty( $panodata['scene-list'] ) && is_array( $panodata['scene-list'] )) {
1296 1424 foreach ($panodata['scene-list'] as $panoscenes){
1297 -
1425 + if ( empty( $panoscenes['hotspot-list'] ) || ! is_array( $panoscenes['hotspot-list'] ) ) {
1426 + continue;
1427 + }
1298 1428 foreach($panoscenes['hotspot-list'] as $hotspot){
1429 + if ( ( $hotspot['hotspot-type'] ?? '' ) === 'sticker' ) {
1430 + continue;
1431 + }
1299 1432 if (isset($hotspot['hotspot-customclass-color-icon-value']) && !empty($hotspot['hotspot-customclass-color-icon-value'])) {
1300 1433 $hotspoticoncolor = $hotspot['hotspot-customclass-color-icon-value'];
1301 1434 } else {
1302 1435 $hotspoticoncolor = "#00b4ff";
@@ -1491,16 +1624,24 @@
1491 1624 $animation_css = apply_filters('wpvr_tour_scene_animation',$animation_type,$animationDuration,$animationDelay,$postdata,$id);
1492 1625 $html .= $animation_css;
1493 1626 }
1494 1627
1628 + $container_width = $width;
1629 + $container_height = $height;
1630 + $container_mobile_height = $mobile_height;
1631 +
1495 1632 if ($width == 'fullwidth') {
1496 - $width = "100%";
1633 + $container_width = "100%";
1634 + } elseif ($width == 'embed') {
1635 + $container_width = "100%";
1636 + $container_height = "100%";
1637 + $container_mobile_height = "100%";
1497 1638 }
1498 1639
1499 1640 if (wpvr_isMobileDevice()) {
1500 - $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; ">';
1501 1642 } else {
1502 - $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; ">';
1503 1644 }
1504 1645 $is_pro = apply_filters('is_wpvr_pro_active',false);
1505 1646 $status = get_option('wpvr_edd_license_status');
1506 1647 $is_cardboard = get_option('wpvr_cardboard_disable');
@@ -1518,9 +1659,9 @@
1518 1659 if($width == "embed"){
1519 1660 $embed_mode = "vr-embade-mode";
1520 1661 }
1521 1662 $html .= '<label class="wpvr-cardboard-switcher '.$embed_mode.'">
1522 - <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">
1523 1664 <span class="switcher-box">
1524 1665 <span class="normal-mode-tooltip">Normal VR Mode</span>
1525 1666 <svg width="78" height="60" viewBox="0 0 78 60" fill="none" xmlns="http://www.w3.org/2000/svg">
1526 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"/>
@@ -1532,43 +1673,43 @@
1532 1673
1533 1674 if ($width == 'fullwidth') {
1534 1675 if (wpvr_isMobileDevice()) {
1535 1676 $html .= '<div class="cardboard-vrfullwidth vrfullwidth">';
1536 - $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>';
1537 - $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 . '" >';
1538 1679 } else {
1539 - $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>';
1540 1681 if ($radius) {
1541 - $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;" >';
1542 1683 } else {
1543 - $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;" >';
1544 1685 }
1545 1686 }
1546 1687 } elseif ($width == 'embed') {
1547 1688 $html .= '<div class="cardboard-vrembed vrembed">';
1548 - $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>';
1549 - $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;" >';
1550 1691 } else {
1551 1692 if (wpvr_isMobileDevice()) {
1552 - $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>';
1553 1694 if ($radius) {
1554 - $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 . ';">';
1555 1696 } else {
1556 - $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%; ">';
1557 1698 }
1558 1699 } else {
1559 - $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>';
1560 1701
1561 1702 if ($radius) {
1562 - $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 . ';">';
1563 1704 } else {
1564 - $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%;">';
1565 1706 }
1566 1707 }
1567 1708 }
1568 1709 // Vr mode transction scene to scene
1569 1710 if ($status !== false && 'valid' == $status && $is_pro) {
1570 - $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>';
1571 1712 }
1572 1713 $social_logo_top = '';
1573 1714 //===company logo===//
1574 1715 if (isset($postdata['cpLogoSwitch'])) {
@@ -1605,14 +1746,14 @@
1605 1746 $generic_form_icon = isset($postdata['genericformicon']) ? (string) $postdata['genericformicon'] : 'fab fa-wpforms';
1606 1747 $generic_form_icon = implode(' ', array_filter(array_map('sanitize_html_class', preg_split('/\s+/', $generic_form_icon))));
1607 1748 $generic_form_icon = $generic_form_icon ?: 'fab fa-wpforms';
1608 1749 $generic_form_icon_color = sanitize_hex_color($postdata['genericformiconcolor'] ?? '') ?: '#f7fffb';
1609 - $html .= '<div class="generic_form_button" id="generic_form_button_' . esc_attr($id) . '">';
1610 - $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>';
1611 1752 $html .= '</div>';
1612 1753
1613 1754 // Generate the modal form container
1614 - $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">';
1615 1756 $html .= '<span class="close-generic-form"><i class="fa fa-times"></i></span>';
1616 1757 $html .= '<div class="generic-form-container">' . $shortcode_content . '</div>';
1617 1758 $html .= '</div>';
1618 1759 }
@@ -1665,23 +1806,23 @@
1665 1806 //===Custom Control===//
1666 1807 if (isset($custom_control)) {
1667 1808 $gyro_button_enabled = wpvr_isMobileDevice() && $custom_control['gyroSwitch'] == "on" && $custom_control['gyroscopeSwitch'] == "on";
1668 1809 if ($custom_control['panZoomInSwitch'] == "on" || $custom_control['panZoomOutSwitch'] == "on" || $gyro_button_enabled || $custom_control['backToHomeSwitch'] == "on") {
1669 - $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">';
1670 1811
1671 1812 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
1672 - $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>';
1673 1814 }
1674 1815
1675 1816 if ($custom_control['panZoomInSwitch'] == "on" && 'valid' == $status && $is_pro) {
1676 - $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>';
1677 1818 }
1678 1819
1679 1820 if ($custom_control['panZoomOutSwitch'] == "on" && 'valid' == $status && $is_pro) {
1680 - $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>';
1681 1822 }
1682 1823 if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
1683 - $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>';
1684 1825 }
1685 1826 $html .= '</div>';
1686 1827 }
1687 1828 //===zoom in out Control===//
@@ -1687,28 +1828,28 @@
1687 1828 //===zoom in out Control===//
1688 1829
1689 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) {
1690 1831 //===Custom Control===//
1691 - $html .= '<div class="controls" id="controls' . $id . '">';
1832 + $html .= '<div class="controls" id="controls' . $pano_suffix . '">';
1692 1833
1693 1834 if ($custom_control['panupSwitch'] == "on") {
1694 - $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>';
1695 1836 }
1696 1837
1697 1838 if ($custom_control['panDownSwitch'] == "on") {
1698 - $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>';
1699 1840 }
1700 1841
1701 1842 if ($custom_control['panLeftSwitch'] == "on") {
1702 - $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>';
1703 1844 }
1704 1845
1705 1846 if ($custom_control['panRightSwitch'] == "on") {
1706 - $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>';
1707 1848 }
1708 1849
1709 1850 if ($custom_control['panFullscreenSwitch'] == "on") {
1710 - $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>';
1711 1852 }
1712 1853 $html .= '</div>';
1713 1854 }
1714 1855 }
@@ -1720,20 +1861,19 @@
1720 1861 $postdata,
1721 1862 $is_pro,
1722 1863 $autoload,
1723 1864 $explainer_right,
1724 - $id
1865 + $pano_suffix
1725 1866 );
1726 1867 //===explainer button end===//
1727 1868
1728 1869 //===Floor map button===//
1729 1870 $status = get_option('wpvr_edd_license_status');
1730 - if ($status !== false && 'valid' == $status && $is_pro){
1731 - if ($floor_plan_enable == "on" && !empty($floor_plan_image)) {
1732 - $html .= '<div class="floor_map_button" id="floor_map_button_' . $id . '" style="right:'.$floor_map_right.'">';
1733 - $html .= '<div class="ctrl" id="floor_map_target_' . $id . '"><i class="fas fa-map" style="color:#f7fffb;"></i></div>';
1734 - $html .= '</div>';
1735 - }
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>';
1736 1876 }
1737 1877 //===floor map button===//
1738 1878
1739 1879 if ($vrgallery && 'valid' == $status && $is_pro ) {
@@ -1741,11 +1881,11 @@
1741 1881 $size = '';
1742 1882 if($vrgallery_icon_size){
1743 1883 $size = 'vrg-icon-size-large';
1744 1884 }
1745 - $html .= '<div id="vrgcontrols' . $id . '" class="vrgcontrols">';
1885 + $html .= '<div id="vrgcontrols' . $pano_suffix . '" class="vrgcontrols">';
1746 1886
1747 - $html .= '<div class="vrgctrl' . $id . ' vrbounce '.$size.'">';
1887 + $html .= '<div class="vrgctrl' . $pano_suffix . ' vrbounce '.$size.'">';
1748 1888 $html .= '</div>';
1749 1889 $html .= '</div>';
1750 1890
1751 1891 $gallery_layout_class = isset($postdata['tourLayout']['layout']) && 'layout1' === $postdata['tourLayout']['layout']
@@ -1750,9 +1890,9 @@
1750 1890
1751 1891 $gallery_layout_class = isset($postdata['tourLayout']['layout']) && 'layout1' === $postdata['tourLayout']['layout']
1752 1892 ? 'wpvr-gallery--modern'
1753 1893 : 'wpvr-gallery--classic';
1754 - $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) . '">';
1755 1895 if (isset($panodata["scene-list"])) {
1756 1896 foreach ($panodata["scene-list"] as $panoscenes) {
1757 1897 $scene_key = $panoscenes['scene-id'];
1758 1898
@@ -1776,11 +1916,11 @@
1776 1916 $thumbnail = $img_src_url;
1777 1917 }
1778 1918
1779 1919 if( isset($postdata['tourLayout']['layout']) && 'layout1' !== $postdata['tourLayout']['layout']) {
1780 - $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>';
1781 1921 }else {
1782 - $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>';
1783 1923 }
1784 1924 }
1785 1925 }
1786 1926
@@ -1811,15 +1951,15 @@
1811 1951 $audio_muted_attr = ($autoplay_bg_music === 'on') ? 'muted' : '';
1812 1952 $audio_icon_class = 'fa-volume-mute'; // Always start with mute icon
1813 1953
1814 1954 if ($bg_music === 'on' && 'valid' == $status && $is_pro) {
1815 - $html .= '<div id="adcontrol' . esc_attr( $id ) . '" class="adcontrol" style="right:' . esc_attr( $audio_right ) . '">';
1816 - $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 . '>
1817 1957 <source src="' . esc_url($bg_music_url) . '" type="audio/mpeg">
1818 1958 Your browser does not support the audio element.
1819 1959 </audio>';
1820 - $html .= '<button onclick="playPause' . esc_attr($id) . '()" class="ctrl audio_control" id="audio_control' . esc_attr($id) . '">
1821 - <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>
1822 1962 </button>';
1823 1963 $html .= '</div>';
1824 1964 }
1825 1965 //===Explainer video section===//
@@ -1826,9 +1966,9 @@
1826 1966 $explainerContent = "";
1827 1967 if (isset($postdata['explainerContent'])) {
1828 1968 $explainerContent = $this->wpvr_sanitize_iframe_only($postdata['explainerContent']);
1829 1969 }
1830 - $html .= '<div class="explainer" id="explainer' . $id . '" style="display: none">';
1970 + $html .= '<div class="explainer" id="explainer' . $pano_suffix . '" style="display: none">';
1831 1971 $html .= '<span class="close-explainer-video"><i class="fa fa-times"></i></span>';
1832 1972 $html .= '' . $explainerContent . '';
1833 1973 $html .= '</div>';
1834 1974 //===Explainer video section End===//
@@ -1846,13 +1986,13 @@
1846 1986 .zoom-in-out-controls {
1847 1987 top: 37px;
1848 1988 }
1849 1989 </style>';
1850 - $html .= '<div id="custom-scene-navigation' . $id . '" class="custom-scene-navigation">
1990 + $html .= '<div id="custom-scene-navigation' . $pano_suffix . '" class="custom-scene-navigation">
1851 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>
1852 1992 </div>
1853 1993
1854 - <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 ) . '">
1855 1995 <ul></ul>
1856 1996 </div>
1857 1997 ';
1858 1998 }
@@ -1860,9 +2000,9 @@
1860 2000
1861 2001
1862 2002 if( 'embed' === $width){
1863 2003 if(WPVR_Helper::is_enable_social_share($postdata) === 'on'){
1864 - $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.'">
1865 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>
1866 2006 <nav class="wpvr-share-nav">
1867 2007 '.WPVR_Helper::social_media_share_links_display_in_embed(home_url().'/?embed_page='. $id).'
1868 2008 </nav>
@@ -1869,45 +2009,88 @@
1869 2009 </div>';
1870 2010 }
1871 2011 }
1872 2012 //===Floor plan section===//
1873 - $floor_map_image = "";
1874 - $floor_map_pointer = array();
1875 - $floor_map_scene_id = '';
1876 - $floor_plan_custom_color = '#cca92c';
1877 - $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';
1878 2019
1879 - if (isset($postdata['floor_plan_attachment_url'])) {
1880 - $floor_map_image = $postdata['floor_plan_attachment_url'];
1881 - $floor_map_pointer = $postdata['floor_plan_pointer_position'];
1882 - $floor_map_scene_id = $postdata['floor_plan_data_list'];
1883 - $floor_plan_custom_color = $postdata['floor_plan_custom_color'];
1884 - }
1885 - $html .= '<div class="wpvr-floor-map" id="wpvr-floor-map' . $id . '" style="display: none">';
1886 - $html .= '<span class="close-floor-map-plan"><i class="fa fa-times"></i></span>';
1887 - $html .= '<img loading="lazy" src="'.$floor_map_image.'">';
1888 - foreach($floor_map_pointer as $key=> $pointer_position){
1889 - $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.'">
1890 - <svg class="floor-pointer-circle" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
1891 - <circle cx="12" cy="12" r="11.5" stroke="'.$floor_plan_custom_color.'"/>
1892 - <circle cx="12" cy="12" r="5" fill="'.$foreground_color_pointer.'"/>
1893 - </svg>';
1894 -
1895 - // Only add the floor pointer flash SVG if floor_plan_direction_indicator is "on"
1896 - if ($floor_plan_direction_indicator === "on") {
1897 - $html .= '<svg class="floor-pointer-flash" width="54" height="35" viewBox="0 0 54 35" fill="none" xmlns="http://www.w3.org/2000/svg">
1898 - <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)"/>
1899 - <defs>
1900 - <linearGradient id="paint0_linear_1_10" x1="27" y1="4.59807e-08" x2="26.5" y2="28" gradientUnits="userSpaceOnUse">
1901 - <stop stop-color="' . esc_attr( $floor_plan_custom_color ) . '" stop-opacity="0"/>
1902 - <stop offset="1" stop-color="' . esc_attr( $floor_plan_custom_color ) . '"/>
1903 - </linearGradient>
1904 - </defs>
1905 - </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;
1906 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 + }
1907 2091 $html .= '</div>';
1908 2092 }
1909 - $html .= '</div>';
1910 2093 //===Floor plan section===//
1911 2094
1912 2095 $html .= '<div class="wpvr-hotspot-tweak-contents-wrapper" style="display: none">';
1913 2096 $html .= '<i class="fa fa-times cross" data-id="' . $id . '"></i>';
@@ -1987,9 +2170,10 @@
1987 2170 border: '.$border_width.'px '.$border_style.' '.$border_color.';
1988 2171 border-radius: '.$border_radius.'px;
1989 2172 padding: '.$button_pt.'px '.$button_pr.'px '.$button_pb.'px '.$button_pl.'px;
1990 2173 ';
1991 - $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 . '">
1992 2176 <a href="'.$buttonurl.'" style="'.$style.'" target="'.$target.'">'.$buttontext.'</a>
1993 2177 </div>';
1994 2178
1995 2179 }
@@ -1999,26 +2183,26 @@
1999 2183 //script started
2000 2184 $html .= '<script>';
2001 2185 if (isset($postdata['bg_music']) && $bg_music == 'on' && 'valid' == $status && $is_pro) {
2002 2186 $html .= '
2003 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
2004 - var playing' . $id . ' = false;
2005 - var autoplaySupported' . $id . ' = false;
2006 - var alertShown' . $id . ' = false;
2007 - 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;
2008 2192
2009 - function playPause' . $id . '() {
2010 - if (playing' . $id . ') {
2011 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2012 - x' . $id . '.pause();
2013 - jQuery("#audio_control' . $id . '").attr("data-play", "off");
2014 - 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;
2015 2199 } else {
2016 - x' . $id . '.muted = false;
2017 - x' . $id . '.play().then(function() {
2018 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2019 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2020 - 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;
2021 2205 }).catch(function(e) {
2022 2206 console.log("Play failed:", e);
2023 2207 });
2024 2208 }
@@ -2023,133 +2207,139 @@
2023 2207 });
2024 2208 }
2025 2209 }
2026 2210
2027 - function audionEnd' . $id . '() {
2028 - playing' . $id . ' = false;
2029 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2030 - 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");
2031 2215 }
2032 2216
2033 - x' . $id . '.addEventListener("ended", audionEnd' . $id . ');';
2217 + x' . $pano_suffix . '.addEventListener("ended", audionEnd' . $pano_suffix . ');';
2034 2218
2035 2219 if ($autoplay_bg_music == 'on') {
2036 2220 $html .= '
2037 2221
2038 - x' . $id . '.addEventListener("loadeddata", function() {
2039 - if (!autoplayChecked' . $id . ') {
2040 - checkAutoplayStatus' . $id . '();
2222 + x' . $pano_suffix . '.addEventListener("loadeddata", function() {
2223 + if (!autoplayChecked' . $pano_suffix . ') {
2224 + checkAutoplayStatus' . $pano_suffix . '();
2041 2225 }
2042 2226 });
2043 2227
2044 - x' . $id . '.addEventListener("canplay", function() {
2045 - if (!autoplayChecked' . $id . ') {
2046 - checkAutoplayStatus' . $id . '();
2228 + x' . $pano_suffix . '.addEventListener("canplay", function() {
2229 + if (!autoplayChecked' . $pano_suffix . ') {
2230 + checkAutoplayStatus' . $pano_suffix . '();
2047 2231 }
2048 2232 });
2049 2233
2050 - x' . $id . '.addEventListener("canplaythrough", function() {
2051 - if (!autoplayChecked' . $id . ') {
2052 - checkAutoplayStatus' . $id . '();
2234 + x' . $pano_suffix . '.addEventListener("canplaythrough", function() {
2235 + if (!autoplayChecked' . $pano_suffix . ') {
2236 + checkAutoplayStatus' . $pano_suffix . '();
2053 2237 }
2054 2238 });
2055 2239
2056 2240 setTimeout(function() {
2057 - if (!autoplayChecked' . $id . ') {
2058 - checkAutoplayStatus' . $id . '();
2241 + if (!autoplayChecked' . $pano_suffix . ') {
2242 + checkAutoplayStatus' . $pano_suffix . '();
2059 2243 }
2060 2244 }, 1000);
2061 2245
2062 - x' . $id . '.addEventListener("play", function() {
2063 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2064 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2065 - 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;
2066 2250 });
2067 2251
2068 - x' . $id . '.addEventListener("pause", function() {
2069 - if (!playing' . $id . ') {
2070 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2071 - 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");
2072 2256 }
2073 2257 });
2074 2258
2075 - function checkAutoplayStatus' . $id . '() {
2076 - autoplayChecked' . $id . ' = true;
2259 + function checkAutoplayStatus' . $pano_suffix . '() {
2260 + autoplayChecked' . $pano_suffix . ' = true;
2077 2261
2078 - x' . $id . '.muted = true;
2079 - var playPromise = x' . $id . '.play();
2262 + x' . $pano_suffix . '.muted = true;
2263 + var playPromise = x' . $pano_suffix . '.play();
2080 2264
2081 2265 if (playPromise !== undefined) {
2082 2266 playPromise.then(function () {
2083 - if (x' . $id . '.muted || x' . $id . '.volume === 0) {
2084 - handleAutoplayBlocked' . $id . '();
2267 + if (x' . $pano_suffix . '.muted || x' . $pano_suffix . '.volume === 0) {
2268 + handleAutoplayBlocked' . $pano_suffix . '();
2085 2269 } else {
2086 - autoplaySupported' . $id . ' = true;
2087 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2088 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2089 - 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;
2090 2274 }
2091 2275 }).catch(function () {
2092 - handleAutoplayBlocked' . $id . '();
2276 + handleAutoplayBlocked' . $pano_suffix . '();
2093 2277 });
2094 2278 } else {
2095 2279 setTimeout(function () {
2096 - if (x' . $id . '.paused || x' . $id . '.currentTime === 0) {
2097 - handleAutoplayBlocked' . $id . '();
2280 + if (x' . $pano_suffix . '.paused || x' . $pano_suffix . '.currentTime === 0) {
2281 + handleAutoplayBlocked' . $pano_suffix . '();
2098 2282 } else {
2099 - autoplaySupported' . $id . ' = true;
2100 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2101 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2102 - 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;
2103 2287 }
2104 2288 }, 300);
2105 2289 }
2106 2290 }
2107 2291
2108 - function handleAutoplayBlocked' . $id . '() {
2109 - autoplaySupported' . $id . ' = false;
2110 - if (!alertShown' . $id . ') {
2292 + function handleAutoplayBlocked' . $pano_suffix . '() {
2293 + autoplaySupported' . $pano_suffix . ' = false;
2294 + if (!alertShown' . $pano_suffix . ') {
2111 2295 alert("Autoplay is not supported in your browser. Please click the audio button to play music.");
2112 - alertShown' . $id . ' = true;
2296 + alertShown' . $pano_suffix . ' = true;
2113 2297 }
2114 2298
2115 - x' . $id . '.pause();
2116 - x' . $id . '.currentTime = 0;
2117 - x' . $id . '.muted = true;
2299 + x' . $pano_suffix . '.pause();
2300 + x' . $pano_suffix . '.currentTime = 0;
2301 + x' . $pano_suffix . '.muted = true;
2118 2302
2119 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up").addClass("fas fa-volume-mute");
2120 - 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");
2121 2305
2122 - document.getElementById("pano' . $id . '").addEventListener("click", musicPlay' . $id . ');
2123 - document.addEventListener("touchstart", musicPlay' . $id . ', { once: true });
2124 - 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 });
2125 2312 }
2126 2313
2127 - function musicPlay' . $id . '() {
2128 - x' . $id . '.muted = false;
2129 - var playPromise = x' . $id . '.play();
2314 + function musicPlay' . $pano_suffix . '() {
2315 + x' . $pano_suffix . '.muted = false;
2316 + var playPromise = x' . $pano_suffix . '.play();
2130 2317
2131 2318 if (playPromise !== undefined) {
2132 2319 playPromise.then(function () {
2133 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2134 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2135 - 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;
2136 2323 }).catch(function(e) {
2137 2324 console.log("Play failed:", e);
2138 2325 });
2139 2326 } else {
2140 2327 setTimeout(function () {
2141 - if (!x' . $id . '.paused) {
2142 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-mute").addClass("fas fa-volume-up");
2143 - jQuery("#audio_control' . $id . '").attr("data-play", "on");
2144 - 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;
2145 2332 }
2146 2333 }, 100);
2147 2334 }
2148 2335
2149 - document.getElementById("pano' . $id . '").removeEventListener("click", musicPlay' . $id . ');
2150 - document.removeEventListener("touchstart", musicPlay' . $id . ');
2151 - 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 . ');
2152 2342 }
2153 2343 ';
2154 2344 }
2155 2345 }
@@ -2156,29 +2346,75 @@
2156 2346 $html .= '(function ($) {';
2157 2347 $html .= 'jQuery(document).ready(function() {';
2158 2348 $html .= 'var response = ' . $response . ';';
2159 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);';
2160 2382 $html .= 'if(scenes) {';
2161 2383 $html .= 'var scenedata = scenes.scenes;';
2162 - $html .= 'for(var i in scenedata) {';
2163 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2164 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2165 - $html .= 'if(scenehotspot[i].type === "info") {';
2166 - $html .= ' scenehotspot[i]["clickHandlerFunc"] = function(div, args) { if (typeof window.wpvrhotspot === "function") { window.wpvrhotspot(div, args); } };';
2167 - $html .= '} else if(scenehotspot[i].type === "scene") {';
2168 - $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"] || "";';
2169 2393 $status = get_option('wpvr_edd_license_status');
2170 2394 if ($status !== false && $status == 'valid') {
2171 - $html .='if(typeof wpvr_public !== "undefined" && wpvr_public.is_pro_active) {';
2172 - $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); } };';
2173 2398 $html .='}';
2399 + $html .='}';
2174 2400 }
2175 2401 $html .= '}';
2176 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 +
2177 2413 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2178 2414 } else {
2179 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2180 - $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); } };';
2181 2417 $html .= '}';
2182 2418 }
2183 2419
2184 2420 $html .= '}';
@@ -2183,24 +2419,25 @@
2183 2419
2184 2420 $html .= '}';
2185 2421 $html .= '}';
2186 2422 $html .= '}';
2187 - $html .= 'var panoshow' . $id . ';';
2188 - $html .= 'var panoshow2' . $id . ';';
2189 - $html .= 'function initWPVRViewer' . $id . '() {';
2190 - $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer' . $id . ', 50); return; }';
2191 - $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);';
2192 2429 $html .= '
2193 2430 window.wpvrViewers = window.wpvrViewers || {};
2194 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
2431 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
2195 2432 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2196 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
2433 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
2197 2434 }));
2198 2435 ';
2199 2436 if ( (float) $scene_fade_duration > 0 ) {
2200 2437 $html .= '
2201 - panoshow' . $id . '.on("scenechange", function() {
2202 - 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");
2203 2440 if (fadeImage) {
2204 2441 fadeImage.style.opacity = "1";
2205 2442 void fadeImage.offsetWidth;
2206 2443 }
@@ -2208,20 +2445,20 @@
2208 2445 }
2209 2446 $html .= '
2210 2447
2211 2448 if(typeof wpvr_public === "undefined" || !wpvr_public.is_pro_active || !wpvr_public.is_license_active) {
2212 - panoshow' . $id . '.on("load", function() {
2449 + panoshow' . $pano_suffix . '.on("load", function() {
2213 2450 jQuery(".pnlm-panorama-info").hide();
2214 2451 jQuery(".pnlm-compass").hide();
2215 2452 });
2216 2453
2217 - panoshow' . $id . '.on("scenechange", function() {
2454 + panoshow' . $pano_suffix . '.on("scenechange", function() {
2218 2455 jQuery(".pnlm-panorama-info").hide();
2219 2456 jQuery(".pnlm-compass").hide();
2220 2457 });
2221 2458 }';
2222 2459 $html .= '}';
2223 - $html .= 'initWPVRViewer' . $id . '();';
2460 + $html .= 'initWPVRViewer' . $pano_suffix . '();';
2224 2461 //===Dplicate mode only for vr mode===//
2225 2462 $response2 = json_decode($response);
2226 2463 $response2[1]->compass = false;
2227 2464 $response2[1]->autoRotate = false;
@@ -2227,43 +2464,57 @@
2227 2464 $response2[1]->autoRotate = false;
2228 2465 $response = json_encode($response2);
2229 2466 $html .= 'var response_duplicate = ' . $response . ';';
2230 2467 $html .= 'var scenes_duplicate = response_duplicate[1];';
2468 + $html .= 'wpvrResolveDevicePanorama(scenes_duplicate);';
2231 2469
2232 2470 $html .= 'if(scenes_duplicate) {';
2233 2471 $html .= 'var scenedata = scenes_duplicate.scenes;';
2234 - $html .= 'for(var i in scenedata) {';
2235 - $html .= 'var scenehotspot = scenedata[i].hotSpots;';
2236 - $html .= 'for(var i = 0; i < scenehotspot.length; i++) {';
2237 - $html .= 'if(scenehotspot[i]["clickHandlerArgs"] != "") {';
2238 - $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); } };';
2239 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 +
2240 2490 if (wpvr_isMobileDevice() && get_option('dis_on_hover') == "true") {
2241 2491 } else {
2242 - $html .= 'if(scenehotspot[i]["createTooltipArgs"] != "") {';
2243 - $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); } };';
2244 2494 $html .= '}';
2245 2495 }
2246 2496 $html .= '}';
2247 2497 $html .= '}';
2248 2498 $html .= '}';
2499 + $html .= '}';
2249 2500
2250 2501 $is_pro = apply_filters('is_wpvr_pro_active',false);
2251 2502 $status = get_option('wpvr_edd_license_status');
2252 2503 $html .= 'var vr_mode = "off";';
2253 2504 if ($status !== false && 'valid' == $status && $is_pro) {
2254 - $html .= 'function initWPVRViewer2' . $id . '() {';
2255 - $html .= 'if (typeof pannellum === "undefined" || typeof jQuery === "undefined") { setTimeout(initWPVRViewer2' . $id . ', 50); return; }';
2256 - $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);';
2257 2508 $html .= '
2258 2509 window.wpvrViewers = window.wpvrViewers || {};
2259 - window.wpvrViewers["pano2' . $id . '"] = panoshow2' . $id . ';
2510 + window.wpvrViewers["' . $panoid2 . '"] = panoshow2' . $pano_suffix . ';
2260 2511 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
2261 - detail: { containerId: "pano2' . $id . '", viewer: panoshow2' . $id . ' }
2512 + detail: { containerId: "' . $panoid2 . '", viewer: panoshow2' . $pano_suffix . ' }
2262 2513 }));
2263 2514 ';
2264 2515 $html .= '}';
2265 - $html .= 'initWPVRViewer2' . $id . '();';
2516 + $html .= 'initWPVRViewer2' . $pano_suffix . '();';
2266 2517 // Show Cardboard Mode in Tour
2267 2518 $html .= '
2268 2519 var tim;
2269 2520 var im = 0;
@@ -2276,43 +2527,45 @@
2276 2527 var scenedata = scenes_duplicate.scenes;
2277 2528 for(var i in scenedata) {
2278 2529 if(active_scene === i) {
2279 2530 var scenehotspot = scenedata[i].hotSpots;
2280 - for(var j in scenehotspot) {
2281 - var plusFiveYaw = Math.round(scenehotspot[j].yaw) + 5;
2282 - var minusFiveYaw = Math.round(scenehotspot[j].yaw) - 5;
2283 - var plusFivePitch = Math.round(scenehotspot[j].pitch) + 5;
2284 - var minusFivePitch = Math.round(scenehotspot[j].pitch) - 5;
2285 - var firstCondition = ( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ;
2286 - var secCondition = (Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw);
2287 - if(( Math.round(data.pitch) > minusFivePitch) && (Math.round(data.pitch) < plusFivePitch) ){
2288 - if((Math.round(data.yaw) > minusFiveYaw) && (Math.round(data.yaw) < plusFiveYaw)){
2289 - jQuery(".center-pointer").addClass("wpvr-pluse-effect")
2290 - var getScene = scenehotspot[j].sceneId;
2291 - if(scenehotspot[j].type == "scene"){
2292 - panoshow' . $id . '.loadScene(getScene);
2293 - panoshow2' . $id . '.loadScene(getScene);
2294 -// var inside_current_time_object = new Date();
2295 -// var inside_timer = inside_current_time_object.getTime();
2296 -// if(inside_timer > timer) {
2297 -// panoshow' . $id . '.loadScene(getScene);
2298 -// panoshow2' . $id . '.loadScene(getScene);
2299 -// jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2300 -// }
2301 - }else{
2302 - 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;
2303 2562 }
2304 - }
2305 - else {
2306 - jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2563 + } else {
2307 2564 c_time = new Date();
2308 2565 timer = c_time.getTime() + 2000;
2309 2566 }
2310 2567 }
2311 - else {
2312 - c_time = new Date();
2313 - timer = c_time.getTime() + 2000;
2314 - }
2315 2568 }
2316 2569 }
2317 2570 }
2318 2571 }
@@ -2318,26 +2571,28 @@
2318 2571 }
2319 2572 };
2320 2573 function vrDeviseOrientation(){
2321 2574 var data = {
2322 - pitch: panoshow' . $id . '.getPitch(),
2323 - yaw: panoshow' . $id . '.getYaw(),
2575 + pitch: panoshow' . $pano_suffix . '.getPitch(),
2576 + yaw: panoshow' . $pano_suffix . '.getYaw(),
2324 2577 };
2325 2578 panoShowCardBoardOnTrigger(data);
2326 2579 }';
2327 2580 $html .= '
2328 2581 function requestFullScreen(){
2329 - var elem = document.getElementById("master-container");
2330 - if (elem.requestFullscreen) {
2331 - elem.requestFullscreen();
2332 - } else if (elem.webkitRequestFullscreen) { /* Safari */
2333 - elem.webkitRequestFullscreen();
2334 - } else if (elem.msRequestFullscreen) { /* IE11 */
2335 - elem.msRequestFullscreen();
2336 - }
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 + }
2337 2592 }
2338 2593 function requestExitFullscreen(){
2339 - var elem = document.getElementById("master-container");
2594 + var elem = document.getElementById("' . $master_container_id . '") || document.getElementById("master-container");
2340 2595 if (document.exitFullscreen) {
2341 2596 document.exitFullscreen();
2342 2597 } else if (document.webkitExitFullscreen) { /* Safari */
2343 2598 document.webkitExitFullscreen();
@@ -2359,29 +2614,33 @@
2359 2614 let onLoadAnalytics = false;
2360 2615 let sceneLoadAnalytics = false;
2361 2616
2362 2617 function storeAnalyticsData(data) {
2363 - if (typeof wpvrAnalyticsObj !== "undefined" && typeof wpvr_public !== "undefined" && wpvr_public.is_pro_active) {
2364 - jQuery.ajax({
2365 - url: wpvrAnalyticsObj.ajaxUrl,
2366 - type: "POST",
2367 - data: {
2368 - action: "store_scene_hotspot_data",
2369 - scene_id: data.scene_id,
2370 - tour_id: data.tour_id,
2371 - type: data.type,
2372 - hotspot_id: data.hotspot_id || "",
2373 - user_agent: navigator.userAgent,
2374 - device_type: getDeviceType() || "desktop",
2375 - nonce: wpvrAnalyticsObj.nonce,
2376 - },
2377 - success: function (response) {
2378 - console.log("Data stored successfully");
2379 - },
2380 - error: function (error) {
2381 - 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 + });
2382 2641 }
2383 - });
2642 + }
2384 2643 } else {
2385 2644 console.warn("Analytics object not available or pro not active");
2386 2645 }
2387 2646 }
@@ -2394,9 +2653,9 @@
2394 2653 } else {
2395 2654 return "desktop";
2396 2655 }
2397 2656 }
2398 - panoshow' . $id . '.on("scenechange", function(scene) {
2657 + panoshow' . $pano_suffix . '.on("scenechange", function(scene) {
2399 2658 onLoadAnalytics = true;
2400 2659 sceneLoadAnalytics = true;
2401 2660 let scene_id = scene;
2402 2661 let tour_id = ' . $id . ';
@@ -2412,29 +2671,31 @@
2412 2671 user_agent: user_agent,
2413 2672 device_type: device_type,
2414 2673 });
2415 2674 });
2416 - panoshow' . $id . '.on("load", function() {
2417 - let scene_id = panoshow' . $id . '.getScene();
2675 + panoshow' . $pano_suffix . '.on("load", function() {
2676 + let scene_id = panoshow' . $pano_suffix . '.getScene();
2418 2677 let tour_id = ' . $id . ';
2419 2678 let type = "scene";
2420 2679 let hotspot_id = "";
2421 2680 let user_agent = navigator.userAgent;
2422 2681 let device_type = getDeviceType() ? getDeviceType() : "desktop";
2423 - if(!onLoadAnalytics && !sceneLoadAnalytics) {
2424 - storeAnalyticsData({
2425 - scene_id: scene_id,
2426 - tour_id: tour_id,
2427 - type: type,
2428 - hotspot_id: hotspot_id,
2429 - user_agent: user_agent,
2430 - device_type: device_type,
2431 - });
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 + }
2432 2693 }
2433 2694 });
2434 - function wpvrhotspotscene(hotSpotDiv, args) {
2695 + function wpvrhotspotscene' . $pano_suffix . '(hotSpotDiv, args) {
2435 2696 onLoadAnalytics = true;
2436 - let scene_id = panoshow' . $id . '.getScene();
2697 + let scene_id = panoshow' . $pano_suffix . '.getScene();
2437 2698 let tour_id = ' . $id . ';
2438 2699 let type = "hotspot";
2439 2700 let hotspot_id = args;
2440 2701 let user_agent = navigator.userAgent;
@@ -2447,27 +2708,28 @@
2447 2708 user_agent: user_agent,
2448 2709 device_type: device_type
2449 2710 });
2450 2711 }
2712 + var wpvrhotspotscene = wpvrhotspotscene' . $pano_suffix . ';
2451 2713 ';
2452 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2714 + $html .= 'panoshow' . $pano_suffix . '.on("scenechange", function (scene){
2453 2715 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2454 2716 active_scene = scene;
2455 2717 // if(localStorage.getItem("vr_mode") == "on") {
2456 2718 if(vr_mode == "on") {
2457 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2458 - 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");
2459 2721 }
2460 2722 });
2461 2723 var compassBlock = "";
2462 2724 var infoBlock = "";
2463 - jQuery(document).on("click",".vr_mode_change' . $id . '",function (){
2464 - jQuery("#pano2' . $id . ' .pnlm-load-button").trigger("click");
2465 - 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");
2466 2728 var getValue = jQuery(this).val();
2467 2729 var getParent = jQuery(this).parent().parent();
2468 - var compass = getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display");
2469 - 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");
2470 2732 if(compass == "block"){
2471 2733 compassBlock = "block";
2472 2734 }
2473 2735 if(panoInfo == "block"){
@@ -2482,79 +2744,79 @@
2482 2744 // localStorage.setItem("vr_mode", "on");
2483 2745 vr_mode = "on";
2484 2746 jQuery(".vr-mode-title").show();
2485 2747 jQuery(this).val("on");
2486 - getParent.find("#pano2' . $id . '").css({
2748 + getParent.find("#' . $panoid2 . '").css({
2487 2749 "opacity": "1",
2488 2750 "visibility": "visible",
2489 2751 "position": "relative",
2490 2752 });
2491 2753 gyroSwitch = true;
2492 - panoshow' . $id . '.startOrientation();
2493 - panoshow2' . $id . '.startOrientation();
2494 - panoshow2' . $id . '.setPitch(panoshow' . $id . '.getPitch(), 0);
2495 - 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);
2496 2758 getParent.find(".pano-wrap").addClass("wpvr-cardboard-disable-event");
2497 - getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").hide();
2498 - getParent.find("#pano' .$id. ' #controls'.$id.'").hide();
2499 - getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").hide();
2500 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").hide();
2501 - getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").hide();
2502 - getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").hide();
2503 - getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2504 - getParent.find("#pano' .$id. ' #adcontrol'.$id.'").hide();
2505 - getParent.find("#pano' .$id. ' .wpvr_slider_nav").hide();
2506 - getParent.find("#pano' .$id. ' #cp-logo-controls").hide();
2507 - getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").hide();
2508 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").hide();
2509 - getParent.find("#pano' . $id . ' .pnlm-controls-container").hide();
2510 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2511 - getParent.find("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").hide();
2512 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").hide();
2513 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").hide();
2514 - getParent.find("#pano' . $id . '").addClass("cardboard-half");
2515 - 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();
2516 2778 getParent.find(".fullscreen-button").hide();
2517 - getParent.find("#pano' . $id . ' #custom-scene-navigation' . $id . '").hide();
2779 + getParent.find("#' . $panoid . ' #custom-scene-navigation' . $pano_suffix . '").hide();
2518 2780 if (window.DeviceOrientationEvent) {
2519 2781 window.addEventListener("deviceorientation", vrDeviseOrientation);
2520 2782 }
2521 - panoshow' . $id . '.on("zoomchange", function (data){
2522 - panoshow2' . $id . '.setHfov(data, 0);
2783 + panoshow' . $pano_suffix . '.on("zoomchange", function (data){
2784 + panoshow2' . $pano_suffix . '.setHfov(data, 0);
2523 2785 });
2524 - panoshow2' . $id . '.on("zoomchange", function (data){
2525 - panoshow' . $id . '.setHfov(data, 0);
2786 + panoshow2' . $pano_suffix . '.on("zoomchange", function (data){
2787 + panoshow' . $pano_suffix . '.setHfov(data, 0);
2526 2788 });
2527 - jQuery(document).on("click","#pano2' . $id . '",function(event) {
2528 - panoshow' . $id . '.startOrientation();
2529 - panoshow2' . $id . '.startOrientation();
2789 + jQuery(document).on("click","#' . $panoid2 . '",function(event) {
2790 + panoshow' . $pano_suffix . '.startOrientation();
2791 + panoshow2' . $pano_suffix . '.startOrientation();
2530 2792 });
2531 - jQuery(document).on("click","#pano' . $id . '",function(event) {
2532 - panoshow' . $id . '.startOrientation();
2533 - panoshow2' . $id . '.startOrientation();
2793 + jQuery(document).on("click","#' . $panoid . '",function(event) {
2794 + panoshow' . $pano_suffix . '.startOrientation();
2795 + panoshow2' . $pano_suffix . '.startOrientation();
2534 2796 });
2535 - panoshow' . $id . '.on("mousemove", function (data){
2536 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2537 - 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);
2538 2800 panoShowCardBoardOnTrigger(data);
2539 2801 });
2540 - panoshow2' . $id . '.on("mousemove", function (data){
2541 - panoshow' . $id . '.setPitch(data.pitch, 0);
2542 - 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);
2543 2805 panoShowCardBoardOnTrigger(data);
2544 2806 });
2545 - panoshow' . $id . '.on("touchmove", function (data){
2546 - panoshow' . $id . '.stopOrientation();
2547 - panoshow2' . $id . '.stopOrientation();
2548 - panoshow2' . $id . '.setPitch(data.pitch, 0);
2549 - 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);
2550 2812 panoShowCardBoardOnTrigger(data);
2551 2813 });
2552 - panoshow2' . $id . '.on("touchmove", function (data){
2553 - panoshow' . $id . '.stopOrientation();
2554 - panoshow2' . $id . '.stopOrientation();
2555 - panoshow' . $id . '.setPitch(data.pitch, 0);
2556 - 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);
2557 2819 panoShowCardBoardOnTrigger(data);
2558 2820 });
2559 2821 } else if(getValue == "on") {
2560 2822 screen.orientation.unlock();
@@ -2562,66 +2824,66 @@
2562 2824 // localStorage.setItem("vr_mode", "off");
2563 2825 vr_mode = "off";
2564 2826 jQuery(".vr-mode-title").hide();
2565 2827 jQuery(this).val("off");
2566 - getParent.find("#pano2' . $id . '").css({
2828 + getParent.find("#' . $panoid2 . '").css({
2567 2829 "opacity": "0",
2568 2830 "visibility": "hidden",
2569 2831 "position": "absolute",
2570 2832 });
2571 2833 getParent.find(".pano-wrap").removeClass("wpvr-cardboard-disable-event");
2572 - getParent.find("#pano' .$id. ' #zoom-in-out-controls'.$id.'").show();
2573 - getParent.find("#pano' .$id. ' #controls'.$id.'").show();
2574 - getParent.find("#pano' .$id. ' #explainer_button_'.$id. '").show();
2575 - getParent.find("#pano' . $id . ' #generic_form_button_' . $id . '").show();
2576 - getParent.find("#pano' .$id. ' #floor_map_button_'.$id.'").show();
2577 - getParent.find("#pano2' . $id . ' .pnlm-controls-container").show();
2578 - getParent.find("#pano' . $id . ' .pnlm-controls-container").show();
2579 - getParent.find("#pano' .$id. ' #vrgcontrols'.$id.'").show();
2580 - getParent.find("#pano' .$id. ' #sccontrols'.$id.'").hide();
2581 - getParent.find("#pano' .$id. ' #adcontrol'.$id.'").show();
2582 - getParent.find("#pano' .$id. ' .wpvr_slider_nav").hide();
2583 - getParent.find("#pano' .$id. ' #cp-logo-controls").show();
2584 - getParent.find("#pano' .$id. ' #wpvr-social-share-bg-box'.$id.'").show();
2585 - 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();
2586 2848 if(compassBlock == "block"){
2587 - getParent.find("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").show();
2588 - 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();
2589 2851 }
2590 2852 if(infoBlock == "block"){
2591 - getParent.find("#pano2' . $id . ' .pnlm-panorama-info").show();
2592 - getParent.find("#pano' . $id . ' .pnlm-panorama-info").show();
2853 + getParent.find("#' . $panoid2 . ' .pnlm-panorama-info").show();
2854 + getParent.find("#' . $panoid . ' .pnlm-panorama-info").show();
2593 2855 }
2594 - getParent.find("#pano' . $id . '").removeClass("cardboard-half");
2595 - getParent.find("#center-pointer' . $id . '").hide();
2856 + getParent.find("#' . $panoid . '").removeClass("cardboard-half");
2857 + getParent.find("#center-pointer' . $pano_suffix . '").hide();
2596 2858 getParent.find(".fullscreen-button").hide();
2597 - panoshow' . $id . '.off("mousemove");
2598 - panoshow' . $id . '.off("touchmove");
2599 - panoshow2' . $id . '.off("mousemove");
2600 - 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");
2601 2863 if (window.DeviceOrientationEvent) {
2602 2864 window.removeEventListener("deviceorientation", vrDeviseOrientation);
2603 2865 }
2604 2866 }
2605 2867 });';
2606 - $html .= 'panoshow2' . $id . '.on("load", function (){
2868 + $html .= 'panoshow2' . $pano_suffix . '.on("load", function (){
2607 2869 // if(localStorage.getItem("vr_mode") == "off") {
2608 2870 if( vr_mode == "off") {
2609 2871 jQuery(".vr-mode-title").hide();
2610 2872 }
2611 2873 else {
2612 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2613 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2614 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2615 - 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();
2616 2878 jQuery(".vr-mode-title").show();
2617 2879 }
2618 2880 });';
2619 2881 }
2620 2882 //=== end Dplicate mode only for vr mode===//
2621 - $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(){
2622 2884 var scene_id = jQuery(this).attr("scene_id");
2623 - panoshow' . $id . '.loadScene(scene_id)
2885 + panoshow' . $pano_suffix . '.loadScene(scene_id)
2624 2886 jQuery(".floor-plan-pointer").removeClass("add-pulse")
2625 2887 jQuery(this).addClass("add-pulse")
2626 2888 });';
2627 2889 if ($scene_animation_enabled && is_plugin_active('wpvr-pro/wpvr-pro.php')) {
@@ -2631,9 +2893,9 @@
2631 2893 $animationDelay = $postdata['sceneAnimationTransitionDelay'] ?? '0ms';
2632 2894 $animation_js = apply_filters('wpvr_scene_animation_js', $id, $animation_type, $animationDuration, $animationDelay);
2633 2895 if (!empty($animation_js)) {
2634 2896 $html .= $animation_js;
2635 - $html .= 'panoshow' . $id . '.on("load", function (scene){
2897 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (scene){
2636 2898 if (typeof changeScene === "function") {
2637 2899 changeScene();
2638 2900 } else {
2639 2901 console.warn("changeScene function is not defined.");
@@ -2641,15 +2903,15 @@
2641 2903 });';
2642 2904 }
2643 2905 }
2644 2906
2645 - $html .= 'panoshow' . $id . '.on("mousemove", function (data){
2907 + $html .= 'panoshow' . $pano_suffix . '.on("mousemove", function (data){
2646 2908 jQuery(".add-pulse").css({"transform":"rotate("+data.yaw+"deg)"});
2647 2909 });
2648 2910 ';
2649 2911 $status = get_option('wpvr_edd_license_status');
2650 2912 if ($status !== false && 'valid' == $status && $is_pro){
2651 - $html .= 'panoshow' . $id . '.on("scenechange", function (scene){
2913 + $html .= 'panoshow' . $pano_suffix . '.on("scenechange", function (scene){
2652 2914 jQuery(".center-pointer").removeClass("wpvr-pluse-effect")
2653 2915 jQuery(".floor-plan-pointer").each(function(index ,element){
2654 2916 var scene_id = jQuery(this).attr("scene_id");
2655 2917 if( active_scene == scene_id ){
@@ -2657,9 +2919,9 @@
2657 2919 jQuery(this).addClass("add-pulse")
2658 2920 }
2659 2921 });
2660 2922 });';
2661 - $html .= 'panoshow' . $id . '.on("load", function (){
2923 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
2662 2924 if(jQuery(".floor-plan-pointer").length > 0){
2663 2925 jQuery(".floor-plan-pointer").each(function(index ,element){
2664 2926 var scene_id = jQuery(this).attr("scene_id");
2665 2927 if( active_scene == scene_id ){
@@ -2671,14 +2933,14 @@
2671 2933 });';
2672 2934 }
2673 2935 if ($status !== false && 'valid' == $status && $is_pro){
2674 2936 $scene_navigation_content_type = isset($postdata['scene_navigation_content_type']) ? $postdata['scene_navigation_content_type'] : 'scene_id';
2675 - $html .= 'jQuery("#pano' . $id . ' .custom-scene-navigation").on("click", function() {
2676 - 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();
2677 2939 if (scenes) {
2678 2940 var scene_navigation_content_type = "' . $scene_navigation_content_type . '";
2679 2941 var sceneList = scenes.scenes;
2680 - var getScene = panoshow' . $id . '.getScene();
2942 + var getScene = panoshow' . $pano_suffix . '.getScene();
2681 2943 for (const key in sceneList) {
2682 2944 let title;
2683 2945 if (scene_navigation_content_type === "scene_title") {
2684 2946 if (sceneList[key].title) {
@@ -2697,9 +2959,9 @@
2697 2959 } else {
2698 2960 title = key;
2699 2961 }
2700 2962 if (sceneList.hasOwnProperty(key)) {
2701 - let ulElement = document.querySelector("#custom-scene-navigation-nav' . $id . ' ul");
2963 + let ulElement = document.querySelector("#custom-scene-navigation-nav' . $pano_suffix . ' ul");
2702 2964 if (ulElement) {
2703 2965 let liElement = document.createElement("li");
2704 2966 liElement.className = "scene-navigation-list" + (key === getScene ? " active" : "");
2705 2967 liElement.setAttribute("scene_id", key);
@@ -2707,9 +2969,9 @@
2707 2969 ulElement.appendChild(liElement);
2708 2970 }
2709 2971 }
2710 2972 }
2711 - jQuery("#custom-scene-navigation-nav' . $id . '").toggleClass("visible");
2973 + jQuery("#custom-scene-navigation-nav' . $pano_suffix . '").toggleClass("visible");
2712 2974 }
2713 2975 });';
2714 2976 $html .='function getImageNameWithoutExtension(imageUrl) {
2715 2977 // Split the URL by "/"
@@ -2722,70 +2984,70 @@
2722 2984 var imageNameWithoutExtension = imageNameParts.slice(0, -1).join(".");
2723 2985 // Return the image name without extension
2724 2986 return imageNameWithoutExtension;
2725 2987 }';
2726 - $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() {
2727 2989 if (scenes) {
2728 2990 jQuery(this).siblings("li").removeClass("active");
2729 2991 jQuery(this).addClass("active");
2730 2992 var scene_key = jQuery(this).attr("scene_id");
2731 - panoshow' . $id . '.loadScene(scene_key);
2993 + panoshow' . $pano_suffix . '.loadScene(scene_key);
2732 2994 }
2733 2995 });';
2734 2996 }
2735 2997 $html .= 'const node = document.querySelector(".add-pulse");
2736 - panoshow' . $id . '.on("compasschange", function (data){
2998 + panoshow' . $pano_suffix . '.on("compasschange", function (data){
2737 2999 // const node = document.querySelector(".add-pulse");
2738 3000 // node.style.transform = data;
2739 3001 // jQuery(".add-pulse").css({"transform":data});
2740 3002 });';
2741 - $html .= 'panoshow' . $id . '.on("load", function (){
3003 + $html .= 'panoshow' . $pano_suffix . '.on("load", function (){
2742 3004 // if(localStorage.getItem("vr_mode") == "off") {
2743 3005 if(vr_mode == "off") {
2744 3006 jQuery(".vr-mode-title").hide();
2745 3007 } else {
2746 - jQuery("#pano2' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2747 - jQuery("#pano' . $id . ' .pnlm-compass.pnlm-controls.pnlm-control").css("display","none");
2748 - jQuery("#pano2' . $id . ' .pnlm-panorama-info").hide();
2749 - 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();
2750 3012 jQuery(".vr-mode-title").show();
2751 3013 }
2752 3014 setTimeout(() => {
2753 3015 window.dispatchEvent(new Event("resize"));
2754 3016 }, 200);
2755 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
2756 - 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");
2757 3019 }
2758 3020 else {
2759 - jQuery("#controls' . $id . '").css("bottom", "5px");
3021 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
2760 3022 }
2761 3023 });';
2762 - $html .= 'panoshow' . $id . '.on("render", function (){
3024 + $html .= 'panoshow' . $pano_suffix . '.on("render", function (){
2763 3025 window.dispatchEvent(new Event("resize"));
2764 3026 });';
2765 3027 $html .= 'if (scenes.autoRotate) {
2766 - var wpvrAutoRotateTimer' . $id . ' = null;
2767 - var wpvrAutoRotateStopDelay' . $id . ' = parseInt(scenes.autoRotateStopDelay, 10) || 0;
2768 - var wpvrScheduleAutoRotate' . $id . ' = function () {
2769 - clearTimeout(wpvrAutoRotateTimer' . $id . ');
2770 - if (wpvrAutoRotateStopDelay' . $id . ' > 0) {
2771 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
2772 - panoshow' . $id . '.stopAutoRotate();
2773 - }, 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 . ');
2774 3036 } else {
2775 - wpvrAutoRotateTimer' . $id . ' = setTimeout(function () {
2776 - panoshow' . $id . '.startAutoRotate(scenes.autoRotate, 0);
3037 + wpvrAutoRotateTimer' . $pano_suffix . ' = setTimeout(function () {
3038 + panoshow' . $pano_suffix . '.startAutoRotate(scenes.autoRotate, 0);
2777 3039 }, 3000);
2778 3040 }
2779 3041 };
2780 - panoshow' . $id . '.on("load", wpvrScheduleAutoRotate' . $id . ');
2781 - panoshow' . $id . '.on("scenechange", wpvrScheduleAutoRotate' . $id . ');
3042 + panoshow' . $pano_suffix . '.on("load", wpvrScheduleAutoRotate' . $pano_suffix . ');
3043 + panoshow' . $pano_suffix . '.on("scenechange", wpvrScheduleAutoRotate' . $pano_suffix . ');
2782 3044 }';
2783 3045 $html .= 'var touchtime = 0;';
2784 3046 $html .= '
2785 - var wpvrHotspotRoot' . $id . ' = document.getElementById("pano' . $id . '");
2786 - if (wpvrHotspotRoot' . $id . ') {
2787 - 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) {
2788 3050 var hotspot = event.target.closest(".pnlm-hotspot-base");
2789 3051
2790 3052 if (!hotspot) {
2791 3053 return;
@@ -2790,8 +3052,13 @@
2790 3052 if (!hotspot) {
2791 3053 return;
2792 3054 }
2793 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 +
2794 3061 var hotspotLink = hotspot.closest("a[href]");
2795 3062 if (!hotspotLink) {
2796 3063 hotspotLink = hotspot.querySelector("a[href]");
2797 3064 }
@@ -2816,11 +3083,11 @@
2816 3083 if (isset($panodata["scene-list"])) {
2817 3084 foreach ($panodata["scene-list"] as $panoscenes) {
2818 3085 $scene_key = $panoscenes['scene-id'];
2819 3086 $gallery_scene_ids[] = (string) $scene_key;
2820 - $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $id;
3087 + $scene_key_gallery = $panoscenes['scene-id'] . '_gallery_' . $pano_suffix;
2821 3088 $html .= 'jQuery(document).on("click","#' . $scene_key_gallery . '",function() {
2822 - panoshow' . $id . '.loadScene("' . $scene_key . '");
3089 + panoshow' . $pano_suffix . '.loadScene(' . wp_json_encode( (string) $scene_key ) . ');
2823 3090 });';
2824 3091 }
2825 3092 }
2826 3093
@@ -2848,22 +3115,22 @@
2848 3115 stagePadding: 0
2849 3116 }';
2850 3117
2851 3118 $html .= '
2852 - var wpvrGallery' . $id . ' = jQuery("#sccontrols' . $id . '");
2853 - var wpvrGalleryRoot' . $id . ' = jQuery("#pano' . $id . '");
2854 - var wpvrGalleryScenes' . $id . ' = ' . wp_json_encode(array_values($gallery_scene_ids)) . ';
2855 - var wpvrGalleryResizeTimer' . $id . ';
2856 - var wpvrGalleryVisibilityTimer' . $id . ';
2857 - 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 . ';
2858 3125
2859 - function wpvrPrepareSceneNavigation' . $id . '() {
2860 - var navigationDisabled = wpvrGalleryScenes' . $id . '.length < 2;
2861 - var previousButtons = wpvrGalleryRoot' . $id . '.find(".wpvr_owl_prev");
2862 - 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");
2863 3130
2864 - wpvrGallery' . $id . '.removeClass("owl-theme");
2865 - 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");
2866 3133 previousButtons
2867 3134 .removeClass("owl-prev")
2868 3135 .prop("disabled", navigationDisabled)
2869 3136 .toggleClass("disabled", navigationDisabled);
@@ -2872,76 +3139,76 @@
2872 3139 .prop("disabled", navigationDisabled)
2873 3140 .toggleClass("disabled", navigationDisabled);
2874 3141 }
2875 3142
2876 - function wpvrRefreshGallery' . $id . '() {
2877 - wpvrPrepareSceneNavigation' . $id . '();
3143 + function wpvrRefreshGallery' . $pano_suffix . '() {
3144 + wpvrPrepareSceneNavigation' . $pano_suffix . '();
2878 3145
2879 - 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")) {
2880 3147 return;
2881 3148 }
2882 3149
2883 - if (wpvrGallery' . $id . '.css("display") === "flex") {
2884 - wpvrGallery' . $id . '.css("display", "block");
3150 + if (wpvrGallery' . $pano_suffix . '.css("display") === "flex") {
3151 + wpvrGallery' . $pano_suffix . '.css("display", "block");
2885 3152 }
2886 - wpvrGallery' . $id . '.trigger("refresh.owl.carousel");
2887 - wpvrUpdateGalleryNavigation' . $id . '(panoshow' . $id . '.getScene());
3153 + wpvrGallery' . $pano_suffix . '.trigger("refresh.owl.carousel");
3154 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2888 3155 }
2889 3156
2890 - function wpvrGallerySceneIndex' . $id . '(sceneId) {
2891 - return wpvrGalleryScenes' . $id . '.indexOf(String(sceneId));
3157 + function wpvrGallerySceneIndex' . $pano_suffix . '(sceneId) {
3158 + return wpvrGalleryScenes' . $pano_suffix . '.indexOf(String(sceneId));
2892 3159 }
2893 3160
2894 - function wpvrUpdateGalleryNavigation' . $id . '(sceneId) {
2895 - var currentIndex = wpvrGallerySceneIndex' . $id . '(sceneId);
2896 - var activeThumbnailId = String(sceneId) + "_gallery_' . $id . '";
2897 - 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");
2898 3165 var activeThumbnail = thumbnails.filter(function () {
2899 3166 return this.id === activeThumbnailId;
2900 3167 });
2901 3168
2902 - wpvrPrepareSceneNavigation' . $id . '();
3169 + wpvrPrepareSceneNavigation' . $pano_suffix . '();
2903 3170 thumbnails.removeClass("wpvr-active-thumbnail");
2904 - wpvrGallery' . $id . '.find(".owl-item").removeClass("clicked");
3171 + wpvrGallery' . $pano_suffix . '.find(".owl-item").removeClass("clicked");
2905 3172 activeThumbnail.addClass("wpvr-active-thumbnail");
2906 3173 activeThumbnail.closest(".owl-item").addClass("clicked");
2907 3174
2908 3175 if (currentIndex >= 0) {
2909 - if (wpvrGallery' . $id . '.hasClass("owl-loaded")) {
2910 - wpvrGallery' . $id . '.trigger("to.owl.carousel", [currentIndex, 300, true]);
2911 - 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);
2912 3179 }
2913 3180 }
2914 3181 }
2915 3182
2916 - function wpvrLoadAdjacentGalleryScene' . $id . '(direction) {
2917 - var currentIndex = wpvrGallerySceneIndex' . $id . '(panoshow' . $id . '.getScene());
3183 + function wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(direction) {
3184 + var currentIndex = wpvrGallerySceneIndex' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2918 3185
2919 - if (currentIndex < 0 || wpvrGalleryScenes' . $id . '.length < 2) {
3186 + if (currentIndex < 0 || wpvrGalleryScenes' . $pano_suffix . '.length < 2) {
2920 3187 return;
2921 3188 }
2922 3189
2923 - var targetIndex = (currentIndex + direction + wpvrGalleryScenes' . $id . '.length) % wpvrGalleryScenes' . $id . '.length;
2924 - 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]);
2925 3192 }
2926 3193
2927 3194 if (jQuery.fn.owlCarousel) {
2928 - if (wpvrGallery' . $id . '.length) {
2929 - if (!wpvrGallery' . $id . '.hasClass("owl-loaded")) {
2930 - 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 . ');
2931 3198 }
2932 3199 }
2933 3200 }
2934 3201
2935 - wpvrGalleryRoot' . $id . '
2936 - .off("click.wpvrGalleryRefresh' . $id . '", "#vrgcontrols' . $id . '")
2937 - .on("click.wpvrGalleryRefresh' . $id . '", "#vrgcontrols' . $id . '", function () {
2938 - wpvrPrepareSceneNavigation' . $id . '();
2939 - 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);
2940 3207 });
2941 3208
2942 - if (wpvrGalleryRoot' . $id . '.length) {
2943 - wpvrGalleryRoot' . $id . '[0].addEventListener("click", function (event) {
3209 + if (wpvrGalleryRoot' . $pano_suffix . '.length) {
3210 + wpvrGalleryRoot' . $pano_suffix . '[0].addEventListener("click", function (event) {
2944 3211 var navigationButton = event.target.closest(".wpvr_owl_prev, .wpvr_owl_next");
2945 3212
2946 3213 if (!navigationButton) {
2947 3214 return;
@@ -2946,9 +3213,9 @@
2946 3213 if (!navigationButton) {
2947 3214 return;
2948 3215 }
2949 3216
2950 - if (!wpvrGalleryRoot' . $id . '[0].contains(navigationButton)) {
3217 + if (!wpvrGalleryRoot' . $pano_suffix . '[0].contains(navigationButton)) {
2951 3218 return;
2952 3219 }
2953 3220
2954 3221 event.preventDefault();
@@ -2954,29 +3221,29 @@
2954 3221 event.preventDefault();
2955 3222 event.stopImmediatePropagation();
2956 3223
2957 3224 if (navigationButton.classList.contains("wpvr_owl_prev")) {
2958 - wpvrLoadAdjacentGalleryScene' . $id . '(-1);
3225 + wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(-1);
2959 3226 } else {
2960 - wpvrLoadAdjacentGalleryScene' . $id . '(1);
3227 + wpvrLoadAdjacentGalleryScene' . $pano_suffix . '(1);
2961 3228 }
2962 3229 }, true);
2963 3230 }
2964 3231
2965 3232 jQuery(window)
2966 - .off("resize.wpvrGallery' . $id . '")
2967 - .on("resize.wpvrGallery' . $id . '", function () {
2968 - window.clearTimeout(wpvrGalleryResizeTimer' . $id . ');
2969 - 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);
2970 3237 });
2971 3238
2972 3239 if (window.MutationObserver) {
2973 - if (wpvrGallery' . $id . '.length) {
2974 - wpvrGalleryObserver' . $id . ' = new MutationObserver(function () {
2975 - window.clearTimeout(wpvrGalleryVisibilityTimer' . $id . ');
2976 - 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);
2977 3244 });
2978 - wpvrGalleryObserver' . $id . '.observe(wpvrGallery' . $id . '[0], {
3245 + wpvrGalleryObserver' . $pano_suffix . '.observe(wpvrGallery' . $pano_suffix . '[0], {
2979 3246 attributes: true,
2980 3247 attributeFilter: ["style"]
2981 3248 });
2982 3249 }
@@ -2981,15 +3248,15 @@
2981 3248 });
2982 3249 }
2983 3250 }
2984 3251
2985 - panoshow' . $id . '.on("scenechange", function (sceneId) {
2986 - wpvrUpdateGalleryNavigation' . $id . '(sceneId);
3252 + panoshow' . $pano_suffix . '.on("scenechange", function (sceneId) {
3253 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(sceneId);
2987 3254 });
2988 3255
2989 - window.setTimeout(wpvrRefreshGallery' . $id . ', 0);
3256 + window.setTimeout(wpvrRefreshGallery' . $pano_suffix . ', 0);
2990 3257 window.setTimeout(function () {
2991 - wpvrUpdateGalleryNavigation' . $id . '(panoshow' . $id . '.getScene());
3258 + wpvrUpdateGalleryNavigation' . $pano_suffix . '(panoshow' . $pano_suffix . '.getScene());
2992 3259 }, 0);
2993 3260 ';
2994 3261 }
2995 3262 //===Custom Control===//
@@ -2994,44 +3261,44 @@
2994 3261 }
2995 3262 //===Custom Control===//
2996 3263 if (isset($custom_control)) {
2997 3264 if ($custom_control['panupSwitch'] == "on" && 'valid' == $status && $is_pro) {
2998 - $html .= 'document.getElementById("pan-up' . $id . '").addEventListener("click", function(e) {';
2999 - $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);';
3000 3267 $html .= '});';
3001 3268 }
3002 3269 if ($custom_control['panDownSwitch'] == "on" && 'valid' == $status && $is_pro) {
3003 - $html .= 'document.getElementById("pan-down' . $id . '").addEventListener("click", function(e) {';
3004 - $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);';
3005 3272 $html .= '});';
3006 3273 }
3007 3274 if ($custom_control['panLeftSwitch'] == "on" && 'valid' == $status && $is_pro) {
3008 - $html .= 'document.getElementById("pan-left' . $id . '").addEventListener("click", function(e) {';
3009 - $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);';
3010 3277 $html .= '});';
3011 3278 }
3012 3279 if ($custom_control['panRightSwitch'] == "on" && 'valid' == $status && $is_pro) {
3013 - $html .= 'document.getElementById("pan-right' . $id . '").addEventListener("click", function(e) {';
3014 - $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);';
3015 3282 $html .= '});';
3016 3283 }
3017 3284 if ($custom_control['panZoomInSwitch'] == "on") {
3018 - $html .= 'document.getElementById("zoom-in' . $id . '").addEventListener("click", function(e) {';
3019 - $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);';
3020 3287 $html .= '});';
3021 3288 }
3022 3289 if ($custom_control['panZoomOutSwitch'] == "on") {
3023 - $html .= 'document.getElementById("zoom-out' . $id . '").addEventListener("click", function(e) {';
3024 - $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);';
3025 3292 $html .= '});';
3026 3293 }
3027 3294 if ($custom_control['panFullscreenSwitch'] == "on" && 'valid' == $status && $is_pro) {
3028 - $html .= 'document.getElementById("fullscreen' . $id . '").addEventListener("click", function(e) {';
3029 - $html .= 'panoshow' . $id . '.toggleFullscreen();';
3295 + $html .= 'document.getElementById("fullscreen' . $pano_suffix . '").addEventListener("click", function(e) {';
3296 + $html .= 'panoshow' . $pano_suffix . '.toggleFullscreen();';
3030 3297 $html .= '});';
3031 3298 $html .= '(function() {';
3032 - $html .= 'function wpvrFsChange' . $id . '() {';
3033 - $html .= 'var fsIcon = document.querySelector("#fullscreen' . $id . ' i");';
3299 + $html .= 'function wpvrFsChange' . $pano_suffix . '() {';
3300 + $html .= 'var fsIcon = document.querySelector("#fullscreen' . $pano_suffix . ' i");';
3034 3301 $html .= 'if (!fsIcon) return;';
3035 3302 $html .= 'if (document.fullscreenElement || document.webkitFullscreenElement || document.mozFullScreenElement || document.msFullscreenElement) {';
3036 3303 $html .= 'fsIcon.classList.remove("fa-expand"); fsIcon.classList.add("fa-minimize");';
3037 3304 $html .= '} else {';
@@ -3037,23 +3304,23 @@
3037 3304 $html .= '} else {';
3038 3305 $html .= 'fsIcon.classList.remove("fa-minimize"); fsIcon.classList.add("fa-expand");';
3039 3306 $html .= '}';
3040 3307 $html .= '}';
3041 - $html .= 'document.addEventListener("fullscreenchange", wpvrFsChange' . $id . ');';
3042 - $html .= 'document.addEventListener("webkitfullscreenchange", wpvrFsChange' . $id . ');';
3043 - $html .= 'document.addEventListener("mozfullscreenchange", wpvrFsChange' . $id . ');';
3044 - $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 . ');';
3045 3312 $html .= '})();';
3046 3313 }
3047 3314 if ($custom_control['backToHomeSwitch'] == "on" && 'valid' == $status && $is_pro) {
3048 - $html .= 'document.getElementById("backToHome' . $id . '").addEventListener("click", function(e) {';
3049 - $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 ) . ');';
3050 3317 $html .= '});';
3051 3318 }
3052 3319 if ($gyro_button_enabled && 'valid' == $status && $is_pro) {
3053 3320 $html .= '
3054 3321 (function() {
3055 - var gyroButton = document.getElementById("gyroscope' . $id . '");
3322 + var gyroButton = document.getElementById("gyroscope' . $pano_suffix . '");
3056 3323 var gyroIcon = gyroButton ? gyroButton.querySelector("i") : null;
3057 3324 var activeColor = ' . wp_json_encode($custom_control['gyroscopeColor']) . ';
3058 3325 var permissionGranted = false;
3059 3326
@@ -3061,20 +3328,20 @@
3061 3328 return;
3062 3329 }
3063 3330
3064 3331 function updateGyroscopeState() {
3065 - gyroIcon.style.color = panoshow' . $id . '.isOrientationActive()
3332 + gyroIcon.style.color = panoshow' . $pano_suffix . '.isOrientationActive()
3066 3333 ? activeColor
3067 3334 : "red";
3068 3335 }
3069 3336
3070 3337 function startGyroscope() {
3071 - if (!panoshow' . $id . '.isOrientationSupported()) {
3338 + if (!panoshow' . $pano_suffix . '.isOrientationSupported()) {
3072 3339 updateGyroscopeState();
3073 3340 return;
3074 3341 }
3075 3342
3076 - panoshow' . $id . '.startOrientation();
3343 + panoshow' . $pano_suffix . '.startOrientation();
3077 3344 window.setTimeout(updateGyroscopeState, 0);
3078 3345 }
3079 3346
3080 3347 function requestGyroscopePermission() {
@@ -3099,14 +3366,14 @@
3099 3366
3100 3367 startGyroscope();
3101 3368 }
3102 3369
3103 - panoshow' . $id . '.on("load", updateGyroscopeState);
3104 - panoshow' . $id . '.on("scenechange", updateGyroscopeState);
3370 + panoshow' . $pano_suffix . '.on("load", updateGyroscopeState);
3371 + panoshow' . $pano_suffix . '.on("scenechange", updateGyroscopeState);
3105 3372
3106 3373 gyroButton.addEventListener("click", function() {
3107 - if (panoshow' . $id . '.isOrientationActive()) {
3108 - panoshow' . $id . '.stopOrientation();
3374 + if (panoshow' . $pano_suffix . '.isOrientationActive()) {
3375 + panoshow' . $pano_suffix . '.stopOrientation();
3109 3376 updateGyroscopeState();
3110 3377 return;
3111 3378 }
3112 3379
@@ -3121,15 +3388,15 @@
3121 3388
3122 3389 //===Explainer Script===//
3123 3390
3124 3391 if ($autoplay_bg_music == 'on') {
3125 - $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
3126 - jQuery("#explainer' . $id . '").slideToggle();
3127 - playing' . $id . ' = false;
3128 - var x' . $id . ' = document.getElementById("vrAudio' . $id . '");
3129 - jQuery("#vr-volume' . $id . '").removeClass("fas fa-volume-up");
3130 - jQuery("#vr-volume' . $id . '").addClass("fas fa-volume-mute");
3131 - 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();
3132 3399 });
3133 3400 jQuery(document).on("click",".close-explainer-video",function() {
3134 3401 jQuery(this).parent(".explainer").hide();
3135 3402 var el_src = jQuery(".vr-iframe").attr("src");
@@ -3135,11 +3402,11 @@
3135 3402 var el_src = jQuery(".vr-iframe").attr("src");
3136 3403 jQuery(".vr-iframe").attr("src", el_src);
3137 3404 });';
3138 3405 } else {
3139 - $html .= 'jQuery(document).on("click","#explainer_button_' . $id . '",function() {
3140 - jQuery("#explainer' . $id . '").slideToggle(function(){
3141 - 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 . '");
3142 3409 var $explainerVideoIframe = $explainerVideoId.find("iframe");
3143 3410 var explainerVideoIframSrc = $explainerVideoIframe.attr("src");
3144 3411 $explainerVideoIframe.attr("src", "");
3145 3412 $explainerVideoIframe.attr("src", explainerVideoIframSrc);
@@ -3155,12 +3422,16 @@
3155 3422 });';
3156 3423 }
3157 3424
3158 3425 $html .= '
3159 - jQuery(document).on("click","#pano' . $id . '",function(event) {
3426 + jQuery(document).on("click","#' . $panoid . '",function(event) {
3427 + var isCross = event.target.closest(".cross");
3160 3428 var isActiveModal = event.target.closest(".custom-ifram-wrapper");
3161 - var isForm = event.target.closest(".wpvr-hotspot-tweak-contents");
3429 + var isForm = event.target.closest(".wpvr-hotspot-tweak-contents-wrapper");
3162 3430 var isHotspot = event.target.closest(".pnlm-hotspot-base");
3431 + if(isCross != null){
3432 + return;
3433 + }
3163 3434 if(isForm != null){
3164 3435 jQuery(this).addClass("show-modal");
3165 3436 }else if(isActiveModal == null){
3166 3437 if(isHotspot == null){
@@ -3166,9 +3437,9 @@
3166 3437 if(isHotspot == null){
3167 3438 jQuery(".custom-ifram-wrapper .custom-ifram").empty();
3168 3439 jQuery(".custom-ifram-wrapper").hide();
3169 3440 jQuery(this).removeClass("show-modal");
3170 - jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide("show-modal");
3441 + jQuery(".wpvr-hotspot-tweak-contents-wrapper").hide();
3171 3442 }
3172 3443 }
3173 3444 });';
3174 3445
@@ -3176,10 +3447,10 @@
3176 3447
3177 3448 //===generic form script===//
3178 3449 if (isset($postdata["genericform"]) && $postdata["genericform"] === 'on') {
3179 3450 $html .= '
3180 - jQuery(document).on("click","#generic_form_button_' . $id . '",function() {
3181 - 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();
3182 3453 });
3183 3454
3184 3455 jQuery(document).on("click",".close-generic-form",function() {
3185 3456 jQuery(this).parent(".wpvr-generic-form").fadeOut()
@@ -3188,12 +3459,12 @@
3188 3459 }
3189 3460 //===generic from script===//
3190 3461
3191 3462 //===Floor map Script===//
3192 - $html .= 'jQuery(document).on("click","#floor_map_button_' . $id . '",function() {
3193 - 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");
3194 3465 });
3195 - jQuery(document).on("dblclick","#wpvr-floor-map' . $id . '",function(){
3466 + jQuery(document).on("dblclick","#wpvr-floor-map' . $pano_suffix . '",function(){
3196 3467 jQuery(this).addClass("fullwindow");
3197 3468 jQuery(this).parents(".pano-wrap").addClass("show-modal");
3198 3469 });
3199 3470 jQuery(document).on("click",".close-floor-map-plan",function() {
@@ -3206,24 +3477,24 @@
3206 3477 if ($vrgallery_display) {
3207 3478
3208 3479 if (!$autoload) {
3209 3480 $html .= 'jQuery(document).ready(function($){
3210 - jQuery("#sccontrols' . $id . '").hide();
3211 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3212 - jQuery("#sccontrols' . $id . '").hide();
3213 - 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();
3214 3485 });';
3215 - $html .= 'var slide' . $id . ' = "down";
3216 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3217 - if (slide' . $id . ' == "up") {
3218 - jQuery(".vrgctrl' . $id . '").empty();
3219 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3220 - slide' . $id . ' = "down";
3221 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3222 - 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(){
3223 3494 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3224 3495 if (jQuery(this).is(":visible")) {
3225 - 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({
3226 3497 "display": "flex",
3227 3498 "justify-content": "center",
3228 3499 "align-items": "center",
3229 3500 "gap": "15px"
@@ -3231,9 +3502,9 @@
3231 3502 }
3232 3503 }
3233 3504 if (jQuery(".bricks-is-frontend").length) {
3234 3505 if (jQuery(this).is(":visible")) {
3235 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3506 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3236 3507 "display": "flex",
3237 3508 "justify-content": "center",
3238 3509 "align-items": "center"
3239 3510 });
@@ -3241,16 +3512,16 @@
3241 3512 }
3242 3513 });
3243 3514 }
3244 3515 else {
3245 - jQuery(".vrgctrl' . $id . '").empty();
3246 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3247 - slide' . $id . ' = "up";
3248 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3249 - 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(){
3250 3521 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3251 3522 if (jQuery(this).is(":visible")) {
3252 - 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({
3253 3524 "display": "flex",
3254 3525 "justify-content": "center",
3255 3526 "align-items": "center",
3256 3527 "gap": "15px"
@@ -3258,9 +3529,9 @@
3258 3529 }
3259 3530 }
3260 3531 if (jQuery(".bricks-is-frontend").length) {
3261 3532 if (jQuery(this).is(":visible")) {
3262 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3533 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3263 3534 "display": "flex",
3264 3535 "justify-content": "center",
3265 3536 "align-items": "center"
3266 3537 });
@@ -3270,28 +3541,28 @@
3270 3541 }
3271 3542 });';
3272 3543 } else {
3273 3544 $html .= 'jQuery(document).ready(function($){
3274 - jQuery("#sccontrols' . $id . '").show();
3275 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3276 - 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();
3277 3548 });';
3278 - $html .= 'var slide' . $id . ' = "down";
3279 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3280 - if (slide' . $id . ' == "up") {
3281 - jQuery(".vrgctrl' . $id . '").empty();
3282 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3283 - 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";
3284 3555 } else {
3285 - jQuery(".vrgctrl' . $id . '").empty();
3286 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3287 - 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";
3288 3559 }
3289 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3290 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3560 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3561 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3291 3562 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3292 3563 if (jQuery(this).is(":visible")) {
3293 - 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({
3294 3565 "display": "flex",
3295 3566 "justify-content": "center",
3296 3567 "align-items": "center",
3297 3568 "gap": "15px"
@@ -3299,9 +3570,9 @@
3299 3570 }
3300 3571 }
3301 3572 if (jQuery(".bricks-is-frontend").length) {
3302 3573 if (jQuery(this).is(":visible")) {
3303 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3574 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3304 3575 "display": "flex",
3305 3576 "justify-content": "center",
3306 3577 "align-items": "center"
3307 3578 });
@@ -3311,29 +3582,29 @@
3311 3582 });';
3312 3583 }
3313 3584 } else {
3314 3585 $html .= 'jQuery(document).ready(function($){
3315 - jQuery("#sccontrols' . $id . '").hide();
3316 - jQuery("#pano' . $id . ' .wpvr_slider_nav").hide();
3317 - 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 . ');
3318 3589 });';
3319 - $html .= 'var slide' . $id . ' = "down";
3320 - jQuery(document).on("click","#vrgcontrols' . $id . '",function() {
3321 - if (slide' . $id . ' == "up") {
3322 - jQuery(".vrgctrl' . $id . '").empty();
3323 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_up . $sin_qout . ');
3324 - 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";
3325 3596 }
3326 3597 else {
3327 - jQuery(".vrgctrl' . $id . '").empty();
3328 - jQuery(".vrgctrl' . $id . '").html(' . $sin_qout . $angle_down . $sin_qout . ');
3329 - 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";
3330 3601 }
3331 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3332 - jQuery("#sccontrols' . $id . '").slideToggle(function(){
3602 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3603 + jQuery("#sccontrols' . $pano_suffix . '").slideToggle(function(){
3333 3604 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3334 3605 if (jQuery(this).is(":visible")) {
3335 - 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({
3336 3607 "display": "flex",
3337 3608 "justify-content": "center",
3338 3609 "align-items": "center",
3339 3610 "gap": "15px"
@@ -3341,9 +3612,9 @@
3341 3612 }
3342 3613 }
3343 3614 if (jQuery(".bricks-is-frontend").length) {
3344 3615 if (jQuery(this).is(":visible")) {
3345 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3616 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3346 3617 "display": "flex",
3347 3618 "justify-content": "center",
3348 3619 "align-items": "center"
3349 3620 });
@@ -3353,33 +3624,33 @@
3353 3624 });';
3354 3625 }
3355 3626 if (!$autoload) {
3356 3627 $html .= 'jQuery(document).ready(function(){
3357 - jQuery("#controls' . $id . '").hide();
3358 - jQuery("#zoom-in-out-controls' . $id . '").hide();
3359 - jQuery("#adcontrol' . $id . '").hide();
3360 - jQuery("#explainer_button_' . $id . '").hide();
3361 - jQuery("#generic_form_button_' . $id . '").hide();
3362 - jQuery("#floor_map_button_' . $id . '").hide();
3363 - 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();
3364 3635 jQuery("#cp-logo-controls").hide();
3365 3636 jQuery(".custom-scene-navigation").hide();
3366 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").hide();
3637 + jQuery("#' . $panoid . '").find(".pnlm-panorama-info").hide();
3367 3638 });';
3368 3639 if ($vrgallery_display) {
3369 - $html .= 'var load_once = "true";';
3370 - $html .= 'panoshow' . $id . '.on("load", function (){
3371 - if (load_once == "true") {
3372 - load_once = "false";
3373 - 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(){
3374 3645 if (jQuery(".elementor-edit-mode .elementor-widget-container").length) {
3375 3646 if (jQuery(this).is(":visible")) {
3376 - 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");
3377 3648 }
3378 3649 }
3379 3650 if (jQuery(".bricks-is-frontend").length) {
3380 3651 if (jQuery(this).is(":visible")) {
3381 - jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $id . '").css({
3652 + jQuery(".bricks-is-frontend .wpvr-cardboard .pnlm-container #sccontrols' . $pano_suffix . '").css({
3382 3653 "display": "flex",
3383 3654 "justify-content": "center",
3384 3655 "align-items": "center"
3385 3656 });
@@ -3385,23 +3656,23 @@
3385 3656 });
3386 3657 }
3387 3658 }
3388 3659 });
3389 - jQuery("#pano' . $id . ' .wpvr_slider_nav").slideToggle();
3660 + jQuery("#' . $panoid . ' .wpvr_slider_nav").slideToggle();
3390 3661 }
3391 3662 });';
3392 3663 }
3393 - $html .= 'panoshow' . $id . '.on("load", function (){
3394 - jQuery("#controls' . $id . '").show();
3395 - jQuery("#zoom-in-out-controls' . $id . '").show();
3396 - jQuery("#adcontrol' . $id . '").show();
3397 - jQuery("#explainer_button_' . $id . '").show();
3398 - jQuery("#generic_form_button_' . $id . '").show();
3399 - jQuery("#floor_map_button_' . $id . '").show();
3400 - 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();
3401 3672 jQuery("#cp-logo-controls").show();
3402 3673 jQuery(".custom-scene-navigation").show();
3403 - jQuery("#pano' . $id . '").find(".pnlm-panorama-info").show();
3674 + jQuery("#' . $panoid . '").find(".pnlm-panorama-info").show();
3404 3675 });';
3405 3676 }
3406 3677
3407 3678 //==Old code working properly==//
@@ -3415,31 +3686,29 @@
3415 3686 var pano_id;
3416 3687 var element_id = this.id;
3417 3688 element_id = element_id.split("-");
3418 3689 element_id = element_id[3];
3419 - 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");
3420 3691 var pano_id = jQuery(".awwww").attr("id");
3421 - 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");;
3422 3693 if (pano_id != undefined) {
3423 - pano_id = pano_id.split("o");
3424 - pano_id = pano_id[1];
3425 - if (pano_id == "' . $id . '") {
3426 - jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3427 - jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3428 - 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);
3429 3698 window.wpvrViewers = window.wpvrViewers || {};
3430 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
3699 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
3431 3700 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
3432 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
3701 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
3433 3702 }));
3434 - 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 ) . ')
3435 3704 setTimeout(function() {
3436 - // panoshow' . $id . '.loadScene("' . $default_scene . '");
3705 + // panoshow' . $pano_suffix . '.loadScene("' . $default_scene . '");
3437 3706 window.dispatchEvent(new Event("resize"));
3438 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3439 - 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");
3440 3709 } else {
3441 - jQuery("#controls' . $id . '").css("bottom", "5px");
3710 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
3442 3711 }
3443 3712 }, 200);
3444 3713 }
3445 3714 }
@@ -3444,30 +3713,30 @@
3444 3713 }
3445 3714 }
3446 3715 });';
3447 3716 $html .= 'jQuery(".geodir-tab-head dd, #vr-tour-tab").click(function(){
3448 - jQuery("#pano' . $id . '").children(".pnlm-render-container").remove();
3449 - jQuery("#pano' . $id . '").children(".pnlm-ui").remove();
3450 - 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);
3451 3720 window.wpvrViewers = window.wpvrViewers || {};
3452 - window.wpvrViewers[response[0]["panoid"]] = panoshow' . $id . ';
3721 + window.wpvrViewers[response[0]["panoid"]] = panoshow' . $pano_suffix . ';
3453 3722 document.dispatchEvent(new CustomEvent("wpvr:viewer-ready", {
3454 - detail: { containerId: response[0]["panoid"], viewer: panoshow' . $id . ' }
3723 + detail: { containerId: response[0]["panoid"], viewer: panoshow' . $pano_suffix . ' }
3455 3724 }));
3456 3725 setTimeout(function() {
3457 - panoshow' . $id . '.loadScene("' . $default_scene . '");
3726 + panoshow' . $pano_suffix . '.loadScene(' . wp_json_encode( (string) $default_scene ) . ');
3458 3727 window.dispatchEvent(new Event("resize"));
3459 - if (jQuery("#pano' . $id . '").children().children(".pnlm-panorama-info:visible").length > 0) {
3460 - 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");
3461 3730 }
3462 3731 else {
3463 - jQuery("#controls' . $id . '").css("bottom", "5px");
3732 + jQuery("#controls' . $pano_suffix . '").css("bottom", "5px");
3464 3733 }
3465 3734 }, 200);
3466 3735 });';
3467 3736 if (isset($previeword) && $previeword != '') {
3468 3737 $html .= '
3469 - 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 ) . ')
3470 3739 ';
3471 3740 }
3472 3741 if ($default_global_zoom != '' || $max_global_zoom != '' || $min_global_zoom != '') {
3473 3742 $html .= 'jQuery(".globalzoom").val("on").change();';
@@ -3472,12 +3741,12 @@
3472 3741 if ($default_global_zoom != '' || $max_global_zoom != '' || $min_global_zoom != '') {
3473 3742 $html .= 'jQuery(".globalzoom").val("on").change();';
3474 3743 }
3475 3744
3476 - $html .= 'jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseenter", function(){
3745 + $html .= 'jQuery("#' . $panoid . ' .pnlm-title-box").on("mouseenter", function(){
3477 3746 jQuery(this).attr("title", jQuery(this).text());
3478 3747 });
3479 - jQuery("#pano' . $id . ' .pnlm-title-box").on("mouseleave", function(){
3748 + jQuery("#' . $panoid . ' .pnlm-title-box").on("mouseleave", function(){
3480 3749 jQuery(this).removeAttr("title");
3481 3750 });';
3482 3751 $html .= '});';
3483 3752 $html .= '})(jQuery);';
@@ -3511,12 +3780,16 @@
3511 3780 private function sanitize_content_preserve_styles($content, $allow_forms = false) {
3512 3781 // Decode HTML entities first (in case content was encoded in database)
3513 3782 $content = html_entity_decode($content, ENT_QUOTES | ENT_HTML5, 'UTF-8');
3514 3783
3515 - // Escape <script> blocks to display as text instead of removing them
3516 - $content = preg_replace_callback('/<script\b[^>]*>(.*?)<\/script>/si', function($matches) {
3517 - return esc_html($matches[0]); // Convert to plain text
3518 - }, $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 + }
3519 3792
3520 3793 // Strip dangerous URL-based attributes
3521 3794 $content = preg_replace('/(href|action|formaction)\s*=\s*["\']?\s*(javascript|vbscript|data|about):/i', '$1=""', $content);
3522 3795
@@ -3559,10 +3832,16 @@
3559 3832 $css = preg_replace('/-moz-binding\s*:/i', '', $css);
3560 3833 return '<style>' . esc_html($css) . '</style>';
3561 3834 }, $content);
3562 3835
3563 - // Allow iframes from safe sources only (e.g., YouTube, Vimeo)
3836 + // Allow iframes and styles from safe sources only
3564 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 + ];
3565 3844 $allowed_tags['iframe'] = [
3566 3845 'src' => true,
3567 3846 'width' => true,
3568 3847 'height' => true,
@@ -3592,37 +3871,47 @@
3592 3871 ];
3593 3872
3594 3873 if ($allow_forms) {
3595 3874 $form_attributes = [
3596 - 'id' => true,
3597 - 'class' => true,
3598 - 'style' => true,
3599 - 'name' => true,
3600 - 'value' => true,
3601 - 'type' => true,
3602 - 'placeholder' => true,
3603 - 'action' => true,
3604 - 'method' => true,
3605 - 'target' => true,
3606 - 'enctype' => true,
3607 - 'disabled' => true,
3608 - 'readonly' => true,
3609 - 'required' => true,
3610 - 'checked' => true,
3611 - 'selected' => true,
3612 - 'multiple' => true,
3613 - 'size' => true,
3614 - 'rows' => true,
3615 - 'cols' => true,
3616 - 'maxlength' => true,
3617 - 'minlength' => true,
3618 - 'min' => true,
3619 - 'max' => true,
3620 - 'step' => true,
3621 - 'pattern' => true,
3622 - 'autocomplete'=> true,
3623 - 'autofocus' => true,
3624 - 'for' => true,
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,
3625 3914 ];
3626 3915 $allowed_tags['form'] = $form_attributes;
3627 3916 $allowed_tags['input'] = $form_attributes;
3628 3917 $allowed_tags['button'] = $form_attributes;
@@ -3632,8 +3921,18 @@
3632 3921 $allowed_tags['optgroup'] = $form_attributes;
3633 3922 $allowed_tags['label'] = $form_attributes;
3634 3923 $allowed_tags['fieldset'] = $form_attributes;
3635 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;
3636 3935 }
3637 3936
3638 3937 // Apply wp_kses() to keep only allowed tags/attributes
3639 3938 $content = wp_kses($content, $allowed_tags);
@@ -3667,7 +3966,41 @@
3667 3966 return 'https://' . $url;
3668 3967 }
3669 3968
3670 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;
3671 4004 }
3672 4005
3673 4006 }