WP VR – 360 Panorama and virtual tour creator for WordPress - Version 7.3.3

Version Description

(16-09-2021) = * Update: Checked Compatibility with WordPress 5.8.1. * Update: Checked Compatibility with PHP 8.0. * Update: Rollback Versions Updated to 7.3.2. * Fix: PHP Error Notices. * New: Full-window Virtual Tour Support. * New: Control video.js loading on specific pages.

Download this release

Release Info

Developer rextheme
Plugin Icon 128x128 WP VR – 360 Panorama and virtual tour creator for WordPress
Version 7.3.3
Comparing to
See all releases

Code changes from version 7.3.2 to 7.3.3

README.txt CHANGED
@@ -1,11 +1,11 @@
1
  === WP VR - 360 Panorama and Virtual Tour Builder For WordPress ===
2
  Contributors: rextheme, coderexco
3
- Tags: virtual tour, real estate tour, panorama, panorama viewer, virtual tour, 360 panorama, interactive tour, 360, streetview, virtual reality, 360 video, virtual, vr, interactive, 360-degree, equirectangular, google streetview, panoramas
4
  Donate link: https://rextheme.com/wp-vr-360-panorama-and-virtual-tour-creator-for-wordpress/
5
  Requires at least: 5.0
6
- Tested up to: 5.8
7
  Requires PHP: 7.0.0
