PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.10.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.10.0
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / v1 / includes / Admin / AdminAjax.php

AdminAjax.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.10.0, at v1/includes/Admin/AdminAjax.php

842 lines 24.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Admin;
4
5 use BitCode\BitForm\Admin\Form\Template\TemplateProvider;
6 use BitCode\BitForm\Core\Database\FormEntryModel;
7 use BitCode\BitForm\Core\Form\FormHandler;
8 use BitCode\BitForm\Core\Integration\IntegrationHandler;
9 use BitCode\BitForm\Core\Integration\Integrations;
10
11 class AdminAjax
12 {
13 public function register()
14 {
15 add_action('wp_ajax_bitforms_integrations', [$this, 'integrations']);
16 add_action('wp_ajax_integration', [$this, 'integration']);
17 add_action('wp_ajax_bitforms_update_form', [$this, 'updateForm']);
18 add_action('wp_ajax_bitforms_templates', [$this, 'templates']);
19 add_action('wp_ajax_bitforms_create_new_form', [$this, 'createNewForm']);
20 add_action('wp_ajax_bitforms_get_template', [$this, 'getTemplate']);
21 add_action('wp_ajax_bitforms_change_status', [$this, 'changeFormStatus']);
22 add_action('wp_ajax_bitforms_bulk_status_change', [$this, 'changeBulkFormStatus']);
23 add_action('wp_ajax_bitforms_get_a_form', [$this, 'getAForm']);
24 add_action('wp_ajax_bitforms_bulk_delete_form', [$this, 'deleteBlukForm']);
25 add_action('wp_ajax_bitforms_bulk_delete_form_entries', [$this, 'deleteBlukFormEntries']);
26 add_action('wp_ajax_bitforms_delete_aform', [$this, 'deleteAForm']);
27 add_action('wp_ajax_bitforms_duplicate_aform', [$this, 'duplicateAForm']);
28 add_action('wp_ajax_bitforms_export_aform', [$this, 'exportAForm']);
29 add_action('wp_ajax_bitforms_import_aform', [$this, 'importAForm']);
30 add_action('wp_ajax_bitforms_get_form_entries', [$this, 'getFormEntry']);
31 add_action('wp_ajax_bitforms_duplicate_form_entries', [$this, 'duplicateFormEntry']);
32 add_action('wp_ajax_bitforms_edit_form_entry', [$this, 'editFormEntry']);
33 add_action('wp_ajax_bitforms_update_form_entry', [$this, 'updateFormEntry']);
34 add_action('wp_ajax_bitforms_get_all_form', [$this, 'getAllForms']);
35 add_action('wp_ajax_bitforms_get_all_wp_pages', [$this, 'getAllWPPages']);
36 add_action('wp_ajax_bitforms_delete_success_messsage', [$this, 'deleteSuccessMessage']);
37 add_action('wp_ajax_bitforms_delete_integration', [$this, 'deleteAIntegration']);
38 add_action('wp_ajax_bitforms_delete_workflow', [$this, 'deleteAWorkflow']);
39 add_action('wp_ajax_bitforms_delete_mailtemplate', [$this, 'deleteAMailTemplate']);
40 add_action('wp_ajax_bitforms_duplicate_mailtemplate', [$this, 'duplicateAMailTemplate']);
41 add_action('wp_ajax_bitforms_save_allForm_report_prefs', [$this, 'setAllFormsReport']);
42 add_action('wp_ajax_bitforms_save_grecaptcha', [$this, 'savegReCaptcha']);
43 add_action('wp_ajax_bitforms_form_log_history', [$this, 'getLogHistory']);
44 add_action('wp_ajax_bitforms_import_file_data', [$this, 'importFileData']);
45 add_action('wp_ajax_bitforms_filter_export_data', [$this, 'filterExportEntry']);
46 add_action('wp_ajax_bitforms_entry_status_update', [$this, 'updateEntryStatus']);
47 add_action('wp_ajax_bitforms_get_form_entry_count', [$this, 'getFormEntryLabelAndCount']);
48 add_action('wp_ajax_bitforms_save_payment_setting', [$this, 'savePaymentSettings']);
49
50 // migrate to v2
51 add_action('wp_ajax_bitforms_start_migration_to_v2', [$this, 'smartMigrationToV2']);
52 }
53
54 public function smartMigrationToV2()
55 {
56 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
57 $formHandler = FormHandler::getInstance();
58 $formHandler->admin->startMigrationProcess();
59 wp_send_json_success(
60 __('Migrated to v2', 'bit-form'),
61 200
62 );
63 } else {
64 wp_send_json_error(
65 __(
66 'Token expired',
67 'bit-form'
68 ),
69 401
70 );
71 }
72 }
73
74 /**
75 * Undocumented function
76 *
77 * @return void
78 */
79 public function integrations()
80 {
81 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
82 $testIntegration = new Integrations();
83 $allIntegrations = $testIntegration->getAllintegrations();
84 if ($allIntegrations) {
85 wp_send_json_success($allIntegrations, 200);
86 } else {
87 wp_send_json_error(
88 __('No Integration Found', 'bit-form'),
89 404
90 );
91 }
92 } else {
93 wp_send_json_error(
94 __(
95 'Token expired',
96 'bit-form'
97 ),
98 401
99 );
100 }
101 }
102
103 public function templates()
104 {
105 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
106 $templateProvider = new TemplateProvider();
107 $status = $templateProvider->getAllTemplates();
108 if (is_wp_error($status)) {
109 wp_send_json_error($status->get_error_message(), 411);
110 } else {
111 wp_send_json_success($status, 200);
112 }
113 } else {
114 wp_send_json_error(
115 __(
116 'Token expired',
117 'bit-form'
118 ),
119 401
120 );
121 }
122 }
123
124 public function getTemplate()
125 {
126 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
127 $inputJSON = file_get_contents('php://input');
128 $input = json_decode($inputJSON);
129 $formHandler = FormHandler::getInstance();
130 $status = $formHandler->admin->getTemplate($_REQUEST, $input);
131 if (is_wp_error($status)) {
132 wp_send_json_error($status->get_error_message(), 411);
133 } else {
134 wp_send_json_success($status, 200);
135 }
136 } else {
137 wp_send_json_error(
138 __(
139 'Token expired',
140 'bit-form'
141 ),
142 401
143 );
144 }
145 }
146
147 public function getAllForms()
148 {
149 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
150 $formHandler = FormHandler::getInstance();
151 $all_forms = $formHandler->admin->getAllForm();
152 if (is_wp_error($all_forms)) {
153 wp_send_json_error($all_forms->get_error_message(), 411);
154 } else {
155 wp_send_json_success($all_forms, 200);
156 }
157 } else {
158 wp_send_json_error(
159 __(
160 'Token expired',
161 'bit-form'
162 ),
163 401
164 );
165 }
166 }
167
168 public function importDataStore()
169 {
170 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
171 $inputJSON = file_get_contents('php://input');
172 $input = json_decode($inputJSON);
173 echo wp_json_encode($input);
174 die;
175 // $formHandler = FormHandler::getInstance();
176 // $status = $formHandler->admin->getFormEntryLabelAndCount($_REQUEST, $input);
177 // if (is_wp_error($status)) {
178 // wp_send_json_error($status->get_error_message(), 411);
179 // } else {
180 // wp_send_json_success($status, 200);
181 // }
182 } else {
183 wp_send_json_error(
184 __(
185 'Token expired',
186 'bit-form'
187 ),
188 401
189 );
190 }
191 }
192
193 public function savePaymentSettings()
194 {
195 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
196 $inputJSON = file_get_contents('php://input');
197 $input = json_decode($inputJSON);
198 $formHandler = FormHandler::getInstance();
199 $status = $formHandler->admin->savePaymentSetting($_REQUEST, $input);
200 if (is_wp_error($status)) {
201 wp_send_json_error($status->get_error_message(), 411);
202 } else {
203 wp_send_json_success($status, 200);
204 }
205 } else {
206 wp_send_json_error(
207 __(
208 'Token expired',
209 'bit-form'
210 ),
211 401
212 );
213 }
214 }
215
216 public function getFormEntryLabelAndCount()
217 {
218 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
219 $inputJSON = file_get_contents('php://input');
220 $input = json_decode($inputJSON);
221 $formHandler = FormHandler::getInstance();
222 $status = $formHandler->admin->getFormEntryLabelAndCount($_REQUEST, $input);
223 if (is_wp_error($status)) {
224 wp_send_json_error($status->get_error_message(), 411);
225 } else {
226 wp_send_json_success($status, 200);
227 }
228 } else {
229 wp_send_json_error(
230 __(
231 'Token expired',
232 'bit-form'
233 ),
234 401
235 );
236 }
237 }
238
239 public function getFormEntry()
240 {
241 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
242 $inputJSON = file_get_contents('php://input');
243 $input = json_decode($inputJSON);
244 $formHandler = FormHandler::getInstance();
245 $status = $formHandler->admin->getFormEntry($_REQUEST, $input);
246 if (is_wp_error($status)) {
247 wp_send_json_error($status->get_error_message(), 411);
248 } else {
249 wp_send_json_success($status, 200);
250 }
251 } else {
252 wp_send_json_error(__('Token expired', 'bit-form'), 401);
253 }
254 }
255
256 public function filterExportEntry()
257 {
258 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
259 $inputJSON = file_get_contents('php://input');
260 $input = json_decode($inputJSON);
261 $formHandler = FormHandler::getInstance();
262 $status = $formHandler->admin->getExportEntry($input->data);
263 if (is_wp_error($status)) {
264 wp_send_json_error($status->get_error_message(), 411);
265 } else {
266 wp_send_json_success($status, 200);
267 }
268 } else {
269 wp_send_json_error(__('Token expired', 'bit-form'), 401);
270 }
271 }
272
273 /**
274 * Undocumented function
275 *
276 * @return void
277 */
278 public function updateForm()
279 {
280 \ignore_user_abort();
281 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
282 $inputJSON = file_get_contents('php://input');
283 $input = json_decode($inputJSON);
284 $formHandler = FormHandler::getInstance();
285 $status = $formHandler->admin->updateForm($_REQUEST, $input);
286 if (is_wp_error($status)) {
287 wp_send_json_error($status->get_error_message(), 411);
288 } else {
289 wp_send_json_success($status, 200);
290 }
291 } else {
292 wp_send_json_error(
293 __(
294 'Token expired',
295 'bit-form'
296 ),
297 401
298 );
299 }
300 }
301
302 public function createNewForm()
303 {
304 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
305 $inputJSON = file_get_contents('php://input');
306 $input = json_decode($inputJSON);
307 $formHandler = FormHandler::getInstance();
308 $status = $formHandler->admin->createNewForm($_REQUEST, $input);
309 if (is_wp_error($status)) {
310 wp_send_json_error($status->get_error_message(), 411);
311 } else {
312 wp_send_json_success($status, 200);
313 }
314 } else {
315 wp_send_json_error(
316 __(
317 'Token expired',
318 'bit-form'
319 ),
320 401
321 );
322 }
323 }
324
325 public function updateEntryStatus()
326 {
327 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
328 $inputJSON = file_get_contents('php://input');
329 $input = json_decode($inputJSON);
330 $formId = sanitize_text_field($input->formId);
331 $entryId = sanitize_text_field($input->entryId);
332 $formEntryModel = new FormEntryModel();
333 $updatedTime = current_time('mysql');
334 $status = $formEntryModel->update(
335 [
336 'status' => 0,
337 'updated_at' => $updatedTime,
338 ],
339 [
340 'form_id' => $formId,
341 'id' => $entryId,
342 ]
343 );
344 if (is_wp_error($status)) {
345 wp_send_json_error($status->get_error_message(), 411);
346 } else {
347 wp_send_json_success(['update_at_time' => $updatedTime], 200);
348 }
349 } else {
350 wp_send_json_error(
351 __(
352 'Token expired',
353 'bit-form'
354 ),
355 401
356 );
357 }
358 }
359
360 public function changeFormStatus()
361 {
362 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
363 $inputJSON = file_get_contents('php://input');
364 $input = json_decode($inputJSON);
365 $formHandler = FormHandler::getInstance();
366 $status = $formHandler->admin->changeFormStatus($_REQUEST, $input);
367 if (is_wp_error($status)) {
368 wp_send_json_error($status->get_error_message(), 411);
369 } else {
370 wp_send_json_success($status, 200);
371 }
372 } else {
373 wp_send_json_error(
374 __(
375 'Token expired',
376 'bit-form'
377 ),
378 401
379 );
380 }
381 }
382
383 public function changeBulkFormStatus()
384 {
385 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
386 $inputJSON = file_get_contents('php://input');
387 $input = json_decode($inputJSON);
388 $formHandler = FormHandler::getInstance();
389 $status = $formHandler->admin->changeBulkFormStatus($_REQUEST, $input);
390 if (is_wp_error($status)) {
391 wp_send_json_error($status->get_error_message(), 411);
392 } else {
393 wp_send_json_success($status, 200);
394 }
395 } else {
396 wp_send_json_error(
397 __(
398 'Token expired',
399 'bit-form'
400 ),
401 401
402 );
403 }
404 }
405
406 public function getAForm()
407 {
408 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
409 $inputJSON = file_get_contents('php://input');
410 $input = json_decode($inputJSON);
411 $formHandler = FormHandler::getInstance();
412 $status = $formHandler->admin->getAForm($_REQUEST, $input);
413 if (is_wp_error($status)) {
414 wp_send_json_error($status->get_error_message(), 411);
415 } else {
416 wp_send_json_success($status, 200);
417 }
418 } else {
419 wp_send_json_error(
420 __(
421 'Token expired',
422 'bit-form'
423 ),
424 401
425 );
426 }
427 }
428
429 public function duplicateAForm()
430 {
431 \ignore_user_abort();
432 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
433 $inputJSON = file_get_contents('php://input');
434 $input = json_decode($inputJSON);
435 $formHandler = FormHandler::getInstance();
436 $status = $formHandler->admin->duplicateAForm($_REQUEST, $input);
437 if (is_wp_error($status)) {
438 wp_send_json_error($status->get_error_message(), 411);
439 } else {
440 wp_send_json_success($status, 200);
441 }
442 } else {
443 wp_send_json_error(
444 __(
445 'Token expired',
446 'bit-form'
447 ),
448 401
449 );
450 }
451 }
452
453 public function importAForm()
454 {
455 \ignore_user_abort();
456 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
457 $inputJSON = file_get_contents('php://input');
458 $input = json_decode($inputJSON);
459 $formHandler = FormHandler::getInstance();
460 $status = $formHandler->admin->importAForm($input);
461 if (is_wp_error($status)) {
462 wp_send_json_error($status->get_error_message(), 411);
463 } else {
464 wp_send_json_success($status, 200);
465 }
466 } else {
467 wp_send_json_error(
468 __(
469 'Token expired',
470 'bit-form'
471 ),
472 401
473 );
474 }
475 }
476
477 public function exportAForm()
478 {
479 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
480 $formHandler = FormHandler::getInstance();
481 $status = $formHandler->admin->exportAForm($_REQUEST);
482 if (is_wp_error($status)) {
483 wp_send_json_error($status->get_error_message(), 411);
484 }
485 } else {
486 wp_send_json_error(
487 __(
488 'Token expired',
489 'bit-form'
490 ),
491 401
492 );
493 }
494 }
495
496 public function deleteAForm()
497 {
498 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
499 $inputJSON = file_get_contents('php://input');
500 $input = json_decode($inputJSON);
501 $formHandler = FormHandler::getInstance();
502 $status = $formHandler->admin->deleteAForm($_REQUEST, $input);
503 if (is_wp_error($status)) {
504 wp_send_json_error($status->get_error_message(), 411);
505 } else {
506 wp_send_json_success($status, 200);
507 }
508 } else {
509 wp_send_json_error(
510 __(
511 'Token expired',
512 'bit-form'
513 ),
514 401
515 );
516 }
517 }
518
519 public function deleteBlukForm()
520 {
521 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
522 $inputJSON = file_get_contents('php://input');
523 $input = json_decode($inputJSON);
524 $formHandler = FormHandler::getInstance();
525 $status = $formHandler->admin->deleteBlukForm($_REQUEST, $input);
526 if (is_wp_error($status)) {
527 wp_send_json_error($status->get_error_message(), 411);
528 } else {
529 wp_send_json_success($status, 200);
530 }
531 } else {
532 wp_send_json_error(
533 __(
534 'Token expired',
535 'bit-form'
536 ),
537 401
538 );
539 }
540 }
541
542 public function deleteBlukFormEntries()
543 {
544 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
545 $inputJSON = file_get_contents('php://input');
546 $input = json_decode($inputJSON);
547 $formHandler = FormHandler::getInstance();
548 $status = $formHandler->admin->deleteBlukFormEntries($_REQUEST, $input);
549 if (is_wp_error($status)) {
550 wp_send_json_error($status->get_error_message(), 411);
551 } else {
552 wp_send_json_success($status, 200);
553 }
554 } else {
555 wp_send_json_error(
556 __(
557 'Token expired',
558 'bit-form'
559 ),
560 401
561 );
562 }
563 }
564
565 public function duplicateFormEntry()
566 {
567 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
568 $inputJSON = file_get_contents('php://input');
569 $input = json_decode($inputJSON);
570 $formHandler = FormHandler::getInstance();
571 $status = $formHandler->admin->duplicateFormEntry($_REQUEST, $input);
572 if (is_wp_error($status)) {
573 wp_send_json_error($status->get_error_message(), 411);
574 } else {
575 wp_send_json_success($status, 200);
576 }
577 } else {
578 wp_send_json_error(
579 __(
580 'Token expired',
581 'bit-form'
582 ),
583 401
584 );
585 }
586 }
587
588 public function editFormEntry()
589 {
590 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
591 $inputJSON = file_get_contents('php://input');
592 $input = json_decode($inputJSON);
593 $formHandler = FormHandler::getInstance();
594 $status = $formHandler->admin->editFormEntry($_REQUEST, $input);
595 if (is_wp_error($status)) {
596 wp_send_json_error($status->get_error_message(), 411);
597 } else {
598 wp_send_json_success($status, 200);
599 }
600 } else {
601 wp_send_json_error(
602 __(
603 'Token expired',
604 'bit-form'
605 ),
606 401
607 );
608 }
609 }
610
611 public function getLogHistory()
612 {
613 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
614 $inputJSON = file_get_contents('php://input');
615 $input = json_decode($inputJSON);
616 $formHandler = FormHandler::getInstance();
617 $status = $formHandler->admin->getLogHistory($_REQUEST, $input);
618 if (is_wp_error($status)) {
619 wp_send_json_error($status->get_error_message(), 411);
620 } else {
621 wp_send_json_success($status, 200);
622 }
623 } else {
624 wp_send_json_error(
625 __(
626 'Token expired',
627 'bit-form'
628 ),
629 401
630 );
631 }
632 }
633
634 public function updateFormEntry()
635 {
636 \ignore_user_abort();
637 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
638 $formHandler = FormHandler::getInstance();
639 $status = $formHandler->admin->updateFormEntry($_REQUEST, $_POST);
640
641 if (is_wp_error($status)) {
642 wp_send_json_error($status->get_error_message(), 411);
643 } else {
644 $status = IntegrationHandler::maybeSetCronForIntegration($status, 'update');
645 wp_send_json_success($status, 200);
646 }
647 } else {
648 wp_send_json_error(
649 __(
650 'Token expired',
651 'bit-form'
652 ),
653 401
654 );
655 }
656 }
657
658 public function getAllWPPages()
659 {
660 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
661 $inputJSON = file_get_contents('php://input');
662 $input = json_decode($inputJSON);
663 $formHandler = FormHandler::getInstance();
664 $status = $formHandler->admin->getAllWPPages($_REQUEST, $input);
665 if (is_wp_error($status)) {
666 wp_send_json_error($status->get_error_message(), 411);
667 } else {
668 wp_send_json_success($status, 200);
669 }
670 } else {
671 wp_send_json_error(
672 __(
673 'Token expired',
674 'bit-form'
675 ),
676 401
677 );
678 }
679 }
680
681 public function deleteSuccessMessage()
682 {
683 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
684 $inputJSON = file_get_contents('php://input');
685 $input = json_decode($inputJSON);
686 $formHandler = FormHandler::getInstance();
687 $status = $formHandler->admin->deleteSuccessMessage($_REQUEST, $input);
688 if (is_wp_error($status)) {
689 wp_send_json_error($status->get_error_message(), 411);
690 } else {
691 wp_send_json_success($status, 200);
692 }
693 } else {
694 wp_send_json_error(
695 __(
696 'Token expired',
697 'bit-form'
698 ),
699 401
700 );
701 }
702 }
703
704 public function deleteAIntegration()
705 {
706 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
707 $inputJSON = file_get_contents('php://input');
708 $input = json_decode($inputJSON);
709 $formHandler = FormHandler::getInstance();
710 $status = $formHandler->admin->deleteAIntegration($_REQUEST, $input);
711 if (is_wp_error($status)) {
712 wp_send_json_error($status->get_error_message(), 411);
713 } else {
714 wp_send_json_success($status, 200);
715 }
716 } else {
717 wp_send_json_error(
718 __(
719 'Token expired',
720 'bit-form'
721 ),
722 401
723 );
724 }
725 }
726
727 public function deleteAWorkflow()
728 {
729 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
730 $inputJSON = file_get_contents('php://input');
731 $input = json_decode($inputJSON);
732 $formHandler = FormHandler::getInstance();
733 $status = $formHandler->admin->deleteAWorkflow($_REQUEST, $input);
734 if (is_wp_error($status)) {
735 wp_send_json_error($status->get_error_message(), 411);
736 } else {
737 wp_send_json_success($status, 200);
738 }
739 } else {
740 wp_send_json_error(
741 __(
742 'Token expired',
743 'bit-form'
744 ),
745 401
746 );
747 }
748 }
749
750 public function deleteAMailTemplate()
751 {
752 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
753 $inputJSON = file_get_contents('php://input');
754 $input = json_decode($inputJSON);
755 $formHandler = FormHandler::getInstance();
756 $status = $formHandler->admin->deleteAMailTemplate($_REQUEST, $input);
757 if (is_wp_error($status)) {
758 wp_send_json_error($status->get_error_message(), 411);
759 } else {
760 wp_send_json_success($status, 200);
761 }
762 } else {
763 wp_send_json_error(
764 __(
765 'Token expired',
766 'bit-form'
767 ),
768 401
769 );
770 }
771 }
772
773 public function duplicateAMailTemplate()
774 {
775 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
776 $inputJSON = file_get_contents('php://input');
777 $input = json_decode($inputJSON);
778 $formHandler = FormHandler::getInstance();
779 $status = $formHandler->admin->duplicateAMailTemplate($_REQUEST, $input);
780 if (is_wp_error($status)) {
781 wp_send_json_error($status->get_error_message(), 411);
782 } else {
783 wp_send_json_success($status, 200);
784 }
785 } else {
786 wp_send_json_error(
787 __(
788 'Token expired',
789 'bit-form'
790 ),
791 401
792 );
793 }
794 }
795
796 public function setAllFormsReport()
797 {
798 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
799 $inputJSON = file_get_contents('php://input');
800 $input = json_decode($inputJSON);
801 $formHandler = FormHandler::getInstance();
802 $status = $formHandler->admin->setAllFormsReport($_REQUEST, $input);
803 if (is_wp_error($status)) {
804 wp_send_json_error($status->get_error_message(), 411);
805 } else {
806 wp_send_json_success($status, 200);
807 }
808 } else {
809 wp_send_json_error(
810 __(
811 'Token expired',
812 'bit-form'
813 ),
814 401
815 );
816 }
817 }
818
819 public function savegReCaptcha()
820 {
821 if (wp_verify_nonce(sanitize_text_field($_REQUEST['_ajax_nonce']), 'bitforms_save')) {
822 $inputJSON = file_get_contents('php://input');
823 $input = json_decode($inputJSON);
824 $formHandler = FormHandler::getInstance();
825 $status = $formHandler->admin->savegReCaptcha($_REQUEST, $input);
826 if (is_wp_error($status)) {
827 wp_send_json_error($status->get_error_message(), 411);
828 } else {
829 wp_send_json_success($status, 200);
830 }
831 } else {
832 wp_send_json_error(
833 __(
834 'Token expired',
835 'bit-form'
836 ),
837 401
838 );
839 }
840 }
841 }
842