PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.0.10
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.0.10
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
← All changes | Inc/Core/Controllers/Submissions.php +28 -69 trunk2.0.10 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 3.1.13 Free
4 + * @version 2.0.10 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2026 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2023 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core\Controllers;
@@ -52,21 +52,10 @@
52 52 * @return void
53 53 */
54 54 public function list()
55 55 {
56 - $forms = \FireBox\Core\Helpers\Form\Form::getForms();
57 - $forms = array_map(function($form) {
58 - return [
59 - 'id' => $form['id'],
60 - 'name' => $form['name']
61 - ];
62 - }, $forms);
63 - usort($forms, function($a, $b) {
64 - return strcmp(strtolower($a['name']), strtolower($b['name']));
65 - });
66 -
67 56 firebox()->renderer->admin->render('pages/submissions/list', [
68 - 'forms' => $forms
57 + 'forms' => \FireBox\Core\Helpers\Form\Form::getForms()
69 58 ]);
70 59 }
71 60
72 61 /**
@@ -75,10 +64,8 @@
75 64 * @return void
76 65 */
77 66 public function edit()
78 67 {
79 - check_admin_referer('edit-firebox-submission');
80 -
81 68 $id = isset($_GET['id']) ? sanitize_key($_GET['id']) : false;
82 69 if (!$id)
83 70 {
84 71 $this->list();
@@ -89,9 +76,9 @@
89 76 {
90 77 $this->list();
91 78 return;
92 79 }
93 -
80 +
94 81 $html = firebox()->renderer->admin->render('pages/submissions/edit', [
95 82 'submission' => $submission
96 83 ], true);
97 84
@@ -99,9 +86,9 @@
99 86 'section_name' => self::settings_name,
100 87 'button_label' => firebox()->_('FB_UPDATE_SUBMISSION')
101 88 ]);
102 89
103 - echo $form->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
90 + echo$form->render();
104 91 }
105 92
106 93 /**
107 94 * Returns current task.
@@ -109,9 +96,9 @@
109 96 * @return mixed
110 97 */
111 98 public function getTask()
112 99 {
113 - $task = isset($_GET['task']) ? sanitize_key($_GET['task']) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
100 + $task = isset($_GET['task']) ? sanitize_key($_GET['task']) : '';
114 101 $allowed_tasks = ['', 'edit'];
115 102
116 103 return in_array($task, $allowed_tasks) ? $task : false;
117 104 }
@@ -126,21 +113,21 @@
126 113 * @return void
127 114 */
128 115 public function processSubmissionEdit($input)
129 116 {
130 - // Validate nonce
131 - if (!check_admin_referer('fpf_form_nonce_firebox_submission', 'fpf_form_nonce_firebox_submission'))
132 - {
133 - return;
134 - }
135 -
136 117 // We use $_POST and $input to retrieve the submission details
137 - $data = wp_unslash($_POST);
118 + $data = $_POST;
138 119
139 120 if (!isset($data['task']) || !isset($data['form_id']) || !isset($data['fb_form']) || !isset($data['submission_id']) || !isset($data[self::settings_name]))
140 121 {
141 122 return;
142 123 }
124 +
125 + // Validate nonce
126 + if (!check_admin_referer('fpf_form_nonce_firebox_submission', 'fpf_form_nonce_firebox_submission'))
127 + {
128 + return;
129 + }
143 130
144 131 $allowed_tasks = [
145 132 'edit_submission'
146 133 ];
@@ -149,17 +136,13 @@
149 136 {
150 137 return;
151 138 }
152 139
153 - // Sanitize
154 - $submission_id = absint($data['submission_id']);
155 - $form_id = sanitize_key($data['form_id']);
156 -
157 140 // Ensure a submission record with given Submission ID and Form ID exist
158 141 $payload = [
159 142 'where' => [
160 - 'id' => ' = ' . $submission_id,
161 - 'form_id' => ' = "' . $form_id . '"'
143 + 'id' => ' = ' . esc_sql($data['submission_id']),
144 + 'form_id' => ' = "' . esc_sql($data['form_id']) . '"'
162 145 ]
163 146 ];
164 147 if (!firebox()->tables->submission->getResults($payload, true, true))
165 148 {
@@ -166,9 +149,9 @@
166 149 return;
167 150 }
168 151
169 152 // Get Form
170 - if (!$form = Form::getFormByID($form_id))
153 + if (!$form = Form::getFormByID($data['form_id']))
171 154 {
172 155 return;
173 156 }
174 157
@@ -173,28 +156,22 @@
173 156 }
174 157
175 158 $controller_settings = $data[self::settings_name];
176 159 $form_fields = $form['fields'];
177 - $fields_values = is_array($data['fb_form']) ? $data['fb_form'] : [];
160 + $fields_values = $data['fb_form'];
178 161 $submission_state = isset($controller_settings['submission_state']) ? $controller_settings['submission_state'] : 'published';
179 -
180 - // Make the form fields not required
181 - foreach ($form_fields as $key => $field)
182 - {
183 - $field->setOptionValue('required', false);
184 - }
185 -
162 +
186 163 $valid = Form::validate($form_fields, $fields_values);
187 164
188 165 if (isset($valid['error']))
189 166 {
190 - $error = firebox()->_('FB_VALIDATION_ERRORS') . ':<br /><br />';
167 + $error = 'Validation errors:<br />';
191 168 foreach ($valid['error'] as $item)
192 169 {
193 - $error .= '<div><strong>' . $item['label'] . ':</strong> ' . $item['validation_message'] . '</div>';
170 + $error .= '<p><strong>' . $item['label'] . ':</strong> ' . $item['validation_message'] . '</p>';
194 171 }
195 172
196 - \FPFramework\Libs\AdminNotice::displayError($error);
173 + add_settings_error(self::settings_name, 'validation_msg', $error, 'error');
197 174 return;
198 175 }
199 176
200 177 // Update submission
@@ -202,46 +179,28 @@
202 179 'modified_at' => gmdate('Y-m-d H:i:s'),
203 180 'state' => $submission_state === 'published' ? 1 : 0
204 181 ];
205 182 $where = [
206 - 'id' => $submission_id,
207 - 'form_id' => $form_id
183 + 'id' => $data['submission_id'],
184 + 'form_id' => $data['form_id']
208 185 ];
209 186 firebox()->tables->submission->update($replace, $where);
210 187
211 188 // Update submission meta for each field
212 - foreach ((is_array($valid) ? $valid : []) as $key => $field)
189 + foreach ($valid as $key => $field)
213 190 {
214 - $field_name = $field->getOptionValue('name');
215 - $meta_value = isset($fields_values[$field_name]) ? $fields_values[$field_name] : '';
216 -
217 - if (is_array($meta_value))
218 - {
219 - $meta_value = wp_json_encode($meta_value);
220 - }
221 -
222 191 $replace = [
223 - 'meta_value' => $meta_value,
192 + 'meta_value' => $fields_values[$field->getOptionValue('name')],
224 193 'modified_at' => gmdate('Y-m-d H:i:s')
225 194 ];
226 195 $where = [
227 - 'submission_id' => $submission_id,
196 + 'submission_id' => $data['submission_id'],
228 197 'meta_key' => $field->getOptionValue('id')
229 198 ];
230 -
231 - $updated = firebox()->tables->submissionmeta->update($replace, $where);
232 -
233 - // The submission wasn't updated, this means this field doesn't have a previous value, so add a new record.
234 - if (!$updated)
235 - {
236 - firebox()->tables->submissionmeta->insert(array_merge($where, $replace, [
237 - 'meta_type' => '',
238 - 'modified_at' => null
239 - ]));
240 - }
199 + firebox()->tables->submissionmeta->update($replace, $where);
241 200 }
242 201
243 - \FPFramework\Libs\AdminNotice::displaySuccess(firebox()->_('FB_SUBMISSION_UPDATED'));
202 + add_settings_error(self::settings_name, 'validation_msg', 'Submission updated.', 'success');
244 203 }
245 204
246 205 /**
247 206 * Load required media files