PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.22
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.22
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Hooks / Ajax.php

Ajax.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 3.6.22, at app/Hooks/Ajax.php

379 lines 14.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Add all ajax hooks
5 */
6
7 use FluentForm\App\Modules\Acl\Acl;
8
9 /**
10 * @var $app \FluentForm\Framework\Foundation\Application
11 */
12
13 $app->addPublicAjaxAction('fluentform_submit', function () use ($app) {
14 (new \FluentForm\App\Modules\Form\FormHandler($app))->onSubmit();
15 });
16
17 $app->addAdminAjaxAction('fluentform_submit', function () use ($app) {
18 (new \FluentForm\App\Modules\Form\FormHandler($app))->onSubmit();
19 });
20
21 $app->addAdminAjaxAction('fluentform-global-settings', function () use ($app) {
22 Acl::verify('fluentform_settings_manager');
23 (new \FluentForm\App\Modules\Settings\Settings($app->request))->get();
24 });
25
26 $app->addAdminAjaxAction('fluentform-global-settings-store', function () use ($app) {
27 Acl::verify('fluentform_settings_manager');
28 (new \FluentForm\App\Modules\Settings\Settings($app->request))->store();
29 });
30
31 $app->addAdminAjaxAction('fluentform-forms', function () use ($app) {
32 Acl::verify('fluentform_dashboard_access');
33 (new \FluentForm\App\Modules\Form\Form($app))->index();
34 });
35
36 $app->addAdminAjaxAction('fluentform-form-store', function () use ($app) {
37 Acl::verify('fluentform_forms_manager');
38 (new \FluentForm\App\Modules\Form\Form($app))->store();
39 });
40
41 $app->addAdminAjaxAction('fluentform-form-find', function () use ($app) {
42 Acl::verify('fluentform_forms_manager');
43 (new \FluentForm\App\Modules\Form\Form($app))->find();
44 });
45
46 $app->addAdminAjaxAction('fluentform-form-update', function () use ($app) {
47 Acl::verify('fluentform_forms_manager');
48 (new \FluentForm\App\Modules\Form\Form($app))->update();
49 });
50
51 $app->addAdminAjaxAction('fluentform-form-delete', function () use ($app) {
52 Acl::verify('fluentform_forms_manager');
53 (new \FluentForm\App\Modules\Form\Form($app))->delete();
54 });
55
56 $app->addAdminAjaxAction('fluentform-form-duplicate', function () use ($app) {
57 Acl::verify('fluentform_forms_manager');
58 (new \FluentForm\App\Modules\Form\Form($app))->duplicate();
59 });
60
61 $app->addAdminAjaxAction('fluentform_get_all_entries', function () use ($app) {
62 Acl::verify('fluentform_entries_viewer');
63 (new \FluentForm\App\Modules\Entries\Entries())->getAllFormEntries();
64 });
65
66 $app->addAdminAjaxAction('fluentform_get_all_entries_report', function () use ($app) {
67 Acl::verify('fluentform_entries_viewer');
68 (new \FluentForm\App\Modules\Entries\Entries())->getEntriesReport();
69 });
70
71 $app->addAdminAjaxAction('fluentform-form-inputs', function () use ($app) {
72 Acl::verify('fluentform_forms_manager');
73 (new \FluentForm\App\Modules\Form\Inputs($app))->index();
74 });
75
76 $app->addAdminAjaxAction('fluentform-load-editor-shortcodes', function () use ($app) {
77 Acl::verify('fluentform_forms_manager');
78 (new \FluentForm\App\Modules\Component\Component($app))->getEditorShortcodes();
79 });
80
81 $app->addAdminAjaxAction('fluentform-load-all-editor-shortcodes', function () use ($app) {
82 Acl::verify('fluentform_forms_manager');
83 (new \FluentForm\App\Modules\Component\Component($app))->getAllEditorShortcodes();
84 });
85
86 $app->addAdminAjaxAction('fluentform-settings-formSettings', function () use ($app) {
87 Acl::verify('fluentform_forms_manager');
88 (new \FluentForm\App\Modules\Form\Settings\FormSettings($app))->index();
89 });
90
91 $app->addAdminAjaxAction('fluentform-settings-general-formSettings', function () use ($app) {
92 Acl::verify('fluentform_forms_manager');
93 (new \FluentForm\App\Modules\Form\Settings\FormSettings($app))->getGeneralSettingsAjax();
94 });
95
96 $app->addAdminAjaxAction('fluentform-save-settings-general-formSettings', function () use ($app) {
97 Acl::verify('fluentform_forms_manager');
98 (new \FluentForm\App\Modules\Form\Settings\FormSettings($app))->saveGeneralSettingsAjax();
99 });
100
101 $app->addAdminAjaxAction('fluentform-settings-formSettings-store', function () use ($app) {
102 Acl::verify('fluentform_forms_manager');
103 (new \FluentForm\App\Modules\Form\Settings\FormSettings($app))->store();
104 });
105
106 $app->addAdminAjaxAction('fluentform-settings-formSettings-remove', function () use ($app) {
107 Acl::verify('fluentform_forms_manager');
108 (new \FluentForm\App\Modules\Form\Settings\FormSettings($app))->remove();
109 });
110
111 $app->addAdminAjaxAction('fluentform-get-form-custom_css_js', function () {
112 Acl::verify('fluentform_forms_manager');
113 (new \FluentForm\App\Modules\Form\Settings\FormCssJs)->getSettingsAjax();
114 });
115
116 $app->addAdminAjaxAction('fluentform-save-form-custom_css_js', function () {
117 Acl::verify('fluentform_forms_manager');
118 (new \FluentForm\App\Modules\Form\Settings\FormCssJs)->saveSettingsAjax();
119 });
120
121 $app->addAdminAjaxAction('fluentform-load-editor-components', function () use ($app) {
122 Acl::verify('fluentform_forms_manager');
123 (new \FluentForm\App\Modules\Component\Component($app))->index();
124 });
125
126 $app->addAdminAjaxAction('fluentform-form-entry-counts', function () use ($app) {
127 Acl::verify('fluentform_entries_viewer');
128 (new \FluentForm\App\Modules\Entries\Entries())->getEntriesGroup();
129 });
130
131 $app->addAdminAjaxAction('fluentform-form-entries', function () use ($app) {
132 Acl::verify('fluentform_entries_viewer');
133 (new \FluentForm\App\Modules\Entries\Entries())->getEntries();
134 });
135
136 $app->addAdminAjaxAction('fluentform-form-report', function () use ($app) {
137 $formId = intval($_REQUEST['form_id']);
138 Acl::verify('fluentform_entries_viewer', $formId);
139 (new \FluentForm\App\Modules\Entries\Report($app))->getReport($formId);
140 });
141
142 $app->addAdminAjaxAction('fluentform-form-entries-export', function () use ($app) {
143 Acl::verify('fluentform_entries_viewer');
144 (new \FluentForm\App\Modules\Entries\Export($app))->index();
145 });
146
147 $app->addAdminAjaxAction('fluentform-get-entry', function () use ($app) {
148 Acl::verify('fluentform_entries_viewer');
149 (new \FluentForm\App\Modules\Entries\Entries())->getEntry();
150 });
151
152 $app->addAdminAjaxAction('fluentform-get-entry-notes', function () use ($app) {
153 Acl::verify('fluentform_entries_viewer');
154 (new \FluentForm\App\Modules\Entries\Entries())->getNotes();
155 });
156
157 $app->addAdminAjaxAction('fluentform-add-entry-note', function () use ($app) {
158 Acl::verify('fluentform_entries_viewer');
159 (new \FluentForm\App\Modules\Entries\Entries())->addNote();
160 });
161
162 $app->addAdminAjaxAction('fluentform-get-entry-logs', function () use ($app) {
163 Acl::verify('fluentform_entries_viewer');
164 $entry_id = intval($_REQUEST['entry_id']);
165 $logType = sanitize_text_field($_REQUEST['log_type']);
166 (new \FluentForm\App\Modules\Logger\DataLogger($app))->getLogsByEntry($entry_id, $logType);
167 });
168
169 $app->addAdminAjaxAction('fluentform_get_activity_log_filters', function () use ($app) {
170 Acl::verify('fluentform_entries_viewer');
171 (new \FluentForm\App\Modules\Logger\DataLogger($app))->getLogFilters();
172 });
173
174 $app->addAdminAjaxAction('fluentform_get_activity_api_log_filters', function () use ($app) {
175 Acl::verify('fluentform_entries_viewer');
176 (new \FluentForm\App\Modules\Logger\DataLogger($app))->getApiLogFilters();
177 });
178
179 $app->addAdminAjaxAction('fluentform_get_all_logs', function () use ($app) {
180 Acl::verify('fluentform_entries_viewer');
181 (new \FluentForm\App\Modules\Logger\DataLogger($app))->getAllLogs();
182 });
183
184 $app->addAdminAjaxAction('fluentform_get_api_logs', function () use ($app) {
185 Acl::verify('fluentform_entries_viewer');
186 (new \FluentForm\App\Modules\Logger\DataLogger($app))->getApiLogs();
187 });
188
189 $app->addAdminAjaxAction('fluentform_delete_logs_by_ids', function () use ($app) {
190 Acl::verify('fluentform_entries_viewer');
191 (new \FluentForm\App\Modules\Logger\DataLogger($app))->deleteLogsByIds();
192 });
193
194 $app->addAdminAjaxAction('fluentform_delete_api_logs_by_ids', function () use ($app) {
195 Acl::verify('fluentform_entries_viewer');
196 (new \FluentForm\App\Modules\Logger\DataLogger($app))->deleteApiLogsByIds();
197 });
198
199 $app->addAdminAjaxAction('fluentform-reset-analytics', function () use ($app) {
200 Acl::verify('fluentform_entries_viewer');
201 (new \FluentForm\App\Modules\Form\Analytics($app))->resetFormAnalytics();
202 });
203
204
205 $app->addAdminAjaxAction('fluentform-change-entry-status', function () use ($app) {
206 Acl::verify('fluentform_entries_viewer');
207 (new \FluentForm\App\Modules\Entries\Entries())->changeEntryStatus();
208 });
209
210 $app->addAdminAjaxAction('fluentform-delete-entry', function () use ($app) {
211 Acl::verify('fluentform_entries_viewer');
212 (new \FluentForm\App\Modules\Entries\Entries())->deleteEntry();
213 });
214
215 $app->addAdminAjaxAction('fluentform-change-entry-favorites', function () use ($app) {
216 Acl::verify('fluentform_entries_viewer');
217 (new \FluentForm\App\Modules\Entries\Entries())->favoriteChange();
218 });
219
220 $app->addAdminAjaxAction('fluentform-do_entry_bulk_actions', function () use ($app) {
221 Acl::verify('fluentform_entries_viewer');
222 (new \FluentForm\App\Modules\Entries\Entries())->handleBulkAction();
223 });
224
225 $app->addAdminAjaxAction('fluentform-get-extra-form-settings', function () use ($app) {
226 Acl::verify('fluentform_forms_manager');
227 (new FluentForm\App\Modules\Form\Settings\ExtraSettings($app))->getExtraSettingNavs();
228 });
229
230 $app->addAdminAjaxAction('fluentform-get-form-settings-extra-component', function () use ($app) {
231 Acl::verify('fluentform_forms_manager');
232 (new FluentForm\App\Modules\Form\Settings\ExtraSettings($app))->getExtraSettingsComponent();
233 });
234
235 $app->addAdminAjaxAction(
236 'fluentform-get-pages',
237 function () {
238 Acl::verify('fluentform_forms_manager');
239
240 $pages = get_pages();
241 $formattedPages = [];
242
243 foreach ($pages as $index => $page) {
244 $formattedPages[] = [
245 'ID' => $page->ID,
246 'post_title' => $page->post_title,
247 'guid' => $page->guid
248 ];
249 }
250
251 wp_send_json_success([
252 'pages' => $formattedPages
253 ], 200);
254 }
255 );
256
257
258 $app->addAdminAjaxAction('fluentform_notice_action_track_yes', function () use ($app) {
259 Acl::hasAnyFormPermission();
260 (new FluentForm\App\Modules\Track\TrackModule())->sendInitialInfo();
261 });
262
263 // Export forms
264 $app->addAdminAjaxAction('fluentform-export-forms', function () use ($app) {
265 Acl::verify('fluentform_settings_manager');
266 (new \FluentForm\App\Modules\Form\Transfer($app))->export();
267 });
268
269 // Import forms
270 $app->addAdminAjaxAction('fluentform-import-forms', function () use ($app) {
271 Acl::verify('fluentform_settings_manager');
272 (new \FluentForm\App\Modules\Form\Transfer($app))->import();
273 });
274
275 $app->addAdminAjaxAction('fluentform-get-all-forms', function () use ($app) {
276 Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
277 (new \FluentForm\App\Modules\Form\Form($app))->getAllForms();
278 });
279
280 // Fetch simplified information for all predefined forms
281 $app->addAdminAjaxAction('fluentform-predefined-forms', function () use ($app) {
282 Acl::hasAnyFormPermission();
283 (new \FluentForm\App\Modules\Form\Predefined($app))->all();
284 });
285
286 // Create a form by predefined data
287 $app->addAdminAjaxAction('fluentform-predefined-create', function () use ($app) {
288 Acl::verify('fluentform_forms_manager');
289 (new \FluentForm\App\Modules\Form\Predefined($app))->create();
290 });
291
292 /**
293 * Add fluentform_submission_inserted actions for
294 * slack and mailchimp if the form was submitted.
295 */
296
297 (new FluentForm\App\Services\Integrations\Slack\SlackNotificationActions($app))->register();
298
299
300 // Permission settings
301 $app->addAdminAjaxAction('fluentform_get_access_roles', function () {
302 Acl::verify('fluentform_full_access');
303 $roleManager = new \FluentForm\App\Modules\Acl\RoleManager();
304 $roleManager->getRoles();
305 });
306
307 $app->addAdminAjaxAction('fluentform_set_access_roles', function () {
308 Acl::verify('fluentform_full_access');
309 $roleManager = new \FluentForm\App\Modules\Acl\RoleManager();
310 $roleManager->setRoles();
311 });
312
313
314 // General Integration Settings Here
315 $app->addAdminAjaxAction('fluentform_get_global_integration_settings', function () use ($app) {
316 Acl::verify('fluentform_settings_manager');
317 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
318 $globalIntegrationManager->getGlobalSettingsAjax();
319 });
320
321 $app->addAdminAjaxAction('fluentform_post_global_integration_settings', function () use ($app) {
322 Acl::verify('fluentform_forms_manager');
323 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
324 $globalIntegrationManager->saveGlobalSettingsAjax();
325 });
326
327 $app->addAdminAjaxAction('fluentform_get_all-general-integration-feeds', function () use ($app) {
328 Acl::verify('fluentform_forms_manager');
329 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
330 $globalIntegrationManager->getAllFormIntegrations();
331 });
332
333 $app->addAdminAjaxAction('fluentform_post_update_form_integration_status', function () use ($app) {
334 Acl::verify('fluentform_forms_manager');
335 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
336 $globalIntegrationManager->updateNotificationStatus();
337 });
338
339 $app->addAdminAjaxAction('fluentform_get_form_integration_settings', function () use ($app) {
340 Acl::verify('fluentform_forms_manager');
341 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
342 $globalIntegrationManager->getIntegrationSettings();
343 });
344 $app->addAdminAjaxAction('fluentform_post_form_integration_settings', function () use ($app) {
345 Acl::verify('fluentform_forms_manager');
346 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
347 $globalIntegrationManager->saveIntegrationSettings();
348 });
349 $app->addAdminAjaxAction('fluentform-delete-general_integration_feed', function () use ($app) {
350 Acl::verify('fluentform_forms_manager');
351 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
352 $globalIntegrationManager->deleteIntegrationFeed();
353 });
354
355 $app->addAdminAjaxAction('fluentform_get_form_integration_list', function () use ($app) {
356 Acl::verify('fluentform_forms_manager');
357 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
358 $globalIntegrationManager->getIntegrationList();
359 });
360
361 $app->addAdminAjaxAction('fluentform_update_modules', function () {
362 Acl::verify('fluentform_settings_manager');
363 return (new \FluentForm\App\Modules\AddOnModule())->updateAddOnsStatus();
364 });
365
366
367 /*
368 * Background Process Receiver
369 */
370
371 $app->addAdminAjaxAction('fluentform_background_process', function () {
372 $this->app['fluentFormAsyncRequest']->handleBackgroundCall();
373 });
374
375 $app->addPublicAjaxAction('fluentform_background_process', function () {
376 $this->app['fluentFormAsyncRequest']->handleBackgroundCall();
377 });
378
379