8
- Stable tag: 7.3.2
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -127,6 +127,7 @@ To have more control over creating a virtual tour, learn about the [Premium vers
127
 
128
  * An unlimited number of virtual tours.
129
  * 360 Degree Video Support (Self-hosted, Youtube and Vimeo Videos).
 
130
  * Shortcode Support.
131
  * Gutenberg Block Support.
132
  * Elementor Widget Support.
@@ -148,7 +149,7 @@ To have more control over creating a virtual tour, learn about the [Premium vers
148
  * Embed Texts, Videos, Images, GIFs, and Website Links on Hotspots.
149
  * Hotspot Customization with Custom CSS.
150
  * Full-width Tour Tag.
151
- * Radius Tag for tour border-radius.
152
  * Multi-Site Support.
153
  * WP User Role Support (Editors and Authors).
154
  * Disable FontAwesome Option.
@@ -303,7 +304,7 @@ Admins & editors will have access to all virtual tours on the site to modify, up
303
 
304
  Authors can access their own tours only and modify, update, or delete them.
305
 
306
- Admins can remove the access from Authors and Editors any time.
307
 
308
  == Screenshots ==
309
  1. Upload 360 Degree Image
@@ -322,11 +323,20 @@ Admins can remove the access from Authors and Editors any time.
322
 
323
  == Changelog ==
324
 
 
 
 
 
 
 
 
 
 
325
  = 7.3.2 (04-08-2021) =
326
- *Fix: PHP Error Notices.
327
 
328
  = 7.3.1 (27-07-2021) =
329
- * Update: Checked compatibility with WordPress 5.8.
330
  * Fix: PHP Error Notice.
331
  * Tweak: Dual Action Warning for Auto-Rotation redesigned & updated.
332
  * Tweak: Invalid Pitch Value Warning redesigned & updated.
@@ -668,4 +678,4 @@ Admins can remove the access from Authors and Editors any time.
668
  * On screen control available.
669
 
670
  == Upgrade Notice ==
671
- Please do update the WP VR to the latest version. Each update makes sure your plugin is supporting all tour features.
1
  === WP VR - 360 Panorama and Virtual Tour Builder For WordPress ===
2
  Contributors: rextheme, coderexco
3
+ Tags: virtual tour, real estate tour, panorama, panorama viewer, virtual tour, 360 panorama, interactive tour, 360, Streetview, virtual reality, 360 video, virtual, vr, interactive, 360-degree, equirectangular, google streetview, panoramas
4
  Donate link: https://rextheme.com/wp-vr-360-panorama-and-virtual-tour-creator-for-wordpress/
5
  Requires at least: 5.0
6
+ Tested up to: 5.8.1
7
  Requires PHP: 7.0.0
8
+ Stable tag: 7.3.3
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
127
 
128
  * An unlimited number of virtual tours.
129
  * 360 Degree Video Support (Self-hosted, Youtube and Vimeo Videos).
130
+ * Full-window Virtual Tours.
131
  * Shortcode Support.
132
  * Gutenberg Block Support.
133
  * Elementor Widget Support.
149
  * Embed Texts, Videos, Images, GIFs, and Website Links on Hotspots.
150
  * Hotspot Customization with Custom CSS.
151
  * Full-width Tour Tag.
152
+ * Radius Tag for tour border radius.
153
  * Multi-Site Support.
154
  * WP User Role Support (Editors and Authors).
155
  * Disable FontAwesome Option.
304
 
305
  Authors can access their own tours only and modify, update, or delete them.
306
 
307
+ Admins can remove the access from Authors and Editors at any time.
308
 
309
  == Screenshots ==
310
  1. Upload 360 Degree Image
323
 
324
  == Changelog ==
325
 
326
+ = 7.3.3 (16-09-2021) =
327
+ * Update: Checked Compatibility with WordPress 5.8.1.
328
+ * Update: Checked Compatibility with PHP 8.0.
329
+ * Update: Rollback Versions Updated to 7.3.2.
330
+ * Fix: PHP Error Notices.
331
+ * New: Full-window Virtual Tour Support.
332
+ * New: Control video.js loading on specific pages.
333
+
334
+
335
  = 7.3.2 (04-08-2021) =
336
+ * Fix: PHP Error Notices.
337
 
338
  = 7.3.1 (27-07-2021) =
339
+ * Update: Checked Compatibility with WordPress 5.8.
340
  * Fix: PHP Error Notice.
341
  * Tweak: Dual Action Warning for Auto-Rotation redesigned & updated.
342
  * Tweak: Invalid Pitch Value Warning redesigned & updated.
678
  * On screen control available.
679
 
680
  == Upgrade Notice ==
681
+ Please do update the WP VR to the latest version. Each update makes sure your plugin is supporting all tour features.
admin/class-wpvr-ajax.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
  /**
4
  * The admin-specific Ajax files.
5
  *
@@ -10,283 +10,310 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
10
  * @subpackage Wpvr/admin
11
  */
12
 
13
- class Wpvr_Ajax {
 
14
 
15
  /**
16
  * Preview show ajax function
17
  */
18
- function wpvr_show_preview() {
19
- $panoid ='';
20
- $postid = sanitize_text_field($_POST['postid']);
21
- $post_type = get_post_type( $postid );
 
 
 
 
 
 
 
 
 
 
22
 
23
- $panoid = 'pano'.$postid;
 
 
 
 
 
24
 
25
- $control = sanitize_text_field($_POST['control']);
26
- if ($control == 'on') {
27
- $control = true;
28
- }
29
- else {
30
- $control = false;
31
- }
32
 
33
- $compass = sanitize_text_field($_POST['compass']);
34
- if ($compass == 'on') {
35
- $compass = true;
36
- }
37
- else {
38
- $compass = false;
39
- }
40
 
41
- $mouseZoom = sanitize_text_field($_POST['mouseZoom']);
42
- if ($mouseZoom == 'off') {
43
- $mouseZoom = false;
44
- }
45
- else {
46
- $mouseZoom = true;
47
- }
48
 
49
- $draggable = sanitize_text_field($_POST['draggable']);
50
- if ($draggable == 'off') {
51
- $draggable = false;
52
- }
53
- else {
54
- $draggable = true;
55
- }
56
 
57
- $diskeyboard = sanitize_text_field($_POST['diskeyboard']);
58
- if ($diskeyboard == 'on') {
59
- $diskeyboard = true;
60
- }
61
- else {
62
- $diskeyboard = false;
63
- }
64
 
65
- $keyboardzoom = sanitize_text_field($_POST['keyboardzoom']);
66
- if ($keyboardzoom == 'off') {
67
- $keyboardzoom = false;
68
- }
69
- else {
70
- $keyboardzoom = true;
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
- $autoload = sanitize_text_field($_POST['autoload']);
74
- if ($autoload == 'on') {
75
- $autoload = true;
76
- }
77
- else {
78
- $autoload = false;
79
- }
80
 
81
- $default_scene = '';
82
- $default_scene = sanitize_text_field($_POST['defaultscene']);
83
- $preview = '';
84
- $preview = esc_url($_POST['preview']);
85
-
86
- $rotation = '';
87
- $rotation = sanitize_text_field($_POST['rotation']);
88
-
89
- $autorotation = '';
90
- $autorotation = sanitize_text_field($_POST['autorotation']);
91
- $autorotationinactivedelay = '';
92
- $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']);
93
- $autorotationstopdelay = '';
94
- $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']);
95
-
96
- $default_global_zoom = '';
97
- $max_global_zoom = '';
98
- $min_global_zoom = '';
99
- if(isset($_POST['gzoom']) == 'on'){
100
- $default_global_zoom = $_POST['dzoom'];
101
- $max_global_zoom = $_POST['maxzoom'];
102
- $min_global_zoom = $_POST['minzoom'];
103
  }
104
- if (!empty($autorotationinactivedelay) && !empty($autorotationstopdelay)) {
105
- wp_send_json_error('<span class="pano-error-title">Dual Action Error for Auto-Rotation</span><p> You can not use both Resume Auto-rotation & Stop Auto-rotation on the same tour. You can use only one of them.</p>');
106
 
107
- die();
108
- }
109
 
110
- $scene_fade_duration = '';
111
- $scene_fade_duration = sanitize_text_field($_POST['scenefadeduration']);
112
-
113
- $panodata = $_POST['panodata'];
114
- $panolist = stripslashes($panodata);
115
- $panodata = (array)json_decode($panolist);
116
- $panolist = array();
117
- if(is_array($panodata["scene-list"])) {
118
- foreach ($panodata["scene-list"] as $scenes_data) {
119
- $temp_array = array();
120
- $temp_array = (array)$scenes_data;
121
- if ($temp_array['hotspot-list']) {
122
- $_hotspot_array = array();
123
- foreach ($temp_array['hotspot-list'] as $temp_hotspot) {
124
- $temp_hotspot = (array)$temp_hotspot;
125
- $_hotspot_array[] = $temp_hotspot;
126
- }
127
  }
128
- $temp_array['hotspot-list'] = $_hotspot_array;
129
- $panolist['scene-list'][] = $temp_array;
130
- }
131
- }
132
- $panodata = $panolist;
133
-
134
- //===Error Control and Validation===//
135
 
136
- if ($panodata["scene-list"] != "") {
137
- foreach ($panodata["scene-list"] as $scenes_val) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
- $scene_id_validate = $scenes_val["scene-id"];
 
 
 
140
 
141
-
142
- if (!empty($scene_id_validate)) {
143
- $scene_id_validated = preg_replace('/[^0-9a-zA-Z_]/',"",$scene_id_validate);
144
- if ($scene_id_validated != $scene_id_validate) {
145
- wp_send_json_error('<span class="pano-error-title">Invalid Scene ID</span> <p>Scene ID can\'t contain spaces and special characters. <br/>Please assign a unique Scene ID with letters and numbers where Scene ID is : '.$scene_id_validate.'</p>');
146
  die();
147
  }
 
148
  if (empty($scenes_val["scene-attachment-url"])) {
149
- wp_send_json_error('<span class="pano-error-title">Missing Scene Image</span><p> Please upload a 360 Degree image where Scene ID is: '.$scene_id_validate.'</p>');
150
  die();
151
  }
 
152
 
153
- if (!empty($scenes_val["scene-pitch"])) {
154
- $validate_scene_pitch = $scenes_val["scene-pitch"];
155
- $validated_scene_pitch = preg_replace('/[^0-9.-]/','',$validate_scene_pitch);
156
- if ($validated_scene_pitch != $validate_scene_pitch) {
157
- wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span><p> The Pitch Value can only contain float numbers where Scene ID: '.$scene_id_validate.'</p>');
158
- die();
159
- }
160
  }
 
161
 
162
- if (!empty($scenes_val["scene-yaw"])) {
163
- $validate_scene_yaw = $scenes_val["scene-yaw"];
164
- $validated_scene_yaw = preg_replace('/[^0-9.-]/','',$validate_scene_yaw);
165
- if ($validated_scene_yaw != $validate_scene_yaw) {
166
- wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span><p> The Yaw Value can only contain float numbers where Scene ID: '.$scene_id_validate.'</p>');
167
- die();
168
- }
169
  }
 
170
 
171
- if (!empty($scenes_val["scene-zoom"])) {
172
- $validate_default_zoom = $scenes_val["scene-zoom"];
173
- $validated_default_zoom = preg_replace('/[^0-9-]/','',$validate_default_zoom);
174
- if ($validated_default_zoom != $validate_default_zoom) {
175
- wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: '.$scene_id_validate.'</p>');
176
- die();
177
- }
178
- $default_zoom_value = (int)$scenes_val["scene-zoom"];
179
- if ($default_zoom_value > 120 || $default_zoom_value < 50) {
180
- wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: '.$scene_id_validate.'</p>');
181
 
182
- die();
183
- }
184
  }
 
185
 
186
- if (!empty($scenes_val["scene-maxzoom"])) {
187
- $validate_max_zoom = $scenes_val["scene-maxzoom"];
188
- $validated_max_zoom = preg_replace('/[^0-9-]/','',$validate_max_zoom);
189
- if ($validated_max_zoom != $validate_max_zoom) {
190
- wp_send_json_error('<span class="pano-error-title">Invalid Max-zoom Value:</span><p> You can only set Max-zoom in degree values (50-120) where Scene ID: '.$scene_id_validate.'</p>');
191
 
192
- die();
193
- }
194
- $max_zoom_value = (int)$scenes_val["scene-maxzoom"];
195
- if ($max_zoom_value > 120 ) {
196
- wp_send_json_error('<span class="pano-error-title">Max-zoom Value Limit Exceeded</span><p> You can set the Max-zoom Value up to 120 degrees.</p>');
197
- die();
198
- }
199
  }
 
 
 
 
 
 
200
 
201
- if (!empty($scenes_val["scene-minzoom"])) {
202
- $validate_min_zoom = $scenes_val["scene-minzoom"];
203
- $validated_min_zoom = preg_replace('/[^0-9-]/','',$validate_min_zoom);
204
- if ($validated_min_zoom != $validate_min_zoom) {
205
- wp_send_json_error('<span class="pano-error-title">Invalid Min-zoom Value</span><p> You can only set Min-zoom in degree values (50-120) where Scene ID: '.$scene_id_validate.'</p>');
206
- die();
207
- }
208
- $min_zoom_value = (int)$scenes_val["scene-minzoom"];
209
- if ($min_zoom_value < 50 ) {
210
- wp_send_json_error('<span class="pano-error-title">Low Min-Zoom Value</span><p> The Min-zoom value must be more than 50 in degree values where Scene ID: '.$scene_id_validate.'</p>');
211
- die();
212
- }
213
  }
214
-
215
- if ($scenes_val["hotspot-list"] != "") {
216
- foreach ($scenes_val["hotspot-list"] as $hotspot_val) {
217
 
218
- $hotspot_title_validate = $hotspot_val["hotspot-title"];
 
219
 
220
-
221
- if (!empty($hotspot_title_validate)) {
222
- $hotspot_title_validated = preg_replace('/[^0-9a-zA-Z_]/',"",$hotspot_title_validate);
223
- if ($hotspot_title_validated != $hotspot_title_validate) {
224
- wp_send_json_error('<span class="pano-error-title">Invalid Hotspot ID</span> <p>Hotspot ID can\'t contain spaces and special characters. <br/>Please assign a unique Hotspot ID with letters and numbers where Scene id: '.$scene_id_validate.' Hotspot ID is: '.$hotspot_title_validate.'</p>');
225
- die();
226
- }
227
 
228
- $hotspot_pitch_validate = $hotspot_val["hotspot-pitch"];
229
- if (!empty($hotspot_pitch_validate)) {
230
- $hotspot_pitch_validated = preg_replace('/[^0-9.-]/','',$hotspot_pitch_validate);
231
- if ($hotspot_pitch_validated != $hotspot_pitch_validate) {
232
- wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span> <p>The Pitch Value can only contain float numbers where Scene ID: '.$scene_id_validate.' Hotspot ID is: '.$hotspot_title_validate.'</p>');
233
-
234
- die();
235
- }
236
- }
237
 
238
- $hotspot_yaw_validate = $hotspot_val["hotspot-yaw"];
239
- if (!empty($hotspot_yaw_validate)) {
240
- $hotspot_yaw_validated = preg_replace('/[^0-9.-]/','',$hotspot_yaw_validate);
241
- if ($hotspot_yaw_validated != $hotspot_yaw_validate) {
242
- wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span> <p>The Yaw Value can only contain float numbers where Scene ID: '.$scene_id_validate.' Hotspot ID is: '.$hotspot_title_validate.'</p>');
 
243
 
244
- die();
245
- }
 
 
 
 
 
246
  }
 
247
 
248
- if(is_plugin_active( 'wpvr-pro/wpvr-pro.php' )){
249
- $status = get_option( 'wpvr_edd_license_status' );
250
- if( $status !== false && $status == 'valid' ) {
251
- if ($hotspot_val["hotspot-customclass-pro"] != 'none' && !empty($hotspot_val["hotspot-customclass"])) {
252
- wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not use both Custom Icon and Custom Icon Class for a hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
253
- die();
254
- }
255
- }
256
  }
257
- $hotspot_type_validate = $hotspot_val["hotspot-type"];
258
- $hotspot_url_validate = $hotspot_val["hotspot-url"];
259
- if (!empty($hotspot_url_validate)) {
260
- $hotspot_url_validated = esc_url($hotspot_url_validate);
261
- if ($hotspot_url_validated != $hotspot_url_validate) {
262
- wp_send_json_error('<p><span>Warning:</span> Hotspot Url is invalid where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
 
263
  die();
264
  }
265
  }
266
- $hotspot_content_validate = $hotspot_val["hotspot-content"];
 
 
 
 
 
 
 
 
 
 
267
 
268
- $hotspot_scene_validate = $hotspot_val["hotspot-scene"];
269
 
270
- if ($hotspot_type_validate == "info") {
271
- if (!empty($hotspot_scene_validate)) {
272
- wp_send_json_error('<p><span>Warning:</span> Don\'t add Target Scene ID on info type hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
273
- die();
274
- }
275
- if (!empty($hotspot_url_validate) && !empty($hotspot_content_validate)) {
276
- wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not set both On Click Content and URL on a hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
277
- die();
278
- }
279
  }
 
280
 
281
- if ($hotspot_type_validate == "scene") {
282
- if (empty($hotspot_scene_validate)) {
283
- wp_send_json_error('<span class="pano-error-title">Target Scene Missing</span> <p>Assign a Target Scene to the Scene-type Hotspot where Scene ID: '.$scene_id_validate.' and Hotspot ID : '.$hotspot_title_validate.'</p>');
284
- die();
285
- }
286
- if (!empty($hotspot_url_validate) || !empty($hotspot_content_validate)) {
287
- wp_send_json_error('<p><span>Warning:</span> Don\'t add Url or On click content on scene type hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
288
- die();
289
- }
290
  }
291
  }
292
  }
@@ -294,911 +321,921 @@ class Wpvr_Ajax {
294
  }
295
  }
296
  }
297
- //===Error Control and Validation===//
298
- foreach ($panodata["scene-list"] as $panoscenes) {
299
- if (empty($panoscenes['scene-id']) && !empty($panoscenes['scene-attachment-url'])) {
300
- wp_send_json_error('<span class="pano-error-title">Missing Scene ID</span> <p>Please assign a unique Scene ID to your uploaded scene.</p>');
301
- die();
302
- }
303
  }
 
304
 
305
- $allsceneids = array();
306
 
307
- foreach ($panodata["scene-list"] as $panoscenes) {
308
- if (!empty($panoscenes['scene-id'])) {
309
- array_push($allsceneids, $panoscenes['scene-id']);
310
- }
311
  }
 
312
 
313
- foreach ($panodata["scene-list"] as $panoscenes) {
314
 
315
- if ($panoscenes['dscene'] == 'on') {
316
- $default_scene = $panoscenes['scene-id'];
317
- }
318
  }
319
- if (empty($default_scene)) {
320
- if ($allsceneids) {
321
- $default_scene = $allsceneids[0];
322
- }
323
- else {
324
- wp_send_json_error('<p><span>Warning:</span> No default scene selected and no scene id found to set as default. You need at least one scene to publish a tour </p>');
325
- die();
326
- }
327
  }
 
328
 
329
- $allsceneids_count = array_count_values($allsceneids);
330
- foreach ($allsceneids_count as $key => $value) {
331
- if ($value > 1) {
332
- wp_send_json_error('<span class="pano-error-title">Duplicate Scene ID</span> <p>You\'ve assigned a duplicate Scene ID. <br/>Please assign unique Scene IDs to each scene. </p>');
333
- die();
334
- }
335
  }
 
336
 
337
- foreach ($panodata["scene-list"] as $panoscenes) {
338
- if (!empty($panoscenes['scene-id'])) {
339
- $allhotspot = array();
340
- foreach ($panoscenes["hotspot-list"] as $hotspot_val) {
341
-
342
- if (!empty($hotspot_val["hotspot-title"])) {
343
- array_push($allhotspot, $hotspot_val["hotspot-title"]);
344
- }
345
- }
346
- $allhotspotcount = array_count_values($allhotspot);
347
- foreach ($allhotspotcount as $key => $value) {
348
- if ($value > 1) {
349
- wp_send_json_error('<span class="pano-error-title">Duplicate Hotspot ID</span> <p>You\'ve assigned a duplicate Hotspot ID. <br/>Please assign unique Hotspot IDs to each Hotspot.</p>');
350
- die();
351
- }
352
- }
353
  }
354
  }
 
355
 
356
- $default_data = array();
357
- if($_POST['gzoom'] == 'on'){
358
- $default_data = array("firstScene"=>$default_scene,"sceneFadeDuration"=>$scene_fade_duration,"hfov"=>$default_global_zoom,"maxHfov"=>$max_global_zoom,"minHfov"=>$min_global_zoom);
359
- }else{
360
- $default_data = array("firstScene"=>$default_scene,"sceneFadeDuration"=>$scene_fade_duration);
361
- }
362
- $scene_data = array();
363
- foreach ($panodata["scene-list"] as $panoscenes) {
364
- if (!empty($panoscenes['scene-id'])) {
365
- $scene_ititle = '';
366
- $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]);
367
- $scene_author = '';
368
- $scene_author = sanitize_text_field($panoscenes["scene-author"]);
369
 
370
- $scene_vaov = 180;
371
- $scene_vaov = (float)$panoscenes["scene-vaov"];
372
 
373
- $scene_haov = 360;
374
- $scene_haov = (float)$panoscenes["scene-haov"];
375
 
376
- $scene_vertical_offset = 0;
377
- $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
378
 
379
- $default_scene_pitch = null;
380
- $default_scene_pitch = (float)$panoscenes["scene-pitch"];
381
 
382
- $default_scene_yaw = null;
383
- $default_scene_yaw = (float)$panoscenes["scene-yaw"];
384
 
385
- $scene_max_pitch = '';
386
- $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
387
 
388
- $scene_min_pitch = '';
389
- $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
390
 
391
- $scene_max_yaw = '';
392
- $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
393
 
394
- $scene_min_yaw = '';
395
- $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
396
 
 
 
 
 
 
397
  $default_zoom = 100;
398
- $default_zoom = $panoscenes["scene-zoom"];
399
- if (!empty($default_zoom)) {
400
- $default_zoom = (int)$panoscenes["scene-zoom"];
401
- }
402
- else {
403
- $default_zoom = 100;
404
- }
405
 
 
 
 
 
 
406
  $max_zoom = 120;
407
- $max_zoom = $panoscenes["scene-maxzoom"];
408
- if (!empty($max_zoom)) {
409
- $max_zoom = (int)$panoscenes["scene-maxzoom"];
410
- }
411
- else {
412
- $max_zoom = 120;
413
- }
414
 
 
 
 
 
 
415
  $min_zoom = 50;
416
- $min_zoom = $panoscenes["scene-minzoom"];
417
- if (!empty($min_zoom)) {
418
- $min_zoom = (int)$panoscenes["scene-minzoom"];
419
- }
420
- else {
421
- $min_zoom = 50;
422
- }
423
 
424
- $hotspot_datas = $panoscenes["hotspot-list"];
425
 
426
- $hotspots = array();
427
- foreach ($hotspot_datas as $hotspot_data) {
428
 
429
- if (!empty($hotspot_data["hotspot-title"])) {
430
 
431
- $hotspot_type = $hotspot_data["hotspot-type"] !== 'scene' ? 'info' : $hotspot_data["hotspot-type"];
432
- $hotspot_content = '';
433
 
434
- ob_start();
435
- do_action('wpvr_hotspot_content_admin', $hotspot_data);
436
- $hotspot_content = ob_get_clean();
437
 
438
 
439
- if(!$hotspot_content) $hotspot_content = $hotspot_data["hotspot-content"];
440
 
441
-
442
- $hotspot_info = array(
443
- "text"=>$hotspot_data["hotspot-title"],
444
- "pitch"=>$hotspot_data["hotspot-pitch"],
445
- "yaw"=>$hotspot_data["hotspot-yaw"],
446
- "type"=>$hotspot_type,
447
- "URL"=>$hotspot_data["hotspot-url"],
448
- "clickHandlerArgs"=>$hotspot_content,
449
- "createTooltipArgs"=>$hotspot_data["hotspot-hover"],
450
- "sceneId"=>$hotspot_data["hotspot-scene"],
451
- "targetPitch"=>(float)$hotspot_data["hotspot-scene-pitch"],
452
- "targetYaw"=>(float)$hotspot_data["hotspot-scene-yaw"],
453
- 'hotspot_type' => $hotspot_data['hotspot-type']
454
- );
455
 
456
- array_push($hotspots, $hotspot_info);
457
- if (empty($hotspot_data["hotspot-scene"])) {
458
- unset($hotspot_info['targetPitch']);
459
- unset($hotspot_info['targetYaw']);
460
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  }
462
  }
 
463
 
464
- $scene_info = array();
465
- $scene_info = array("type"=>$panoscenes["scene-type"],"panorama"=>$panoscenes["scene-attachment-url"],"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 ,"vaov"=>$scene_vaov, "haov"=>$scene_haov, "vOffset"=>$scene_vertical_offset, "hotSpots"=>$hotspots);
 
 
 
 
 
 
 
 
 
466
 
467
- if ($panoscenes["ptyscene"] == "off") {
468
- unset($scene_info['pitch']);
469
- unset($scene_info['yaw']);
470
- }
471
 
472
- if (empty($panoscenes["scene-ititle"])) {
473
- unset($scene_info['title']);
474
- }
475
- if (empty($panoscenes["scene-author"])) {
476
- unset($scene_info['author']);
477
- }
478
 
479
- if (empty($scene_vaov)) {
480
- unset($scene_info['vaov']);
481
- }
 
482
 
483
- if (empty($scene_haov)) {
484
- unset($scene_info['haov']);
485
- }
 
 
 
486
 
487
- if (empty($scene_vertical_offset)) {
488
- unset($scene_info['vOffset']);
489
- }
490
 
491
- if ($panoscenes["cvgscene"] == "off") {
492
- unset($scene_info['maxPitch']);
493
- unset($scene_info['minPitch']);
494
- }
495
- if (empty($panoscenes["scene-maxpitch"])) {
496
- unset($scene_info['maxPitch']);
497
- }
498
 
499
- if (empty($panoscenes["scene-minpitch"])) {
500
- unset($scene_info['minPitch']);
501
- }
502
 
503
- if ($panoscenes["chgscene"] == "off") {
504
- unset($scene_info['maxYaw']);
505
- unset($scene_info['minYaw']);
 
 
 
 
506
 
507
- }
508
- if (empty($panoscenes["scene-maxyaw"])) {
509
- unset($scene_info['maxYaw']);
510
- }
511
 
512
- if (empty($panoscenes["scene-minyaw"])) {
513
- unset($scene_info['minYaw']);
514
- }
 
 
 
 
515
 
516
- // if ($panoscenes["czscene"] == "off") {
517
- // unset($scene_info['hfov']);
518
- // unset($scene_info['maxHfov']);
519
- // unset($scene_info['minHfov']);
520
- // }
521
 
522
- $scene_array = array();
523
- $scene_array = array(
524
- $panoscenes["scene-id"]=>$scene_info
525
- );
526
- $scene_data[$panoscenes["scene-id"]] = $scene_info;
527
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
 
 
 
 
 
529
  }
530
-
531
- $pano_id_array = array();
532
- $pano_id_array = array("panoid"=>$panoid);
533
- $pano_response = array();
534
- $pano_response = array("autoLoad"=>$autoload,"defaultZoom"=>$default_global_zoom,"minZoom"=>$min_global_zoom,"maxZoom"=>$max_global_zoom,"showControls"=>$control,"compass"=>$compass,"mouseZoom"=>$mouseZoom,"draggable"=>$draggable,"disableKeyboardCtrl"=>$diskeyboard,'keyboardZoom'=>$keyboardzoom,"preview"=>$preview,"autoRotate"=>$autorotation,"autoRotateInactivityDelay"=>$autorotationinactivedelay,"autoRotateStopDelay"=>$autorotationstopdelay,"default"=>$default_data,"scenes"=>$scene_data);
535
-
536
- if ($rotation == 'off') {
537
- unset($pano_response['autoRotate']);
538
- unset($pano_response['autoRotateInactivityDelay']);
539
- unset($pano_response['autoRotateStopDelay']);
 
 
 
 
 
540
  }
541
- if (empty($autorotation)) {
542
- unset($pano_response['autoRotate']);
543
- unset($pano_response['autoRotateInactivityDelay']);
544
- unset($pano_response['autoRotateStopDelay']);
 
545
  }
546
- if (empty($autorotationinactivedelay)) {
547
- unset($pano_response['autoRotateInactivityDelay']);
 
 
 
 
 
 
 
 
 
548
  }
549
- if (empty($autorotationstopdelay)) {
550
- unset($pano_response['autoRotateStopDelay']);
 
 
 
 
551
  }
552
 
553
- // if($_POST['gzoom'] == 'off' ){
554
- // unset($pano_response['defaultZoom']);
555
- // unset($pano_response['minZoom']);
556
- // unset($pano_response['maxZoom']);
557
- // }
558
- $response = array();
559
- $response = array($pano_id_array,$pano_response);
560
- wp_send_json_success( $response );
 
 
 
 
561
  }
562
 
563
- /**
564
- * Video Preview show ajax function
565
- */
566
- function wpvrvideo_preview() {
567
- $panoid ='';
568
- $postid = sanitize_text_field($_POST['postid']);
569
- $panoid = 'pano'.$postid;
570
- $randid = rand(1000, 1000000);
571
- $vidid = 'vid'.$randid;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  $videourl = esc_url_raw($_POST['videourl']);
573
  $autoplay = sanitize_text_field($_POST['autoplay']);
 
574
  $loop = sanitize_text_field($_POST['loop']);
575
-
576
  $vidtype = '';
 
577
  if (strpos($videourl, 'youtube') > 0) {
578
  $vidtype = 'youtube';
579
  $explodeid = '';
580
- $explodeid = explode("=",$videourl);
 
581
 
582
  if ($autoplay == 'on') {
583
  $autoplay = '&autoplay=1';
584
- $muted = '&mute=1';
585
- }
586
- else {
587
  $autoplay = '';
588
- $muted = '';
589
  }
590
 
591
  if ($loop == 'on') {
592
  $loop = '&loop=1';
593
- }
594
- else {
595
  $loop = '';
596
  }
597
 
598
- $foundid = '';
599
- $foundid = $explodeid[1].'?'.$autoplay.$loop;
600
  $html = '';
601
- $html .= '
602
- <iframe src="https://www.youtube.com/embed/'.$explodeid[1].'?rel=0&modestbranding=1'.$loop.'&autohide=1'.$muted.'&showinfo=0&controls=1'.$autoplay.'" width="600" height="400" frameborder="0" allowfullscreen></iframe>
603
- ';
604
-
605
  } elseif (strpos($videourl, 'youtu.be') > 0) {
606
  $vidtype = 'youtube';
607
  $explodeid = '';
608
- $explodeid = explode("/",$videourl);
 
609
 
610
  if ($autoplay == 'on') {
611
  $autoplay = '&autoplay=1';
612
- }
613
- else {
614
  $autoplay = '';
615
  }
616
 
617
  if ($loop == 'on') {
618
  $loop = '&loop=1';
619
- }
620
- else {
621
  $loop = '';
622
  }
623
 
624
- $foundid = '';
625
- $foundid = $explodeid[3].'?'.$autoplay.$loop;
626
  $html = '';
627
- $html .= '<iframe width="600" height="400" src="https://www.youtube.com/embed/'.$foundid.'" frameborder="0" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
628
-
629
- }
630
- elseif (strpos($videourl, 'vimeo') > 0) {
631
  $vidtype = 'vimeo';
632
  $explodeid = '';
633
- $explodeid = explode("/",$videourl);
634
  $foundid = '';
635
 
636
  if ($autoplay == 'on') {
637
  $autoplay = '&autoplay=1&muted=1';
638
- }
639
- else {
640
  $autoplay = '';
641
  }
642
 
643
  if ($loop == 'on') {
644
  $loop = '&loop=1';
645
- }
646
- else {
647
  $loop = '';
648
  }
649
 
650
- $foundid = $explodeid[3].'?'.$autoplay.$loop;
651
  $html = '';
652
- $html .= '<iframe src="https://player.vimeo.com/video/'.$foundid.'" width="600" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
653
-
654
  } else {
655
  $vidtype = 'selfhost';
 
 
 
656
 
657
  if ($autoplay == 'on') {
658
- $autoplay = 'autoplay';
659
- }
660
- else {
661
  $autoplay = '';
662
  }
663
 
664
-
665
  if ($loop == 'on') {
666
  $loop = 'loop';
667
- }
668
- else {
669
  $loop = '';
670
  }
671
 
672
  $html = '';
673
- $html .= '<video id="'.$vidid.'" class="video-js vjs-default-skin vjs-big-play-centered" '.$autoplay.' '.$loop.' controls preload="none" style="width:100%;height:400px;" poster="" >';
674
- $html .= '<source src="'.$videourl.'" type="video/mp4"/>';
675
- $html .= '<p class="vjs-no-js">';
676
- $html .= 'To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com html5-video-support/" target="_blank">supports HTML5 video</a>';
677
- $html .= '</p>';
678
  $html .= '</video>';
679
  }
680
 
681
- $response = array();
682
- $response = array(__( "panoid" )=>$panoid,__( "panodata" )=>$html,__( "vidid" )=>$vidid,__( "vidtype" )=>$vidtype);
683
- wp_send_json_success( $response );
684
- }
685
 
686
- function wpvr_save_data() {
687
 
688
- $panoid ='';
689
- $postid = sanitize_text_field($_POST['postid']);
690
- $prevtext = sanitize_text_field($_POST['previewtext']);
691
- // error_log(print_r($_POST['customColor'],1));
692
- $previewtext = '';
693
- if(strlen($prevtext) <= 50 ){
694
- $previewtext = $prevtext;
695
- }
696
- $post_type = get_post_type( $postid );
697
- if ($post_type != 'wpvr_item') {
698
- die();
699
- }
700
- $panoid = 'pano'.$postid;
701
-
702
- $default_global_zoom = '';
703
- $max_global_zoom = '';
704
- $min_global_zoom = '';
705
- if(isset($_POST['gzoom']) == 'on'){
706
- $default_global_zoom = $_POST['dzoom'];
707
- $max_global_zoom = $_POST['maxzoom'];
708
- $min_global_zoom = $_POST['minzoom'];
709
- }
710
-
711
- if(isset($_POST['streetview'])){
712
- $streetview = $_POST['streetview'];
713
- if ($streetview == 'on') {
714
- $streetviewurl = esc_url_raw($_POST['streetviewurl']);
715
- if ($streetviewurl) {
716
- $html .= '<iframe src="'.$streetviewurl.'" width="600" height="400" frameborder="0" style="border:0;" allowfullscreen=""></iframe>';
717
- }
718
- $streetviewarray = array();
719
- $streetviewarray = array(__( "panoid" )=>$panoid,__( "streetviewdata" )=>$html,__( "streetviewurl" )=>$streetviewurl,__( "streetview" )=>$streetview);
720
- update_post_meta( $postid, 'panodata', $streetviewarray );
721
- die();
722
- }
723
-
724
- }
725
-
726
-
727
- $pnovideo = $_POST['panovideo'];
728
- if ($pnovideo == "on") {
729
-
730
- $vidid = 'vid'.$postid;
731
- $videourl = esc_url_raw($_POST['videourl']);
732
- $autoplay = sanitize_text_field($_POST['autoplay']);
733
- $vidautoplay = sanitize_text_field($_POST['autoplay']);
734
- $loop = sanitize_text_field($_POST['loop']);
735
- $vidloop = sanitize_text_field($_POST['loop']);
736
- $vidtype = '';
737
-
738
- if (strpos($videourl, 'youtube') > 0) {
739
- $vidtype = 'youtube';
740
- $explodeid = '';
741
- $explodeid = explode("=",$videourl);
742
- $foundid = '';
743
-
744
- if ($autoplay == 'on') {
745
- $autoplay = '&autoplay=1';
746
- }
747
- else {
748
- $autoplay = '';
749
- }
750
-
751
- if ($loop == 'on') {
752
- $loop = '&loop=1';
753
- }
754
- else {
755
- $loop = '';
756
- }
757
-
758
- $foundid = $explodeid[1].'?'.$autoplay.$loop;
759
- $html = '';
760
- $html .= '<iframe width="600" height="400" src="https://www.youtube.com/embed/'.$foundid.'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
761
-
762
- }
763
- elseif (strpos($videourl, 'youtu.be') > 0) {
764
- $vidtype = 'youtube';
765
- $explodeid = '';
766
- $explodeid = explode("/",$videourl);
767
- $foundid = '';
768
-
769
- if ($autoplay == 'on') {
770
- $autoplay = '&autoplay=1';
771
- }
772
- else {
773
- $autoplay = '';
774
- }
775
-
776
- if ($loop == 'on') {
777
- $loop = '&loop=1';
778
- }
779
- else {
780
- $loop = '';
781
- }
782
-
783
- $foundid = $explodeid[3].'?'.$autoplay.$loop;
784
- $html = '';
785
- $html .= '<iframe width="600" height="400" src="https://www.youtube.com/embed/'.$foundid.'" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>';
786
 
787
- }
788
 
789
- elseif (strpos($videourl, 'vimeo') > 0) {
790
- $vidtype = 'vimeo';
791
- $explodeid = '';
792
- $explodeid = explode("/",$videourl);
793
- $foundid = '';
 
794
 
795
- if ($autoplay == 'on') {
796
- $autoplay = '&autoplay=1&muted=1';
797
- }
798
- else {
799
- $autoplay = '';
800
- }
801
 
802
- if ($loop == 'on') {
803
- $loop = '&loop=1';
804
- }
805
- else {
806
- $loop = '';
807
- }
808
 
809
- $foundid = $explodeid[3].'?'.$autoplay.$loop;
810
- $html = '';
811
- $html .= '<iframe src="https://player.vimeo.com/video/'.$foundid.'" width="600" height="400" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
 
 
 
812
 
813
- }
814
- else {
815
- $vidtype = 'selfhost';
816
- $vidautoplay = '';
817
- // $vidautoplay = sanitize_text_field($_POST['vidautoplay']);
818
- $vidautoplay = sanitize_text_field($_POST['autoplay']);
819
-
820
- if ($autoplay == 'on') {
821
- $autoplay = 'autoplay muted';
822
- }
823
- else {
824
- $autoplay = '';
825
- }
826
-
827
- if ($loop == 'on') {
828
- $loop = 'loop';
829
- }
830
- else {
831
- $loop = '';
832
- }
833
 
834
- $html = '';
835
- $html .= '<video id="'.$vidid.'" class="video-js vjs-default-skin vjs-big-play-centered" '.$autoplay.' '.$loop.' controls preload="auto" style="width:100%;height:100%;" poster="" >';
836
- $html .= '<source src="'.$videourl.'" type="video/mp4"/>';
837
- $html .= '<p class="vjs-no-js">';
838
- $html .= 'To view this video please enable JavaScript, and consider upgrading to a web browser that <a href="http://videojs.com html5-video-support/" target="_blank">supports HTML5 video</a>';
839
- $html .= '</p>';
840
- $html .= '</video>';
841
- }
842
 
 
 
 
 
843
 
 
844
 
845
- $videoarray = array();
846
- $videoarray = array(__( "panoid" )=>$panoid,__( "panoviddata" )=>$html,__( "vidid" )=>$vidid,__( "vidurl" )=>$videourl,__( "autoplay" )=>$autoplay,__( "loop" )=>$vidloop,__( "vidtype" )=>$vidtype);
847
- update_post_meta( $postid, 'panodata', $videoarray );
848
  die();
849
  }
 
 
 
 
 
 
 
 
 
 
850
 
 
 
 
 
 
 
851
 
852
- $control = sanitize_text_field($_POST['control']);
853
- if ($control == 'on') {
854
- $control = true;
855
- }
856
- else {
857
- $control = false;
858
- }
859
 
860
- //===Custom Control===//
861
- $custom_control = $_POST['customcontrol'];
 
 
 
 
862
 
863
- //===Custom Control End===//
 
 
 
 
 
864
 
865
- $vrgallery = sanitize_text_field($_POST['vrgallery']);
866
- if ($vrgallery == 'on') {
867
- $vrgallery = true;
868
- }
869
- else {
870
- $vrgallery = false;
871
- }
872
 
873
- $vrgallery_title = sanitize_text_field($_POST['vrgallery_title']);
874
- if ($vrgallery_title == 'on') {
875
- $vrgallery_title = true;
876
- }
877
- else {
878
- $vrgallery_title = false;
879
- }
880
 
881
- $vrgallery_display = sanitize_text_field($_POST['vrgallery_display']);
882
- if ($vrgallery_display == 'on') {
883
- $vrgallery_display = true;
884
- }
885
- else {
886
- $vrgallery_display = false;
887
- }
888
 
889
- $gyro = false;
890
- if( isset($_POST['gyro']) ){
891
- $gyro = sanitize_text_field($_POST['gyro']);
892
- }
893
-
894
- $deviceorientationcontrol = sanitize_text_field($_POST['deviceorientationcontrol']);
895
 
896
- if ($gyro == 'on') {
897
- if (!is_ssl()) {
898
- wp_send_json_error('<p><span>Warning:</span> Please add SSL to enable Gyroscope for WP VR. </p>');
899
- die();
900
- }
901
- $gyro = true;
902
- if ($deviceorientationcontrol == 'on') {
903
- $deviceorientationcontrol = true;
904
- }
905
- else {
906
- $deviceorientationcontrol = false;
907
- }
908
- }
909
- else {
910
- $gyro = false;
911
- $deviceorientationcontrol = false;
912
- }
913
 
914
- $compass = sanitize_text_field($_POST['compass']);
915
- if ($compass == 'on') {
916
- $compass = true;
917
- }
918
- else {
919
- $compass = false;
920
- }
921
 
922
- $mouseZoom = sanitize_text_field($_POST['mouseZoom']);
923
- if ($mouseZoom == 'off') {
924
- $mouseZoom = false;
925
- }
926
- else {
927
- $mouseZoom = true;
928
- }
929
 
930
- $draggable = sanitize_text_field($_POST['draggable']);
931
- if ($draggable == 'off') {
932
- $draggable = false;
933
- }
934
- else {
935
- $draggable = true;
936
- }
937
 
938
- $diskeyboard = sanitize_text_field($_POST['diskeyboard']);
939
- if ($diskeyboard == 'on') {
940
- $diskeyboard = true;
941
- }
942
- else {
943
- $diskeyboard = false;
944
- }
945
 
946
- $keyboardzoom = sanitize_text_field($_POST['keyboardzoom']);
 
 
 
947
 
948
- if ($keyboardzoom == 'off') {
949
- $keyboardzoom = false;
950
- }
951
- else {
952
- $keyboardzoom = true;
953
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
954
 
955
- $autoload = sanitize_text_field($_POST['autoload']);
956
- if ($autoload == 'on') {
957
- $autoload = true;
958
- }
959
- else {
960
- $autoload = false;
961
  }
 
 
962
 
963
- $default_scene = '';
964
-
965
- $preview = '';
966
- $preview = esc_url($_POST['preview']);
967
 
968
- $rotation = '';
969
- $rotation = sanitize_text_field($_POST['rotation']);
970
 
971
- $autorotation = '';
972
- $autorotation = sanitize_text_field($_POST['autorotation']);
973
- $autorotationinactivedelay = '';
974
- $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']);
975
- $autorotationstopdelay = '';
976
- $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']);
 
977
 
 
 
 
 
 
978
 
 
 
 
 
979
 
980
- if (!empty($autorotationinactivedelay) && !empty($autorotationstopdelay)) {
981
- wp_send_json_error('<span class="pano-error-title">Dual Action Error for Auto-Rotation</span><p> You can not use both Resume Auto-rotation & Stop Auto-rotation on the same tour. You can use only one of them.</p>');
982
- die();
983
- }
984
 
985
- //===Company Logo===//
986
- $cpLogoSwitch = 'off';
987
- $cpLogoSwitch = $_POST['cpLogoSwitch'];
988
- $cpLogoImg = '';
989
- $cpLogoImg = $_POST['cpLogoImg'];
990
- $cpLogoContent = '';
991
- $cpLogoContent = sanitize_text_field($_POST['cpLogoContent']);
992
- //===Company Logo===//
993
-
994
-
995
- // update_post_meta($postid,'hotspot_colors',$_POST['customColor']);
996
-
997
- $scene_fade_duration = '';
998
- $scene_fade_duration = $_POST['scenefadeduration'];
999
-
1000
- $panodata = $_POST['panodata'];
1001
- $panolist = stripslashes($panodata);
1002
- $panodata = (array)json_decode($panolist);
1003
- $panolist = array();
1004
- if(is_array($panodata["scene-list"])) {
1005
- foreach ($panodata["scene-list"] as $scenes_data) {
1006
- $temp_array = array();
1007
- $temp_array = (array)$scenes_data;
1008
- // $scene_id_ = $temp_array["scene-id"];
1009
-
1010
- if ($temp_array['hotspot-list']) {
1011
- $_hotspot_array = array();
1012
- foreach ($temp_array['hotspot-list'] as $temp_hotspot) {
1013
-
1014
- $temp_hotspot = (array)$temp_hotspot;
1015
- $_hotspot_array[] = $temp_hotspot;
1016
  }
1017
- }
1018
-
1019
- $temp_array['hotspot-list'] = $_hotspot_array;
1020
- $panolist['scene-list'][] = $temp_array;
1021
- }
1022
- }
1023
- $panodata = $panolist;
1024
-
1025
- //===Error Control and Validation===//
1026
-
1027
- if ($panodata["scene-list"] != "") {
1028
- foreach ($panodata["scene-list"] as $scenes_val) {
1029
-
1030
- $scene_id_validate = $scenes_val["scene-id"];
1031
- if (!empty($scene_id_validate)) {
1032
- $scene_id_validated = preg_replace('/[^0-9a-zA-Z_]/',"",$scene_id_validate);
1033
- if ($scene_id_validated != $scene_id_validate) {
1034
- wp_send_json_error('<span class="pano-error-title">Invalid Scene ID</span> <p>Scene ID can\'t contain spaces and special characters. <br/>Please assign a unique Scene ID with letters and numbers where Scene ID is : '.$scene_id_validate.'</p>');
1035
  die();
1036
  }
1037
 
 
 
 
 
 
1038
  if (empty($scenes_val["scene-attachment-url"])) {
1039
- wp_send_json_error('<span class="pano-error-title">Missing Scene Image</span><p> Please upload a 360 Degree image where Scene ID is: '.$scene_id_validate.'</p>');
1040
  die();
1041
  }
 
1042
 
1043
- if (!empty($scenes_val["scene-pitch"])) {
1044
- $validate_scene_pitch = $scenes_val["scene-pitch"];
1045
- $validated_scene_pitch = preg_replace('/[^0-9.-]/','',$validate_scene_pitch);
1046
- if ($validated_scene_pitch != $validate_scene_pitch) {
1047
- wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span><p> The Pitch Value can only contain float numbers where Scene ID: '.$scene_id_validate.'</p>');
1048
- die();
1049
- }
1050
  }
 
1051
 
1052
- if (!empty($scenes_val["scene-yaw"])) {
1053
- $validate_scene_yaw = $scenes_val["scene-yaw"];
1054
- $validated_scene_yaw = preg_replace('/[^0-9.-]/','',$validate_scene_yaw);
1055
- if ($validated_scene_yaw != $validate_scene_yaw) {
1056
- wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span><p> The Yaw Value can only contain float numbers where Scene ID: '.$scene_id_validate.'</p>');
1057
- die();
1058
- }
1059
  }
 
1060
 
1061
- if (!empty($scenes_val["scene-zoom"])) {
1062
- $validate_default_zoom = $scenes_val["scene-zoom"];
1063
- $validated_default_zoom = preg_replace('/[^0-9-]/','',$validate_default_zoom);
1064
- if ($validated_default_zoom != $validate_default_zoom) {
1065
- wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: '.$scene_id_validate.'</p>');
1066
 
1067
- die();
1068
- }
1069
- $default_zoom_value = (int)$scenes_val["scene-zoom"];
1070
- if ($default_zoom_value > 120 || $default_zoom_value < 50) {
1071
- wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: '.$scene_id_validate.'</p>');
1072
 
1073
- die();
1074
- }
1075
  }
 
1076
 
1077
- if (!empty($scenes_val["scene-maxzoom"])) {
1078
- $validate_max_zoom = $scenes_val["scene-maxzoom"];
1079
- $validated_max_zoom = preg_replace('/[^0-9-]/','',$validate_max_zoom);
1080
- if ($validated_max_zoom != $validate_max_zoom) {
1081
- wp_send_json_error('<span class="pano-error-title">Invalid Max-zoom Value:</span><p> You can only set Max-zoom in degree values (50-120) where Scene ID: '.$scene_id_validate.'</p>');
1082
 
1083
- die();
1084
- }
1085
- $max_zoom_value = (int)$scenes_val["scene-maxzoom"];
1086
- if ($max_zoom_value > 120 ) {
1087
- wp_send_json_error('<span class="pano-error-title">Max-zoom Value Limit Exceeded</span><p> You can set the Max-zoom Value up to 120 degrees.</p>');
1088
 
1089
- die();
1090
- }
1091
  }
 
1092
 
1093
- if (!empty($scenes_val["scene-minzoom"])) {
1094
- $validate_min_zoom = $scenes_val["scene-minzoom"];
1095
- $validated_min_zoom = preg_replace('/[^0-9-]/','',$validate_min_zoom);
1096
- if ($validated_min_zoom != $validate_min_zoom) {
1097
- wp_send_json_error('<span class="pano-error-title">Invalid Min-zoom Value</span><p> You can only set Min-zoom in degree values (50-120) where Scene ID: '.$scene_id_validate.'</p>');
1098
- die();
1099
- }
1100
- $min_zoom_value = (int)$scenes_val["scene-minzoom"];
1101
- if ($min_zoom_value < 50 ) {
1102
- wp_send_json_error('<span class="pano-error-title">Low Min-Zoom Value</span><p> The Min-zoom value must be more than 50 in degree values where Scene ID: '.$scene_id_validate.'</p>');
1103
- die();
1104
- }
1105
  }
 
1106
 
1107
- if ($scenes_val["hotspot-list"] != "") {
1108
- foreach ($scenes_val["hotspot-list"] as $hotspot_val) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1109
 
1110
- $hotspot_title_validate = $hotspot_val["hotspot-title"];
1111
 
1112
- if (!empty($hotspot_title_validate)) {
1113
- $hotspot_title_validated = preg_replace('/[^0-9a-zA-Z_]/',"",$hotspot_title_validate);
1114
- if ($hotspot_title_validated != $hotspot_title_validate) {
1115
- wp_send_json_error('<span class="pano-error-title">Invalid Hotspot ID</span> <p>Hotspot ID can\'t contain spaces and special characters.<br/> Please assign a unique Hotspot ID with letters and numbers where Scene id: '.$scene_id_validate.' Hotspot ID is: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1116
  die();
1117
  }
1118
- $hotspot_pitch_validate = $hotspot_val["hotspot-pitch"];
1119
- if (empty($hotspot_pitch_validate)) {
1120
- wp_send_json_error('<p><span>Warning:</span> Hotspot pitch is required for every hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
 
 
 
 
 
 
 
 
 
1121
  die();
1122
  }
1123
- if (!empty($hotspot_pitch_validate)) {
1124
- $hotspot_pitch_validated = preg_replace('/[^0-9.-]/','',$hotspot_pitch_validate);
1125
- if ($hotspot_pitch_validated != $hotspot_pitch_validate) {
1126
- wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span> <p>The Pitch Value can only contain float numbers where Scene ID: '.$scene_id_validate.' Hotspot ID is: '.$hotspot_title_validate.'</p>');
1127
 
1128
-
 
 
 
 
1129
  die();
1130
  }
1131
  }
1132
-
1133
- $hotspot_yaw_validate = $hotspot_val["hotspot-yaw"];
1134
- if (empty($hotspot_yaw_validate)) {
1135
- wp_send_json_error('<p><span>Warning:</span> Hotspot yaw is required for every hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1136
- die();
 
 
 
1137
  }
1138
- if (!empty($hotspot_yaw_validate)) {
1139
- $hotspot_yaw_validated = preg_replace('/[^0-9.-]/','',$hotspot_yaw_validate);
1140
- if ($hotspot_yaw_validated != $hotspot_yaw_validate) {
1141
- wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span> <p>The Yaw Value can only contain float numbers where Scene ID: '.$scene_id_validate.' Hotspot ID is: '.$hotspot_title_validate.'</p>');
1142
 
1143
- die();
1144
- }
1145
- }
1146
 
1147
- if(is_plugin_active( 'wpvr-pro/wpvr-pro.php' )){
1148
- $status = get_option( 'wpvr_edd_license_status' );
1149
- if( $status !== false && $status == 'valid' ) {
1150
- if ($hotspot_val["hotspot-customclass-pro"] != 'none' && !empty($hotspot_val["hotspot-customclass"])) {
1151
- wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not use both Custom Icon and Custom Icon Class for a hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1152
- die();
1153
- }
1154
- }
1155
  }
1156
- $hotspot_type_validate = $hotspot_val["hotspot-type"];
1157
- $hotspot_url_validate = $hotspot_val["hotspot-url"];
1158
- if (!empty($hotspot_url_validate)) {
1159
- $hotspot_url_validated = esc_url($hotspot_url_validate);
1160
- if ($hotspot_url_validated != $hotspot_url_validate) {
1161
- wp_send_json_error('<p><span>Warning:</span> Hotspot Url is invalid where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1162
- die();
1163
- }
1164
  }
1165
- $hotspot_content_validate = $hotspot_val["hotspot-content"];
1166
 
1167
- $hotspot_scene_validate = $hotspot_val["hotspot-scene"];
1168
 
1169
- if ($hotspot_type_validate == "info") {
1170
- if (!empty($hotspot_scene_validate)) {
1171
- wp_send_json_error('<p><span>Warning:</span> Don\'t add Target Scene ID on info type hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1172
- die();
1173
- }
1174
- if (!empty($hotspot_url_validate) && !empty($hotspot_content_validate)) {
1175
- wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not set both On Click Content and URL on a hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1176
  die();
1177
  }
1178
  }
 
1179
 
1180
-
1181
-
1182
- if ($hotspot_type_validate == "shortcode_editor") {
1183
- if ( substr( $hotspot_val['hotspot-shortcode'], 0, 1 ) === '[' ) {
1184
- $pattern = get_shortcode_regex();
1185
- preg_match('/'.$pattern.'/s', $hotspot_val['hotspot-shortcode'], $matches);
1186
- if(is_array($matches) && !isset($matches[2])) {
1187
- wp_send_json_error('<p><span>Warning:</span> This is not a valid shortcode where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1188
- die();
1189
- }
1190
- }
1191
- }
1192
-
1193
- if ($hotspot_type_validate == "scene") {
1194
- if (empty($hotspot_scene_validate)) {
1195
- wp_send_json_error('<span class="pano-error-title">Target Scene Missing</span> <p>Assign a Target Scene to the Scene-type Hotspot where Scene ID: '.$scene_id_validate.' and Hotspot ID : '.$hotspot_title_validate.'</p>');
1196
- die();
1197
- }
1198
- if (!empty($hotspot_url_validate) || !empty($hotspot_content_validate)) {
1199
- wp_send_json_error('<p><span>Warning:</span> Don\'t add Url or On click content on scene type hotspot where scene id: '.$scene_id_validate.' and hotspot id : '.$hotspot_title_validate.'</p>');
1200
- die();
1201
- }
1202
  }
1203
  }
1204
  }
@@ -1206,336 +1243,448 @@ class Wpvr_Ajax {
1206
  }
1207
  }
1208
  }
1209
- //===Error Control and Validation===//
1210
-
1211
- foreach ($panodata["scene-list"] as $panoscenes) {
1212
- if (empty($panoscenes['scene-id']) && !empty($panoscenes['scene-attachment-url'])) {
1213
- wp_send_json_error('<span class="pano-error-title">Missing Scene ID</span> <p>Please assign a unique Scene ID to your uploaded scene.</p>');
1214
- die();
1215
- }
1216
  }
 
1217
 
1218
- $allsceneids = array();
1219
 
1220
- foreach ($panodata["scene-list"] as $panoscenes) {
1221
- if (!empty($panoscenes['scene-id'])) {
1222
- array_push($allsceneids, $panoscenes['scene-id']);
1223
- }
1224
  }
 
1225
 
1226
- foreach ($panodata["scene-list"] as $panoscenes) {
1227
 
1228
- if ($panoscenes['dscene'] == 'on') {
1229
- $default_scene = $panoscenes['scene-id'];
1230
- }
1231
  }
1232
- if (empty($default_scene)) {
1233
- if ($allsceneids) {
1234
- $default_scene = $allsceneids[0];
1235
- }
1236
- else {
1237
- wp_send_json_error('<p><span>Warning:</span> No default scene selected and no scene id found to set as default. You need at least one scene to publish a tour </p>');
1238
- die();
1239
- }
1240
  }
 
1241
 
1242
- $allsceneids_count = array_count_values($allsceneids);
1243
- foreach ($allsceneids_count as $key => $value) {
1244
- if ($value > 1) {
1245
- wp_send_json_error('<span class="pano-error-title">Duplicate Scene ID</span> <p>You\'ve assigned a duplicate Scene ID. <br/>Please assign unique Scene IDs to each scene. </p>');
1246
- die();
1247
- }
1248
  }
 
1249
 
1250
- foreach ($panodata["scene-list"] as $panoscenes) {
1251
- if (!empty($panoscenes['scene-id'])) {
1252
- $allhotspot = array();
1253
- foreach ($panoscenes["hotspot-list"] as $hotspot_val) {
1254
- if (!empty($hotspot_val["hotspot-title"])) {
1255
- array_push($allhotspot, $hotspot_val["hotspot-title"]);
1256
- }
1257
- }
1258
- $allhotspotcount = array_count_values($allhotspot);
1259
- foreach ($allhotspotcount as $key => $value) {
1260
- if ($value > 1) {
1261
- wp_send_json_error('<span class="pano-error-title">Duplicate Hotspot ID</span> <p>You\'ve assigned a duplicate Hotspot ID. <br/>Please assign unique Hotspot IDs to each Hotspot.</p>');
1262
- die();
1263
- }
1264
- }
1265
  }
1266
  }
 
1267
 
1268
- $panolength = count($panodata["scene-list"]);
1269
- for ($i=0; $i < $panolength; $i++) {
1270
- if (empty($panodata["scene-list"][$i]['scene-id'])) {
1271
- unset($panodata["scene-list"][$i]);
1272
- }
1273
- else {
1274
- $panohotspotlength = count($panodata["scene-list"][$i]['hotspot-list']);
1275
- for ($j=0; $j < $panohotspotlength; $j++) {
1276
- if (empty($panodata["scene-list"][$i]['hotspot-list'][$j]['hotspot-title'])) {
1277
- unset($panodata["scene-list"][$i]['hotspot-list'][$j]);
1278
- }
1279
  }
1280
  }
1281
  }
 
1282
 
1283
- //===audio===//
1284
- $bg_music = 'off';
1285
- $bg_music_url = '';
1286
- $autoplay_bg_music = 'off';
1287
- $loop_bg_music = 'off';
1288
- $bg_music = sanitize_text_field($_POST['bg_music']);
1289
- $bg_music_url = esc_url_raw($_POST['bg_music_url']);
1290
- $autoplay_bg_music = sanitize_text_field($_POST['autoplay_bg_music']);
1291
- $loop_bg_music = sanitize_text_field($_POST['loop_bg_music']);
1292
- if ($bg_music == 'on') {
1293
- if (empty($bg_music_url)) {
1294
- wp_send_json_error('<p><span>Warning:</span> Please add an audio file as you enabled audio for this tour </p>');
1295
- die();
1296
- }
1297
  }
1298
- //===audio===//
 
1299
 
1300
- $pano_array = array();
1301
- $pano_array = array(__( "panoid" )=>$panoid,__( "autoLoad" )=>$autoload,__("hfov")=>$default_global_zoom,__("maxHfov")=>$max_global_zoom,__("minHfov")=>$min_global_zoom,__( "showControls" )=>$control,__( "cpLogoSwitch" )=>$cpLogoSwitch,__( "cpLogoImg" )=>$cpLogoImg,__( "cpLogoContent" )=>$cpLogoContent,__( "vrgallery" )=>$vrgallery,__( "vrgallery_title" )=>$vrgallery_title,__( "vrgallery_display" )=>$vrgallery_display,__( "customcontrol" )=>$custom_control,__( "gyro" )=>$gyro,__( "deviceorientationcontrol" )=>$deviceorientationcontrol,__( "compass" )=>$compass,__( "mouseZoom" )=>$mouseZoom,__( "draggable" )=>$draggable,__( "diskeyboard" )=>$diskeyboard,__( "keyboardzoom" )=>$keyboardzoom,__( "autoRotate" )=>$autorotation,__( "autoRotateInactivityDelay" )=>$autorotationinactivedelay,__( "autoRotateStopDelay" )=>$autorotationstopdelay,__( "preview" )=>$preview,__( "defaultscene" )=>$default_scene,__( "scenefadeduration" )=>$scene_fade_duration,__( "bg_music" )=>$bg_music,__( "bg_music_url" )=>$bg_music_url,__( "autoplay_bg_music" )=>$autoplay_bg_music,__( "loop_bg_music" )=>$loop_bg_music,__( "panodata" )=>$panodata,__("previewtext")=>$previewtext);
1302
 
1303
- if ($rotation == 'off') {
1304
- unset($pano_array['autoRotate']);
1305
- unset($pano_array['autoRotateInactivityDelay']);
1306
- unset($pano_array['autoRotateStopDelay']);
1307
- }
1308
- if (empty($autorotation)) {
1309
- unset($pano_array['autoRotate']);
1310
- unset($pano_array['autoRotateInactivityDelay']);
1311
- unset($pano_array['autoRotateStopDelay']);
1312
- }
1313
- if (empty($autorotationinactivedelay)) {
1314
- unset($pano_array['autoRotateInactivityDelay']);
1315
- }
1316
- if (empty($autorotationstopdelay)) {
1317
- unset($pano_array['autoRotateStopDelay']);
1318
- }
1319
- if (empty($autorotationstopdelay)) {
1320
- unset($pano_array['autoRotateStopDelay']);
1321
- }
1322
- update_post_meta( $postid, 'panodata', $pano_array );
1323
- die();
1324
  }
1325
 
1326
- function wpvr_file_import() {
1327
- set_time_limit(20000000000000000);
 
 
 
 
 
 
 
 
 
 
 
1328
  wpvr_delete_temp_file();
1329
- if ($_POST['fileurl']) {
1330
- WP_Filesystem();
1331
- $file_save_url = wp_upload_dir();
1332
- $fileurl = $_POST['fileurl'];
1333
- $attachment_id = $_POST['data_id'];
1334
- $zip_file_path = get_attached_file( $attachment_id );
1335
- $unzipfile = unzip_file($zip_file_path,$file_save_url['basedir'].'/wpvr/temp/');
1336
-
1337
- if ( is_wp_error( $unzipfile ) ) {
1338
- wpvr_delete_temp_file();
1339
- wp_send_json_error('Failed to unzip file');
1340
- }
1341
- $result = glob($file_save_url["basedir"].'/wpvr/temp/*.json');
1342
- if (!$result) {
1343
- wpvr_delete_temp_file();
1344
- wp_send_json_error('Tour json file not found');
1345
- }
1346
- $tour_json = $result[0];
1347
- $arrContextOptions=array(
1348
- "ssl"=>array(
1349
- "verify_peer"=>false,
1350
- "verify_peer_name"=>false,
1351
- ),
1352
- );
1353
- $getfile = file_get_contents($tour_json, false, stream_context_create($arrContextOptions));
1354
- $file_content = json_decode($getfile, true);
1355
-
1356
- $new_title = $file_content['title'];
1357
- $new_data = $file_content['data'];
1358
- $new_post_id = wp_insert_post( array(
1359
- 'post_title' => $new_title,
1360
- 'post_type' => 'wpvr_item',
1361
- 'post_status' => 'publish',
1362
- ) );
1363
- if ($new_post_id) {
1364
- if ($new_data['panoid']) {
1365
- $new_data['panoid'] = 'pano'.$new_post_id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1366
  }
1367
- if ($new_data['preview']) {
1368
- $preview_url = $file_save_url['baseurl'].'/wpvr/temp/scene_preview.jpg';
1369
- $media_get = wpvr_handle_media_import($preview_url, $new_post_id);
1370
- if ($media_get['status'] == 'error') {
1371
- wp_delete_post($new_post_id, true);
1372
- wpvr_delete_temp_file();
1373
- wp_send_json_error($media_get['message']);
1374
- }
1375
- elseif ($media_get['status'] == 'success') {
1376
- $new_data['preview'] = $media_get['message'];
1377
- }
1378
- else {
1379
- wp_delete_post($new_post_id, true);
1380
- wpvr_delete_temp_file();
1381
- wp_send_json_error('Media transfer process failed');
1382
- }
 
1383
  }
1384
- if ($new_data['preview']) {
1385
- $preview_url = $file_save_url['baseurl'].'/wpvr/temp/scene_preview.jpg';
1386
- $media_get = wpvr_handle_media_import($preview_url, $new_post_id);
1387
- if ($media_get['status'] == 'error') {
1388
- wp_delete_post($new_post_id, true);
1389
- wpvr_delete_temp_file();
1390
- wp_send_json_error($media_get['message']);
1391
- }
1392
- elseif ($media_get['status'] == 'success') {
1393
- $new_data['preview'] = $media_get['message'];
1394
- }
1395
- else {
1396
- wp_delete_post($new_post_id, true);
1397
- wpvr_delete_temp_file();
1398
- wp_send_json_error('Media transfer process failed');
1399
- }
 
1400
  }
1401
- if ($new_data['cpLogoImg']) {
1402
- $logo = $new_data['cpLogoImg'];
1403
- $get_logo_format = explode(".", $logo);
1404
- $logo_format = end($get_logo_format);
1405
- $logo_img = $file_save_url['baseurl'].'/wpvr/temp/logo_img.'.$logo_format;
1406
- $media_get = wpvr_handle_media_import($logo_img, $new_post_id);
1407
- if ($media_get['status'] == 'error') {
1408
- wp_delete_post($new_post_id, true);
1409
- wpvr_delete_temp_file();
1410
- wp_send_json_error($media_get['message']);
1411
- }
1412
- elseif ($media_get['status'] == 'success') {
1413
- $new_data['cpLogoImg'] = $media_get['message'];
1414
- }
1415
- else {
1416
- wp_delete_post($new_post_id, true);
1417
- wpvr_delete_temp_file();
1418
- wp_send_json_error('Media transfer process failed');
1419
- }
1420
  }
1421
- if ($new_data['bg_music_url']) {
1422
- $music_url = $new_data['bg_music_url'];
1423
- $get_music_format = explode(".", $music_url);
1424
- $music_format = end($get_music_format);
1425
- $music_url = $file_save_url['baseurl'].'/wpvr/temp/music_url.'.$music_format;
1426
- $media_get = wpvr_handle_media_import($music_url, $new_post_id);
1427
- if ($media_get['status'] == 'error') {
1428
- wp_delete_post($new_post_id, true);
1429
- wpvr_delete_temp_file();
1430
- wp_send_json_error($media_get['message']);
1431
- }
1432
- elseif ($media_get['status'] == 'success') {
1433
- $new_data['bg_music_url'] = $media_get['message'];
1434
- }
1435
- else {
1436
- wp_delete_post($new_post_id, true);
1437
- wpvr_delete_temp_file();
1438
- wp_send_json_error('Media transfer process failed');
1439
- }
1440
  }
1441
- if ($new_data['panodata']) {
1442
-
1443
- if ($new_data['panodata']["scene-list"]) {
1444
-
1445
- foreach ($new_data['panodata']["scene-list"] as $key => $panoscenes) {
1446
- if ($panoscenes["scene-attachment-url"]) {
1447
- $scene_id = $panoscenes['scene-id'];
1448
- $url = $file_save_url['baseurl'].'/wpvr/temp/'.$scene_id.'.jpg';
1449
- $media_get = wpvr_handle_media_import($url, $new_post_id);
1450
- if ($media_get['status'] == 'error') {
1451
- wp_delete_post($new_post_id, true);
1452
- wpvr_delete_temp_file();
1453
- wp_send_json_error($media_get['message']);
1454
- }
1455
- elseif ($media_get['status'] == 'success') {
1456
- $new_data['panodata']["scene-list"][$key]['scene-attachment-url'] = $media_get['message'];
1457
- }
1458
- else {
1459
- wp_delete_post($new_post_id, true);
1460
- wpvr_delete_temp_file();
1461
- wp_send_json_error('Media transfer process failed');
1462
- }
1463
- }
1464
- }
1465
- }
1466
- update_post_meta( $new_post_id, 'panodata', $new_data );
 
 
 
 
 
1467
  wpvr_delete_temp_file();
 
 
1468
  }
 
1469
  }
 
 
 
1470
  }
1471
- else {
1472
- wpvr_delete_temp_file();
1473
- wp_send_json_error('No file found to import');
1474
- }
1475
- die();
1476
  }
 
 
1477
 
1478
  /**
1479
- * Video Preview show ajax function
1480
- */
1481
- function wpvrstreetview_preview() {
1482
- $panoid ='';
1483
- $postid = sanitize_text_field($_POST['postid']);
1484
- $panoid = 'pano'.$postid;
1485
- $randid = rand(1000, 1000000);
1486
- $streetviewid = 'streetview'.$randid;
1487
- $streetviewurl = $_POST['streetview'];
1488
- if ($streetviewurl) {
1489
- $html .= '<iframe src="'.$streetviewurl.'" width="600" height="400" frameborder="0" style="border:0;" allowfullscreen=""></iframe>';
1490
- }
 
 
1491
 
1492
- $response = array();
1493
- $response = array(__( "panoid" )=>$panoid,__( "panodata" )=>$html,__( "streetview" )=>$streetviewid);
1494
- wp_send_json_success( $response );
1495
  }
1496
 
1497
  /**
1498
- * Role management
1499
- */
1500
- function wpvr_role_management() {
1501
- $editor = sanitize_text_field($_POST['editor']);
1502
- $author = sanitize_text_field($_POST['author']);
1503
- $fontawesome = sanitize_text_field($_POST['fontawesome']);
1504
- $mobile_media_resize = sanitize_text_field($_POST['mobile_media_resize']);
1505
- $high_res_image = sanitize_text_field($_POST['high_res_image']);
1506
- $wpvr_frontend_notice = sanitize_text_field($_POST['wpvr_frontend_notice']);
1507
- $wpvr_frontend_notice_area = sanitize_text_field($_POST['wpvr_frontend_notice_area']);
1508
- $wpvr_script_control = sanitize_text_field($_POST['wpvr_script_control']);
1509
- $wpvr_script_list = sanitize_text_field($_POST['wpvr_script_list']);
1510
-
1511
- // $enable_woocommerce = sanitize_text_field($_POST['woocommerce']);
1512
-
1513
- $wpvr_script_list = str_replace(' ', '', $wpvr_script_list);
1514
-
1515
- update_option('wpvr_editor_active', $editor);
1516
- update_option('wpvr_author_active', $author);
1517
- update_option('wpvr_fontawesome_disable', $fontawesome);
1518
- update_option('mobile_media_resize', $mobile_media_resize);
1519
- update_option('high_res_image', $high_res_image);
1520
- update_option('wpvr_frontend_notice', $wpvr_frontend_notice);
1521
- update_option('wpvr_frontend_notice_area', $wpvr_frontend_notice_area);
1522
- update_option('wpvr_script_control', $wpvr_script_control);
1523
- update_option('wpvr_script_list', $wpvr_script_list);
1524
-
1525
- // update_option('wpvr_enable_woocommerce', $enable_woocommerce);
1526
-
1527
- $response = array(
1528
- 'status' => 'success',
1529
- 'message' => 'Successfully saved',
1530
- );
1531
- wp_send_json($response);
 
 
 
 
 
 
 
1532
  }
1533
 
1534
  /**
1535
- * Notice
1536
- */
1537
- function wpvr_notice() {
1538
- update_option( 'wpvr_warning', '1' );
 
1539
  }
1540
-
1541
  }
1
  <?php
2
+ if (!defined('ABSPATH')) exit; // Exit if accessed directly
3
  /**
4
  * The admin-specific Ajax files.
5
  *
10
  * @subpackage Wpvr/admin
11
  */
12
 
13
+ class Wpvr_Ajax
14
+ {
15
 
16
  /**
17
  * Preview show ajax function
18
  */
19
+ function wpvr_show_preview()
20
+ {
21
+ $panoid = '';
22
+ $postid = sanitize_text_field($_POST['postid']);
23
+ $post_type = get_post_type($postid);
24
+
25
+ $panoid = 'pano' . $postid;
26
+
27
+ $control = sanitize_text_field($_POST['control']);
28
+ if ($control == 'on') {
29
+ $control = true;
30
+ } else {
31
+ $control = false;
32
+ }
33
 
34
+ $compass = sanitize_text_field($_POST['compass']);
35
+ if ($compass == 'on') {
36
+ $compass = true;
37
+ } else {
38
+ $compass = false;
39
+ }
40
 
41
+ $mouseZoom = sanitize_text_field($_POST['mouseZoom']);
42
+ if ($mouseZoom == 'off') {
43
+ $mouseZoom = false;
44
+ } else {
45
+ $mouseZoom = true;
46
+ }
 
47
 
48
+ $draggable = sanitize_text_field($_POST['draggable']);
49
+ if ($draggable == 'off') {
50
+ $draggable = false;
51
+ } else {
52
+ $draggable = true;
53
+ }
 
54
 
55
+ $diskeyboard = sanitize_text_field($_POST['diskeyboard']);
56
+ if ($diskeyboard == 'on') {
57
+ $diskeyboard = true;
58
+ } else {
59
+ $diskeyboard = false;
60
+ }
 
61
 
62
+ $keyboardzoom = sanitize_text_field($_POST['keyboardzoom']);
63
+ if ($keyboardzoom == 'off') {
64
+ $keyboardzoom = false;
65
+ } else {
66
+ $keyboardzoom = true;
67
+ }
 
68
 
69
+ $autoload = sanitize_text_field($_POST['autoload']);
70
+ if ($autoload == 'on') {
71
+ $autoload = true;
72
+ } else {
73
+ $autoload = false;
74
+ }
 
75
 
76
+ $default_scene = '';
77
+ $default_scene = sanitize_text_field($_POST['defaultscene']);
78
+ $preview = '';
79
+ $preview = esc_url($_POST['preview']);
80
+
81
+ $rotation = '';
82
+ $rotation = sanitize_text_field($_POST['rotation']);
83
+
84
+ $autorotation = '';
85
+ $autorotation = sanitize_text_field($_POST['autorotation']);
86
+ $autorotationinactivedelay = '';
87
+ $autorotationinactivedelay = sanitize_text_field($_POST['autorotationinactivedelay']);
88
+ $autorotationstopdelay = '';
89
+ $autorotationstopdelay = sanitize_text_field($_POST['autorotationstopdelay']);
90
+
91
+ $default_global_zoom = '';
92
+ $max_global_zoom = '';
93
+ $min_global_zoom = '';
94
+ if (isset($_POST['gzoom']) == 'on') {
95
+ $default_global_zoom = $_POST['dzoom'];
96
+ $max_global_zoom = $_POST['maxzoom'];
97
+ $min_global_zoom = $_POST['minzoom'];
98
+ }
99
+ if (!empty($autorotationinactivedelay) && !empty($autorotationstopdelay)) {
100
+ wp_send_json_error('<span class="pano-error-title">Dual Action Error for Auto-Rotation</span><p> You can not use both Resume Auto-rotation & Stop Auto-rotation on the same tour. You can use only one of them.</p>');
101
 
102
+ die();
103
+ }
 
 
 
 
 
104
 
105
+ $scene_fade_duration = '';
106
+ $scene_fade_duration = sanitize_text_field($_POST['scenefadeduration']);
107
+
108
+ $panodata = $_POST['panodata'];
109
+ $panolist = stripslashes($panodata);
110
+ $panodata = (array)json_decode($panolist);
111
+ $panolist = array();
112
+ if (is_array($panodata["scene-list"])) {
113
+ foreach ($panodata["scene-list"] as $scenes_data) {
114
+ $temp_array = array();
115
+ $temp_array = (array)$scenes_data;
116
+ if ($temp_array['hotspot-list']) {
117
+ $_hotspot_array = array();
118
+ foreach ($temp_array['hotspot-list'] as $temp_hotspot) {
119
+ $temp_hotspot = (array)$temp_hotspot;
120
+ $_hotspot_array[] = $temp_hotspot;
121
+ }
122
+ }
123
+ $temp_array['hotspot-list'] = $_hotspot_array;
124
+ $panolist['scene-list'][] = $temp_array;
 
 
125
  }
126
+ }
127
+ $panodata = $panolist;
128
 
129
+ //===Error Control and Validation===//
 
130
 
131
+ if ($panodata["scene-list"] != "") {
132
+ foreach ($panodata["scene-list"] as $scenes_val) {
133
+
134
+ $scene_id_validate = $scenes_val["scene-id"];
135
+
136
+
137
+ if (!empty($scene_id_validate)) {
138
+ $scene_id_validated = preg_replace('/[^0-9a-zA-Z_]/', "", $scene_id_validate);
139
+ if ($scene_id_validated != $scene_id_validate) {
140
+ wp_send_json_error('<span class="pano-error-title">Invalid Scene ID</span> <p>Scene ID can\'t contain spaces and special characters. <br/>Please assign a unique Scene ID with letters and numbers where Scene ID is : ' . $scene_id_validate . '</p>');
141
+ die();
 
 
 
 
 
 
142
  }
 
 
 
 
 
 
 
143
 
144
+ if ($scenes_val['scene-type'] == 'cubemap') {
145
+ if (empty($scenes_val["scene-attachment-url-face0"])) {
146
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 0</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
147
+ die();
148
+ }
149
+
150
+ if (empty($scenes_val["scene-attachment-url-face1"])) {
151
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 1</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
152
+ die();
153
+ }
154
+
155
+ if (empty($scenes_val["scene-attachment-url-face2"])) {
156
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 2</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
157
+ die();
158
+ }
159
+
160
+ if (empty($scenes_val["scene-attachment-url-face3"])) {
161
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 3</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
162
+ die();
163
+ }
164
 
165
+ if (empty($scenes_val["scene-attachment-url-face4"])) {
166
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 4</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
167
+ die();
168
+ }
169
 
170
+ if (empty($scenes_val["scene-attachment-url-face5"])) {
171
+ wp_send_json_error('<span class="pano-error-title">Missing Cubemap Scene Face 5</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
 
 
 
172
  die();
173
  }
174
+ } else {
175
  if (empty($scenes_val["scene-attachment-url"])) {
176
+ wp_send_json_error('<span class="pano-error-title">Missing Scene Image</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
177
  die();
178
  }
179
+ }
180
 
181
+ if (!empty($scenes_val["scene-pitch"])) {
182
+ $validate_scene_pitch = $scenes_val["scene-pitch"];
183
+ $validated_scene_pitch = preg_replace('/[^0-9.-]/', '', $validate_scene_pitch);
184
+ if ($validated_scene_pitch != $validate_scene_pitch) {
185
+ wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span><p> The Pitch Value can only contain float numbers where Scene ID: ' . $scene_id_validate . '</p>');
186
+ die();
 
187
  }
188
+ }
189
 
190
+ if (!empty($scenes_val["scene-yaw"])) {
191
+ $validate_scene_yaw = $scenes_val["scene-yaw"];
192
+ $validated_scene_yaw = preg_replace('/[^0-9.-]/', '', $validate_scene_yaw);
193
+ if ($validated_scene_yaw != $validate_scene_yaw) {
194
+ wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span><p> The Yaw Value can only contain float numbers where Scene ID: ' . $scene_id_validate . '</p>');
195
+ die();
 
196
  }
197
+ }
198
 
199
+ if (!empty($scenes_val["scene-zoom"])) {
200
+ $validate_default_zoom = $scenes_val["scene-zoom"];
201
+ $validated_default_zoom = preg_replace('/[^0-9-]/', '', $validate_default_zoom);
202
+ if ($validated_default_zoom != $validate_default_zoom) {
203
+ wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: ' . $scene_id_validate . '</p>');
204
+ die();
205
+ }
206
+ $default_zoom_value = (int)$scenes_val["scene-zoom"];
207
+ if ($default_zoom_value > 120 || $default_zoom_value < 50) {
208
+ wp_send_json_error('<span class="pano-error-title">Invalid Default Zoom Value</span><p> You can only set Default Zoom in Degree values from 50 to 120 where Scene ID: ' . $scene_id_validate . '</p>');
209
 
210
+ die();
 
211
  }
212
+ }
213
 
214
+ if (!empty($scenes_val["scene-maxzoom"])) {
215
+ $validate_max_zoom = $scenes_val["scene-maxzoom"];
216
+ $validated_max_zoom = preg_replace('/[^0-9-]/', '', $validate_max_zoom);
217
+ if ($validated_max_zoom != $validate_max_zoom) {
218
+ wp_send_json_error('<span class="pano-error-title">Invalid Max-zoom Value:</span><p> You can only set Max-zoom in degree values (50-120) where Scene ID: ' . $scene_id_validate . '</p>');
219
 
220
+ die();
 
 
 
 
 
 
221
  }
222
+ $max_zoom_value = (int)$scenes_val["scene-maxzoom"];
223
+ if ($max_zoom_value > 120) {
224
+ wp_send_json_error('<span class="pano-error-title">Max-zoom Value Limit Exceeded</span><p> You can set the Max-zoom Value up to 120 degrees.</p>');
225
+ die();
226
+ }
227
+ }
228
 
229
+ if (!empty($scenes_val["scene-minzoom"])) {
230
+ $validate_min_zoom = $scenes_val["scene-minzoom"];
231
+ $validated_min_zoom = preg_replace('/[^0-9-]/', '', $validate_min_zoom);
232
+ if ($validated_min_zoom != $validate_min_zoom) {
233
+ wp_send_json_error('<span class="pano-error-title">Invalid Min-zoom Value</span><p> You can only set Min-zoom in degree values (50-120) where Scene ID: ' . $scene_id_validate . '</p>');
234
+ die();
235
+ }
236
+ $min_zoom_value = (int)$scenes_val["scene-minzoom"];
237
+ if ($min_zoom_value < 50) {
238
+ wp_send_json_error('<span class="pano-error-title">Low Min-Zoom Value</span><p> The Min-zoom value must be more than 50 in degree values where Scene ID: ' . $scene_id_validate . '</p>');
239
+ die();
 
240
  }
241
+ }
 
 
242
 
243
+ if ($scenes_val["hotspot-list"] != "") {
244
+ foreach ($scenes_val["hotspot-list"] as $hotspot_val) {
245
 
246
+ $hotspot_title_validate = $hotspot_val["hotspot-title"];
 
 
 
 
 
 
247
 
 
 
 
 
 
 
 
 
 
248
 
249
+ if (!empty($hotspot_title_validate)) {
250
+ $hotspot_title_validated = preg_replace('/[^0-9a-zA-Z_]/', "", $hotspot_title_validate);
251
+ if ($hotspot_title_validated != $hotspot_title_validate) {
252
+ wp_send_json_error('<span class="pano-error-title">Invalid Hotspot ID</span> <p>Hotspot ID can\'t contain spaces and special characters. <br/>Please assign a unique Hotspot ID with letters and numbers where Scene id: ' . $scene_id_validate . ' Hotspot ID is: ' . $hotspot_title_validate . '</p>');
253
+ die();
254
+ }
255
 
256
+ $hotspot_pitch_validate = $hotspot_val["hotspot-pitch"];
257
+ if (!empty($hotspot_pitch_validate)) {
258
+ $hotspot_pitch_validated = preg_replace('/[^0-9.-]/', '', $hotspot_pitch_validate);
259
+ if ($hotspot_pitch_validated != $hotspot_pitch_validate) {
260
+ wp_send_json_error('<span class="pano-error-title">Invalid Pitch Value</span> <p>The Pitch Value can only contain float numbers where Scene ID: ' . $scene_id_validate . ' Hotspot ID is: ' . $hotspot_title_validate . '</p>');
261
+
262
+ die();
263
  }
264
+ }
265
 
266
+ $hotspot_yaw_validate = $hotspot_val["hotspot-yaw"];
267
+ if (!empty($hotspot_yaw_validate)) {
268
+ $hotspot_yaw_validated = preg_replace('/[^0-9.-]/', '', $hotspot_yaw_validate);
269
+ if ($hotspot_yaw_validated != $hotspot_yaw_validate) {
270
+ wp_send_json_error('<span class="pano-error-title">Invalid Yaw Value</span> <p>The Yaw Value can only contain float numbers where Scene ID: ' . $scene_id_validate . ' Hotspot ID is: ' . $hotspot_title_validate . '</p>');
271
+
272
+ die();
 
273
  }
274
+ }
275
+
276
+ if (is_plugin_active('wpvr-pro/wpvr-pro.php')) {
277
+ $status = get_option('wpvr_edd_license_status');
278
+ if ($status !== false && $status == 'valid') {
279
+ if ($hotspot_val["hotspot-customclass-pro"] != 'none' && !empty($hotspot_val["hotspot-customclass"])) {
280
+ wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not use both Custom Icon and Custom Icon Class for a hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
281
  die();
282
  }
283
  }
284
+ }
285
+ $hotspot_type_validate = $hotspot_val["hotspot-type"];
286
+ $hotspot_url_validate = $hotspot_val["hotspot-url"];
287
+ if (!empty($hotspot_url_validate)) {
288
+ $hotspot_url_validated = esc_url($hotspot_url_validate);
289
+ if ($hotspot_url_validated != $hotspot_url_validate) {
290
+ wp_send_json_error('<p><span>Warning:</span> Hotspot Url is invalid where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
291
+ die();
292
+ }
293
+ }
294
+ $hotspot_content_validate = $hotspot_val["hotspot-content"];
295
 
296
+ $hotspot_scene_validate = $hotspot_val["hotspot-scene"];
297
 
298
+ if ($hotspot_type_validate == "info") {
299
+ if (!empty($hotspot_scene_validate)) {
300
+ wp_send_json_error('<p><span>Warning:</span> Don\'t add Target Scene ID on info type hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
301
+ die();
302
+ }
303
+ if (!empty($hotspot_url_validate) && !empty($hotspot_content_validate)) {
304
+ wp_send_json_error('<span class="pano-error-title">Warning!</span> <p>You can not set both On Click Content and URL on a hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
305
+ die();
 
306
  }
307
+ }
308
 
309
+ if ($hotspot_type_validate == "scene") {
310
+ if (empty($hotspot_scene_validate)) {
311
+ wp_send_json_error('<span class="pano-error-title">Target Scene Missing</span> <p>Assign a Target Scene to the Scene-type Hotspot where Scene ID: ' . $scene_id_validate . ' and Hotspot ID : ' . $hotspot_title_validate . '</p>');
312
+ die();
313
+ }
314
+ if (!empty($hotspot_url_validate) || !empty($hotspot_content_validate)) {
315
+ wp_send_json_error('<p><span>Warning:</span> Don\'t add Url or On click content on scene type hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
316
+ die();
 
317
  }
318
  }
319
  }
321
  }
322
  }
323
  }
324
+ }
325
+ //===Error Control and Validation===//
326
+ foreach ($panodata["scene-list"] as $panoscenes) {
327
+ if (empty($panoscenes['scene-id']) && !empty($panoscenes['scene-attachment-url'])) {
328
+ wp_send_json_error('<span class="pano-error-title">Missing Scene ID</span> <p>Please assign a unique Scene ID to your uploaded scene.</p>');
329
+ die();
330
  }
331
+ }
332
 
333
+ $allsceneids = array();
334
 
335
+ foreach ($panodata["scene-list"] as $panoscenes) {
336
+ if (!empty($panoscenes['scene-id'])) {
337
+ array_push($allsceneids, $panoscenes['scene-id']);
 
338
  }
339
+ }
340
 
341
+ foreach ($panodata["scene-list"] as $panoscenes) {
342
 
343
+ if ($panoscenes['dscene'] == 'on') {
344
+ $default_scene = $panoscenes['scene-id'];
 
345
  }
346
+ }
347
+ if (empty($default_scene)) {
348
+ if ($allsceneids) {
349
+ $default_scene = $allsceneids[0];
350
+ } else {
351
+ wp_send_json_error('<p><span>Warning:</span> No default scene selected and no scene id found to set as default. You need at least one scene to publish a tour </p>');
352
+ die();
 
353
  }
354
+ }
355
 
356
+ $allsceneids_count = array_count_values($allsceneids);
357
+ foreach ($allsceneids_count as $key => $value) {
358
+ if ($value > 1) {
359
+ wp_send_json_error('<span class="pano-error-title">Duplicate Scene ID</span> <p>You\'ve assigned a duplicate Scene ID. <br/>Please assign unique Scene IDs to each scene. </p>');
360
+ die();
 
361
  }
362
+ }
363
 
364
+ foreach ($panodata["scene-list"] as $panoscenes) {
365
+ if (!empty($panoscenes['scene-id'])) {
366
+ $allhotspot = array();
367
+ foreach ($panoscenes["hotspot-list"] as $hotspot_val) {
368
+
369
+ if (!empty($hotspot_val["hotspot-title"])) {
370
+ array_push($allhotspot, $hotspot_val["hotspot-title"]);
371
+ }
372
+ }
373
+ $allhotspotcount = array_count_values($allhotspot);
374
+ foreach ($allhotspotcount as $key => $value) {
375
+ if ($value > 1) {
376
+ wp_send_json_error('<span class="pano-error-title">Duplicate Hotspot ID</span> <p>You\'ve assigned a duplicate Hotspot ID. <br/>Please assign unique Hotspot IDs to each Hotspot.</p>');
377
+ die();
378
+ }
 
379
  }
380
  }
381
+ }
382
 
383
+ $default_data = array();
384
+ if ($_POST['gzoom'] == 'on') {
385
+ $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration, "hfov" => $default_global_zoom, "maxHfov" => $max_global_zoom, "minHfov" => $min_global_zoom);
386
+ } else {
387
+ $default_data = array("firstScene" => $default_scene, "sceneFadeDuration" => $scene_fade_duration);
388
+ }
389
+ $scene_data = array();
390
+ foreach ($panodata["scene-list"] as $panoscenes) {
391
+ if (!empty($panoscenes['scene-id'])) {
392
+ $scene_ititle = '';
393
+ $scene_ititle = sanitize_text_field($panoscenes["scene-ititle"]);
394
+ $scene_author = '';
395
+ $scene_author = sanitize_text_field($panoscenes["scene-author"]);
396
 
397
+ $scene_vaov = 180;
398
+ $scene_vaov = (float)$panoscenes["scene-vaov"];
399
 
400
+ $scene_haov = 360;
401
+ $scene_haov = (float)$panoscenes["scene-haov"];
402
 
403
+ $scene_vertical_offset = 0;
404
+ $scene_vertical_offset = (float)$panoscenes["scene-vertical-offset"];
405
 
406
+ $default_scene_pitch = null;
407
+ $default_scene_pitch = (float)$panoscenes["scene-pitch"];
408
 
409
+ $default_scene_yaw = null;
410
+ $default_scene_yaw = (float)$panoscenes["scene-yaw"];
411
 
412
+ $scene_max_pitch = '';
413
+ $scene_max_pitch = (float)$panoscenes["scene-maxpitch"];
414
 
415
+ $scene_min_pitch = '';
416
+ $scene_min_pitch = (float)$panoscenes["scene-minpitch"];
417
 
418
+ $scene_max_yaw = '';
419
+ $scene_max_yaw = (float)$panoscenes["scene-maxyaw"];
420
 
421
+ $scene_min_yaw = '';
422
+ $scene_min_yaw = (float)$panoscenes["scene-minyaw"];
423
 
424
+ $default_zoom = 100;
425
+ $default_zoom = $panoscenes["scene-zoom"];
426
+ if (!empty($default_zoom)) {
427
+ $default_zoom = (int)$panoscenes["scene-zoom"];
428
+ } else {
429
  $default_zoom = 100;
430
+ }
 
 
 
 
 
 
431
 
432