PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 3.6.65
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v3.6.65
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.65, at app/Hooks/Ajax.php

387 lines 14.8 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_retry_api_action', function () use ($app) {
190 Acl::verify('fluentform_entries_viewer');
191 (new \FluentForm\App\Modules\Logger\DataLogger($app))->retryApiAction();
192 });
193
194 $app->addAdminAjaxAction('fluentform_delete_logs_by_ids', function () use ($app) {
195 Acl::verify('fluentform_entries_viewer');
196 (new \FluentForm\App\Modules\Logger\DataLogger($app))->deleteLogsByIds();
197 });
198
199 $app->addAdminAjaxAction('fluentform_delete_api_logs_by_ids', function () use ($app) {
200 Acl::verify('fluentform_entries_viewer');
201 (new \FluentForm\App\Modules\Logger\DataLogger($app))->deleteApiLogsByIds();
202 });
203
204 $app->addAdminAjaxAction('fluentform-reset-analytics', function () use ($app) {
205 Acl::verify('fluentform_entries_viewer');
206 (new \FluentForm\App\Modules\Form\Analytics($app))->resetFormAnalytics();
207 });
208
209
210 $app->addAdminAjaxAction('fluentform-change-entry-status', function () use ($app) {
211 Acl::verify('fluentform_entries_viewer');
212 (new \FluentForm\App\Modules\Entries\Entries())->changeEntryStatus();
213 });
214
215 $app->addAdminAjaxAction('fluentform-delete-entry', function () use ($app) {
216 Acl::verify('fluentform_entries_viewer');
217 (new \FluentForm\App\Modules\Entries\Entries())->deleteEntry();
218 });
219
220 $app->addAdminAjaxAction('fluentform-change-entry-favorites', function () use ($app) {
221 Acl::verify('fluentform_entries_viewer');
222 (new \FluentForm\App\Modules\Entries\Entries())->favoriteChange();
223 });
224
225 $app->addAdminAjaxAction('fluentform-do_entry_bulk_actions', function () use ($app) {
226 Acl::verify('fluentform_entries_viewer');
227 (new \FluentForm\App\Modules\Entries\Entries())->handleBulkAction();
228 });
229
230 $app->addAdminAjaxAction('fluentform-get-extra-form-settings', function () use ($app) {
231 Acl::verify('fluentform_forms_manager');
232 (new FluentForm\App\Modules\Form\Settings\ExtraSettings($app))->getExtraSettingNavs();
233 });
234
235 $app->addAdminAjaxAction('fluentform-get-form-settings-extra-component', function () use ($app) {
236 Acl::verify('fluentform_forms_manager');
237 (new FluentForm\App\Modules\Form\Settings\ExtraSettings($app))->getExtraSettingsComponent();
238 });
239
240 $app->addAdminAjaxAction(
241 'fluentform-get-pages',
242 function () {
243 Acl::verify('fluentform_forms_manager');
244
245 $pages = get_pages();
246 $formattedPages = [];
247
248 foreach ($pages as $index => $page) {
249 $formattedPages[] = [
250 'ID' => $page->ID,
251 'post_title' => $page->post_title,
252 'guid' => $page->guid
253 ];
254 }
255
256 wp_send_json_success([
257 'pages' => $formattedPages
258 ], 200);
259 }
260 );
261
262
263 $app->addAdminAjaxAction('fluentform_notice_action_track_yes', function () use ($app) {
264 Acl::hasAnyFormPermission();
265 (new FluentForm\App\Modules\Track\TrackModule())->sendInitialInfo();
266 });
267
268 $app->addAdminAjaxAction('fluentform_install_fluentsmtp', function () {
269 Acl::hasAnyFormPermission();
270 (new FluentForm\App\Modules\Track\SetupModule())->installPlugin('fluent-smtp');
271 });
272
273 // Export forms
274 $app->addAdminAjaxAction('fluentform-export-forms', function () use ($app) {
275 Acl::verify('fluentform_settings_manager');
276 (new \FluentForm\App\Modules\Form\Transfer($app))->export();
277 });
278
279 // Import forms
280 $app->addAdminAjaxAction('fluentform-import-forms', function () use ($app) {
281 Acl::verify('fluentform_settings_manager');
282 (new \FluentForm\App\Modules\Form\Transfer($app))->import();
283 });
284
285 $app->addAdminAjaxAction('fluentform-get-all-forms', function () use ($app) {
286 Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
287 (new \FluentForm\App\Modules\Form\Form($app))->getAllForms();
288 });
289
290 // Fetch simplified information for all predefined forms
291 $app->addAdminAjaxAction('fluentform-predefined-forms', function () use ($app) {
292 Acl::hasAnyFormPermission();
293 (new \FluentForm\App\Modules\Form\Predefined($app))->all();
294 });
295
296 // Create a form by predefined data
297 $app->addAdminAjaxAction('fluentform-predefined-create', function () use ($app) {
298 Acl::verify('fluentform_forms_manager');
299 (new \FluentForm\App\Modules\Form\Predefined($app))->create();
300 });
301
302 /**
303 * Add fluentform_submission_inserted actions for
304 * slack and mailchimp if the form was submitted.
305 */
306
307
308 // Permission settings
309 $app->addAdminAjaxAction('fluentform_get_access_roles', function () {
310 Acl::verify('fluentform_full_access');
311 $roleManager = new \FluentForm\App\Modules\Acl\RoleManager();
312 $roleManager->getRoles();
313 });
314
315 $app->addAdminAjaxAction('fluentform_set_access_roles', function () {
316 Acl::verify('fluentform_full_access');
317 $roleManager = new \FluentForm\App\Modules\Acl\RoleManager();
318 $roleManager->setRoles();
319 });
320
321
322 // General Integration Settings Here
323 $app->addAdminAjaxAction('fluentform_get_global_integration_settings', function () use ($app) {
324 Acl::verify('fluentform_settings_manager');
325 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
326 $globalIntegrationManager->getGlobalSettingsAjax();
327 });
328
329 $app->addAdminAjaxAction('fluentform_post_global_integration_settings', function () use ($app) {
330 Acl::verify('fluentform_forms_manager');
331 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
332 $globalIntegrationManager->saveGlobalSettingsAjax();
333 });
334
335 $app->addAdminAjaxAction('fluentform_get_all-general-integration-feeds', function () use ($app) {
336 Acl::verify('fluentform_forms_manager');
337 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
338 $globalIntegrationManager->getAllFormIntegrations();
339 });
340
341 $app->addAdminAjaxAction('fluentform_post_update_form_integration_status', function () use ($app) {
342 Acl::verify('fluentform_forms_manager');
343 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
344 $globalIntegrationManager->updateNotificationStatus();
345 });
346
347 $app->addAdminAjaxAction('fluentform_get_form_integration_settings', function () use ($app) {
348 Acl::verify('fluentform_forms_manager');
349 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
350 $globalIntegrationManager->getIntegrationSettings();
351 });
352 $app->addAdminAjaxAction('fluentform_post_form_integration_settings', function () use ($app) {
353 Acl::verify('fluentform_forms_manager');
354 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
355 $globalIntegrationManager->saveIntegrationSettings();
356 });
357 $app->addAdminAjaxAction('fluentform-delete-general_integration_feed', function () use ($app) {
358 Acl::verify('fluentform_forms_manager');
359 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
360 $globalIntegrationManager->deleteIntegrationFeed();
361 });
362
363 $app->addAdminAjaxAction('fluentform_get_form_integration_list', function () use ($app) {
364 Acl::verify('fluentform_forms_manager');
365 $globalIntegrationManager = new \FluentForm\App\Services\Integrations\GlobalIntegrationManager($app);
366 $globalIntegrationManager->getIntegrationList();
367 });
368
369 $app->addAdminAjaxAction('fluentform_update_modules', function () {
370 Acl::verify('fluentform_settings_manager');
371 return (new \FluentForm\App\Modules\AddOnModule())->updateAddOnsStatus();
372 });
373
374
375 /*
376 * Background Process Receiver
377 */
378
379 $app->addAdminAjaxAction('fluentform_background_process', function () {
380 $this->app['fluentFormAsyncRequest']->handleBackgroundCall();
381 });
382
383 $app->addPublicAjaxAction('fluentform_background_process', function () {
384 $this->app['fluentFormAsyncRequest']->handleBackgroundCall();
385 });
386
387