PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 1.9
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v1.9
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 2.10.2 All 137 releases
bit-form / includes / Admin / AdminAjax.php

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

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