PluginProbe
The Innovative Form Builder – IvyForms / 1.5.1
The Innovative Form Builder – IvyForms v1.5.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
← All changes | backend/src/Controllers/Form/GetFormController.php +9 -18 0.6.1.1 → 1.5.1 View file →
@@ -6,13 +6,8 @@
6 6 */
7 7
8 8 namespace IvyForms\Controllers\Form;
9 9
10 -// phpcs:disable PSR1.Files.SideEffects
11 -if (!defined('ABSPATH')) {
12 - exit; // Exit if accessed directly
13 -}
14 -
15 10 use IvyForms\Common\Exceptions\ForbiddenException;
16 11 use IvyForms\Common\Exceptions\InvalidArgumentException;
17 12 use IvyForms\Common\Exceptions\NotFoundException;
18 13 use IvyForms\Common\Exceptions\QueryExecutionException;
@@ -41,10 +36,10 @@
41 36 FormService $formService,
42 37 FieldService $fieldService,
43 38 ConfirmationService $confirmationService
44 39 ) {
45 - $this->formService = $formService;
46 - $this->fieldService = $fieldService;
40 + $this->formService = $formService;
41 + $this->fieldService = $fieldService;
47 42 $this->confirmationService = $confirmationService;
48 43 }
49 44
50 45 /**
@@ -64,27 +59,23 @@
64 59 throw new InvalidArgumentException(
65 60 BackendStrings::getExceptionStrings()['invalid_request_data']
66 61 );
67 62 }
63 +
68 64 // Sanitize the input data
69 65 $formId = Sanitizer::sanitizeId($data->get_param('id'));
70 66
71 - $form = $this->formService->getFormById($formId);
72 -
73 - // Use the service to get fields with options
67 + $form = $this->formService->getFormById($formId);
74 68 $fieldsMap = $this->fieldService->getAllFieldsWithOptions($form->getId());
75 69 $form->setFields($fieldsMap);
76 70
77 - $confirmationsArr = $this->confirmationService->getConfirmationsById($formId);
71 + $defaultConfirmationId = $this->confirmationService->ensureDefaultConfirmationExists($formId);
78 72
79 - $confirmations = [];
80 -
81 - foreach ($confirmationsArr as $confirmation) {
82 - $confirmations[] = $confirmation->toArray();
83 - }
84 -
85 73 return new WP_REST_Response([
86 74 'message' => BackendStrings::getCommonStrings()['ok'],
87 - 'data' => array_merge($form->toArray(), ['confirmationId' => $confirmations[0]['id']])
75 + 'data' => array_merge($form->toArray(), [
76 + 'confirmationId' => $defaultConfirmationId,
77 + 'submissionNonce' => wp_create_nonce('ivyformsFrontSubmissionNonce_' . $formId),
78 + ]),
88 79 ], 200);
89 80 }
90 81 }