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

class-wpvr-validator.php in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.4, at admin/helpers/class-wpvr-validator.php

604 lines 22.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) exit; // Exit if accessed directly
3 /**
4 * Manage all validation requirements and messages
5 *
6 * @link http://rextheme.com/
7 * @since 8.0.0
8 *
9 * @package Wpvr
10 * @subpackage Wpvr/admin/classes
11 */
12
13 class WPVR_Validator {
14
15 /**
16 * Get all error messages
17 *
18 * @var array
19 * @since 8.0.0
20 */
21 public $errors = array();
22
23
24 /**
25 * Auto-rotation data error control and validation
26 *
27 * @param number $autorotationinactivedelay
28 * @param number $autorotationstopdelay
29 *
30 * @return void
31 * @since 8.0.0
32 */
33 public function basic_setting_validation($autorotationinactivedelay, $autorotationstopdelay)
34 {
35 if (!empty($autorotationinactivedelay) && !empty($autorotationstopdelay)) {
36 $this->add_error('autorotation_dual_action', '<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>');
37 }
38 }
39
40
41 /**
42 * Preview Image Message error control and validation
43 *
44 * @param string $text
45 *
46 * @return string
47 * @since 8.0.0
48 */
49 public function preview_text_validation($text)
50 {
51 $prevtext = sanitize_text_field($text);
52 if (strlen($prevtext) > 50) {
53 $this->add_error('preview_text', '<p><span>Warning:</span> Don\'t add more than 50 characters in Preview Image Message</p>');
54 }
55 return $prevtext;
56 }
57
58
59 /**
60 * Scene content error control and validation
61 * @param array $panodata
62 *
63 * @return void
64 * @since 8.0.0
65 */
66 public function scene_validation($panodata)
67 {
68 if ($panodata["scene-list"] != "") {
69 foreach ($panodata["scene-list"] as $scenes_val) {
70 $scene_id_validate = $scenes_val["scene-id"];
71
72 if (!empty($scene_id_validate)) {
73
74 $scene_id_validated = preg_replace('/[^0-9a-zA-Z_]/', "", $scene_id_validate);
75 if ($scene_id_validated != $scene_id_validate) {
76 $this->add_error('invalid_scene_id', '<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>');
77 }
78
79 $this->scene_attachment_validation($scenes_val, $scene_id_validate); // Attachment error control and validation //
80
81 $this->scene_pitch_yaw_validation($scenes_val, $scene_id_validate); // Pitch and yaw error controll and validation //
82
83 $this->scene_default_zoom_validation($scenes_val, $scene_id_validate); // Default zoom error controll and validation //
84
85 $this->scene_max_zoom_validation($scenes_val, $scene_id_validate); // Max zoom error controll and validation //
86
87 $this->scene_min_zoom_validation($scenes_val, $scene_id_validate); // Min zoom error controll and validation //
88
89 $this->scene_hotspot_validation($scenes_val, $scene_id_validate); // Hotspot error controll and validation //
90 }
91 }
92 }
93 }
94
95
96 /**
97 * Empty image, Scene ID, and duplicate scene
98 * Error control and validation
99 *
100 * @param array $panodata
101 *
102 * @return void
103 * @since 8.0.0
104 */
105 public function empty_scene_validation($panodata)
106 {
107 $allsceneids = array();
108
109 foreach ($panodata["scene-list"] as $panoscenes) {
110 if (empty($panoscenes['scene-id']) && !empty($panoscenes['scene-attachment-url'])) {
111 $this->add_error('missing_scene_id', '<span class="pano-error-title">Missing Scene ID</span> <p>Please assign a unique Scene ID to your uploaded scene.</p>');
112 }
113 if (!empty($panoscenes['scene-id'])) {
114 array_push($allsceneids, $panoscenes['scene-id']);
115 }
116 }
117
118 foreach ($panodata["scene-list"] as $panoscenes) {
119
120 if ($panoscenes['dscene'] == 'on') {
121 $default_scene = $panoscenes['scene-id'];
122 }
123 }
124 if (empty($default_scene)) {
125 if ($allsceneids) {
126 $default_scene = $allsceneids[0];
127 } else {
128 $this->add_error('missing_image_scene', '<span class="pano-error-title">Missing Image & Scene ID</span> <p>Please Upload An Image and Set A Scene ID To See The Preview</p>');
129 }
130 }
131
132 $allsceneids_count = array_count_values($allsceneids);
133 foreach ($allsceneids_count as $key => $value) {
134 if ($value > 1) {
135 $this->add_error('duplicate_scene', '<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>');
136 }
137 }
138 }
139
140
141 /**
142 * Scene attachment error controll and validation
143 *
144 * @param array $scenes_val
145 * @param string $scene_id_validate
146 *
147 * @return void
148 * @since 8.0.0
149 */
150 private function scene_attachment_validation($scenes_val, $scene_id_validate)
151 {
152 if ($scenes_val['scene-type'] == 'cubemap') {
153 if (empty($scenes_val["scene-attachment-url-face0"])) {
154 $this->add_error('cubemap_0', '<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>');
155 }
156
157 if (empty($scenes_val["scene-attachment-url-face1"])) {
158 $this->add_error('cubemap_1', '<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>');
159 }
160
161 if (empty($scenes_val["scene-attachment-url-face2"])) {
162 $this->add_error('cubemap_2', '<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>');
163 }
164
165 if (empty($scenes_val["scene-attachment-url-face3"])) {
166 $this->add_error('cubemap_3', '<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>');
167 }
168
169 if (empty($scenes_val["scene-attachment-url-face4"])) {
170 $this->add_error('cubemap_4', '<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>');
171 }
172
173 if (empty($scenes_val["scene-attachment-url-face5"])) {
174 $this->add_error('cubemap_5', '<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>');
175 }
176 } else {
177 if (empty($scenes_val["scene-attachment-url"])) {
178 $this->add_error('missing_scene', '<span class="pano-error-title">Missing Scene Image</span><p> Please upload a 360 Degree image where Scene ID is: ' . $scene_id_validate . '</p>');
179 }
180 }
181 }
182
183
184
185 /**
186 * Scene default zoom error control and validation
187 *
188 * @param array $scenes_val
189 * @param string $scene_id_validate
190 *
191 * @return void
192 * @since 8.0.0
193 */
194 private function scene_default_zoom_validation($scenes_val, $scene_id_validate)
195 {
196 if (!empty($scenes_val["scene-zoom"])) {
197 $validate_default_zoom = $scenes_val["scene-zoom"];
198 $validated_default_zoom = preg_replace('/[^0-9-]/', '', $validate_default_zoom);
199 if ($validated_default_zoom != $validate_default_zoom) {
200 $this->add_error('invalid_default_zoom', '<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>');
201 }
202 $default_zoom_value = (int)$scenes_val["scene-zoom"];
203 if ($default_zoom_value > 120 || $default_zoom_value < 50) {
204 $this->add_error('invalid_default_zoom', '<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>');
205 }
206 }
207 }
208
209
210 /**
211 * Scene max zoom error control and validation
212 *
213 * @param array $scenes_val
214 * @param string $scene_id_validate
215 *
216 * @return void
217 * @since 8.0.0
218 */
219 private function scene_max_zoom_validation($scenes_val, $scene_id_validate)
220 {
221 if (!empty($scenes_val["scene-maxzoom"])) {
222 $validate_max_zoom = $scenes_val["scene-maxzoom"];
223 $validated_max_zoom = preg_replace('/[^0-9-]/', '', $validate_max_zoom);
224 if ($validated_max_zoom != $validate_max_zoom) {
225 $this->add_error('invalid_max_zoom', '<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>');
226 }
227 $max_zoom_value = (int)$scenes_val["scene-maxzoom"];
228 if ($max_zoom_value > 120) {
229 $this->add_error('limit_max_zoom', '<span class="pano-error-title">Max-zoom Value Limit Exceeded</span><p> You can set the Max-zoom Value up to 120 degrees.</p>');
230 }
231
232 if ($max_zoom_value < 50) {
233 $this->add_error('limit_max_zoom', '<span class="pano-error-title">Max-zoom Value Limit Exceeded</span><p> You can not set the Max-zoom Value lower than 50 degrees.</p>');
234 }
235 }
236 }
237
238
239 /**
240 * Scene min zoom error control and validation
241 *
242 * @param array $scenes_val
243 * @param string $scene_id_validate
244 *
245 * @return void
246 * @since 8.0.0
247 */
248 private function scene_min_zoom_validation($scenes_val, $scene_id_validate)
249 {
250 if (!empty($scenes_val["scene-minzoom"])) {
251 $validate_min_zoom = $scenes_val["scene-minzoom"];
252 $validated_min_zoom = preg_replace('/[^0-9-]/', '', $validate_min_zoom);
253 if ($validated_min_zoom != $validate_min_zoom) {
254 $this->add_error('invalid_min_zomm', '<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>');
255 }
256 $min_zoom_value = (int)$scenes_val["scene-minzoom"];
257 if ($min_zoom_value < 50) {
258 $this->add_error('low_min_zoom', '<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>');
259 }
260
261 if ($min_zoom_value > 120) {
262 $this->add_error('low_min_zoom', '<span class="pano-error-title">Hight Min-Zoom Value</span><p> The Min-zoom value must be less than 120 in degree values where Scene ID: ' . $scene_id_validate . '</p>');
263 }
264 }
265 }
266
267
268 /**
269 * Scene hotspot error control and validation
270 *
271 * @param array $scenes_val
272 * @param string $scene_id_validate
273 *
274 * @return void
275 * @since 8.0.0
276 */
277 private function scene_hotspot_validation($scenes_val, $scene_id_validate)
278 {
279 if ($scenes_val["hotspot-list"] != "") {
280 foreach ($scenes_val["hotspot-list"] as $hotspot_val) {
281
282 $hotspot_title_validate = $hotspot_val["hotspot-title"];
283
284 if (!empty($hotspot_title_validate)) {
285 $this->hotspot_id_validation($scene_id_validate, $hotspot_title_validate); // ID error control and validation //
286
287 $this->hotspot_pitch_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Pitch error control and validation //
288
289 $this->hotspot_yaw_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Yaw error control and validation //
290
291 $this->hotspot_custom_icon_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Custom icon error control and validation //
292
293 $this->hotspot_url_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // URL error control and validation //
294
295 $this->info_hotspot_type_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Info type error control and validation //
296
297 $this->hotspot_shortcode_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Shortcode error control and validation //
298
299 $this->scene_type_hotspot_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate); // Scene type error control and validation //
300 }
301 }
302 }
303 }
304
305
306 /**
307 * Scene pitch and yaw error control and validation
308 *
309 * @param array $scenes_val
310 * @param string $scene_id_validate
311 *
312 * @return void
313 * @since 8.0.0
314 */
315 private function scene_pitch_yaw_validation($scenes_val, $scene_id_validate)
316 {
317 if (!empty($scenes_val["scene-pitch"])) {
318 $validate_scene_pitch = $scenes_val["scene-pitch"];
319 $validated_scene_pitch = preg_replace('/[^0-9.-]/', '', $validate_scene_pitch);
320 if ($validated_scene_pitch != $validate_scene_pitch) {
321 $this->add_error('invalid_pitch', '<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>');
322 }
323 }
324
325 if (!empty($scenes_val["scene-yaw"])) {
326 $validate_scene_yaw = $scenes_val["scene-yaw"];
327 $validated_scene_yaw = preg_replace('/[^0-9.-]/', '', $validate_scene_yaw);
328 if ($validated_scene_yaw != $validate_scene_yaw) {
329 $this->add_error('invalid_yaw', '<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>');
330 }
331 }
332 }
333
334
335 /**
336 * Hotspot pitch error control and validation
337 *
338 * @param array $hotspot_val
339 * @param string $scene_id_validate
340 * @param string $hotspot_title_validate
341 *
342 * @return void
343 * @since 8.0.0
344 */
345 private function hotspot_pitch_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
346 {
347 $hotspot_pitch_validate = $hotspot_val["hotspot-pitch"];
348 if (empty($hotspot_pitch_validate)) {
349 $this->add_error('pitch_required', '<p><span>Warning:</span> Hotspot pitch is required for every hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
350 }
351 if (!empty($hotspot_pitch_validate)) {
352 $hotspot_pitch_validated = preg_replace('/[^0-9.-]/', '', $hotspot_pitch_validate);
353 if ($hotspot_pitch_validated != $hotspot_pitch_validate) {
354 $this->add_error('invalid_pitch', '<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>');
355 }
356 }
357 }
358
359
360 /**
361 * Hotspot yaw error control and validation
362 *
363 * @param array $hotspot_val
364 * @param string $scene_id_validate
365 * @param string $hotspot_title_validate
366 *
367 * @return void
368 * @since 8.0.0
369 */
370 private function hotspot_yaw_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
371 {
372 $hotspot_yaw_validate = $hotspot_val["hotspot-yaw"];
373 if (empty($hotspot_yaw_validate)) {
374 $this->add_error('yaw_required', '<p><span>Warning:</span> Hotspot yaw is required for every hotspot where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
375 }
376 if (!empty($hotspot_yaw_validate)) {
377 $hotspot_yaw_validated = preg_replace('/[^0-9.-]/', '', $hotspot_yaw_validate);
378 if ($hotspot_yaw_validated != $hotspot_yaw_validate) {
379 $this->add_error('invalid_yaw', '<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>');
380 }
381 }
382 }
383
384
385 /**
386 * Info type hotspot error control and validation
387 *
388 * @param array $hotspot_val
389 * @param string $scene_id_validate
390 * @param string $hotspot_title_validate
391 *
392 * @return void
393 * @since 8.0.0
394 */
395 private function info_hotspot_type_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
396 {
397 if ($hotspot_val["hotspot-type"] == "info") {
398 if (!empty($hotspot_val["hotspot-scene"])) {
399 $this->add_error('target_scene_info_type', '<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>');
400 }
401 if (!empty($hotspot_val["hotspot-url"]) && !empty($hotspot_val["hotspot-content"])) {
402 $this->add_error('both_click_content_url', '<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>');
403 }
404 }
405 }
406
407 /**
408 * Scene type hotspot error control and validation
409 *
410 * @param array $hotspot_val
411 * @param string $scene_id_validate
412 * @param string $hotspot_title_validate
413 *
414 * @return void
415 * @since 8.0.0
416 */
417 private function scene_type_hotspot_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
418 {
419 if ($hotspot_val["hotspot-type"] == "scene") {
420 if (empty($hotspot_val["hotspot-scene"])) {
421 $this->add_error('target_scene_missing', '<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>');
422 }
423 if (!empty($hotspot_val["hotspot-url"]) || !empty($hotspot_val["hotspot-content"])) {
424 $this->add_error('both_url_click_content', '<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>');
425 }
426 }
427 }
428
429
430 /**
431 * Hotspot URL error control and validation
432 *
433 * @param array $hotspot_val
434 * @param string $scene_id_validate
435 * @param string $hotspot_title_validate
436 *
437 * @return void
438 * @since 8.0.0
439 */
440 private function hotspot_url_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
441 {
442 $hotspot_url_validate = $hotspot_val["hotspot-url"];
443 if (!empty($hotspot_url_validate)) {
444 $hotspot_url_validated = esc_url($hotspot_url_validate);
445 if ($hotspot_url_validated != $hotspot_url_validate) {
446 $this->add_error('invalid_hotspot_url', '<p><span>Warning:</span> Hotspot Url is invalid where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
447 }
448 }
449 }
450
451
452 /**
453 * Hotspot Shortcode error control and validation
454 *
455 * @param array $hotspot_val
456 * @param string $scene_id_validate
457 * @param string $hotspot_title_validate
458 *
459 * @return void
460 * @since 8.0.0
461 */
462 private function hotspot_shortcode_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
463 {
464 if ($hotspot_val["hotspot-type"] == "shortcode_editor") {
465 if (substr($hotspot_val['hotspot-shortcode'], 0, 1) === '[') {
466 $pattern = get_shortcode_regex();
467 preg_match('/' . $pattern . '/s', $hotspot_val['hotspot-shortcode'], $matches);
468 if (is_array($matches) && !isset($matches[2])) {
469 $this->add_error('invalid_shortcode', '<p><span>Warning:</span> This is not a valid shortcode where scene id: ' . $scene_id_validate . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
470 }
471 }
472 }
473 }
474
475 /**
476 * Hotspot custom icon error control and validation
477 *
478 * @param array $hotspot_val
479 * @param string $scene_id_validate
480 * @param string $hotspot_title_validate
481 *
482 * @return void
483 * @since 8.0.0
484 */
485 private function hotspot_custom_icon_validation($hotspot_val, $scene_id_validate, $hotspot_title_validate)
486 {
487 if (is_plugin_active('wpvr-pro/wpvr-pro.php')) {
488 $status = get_option('wpvr_edd_license_status');
489 if ($status !== false && $status == 'valid') {
490 if ($hotspot_val["hotspot-customclass-pro"] != 'none' && !empty($hotspot_val["hotspot-customclass"])) {
491 $this->add_error('both_custom_icon', '<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>');
492 }
493 }
494 }
495 }
496
497
498 /**
499 * Hotspot ID error control and validation
500 *
501 * @param string $scene_id_validate
502 * @param string $hotspot_title_validate
503 *
504 * @return void
505 */
506 private function hotspot_id_validation($scene_id_validate, $hotspot_title_validate)
507 {
508 $hotspot_title_validated = preg_replace('/[^0-9a-zA-Z_]/', "", $hotspot_title_validate);
509 if ($hotspot_title_validated != $hotspot_title_validate) {
510 $this->add_error('invalid_hotspot_id', '<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 . ' and hotspot id : ' . $hotspot_title_validate . '</p>');
511 }
512 }
513
514
515 /**
516 * Duplicate hotspot error control and validation
517 *
518 * @param array $panodata
519 *
520 * @return void
521 * @since 8.0.0
522 */
523 public function duplicate_hotspot_validation($panodata)
524 {
525 foreach ($panodata["scene-list"] as $panoscenes) {
526 if (!empty($panoscenes['scene-id'])) {
527 $allhotspot = array();
528 foreach ($panoscenes["hotspot-list"] as $hotspot_val) {
529 if (!empty($hotspot_val["hotspot-title"])) {
530 array_push($allhotspot, $hotspot_val["hotspot-title"]);
531 }
532 }
533 $allhotspotcount = array_count_values($allhotspot);
534 foreach ($allhotspotcount as $key => $value) {
535 if ($value > 1) {
536 $this->add_error('duplicate_hotspot', '<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>');
537 }
538 }
539 }
540 }
541 }
542
543
544 /**
545 * Empty or no video url error control and validation
546 *
547 * @param string $videourl
548 *
549 * @return void
550 * @since 8.0.0
551 */
552 public function empty_video_validation($videourl)
553 {
554 if($videourl == ''){
555 $this->add_error('no_video', '<span class="pano-error-title">No Video Found!</span> <p>You haven\'t uploaded or set the link to a 360 degree video. Please Upload or Set a video to see the Preview.</p>');
556 }
557 }
558
559 /**
560 * Empty or no video url error control and validation
561 *
562 * @param string $videourl
563 *
564 * @return void
565 * @since 8.0.0
566 */
567 public function empty_floor_plan_image_validation($floor_plan)
568 {
569 if($floor_plan == ''){
570 $this->add_error('no_floor_plan_image', '<span class="pano-error-title">No Image Found!</span> <p>Please provide floor plan image</p>');
571 }
572 }
573
574
575 /**
576 * Add validation messages to errors array
577 *
578 * @param string $key
579 * @param string $value
580 *
581 * @return void
582 * @since 8.0.0
583 */
584 public function add_error($key, $value)
585 {
586 $this->errors[$key] = $value;
587 $this->display_errors();
588 }
589
590
591 /**
592 * Display validation message or sending back responses
593 *
594 * @return wp_send_json_error
595 * @since 8.0.0
596 */
597 private function display_errors()
598 {
599 foreach($this->errors as $error){
600 wp_send_json_error($error);
601 die();
602 }
603 }
604 }