PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.3
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.3
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 / Modules / Registerer / Menu.php

Menu.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.3, at app/Modules/Registerer/Menu.php

1,273 lines 54.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Modules\Registerer;
4
5 defined('ABSPATH') or die;
6
7 use FluentForm\App\Helpers\Helper;
8 use FluentForm\App\Hooks\Handlers\ActivationHandler;
9 use FluentForm\App\Modules\Acl\Acl;
10 use FluentForm\App\Modules\AddOnModule;
11 use FluentForm\App\Modules\DocumentationModule;
12 use FluentForm\App\Modules\Payments\PaymentHelper;
13 use FluentForm\App\Services\FluentConversational\Classes\Converter\Converter;
14 use FluentForm\App\Services\Form\Fields;
15 use FluentForm\App\Services\Manager\FormManagerService;
16 use FluentForm\Framework\Foundation\Application;
17 use FluentForm\Framework\Helpers\ArrayHelper;
18
19 class Menu
20 {
21 /**
22 * App instance
23 *
24 * @var \FluentForm\Framework\Foundation\Application
25 */
26 protected $app;
27
28 /**
29 * Menu constructor.
30 *
31 * @param \FluentForm\Framework\Foundation\Application $application
32 */
33 public function __construct(Application $application)
34 {
35 $this->app = $application;
36
37 $this->app->addFilter('fluentform/form_settings_menu', [
38 $this, 'filterFormSettingsMenu',
39 ], 10, 2);
40 }
41
42 public function reisterScripts()
43 {
44 if (!$this->isFluentPages()) {
45 return;
46 }
47
48 $app = $this->app;
49
50 wp_register_script(
51 'fluent_forms_global',
52 fluentFormMix('js/fluent_forms_global.js'),
53 ['jquery'],
54 FLUENTFORM_VERSION,
55 true
56 );
57
58 $settingsGlobalStyle = fluentFormMix('css/settings_global.css');
59 $allFormsStyle = fluentFormMix('css/fluent-all-forms.css');
60 $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass.css');
61 $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin.css');
62 $addOnsCss = fluentFormMix('css/add-ons.css');
63 $adminDocCss = fluentFormMix('css/admin_docs.css');
64 $reportsCss = fluentFormMix('css/fluent-forms-reports.css');
65 if (is_rtl()) {
66 $settingsGlobalStyle = fluentFormMix('css/settings_global_rtl.css');
67 $allFormsStyle = fluentFormMix('css/fluent-all-forms-rtl.css');
68 $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass-rtl.css');
69 $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin-rtl.css');
70 $addOnsCss = fluentFormMix('css/add-ons-rtl.css');
71 $adminDocCss = fluentFormMix('css/admin_docs_rtl.css');
72 $reportsCss = fluentFormMix('css/fluent-forms-reports-rtl.css');
73 }
74
75 wp_register_style(
76 'fluentform_settings_global',
77 $settingsGlobalStyle,
78 [],
79 FLUENTFORM_VERSION,
80 'all'
81 );
82
83 wp_register_script(
84 'clipboard',
85 fluentFormMix('libs/clipboard.min.js'),
86 [],
87 FLUENTFORM_VERSION,
88 true
89 );
90
91 wp_register_script(
92 'copier',
93 fluentFormMix('js/copier.js'),
94 [],
95 FLUENTFORM_VERSION,
96 true
97 );
98
99 wp_register_script(
100 'fluentform_form_settings',
101 fluentFormMix('js/form_settings_app.js'),
102 ['jquery'],
103 FLUENTFORM_VERSION,
104 true
105 );
106
107 wp_register_script(
108 'fluent_all_forms',
109 fluentFormMix('js/fluent-all-forms-admin.js'),
110 ['jquery'],
111 FLUENTFORM_VERSION,
112 true
113 );
114
115 wp_register_style(
116 'fluent_all_forms',
117 $allFormsStyle,
118 [],
119 FLUENTFORM_VERSION,
120 'all'
121 );
122
123 wp_register_script(
124 'fluentform_editor_script',
125 fluentFormMix('js/fluent-forms-editor.js'),
126 ['jquery'],
127 FLUENTFORM_VERSION,
128 true
129 );
130
131
132 wp_register_style(
133 'fluentform_editor_style',
134 $fluentFormAdminEditorStyles,
135 [],
136 FLUENTFORM_VERSION,
137 'all'
138 );
139
140 wp_register_style(
141 'fluentform_editor_sass',
142 $fluentFormAdminCSS,
143 [],
144 FLUENTFORM_VERSION,
145 'all'
146 );
147
148 wp_register_script(
149 'fluentform-transfer-js',
150 fluentFormMix('js/fluentform-transfer.js'),
151 ['jquery'],
152 FLUENTFORM_VERSION,
153 true
154 );
155
156 wp_register_script(
157 'fluentform-global-settings-js',
158 fluentFormMix('js/fluentform-global-settings.js'),
159 ['jquery'],
160 FLUENTFORM_VERSION,
161 true
162 );
163
164 wp_register_script(
165 'fluentform-modules',
166 fluentFormMix('js/modules.js'),
167 ['jquery'],
168 FLUENTFORM_VERSION,
169 true
170 );
171
172 wp_register_script(
173 'fluentform-docs',
174 fluentFormMix('js/docs.js'),
175 ['jquery'],
176 FLUENTFORM_VERSION,
177 true
178 );
179
180 wp_register_script(
181 'fluentform_form_entries',
182 fluentFormMix('js/form_entries.js'),
183 ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
184 FLUENTFORM_VERSION,
185 true
186 );
187
188 wp_register_script(
189 'fluentform_reports',
190 fluentFormMix('js/reports.js'),
191 ['jquery'],
192 FLUENTFORM_VERSION,
193 true
194 );
195
196 wp_register_style(
197 'fluentform_reports',
198 $reportsCss,
199 [],
200 FLUENTFORM_VERSION,
201 'all'
202 );
203
204 wp_register_script(
205 'fluentform_all_entries',
206 fluentFormMix('js/all_entries.js'),
207 ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
208 FLUENTFORM_VERSION,
209 true
210 );
211
212 wp_register_script(
213 'fluentform_chart_js',
214 fluentFormMix('libs/chartjs/chart.min.js'),
215 [],
216 FLUENTFORM_VERSION,
217 true
218 );
219
220 wp_register_script(
221 'fluentform_vue_chart_js',
222 fluentFormMix('libs/chartjs/vue-chartjs.min.js'),
223 [],
224 FLUENTFORM_VERSION,
225 true
226 );
227
228 wp_register_style(
229 'fluentform-add-ons',
230 $addOnsCss,
231 [],
232 FLUENTFORM_VERSION,
233 'all'
234 );
235
236 wp_register_style(
237 'fluentform_doc_style',
238 $adminDocCss,
239 [],
240 FLUENTFORM_VERSION,
241 'all'
242 );
243
244 add_filter('admin_footer_text', function ($text) {
245 return '<span id="footer-thankyou">If you like the plugin please rate Fluent Forms <a target="_blank" rel="nofollow" href="https://wordpress.org/support/plugin/fluentform/reviews/#new-post">�
246
247
248
249
250 </a> on <a target="_blank" rel="nofollow" href="https://wordpress.org/support/plugin/fluentform/reviews/#new-post">WordPress.org</a> to help us spread the word from the Fluent Forms team. </span>';
251 });
252
253 add_filter('update_footer', function ($text) {
254 $footerContent = 'Version ' . FLUENTFORM_VERSION;
255 if (defined('FLUENTFORMPRO')) {
256 $footerContent .= ' & Pro ' . FLUENTFORMPRO_VERSION;
257 }
258 return $footerContent;
259 });
260
261 $elementUIStyle = fluentFormMix('css/element-ui-css.css');
262 if (is_rtl()) {
263 $elementUIStyle = fluentFormMix('css/element-ui-css-rtl.css');
264 }
265 wp_enqueue_style(
266 'fluentform_global_elements',
267 $elementUIStyle,
268 [],
269 FLUENTFORM_VERSION,
270 'all'
271 );
272 }
273
274 public function isFluentPages()
275 {
276 return Helper::isFluentAdminPage();
277 }
278
279 public function enqueuePageScripts()
280 {
281 if (!$this->isFluentPages()) {
282 return;
283 }
284
285 $forms = wpFluent()->table('fluentform_forms')
286 ->orderBy('id', 'desc')
287 ->select(['id', 'title'])
288 ->get();
289
290 wp_enqueue_script('fluent_forms_global');
291
292 // Check if default style is enabled
293 $defaultTemplate = get_option('_fluentform_default_style_template');
294 $hasDefaultStyle = false;
295 if ($defaultTemplate && is_array($defaultTemplate)) {
296 $hasDefaultStyle = \FluentForm\Framework\Helpers\ArrayHelper::get($defaultTemplate, 'enabled') === 'yes';
297 }
298
299 $globalVars = [
300 'ajaxurl' => Helper::getAjaxUrl(),
301 'admin_i18n' => TranslationString::getAdminI18n(),
302 'global_search_active' => apply_filters('fluentform/global_search_active', 'yes'),
303 'payments_str' => TranslationString::getPaymentsI18n(),
304 'permissions' => Acl::getCurrentUserPermissions(),
305 'rest' => Helper::getRestInfo(),
306 'card_brands' => [
307 'visa' => fluentformMix('img/card-brand/visa.jpg'),
308 'paypal' => fluentformMix('img/card-brand/paypal.jpg'),
309 'mastercard' => fluentformMix('img/card-brand/mastercard.jpg'),
310 'amex' => fluentformMix('img/card-brand/amex.jpg')
311 ],
312 'payment_icons' => [
313 'offline' => fluentformMix('img/payment/offline.png'),
314 'mollie' => fluentformMix('img/payment/mollie.png'),
315 'paypal' => fluentformMix('img/payment/paypal.png'),
316 'stripe' => fluentformMix('img/payment/stripe.png')
317 ],
318 'forms' => $forms,
319 'hasPro' => defined('FLUENTFORMPRO'),
320 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
321 'disable_time_diff' => Helper::isDefaultWPDateEnabled(),
322 'wp_date_time_format' => Helper::getDefaultDateTimeFormatForMoment(),
323 'server_time' => current_time('mysql'),
324 'has_default_style' => $hasDefaultStyle,
325 ];
326
327 if (Acl::hasAnyFormPermission()) {
328 $globalVars['fluent_forms_admin_nonce'] = wp_create_nonce('fluent_forms_admin_nonce');
329 }
330
331 wp_localize_script('fluent_forms_global', 'fluent_forms_global_var', $globalVars);
332
333 $page = sanitize_text_field($this->app->request->get('page'));
334 $route = sanitize_text_field($this->app->request->get('route'));
335 $formId = intval($this->app->request->get('form_id'));
336
337 if ('fluent_forms' == $page && $route && $formId) {
338 if (true) {
339 wp_enqueue_style('fluentform_settings_global');
340 wp_enqueue_script('clipboard');
341 wp_enqueue_script('copier');
342
343 if (Acl::hasPermission('fluentform_forms_manager', $formId)) {
344 if ('settings' == $route) {
345 if (function_exists('wp_enqueue_editor')) {
346 add_filter('user_can_richedit', function ($status) {
347 return true;
348 });
349
350 wp_enqueue_editor();
351 wp_enqueue_media();
352 }
353 do_action('fluentform/loading_settings_assets', $formId);
354 wp_enqueue_script('fluentform_form_settings');
355 } elseif ('editor' == $route) {
356 $this->enqueueEditorAssets();
357 }
358 }
359 }
360 } elseif ('fluent_forms' == $page) {
361 wp_enqueue_script('fluent_all_forms');
362 wp_enqueue_style('fluent_all_forms');
363 }elseif ('fluent_forms_transfer' == $page) {
364 wp_enqueue_style('fluentform_settings_global');
365 wp_enqueue_script('fluentform-transfer-js');
366 } elseif (
367 'fluent_forms_settings' == $page ||
368 'fluent_forms_payment_entries' == $page ||
369 'fluent_forms_all_entries' == $page
370 ) {
371 wp_enqueue_style('fluentform_settings_global');
372 } elseif ('fluent_forms_add_ons' == $page) {
373 wp_enqueue_style('fluentform-add-ons');
374 } elseif ('fluent_forms_docs' == $page) {
375 wp_enqueue_style('fluentform_doc_style');
376 }
377 }
378
379 /**
380 * Register menu and sub-menus.
381 */
382 public function register()
383 {
384 $dashBoardCapability = apply_filters_deprecated(
385 'fluentform_dashboard_capability',
386 [
387 'fluentform_dashboard_access'
388 ],
389 FLUENTFORM_FRAMEWORK_UPGRADE,
390 'fluentform/dashboard_capability',
391 'Use fluentform/dashboard_capability instead of fluentform_dashboard_capability.'
392 );
393
394 $dashBoardCapability = $this->app->applyFilters(
395 'fluentform/dashboard_capability',
396 $dashBoardCapability
397 );
398
399 $settingManager = apply_filters_deprecated(
400 'fluentform_settings_capability',
401 [
402 'fluentform_settings_manager'
403 ],
404 FLUENTFORM_FRAMEWORK_UPGRADE,
405 'fluentform/settings_capability',
406 'Use fluentform/settings_capability instead of fluentform_settings_capability.'
407 );
408
409 $settingsCapability = $this->app->applyFilters(
410 'fluentform/settings_capability',
411 $settingManager
412 );
413
414 $fromRole = false;
415 if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
416 $currentUserCapability = Acl::getCurrentUserCapability();
417
418 if (!$currentUserCapability) {
419 return;
420 } else {
421 $fromRole = true;
422 $dashBoardCapability = $settingsCapability = $currentUserCapability;
423 }
424 }
425
426 if (Acl::isSuperMan()) {
427 $fromRole = true;
428 }
429
430 if (defined('FLUENTFORMPRO')) {
431 $title = __('Fluent Forms Pro', 'fluentform');
432 } else {
433 $title = __('Fluent Forms', 'fluentform');
434 }
435
436 $menuPriority = 25;
437
438 if (defined('FLUENTCRM')) {
439 $menuPriority = 3;
440 }
441
442 add_menu_page(
443 $title,
444 $title,
445 $dashBoardCapability,
446 'fluent_forms',
447 [$this, 'renderFormAdminRoute'],
448 $this->getMenuIcon(),
449 $menuPriority
450 );
451
452 add_submenu_page(
453 'fluent_forms',
454 __('Forms', 'fluentform'),
455 __('Forms', 'fluentform'),
456 $dashBoardCapability,
457 'fluent_forms',
458 [$this, 'renderFormAdminRoute']
459 );
460
461 if ($settingsCapability) {
462 add_submenu_page(
463 'fluent_forms',
464 __('New Form', 'fluentform'),
465 __('New Form', 'fluentform'),
466 $fromRole ? $settingsCapability : 'fluentform_forms_manager',
467 'fluent_forms#add=1',
468 [$this, 'renderAddNewFormRoute']
469 );
470
471 $entriesTitle = __('Entries', 'fluentform');
472
473 if (Helper::isFluentAdminPage()) {
474 $allowForms = FormManagerService::getUserAllowedFormsScope();
475 $entriesCount = wpFluent()->table('fluentform_submissions')
476 ->where('status', 'unread')
477 ->when(false !== $allowForms, function ($q) use ($allowForms){
478 return $q->whereIn('form_id', $allowForms ?: [0]);
479 })
480 ->count();
481
482 if ($entriesCount) {
483 $entriesTitle .= ' <span class="ff_unread_count" style="background: #197efb;color: white;border-radius: 8px;padding: 1px 8px;">' . $entriesCount . '</span>';
484 }
485 }
486
487 // Register entries intermediary page
488 add_submenu_page(
489 'fluent_forms',
490 $entriesTitle,
491 $entriesTitle,
492 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
493 'fluent_forms_all_entries',
494 [$this, 'renderAllEntriesAdminRoute']
495 );
496
497 // Register Reports sub menu page.
498 add_submenu_page(
499 'fluent_forms',
500 __('Reports', 'fluentform'),
501 __('Reports', 'fluentform'),
502 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
503 'fluent_forms_reports',
504 [$this, 'renderReports']
505 );
506
507 $isShowPaymentSubmission = apply_filters_deprecated(
508 'fluentform_show_payment_entries',
509 [
510 false
511 ],
512 FLUENTFORM_FRAMEWORK_UPGRADE,
513 'fluentform/show_payment_entries',
514 'Use fluentform/show_payment_entries instead of fluentform_show_payment_entries.'
515 );
516
517 if (apply_filters('fluentform/show_payment_entries', $isShowPaymentSubmission)) {
518 add_submenu_page(
519 'fluent_forms',
520 __('Payments', 'fluentform'),
521 __('Payments', 'fluentform'),
522 $fromRole ? $settingsCapability : 'fluentform_view_payments',
523 'fluent_forms_payment_entries',
524 [$this, 'renderPaymentEntries']
525 );
526 }
527
528 // Register global settings sub menu page.
529 add_submenu_page(
530 'fluent_forms',
531 __('Global Settings', 'fluentform'),
532 __('Global Settings', 'fluentform'),
533 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
534 'fluent_forms_settings',
535 [$this, 'renderGlobalSettings']
536 );
537
538 // Register import/export sub menu page.
539 add_submenu_page(
540 'fluent_forms',
541 __('Tools', 'fluentform'),
542 __('Tools', 'fluentform'),
543 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
544 'fluent_forms_transfer',
545 [$this, 'renderTransfer']
546 );
547
548 // Register Add-Ons
549 add_submenu_page(
550 'fluent_forms',
551 __('Integrations', 'fluentform'),
552 __('Integrations', 'fluentform'),
553 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
554 'fluent_forms_add_ons',
555 [$this, 'renderAddOns']
556 );
557 }
558
559 // Register Documentation
560 add_submenu_page(
561 'fluent_forms',
562 __('Support', 'fluentform'),
563 __('Support', 'fluentform'),
564 $dashBoardCapability,
565 'fluent_forms_docs',
566 [$this, 'renderDocs']
567 );
568
569 $this->commonAction();
570 }
571
572 private function getMenuIcon()
573 {
574 return 'data:image/svg+xml;base64,' . base64_encode('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><defs><style>.cls-1{fill:#fff;}</style></defs><title>dashboard_icon</title><g id="Layer_2" data-name="Layer 2"><g id="Layer_1-2" data-name="Layer 1"><path class="cls-1" d="M15.57,0H4.43A4.43,4.43,0,0,0,0,4.43V15.57A4.43,4.43,0,0,0,4.43,20H15.57A4.43,4.43,0,0,0,20,15.57V4.43A4.43,4.43,0,0,0,15.57,0ZM12.82,14a2.36,2.36,0,0,1-1.66.68H6.5A2.31,2.31,0,0,1,7.18,13a2.36,2.36,0,0,1,1.66-.68l4.66,0A2.34,2.34,0,0,1,12.82,14Zm3.3-3.46a2.36,2.36,0,0,1-1.66.68H3.21a2.25,2.25,0,0,1,.68-1.64,2.36,2.36,0,0,1,1.66-.68H16.79A2.25,2.25,0,0,1,16.12,10.53Zm0-3.73a2.36,2.36,0,0,1-1.66.68H3.21a2.25,2.25,0,0,1,.68-1.64,2.36,2.36,0,0,1,1.66-.68H16.79A2.25,2.25,0,0,1,16.12,6.81Z"/></g></g></svg>');
575 }
576
577 public function renderFormAdminRoute()
578 {
579 $formId = intval($this->app->request->get('form_id'));
580 $route = sanitize_key($this->app->request->get('route'));
581
582 if ($route && $formId) {
583 $formRoutePermissionSet = apply_filters('fluentform/form_inner_route_permission_set', [
584 'editor' => 'fluentform_forms_manager',
585 'settings' => 'fluentform_forms_manager',
586 'entries' => 'fluentform_entries_viewer',
587 'reports' => 'fluentform_entries_viewer',
588 ]);
589
590 $toVerifyPermission = ArrayHelper::get(
591 $formRoutePermissionSet,
592 $route,
593 'fluentform_forms_manager'
594 );
595
596 $hasPermission = apply_filters(
597 'fluentform/inner_route_has_permission',
598 Acl::hasPermission($toVerifyPermission, $formId),
599 $route,
600 $formId
601 );
602
603 if ($hasPermission) {
604 return $this->renderFormInnerPages();
605 } else {
606 return $this->app->view->render('admin.no_permission');
607 }
608 }
609
610 $this->renderForms();
611 }
612
613 public function renderAllEntriesAdminRoute()
614 {
615 wp_enqueue_script('fluentform_all_entries');
616 $this->app->view->render('admin.all_entries', []);
617 }
618
619 public function renderFormInnerPages()
620 {
621 $form_id = intval($this->app->request->get('form_id'));
622
623 $form = wpFluent()->table('fluentform_forms')->find($form_id);
624
625 if (!$form) {
626 echo '<h2>' . esc_html__('No form found', 'fluentform') . '</h2>';
627 return;
628 }
629
630 $formAdminMenus = [];
631
632 if (Acl::hasPermission('fluentform_forms_manager', $form_id)) {
633 $formAdminMenus = [
634 'editor' => [
635 'slug' => 'editor',
636 'title' => __('Editor', 'fluentform'),
637 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor'),
638 ],
639 'settings' => [
640 'slug' => 'settings',
641 'hash' => 'basic_settings',
642 'title' => __('Settings & Integrations', 'fluentform'),
643 'sub_route' => 'form_settings',
644 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings'),
645 ],
646 ];
647 }
648
649 if (Acl::hasPermission('fluentform_entries_viewer', $form_id)) {
650 $formAdminMenus['entries'] = [
651 'slug' => 'entries',
652 'hash' => '/',
653 'title' => __('Entries', 'fluentform'),
654 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries'),
655 ];
656 }
657
658 $formAdminMenus = apply_filters_deprecated(
659 'fluentform_form_admin_menu',
660 [
661 $formAdminMenus,
662 $form_id,
663 $form
664 ],
665 FLUENTFORM_FRAMEWORK_UPGRADE,
666 'fluentform/form_admin_menu',
667 'Use fluentform/form_admin_menu instead of fluentform_form_admin_menu.'
668 );
669
670 $formAdminMenus = apply_filters('fluentform/form_admin_menu', $formAdminMenus, $form_id, $form);
671
672 $route = sanitize_key($this->app->request->get('route'));
673
674 $this->app->view->render('admin.form.form_wrapper', [
675 'route' => $route,
676 'form_id' => $form_id,
677 'form' => $form,
678 'menu_items' => $formAdminMenus,
679 ]);
680 }
681
682 public function renderSettings($form_id)
683 {
684 $settingsMenus = [
685 'form_settings' => [
686 'title' => __('Form Settings', 'fluentform'),
687 'slug' => 'form_settings',
688 'hash' => 'basic_settings',
689 'route' => '/',
690 ],
691 'email_notifications' => [
692 'title' => __('Email Notifications', 'fluentform'),
693 'slug' => 'form_settings',
694 'hash' => 'email_notifications',
695 'route' => '/email-settings',
696 ],
697 'conditional_confirmations' => [
698 'title' => __('Conditional Confirmations', 'fluentform'),
699 'slug' => 'form_settings',
700 'hash' => 'conditional_confirmations',
701 'route' => '/conditional-confirmations',
702 ],
703 'all_integrations' => [
704 'title' => __('Configure Integrations', 'fluentform'),
705 'slug' => 'form_settings',
706 'route' => '/all-integrations',
707 ],
708 ];
709
710 if (Helper::isSlackEnabled()) {
711 $settingsMenus['slack'] = [
712 'title' => __('Slack', 'fluentform'),
713 'slug' => 'form_settings',
714 'hash' => 'slack',
715 'route' => '/slack',
716 ];
717 }
718
719 $settingsMenus = apply_filters_deprecated('fluentform_form_settings_menu', [
720 $settingsMenus,
721 $form_id
722 ],
723 FLUENTFORM_FRAMEWORK_UPGRADE,
724 'fluentform/form_settings_menu',
725 'Use fluentform/form_settings_menu instead of fluentform_form_settings_menu.'
726 );
727
728 $settingsMenus = apply_filters('fluentform/form_settings_menu', $settingsMenus, $form_id);
729
730 $externalMenuItems = [];
731 foreach ($settingsMenus as $key => $menu) {
732 if (empty($menu['hash'])) {
733 unset($settingsMenus[$key]);
734 $externalMenuItems[$key] = $menu;
735 }
736 }
737
738 $settingsMenus['custom_css_js'] = [
739 'title' => __('Custom CSS/JS', 'fluentform'),
740 'slug' => 'form_settings',
741 'hash' => 'custom_css_js',
742 'route' => '/custom-css-js',
743 ];
744
745 $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
746
747 $currentRoute = sanitize_key($this->app->request->get('sub_route', ''));
748
749 $hasDoubleOptinEnable = 'yes' === ArrayHelper::get(get_option('_fluentform_double_optin_settings'), 'enabled');
750
751 $this->app->view->render('admin.form.settings_wrapper', [
752 'form_id' => $form_id,
753 'settings_menus' => $settingsMenus,
754 'current_sub_route' => $currentRoute,
755 'has_double_opt_in' => $hasDoubleOptinEnable
756 ]);
757 }
758
759 /**
760 * Remove the inactive addOn menu items
761 *
762 * @param string $addOn
763 *
764 * @return boolean
765 */
766 public function filterFormSettingsMenu($settingsMenus, $form_id)
767 {
768 if (array_key_exists('mailchimp_integration', $settingsMenus)) {
769 $option = (array) get_option('_fluentform_mailchimp_details');
770 if (!isset($option['status']) || !$option['status']) {
771 unset($settingsMenus['mailchimp_integration']);
772 }
773 }
774
775 return $settingsMenus;
776 }
777
778 public function renderFormSettings($form_id)
779 {
780 wp_localize_script('fluentform_form_settings', 'FluentFormApp', [
781 'form_id' => $form_id,
782 'plugin' => $this->app->config->get('app.slug'),
783 'hasPro' => defined('FLUENTFORMPRO'),
784 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
785 'hasFluentCRM' => defined('FLUENTCRM'),
786 'upgrade_url' => fluentform_upgrade_url(),
787 'ace_path_url' => fluentformMix('libs/ace'),
788 'is_conversion_form' => Helper::isConversionForm($form_id),
789 'has_fluent_smtp' => defined('FLUENTMAIL'),
790 'fluent_smtp_url' => defined('FLUENTMAIL')
791 ? admin_url('options-general.php?page=fluent-mail#/connections')
792 : admin_url('admin.php?page=fluent_forms_add_ons&sub_page=suggested_plugins'),
793 'form_settings_str' => TranslationString::getSettingsI18n(),
794 'integrationsResource' => [
795 'asset_url' => fluentformMix('img/integrations.png'),
796 'list_url' => fluentform_integrations_url(),
797 'instruction' => __("Fluent Forms Pro has tons of integrations to take your forms to the next level. From payment gateways to quiz building, SMS notifications to email marketing - you'll get integrations for various purposes. Even if you don't find your favorite tools, you can integrate them easily with Zapier.", 'fluentform'),
798 ],
799 'countries' => getFluentFormCountryList(),
800 'getIpInfo' => Helper::getIpinfo(),
801 'has_conv_form_save_and_resume' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.12', '>=')
802 ]);
803
804 $this->app->view->render('admin.form.settings', [
805 'form_id' => $form_id,
806 ]);
807 }
808
809 public function renderForms()
810 {
811 if (!get_option('_fluentform_installed_version')) {
812 (new ActivationHandler())->migrate();
813 }
814
815 if (false !== ($allowForms = FormManagerService::getUserAllowedFormsScope())) {
816 $formsCount = wpFluent()->table('fluentform_forms')->whereIn('id', $allowForms ?: [0])->count();
817 } else {
818 $formsCount = wpFluent()->table('fluentform_forms')->count();
819 }
820
821 $isDisabledAnalytics = apply_filters_deprecated(
822 'fluentform-disabled_analytics',
823 [
824 true
825 ],
826 FLUENTFORM_FRAMEWORK_UPGRADE,
827 'fluentform/disabled_analytics',
828 'Use fluentform/disabled_analytics instead of fluentform-disabled_analytics.'
829 );
830
831 $data = [
832 'plugin' => $this->app->config->get('app.slug'),
833 'formsCount' => $formsCount,
834 'hasPro' => defined('FLUENTFORMPRO'),
835 'upgrade_url' => fluentform_upgrade_url(),
836 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
837 'adminUrlWithoutPageHash' => admin_url('admin.php'),
838 'isDisableAnalytics' => $this->app->applyFilters('fluentform/disabled_analytics', $isDisabledAnalytics),
839 'plugin_public_url' => fluentformMix(),
840 'siteUrl' => site_url(),
841 ];
842
843 if (defined('FLUENTFORMPRO')){
844 $data['landing_page_enabled_forms']= Helper::getLandingPageEnabledForms();
845 }
846
847
848 $data = apply_filters_deprecated(
849 'fluent_all_forms_vars',
850 [
851 $data
852 ],
853 FLUENTFORM_FRAMEWORK_UPGRADE,
854 'fluentform/all_forms_vars',
855 'Use fluentform/all_forms_vars instead of fluent_all_forms_vars.'
856 );
857
858 wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluentform/all_forms_vars', $data));
859
860 $this->app->view->render('admin.all_forms', []);
861 }
862
863 public function renderEditor($form_id)
864 {
865 $this->app->view->render('admin.form.editor', [
866 'plugin' => $this->app->config->get('app.slug'),
867 'form_id' => $form_id,
868 ]);
869 }
870
871 public function renderDocs()
872 {
873 (new DocumentationModule())->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --
874 }
875
876 public function renderAddOns()
877 {
878 (new AddOnModule())->render();
879 }
880
881 private function enqueueEditorAssets()
882 {
883 $formId = (int) $this->app->request->get('form_id');
884
885 $form = wpFluent()->table('fluentform_forms')->find($formId);
886
887 do_action_deprecated(
888 'fluentform_loading_editor_assets',
889 [
890 $form
891 ],
892 FLUENTFORM_FRAMEWORK_UPGRADE,
893 'fluentform/loading_editor_assets',
894 'Use fluentform/loading_editor_assets instead of fluentform_loading_editor_assets'
895 );
896
897 do_action('fluentform/loading_editor_assets', $form);
898
899 wp_enqueue_style('fluentform_editor_sass');
900 wp_enqueue_style('fluentform_editor_style');
901
902 $pluginSlug = $this->app->config->get('app.slug');
903
904 if (function_exists('wp_enqueue_editor')) {
905 add_filter('user_can_richedit', '__return_true');
906 wp_enqueue_editor();
907 wp_enqueue_media();
908 }
909
910 wp_enqueue_script('fluentform_editor_script');
911
912 $jsonData = $form->form_fields;
913
914 if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
915 $formFields = $form->form_fields;
916
917 if ($formFields) {
918 $formFields = json_decode($formFields, true);
919
920 foreach ($formFields['fields'] as $index => $formField) {
921 $formField = apply_filters_deprecated(
922 'fluentform_editor_init_element_' . $formField['element'],
923 [
924 $formField,
925 $form
926 ],
927 FLUENTFORM_FRAMEWORK_UPGRADE,
928 'fluentform/editor_init_element_' . $formField['element'],
929 'Use fluentform/editor_init_element_' . $formField['element'] . ' instead of fluentform_editor_init_element_' . $formField['element']
930 );
931
932 $formField = $formFields['fields'][$index] = apply_filters(
933 'fluentform/editor_init_element_' . $formField['element'],
934 $formField,
935 $form
936 );
937
938 if (!$formFields['fields'][$index]) {
939 unset($formFields['fields'][$index]);
940 continue;
941 }
942
943 if ('container' == $formField['element']) {
944 $columns = $formField['columns'];
945 foreach ($columns as $columnIndex => $column) {
946 foreach ($column['fields'] as $fieldIndex => $columnField) {
947 $columnField = apply_filters_deprecated(
948 'fluentform_editor_init_element_' . $columnField['element'],
949 [
950 $columnField,
951 $form
952 ],
953 FLUENTFORM_FRAMEWORK_UPGRADE,
954 'fluentform/editor_init_element_' . $columnField['element'],
955 'Use fluentform/editor_init_element_' . $columnField['element'] . ' instead of fluentform_editor_init_element_' . $columnField['element']
956 );
957
958 $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
959 'fluentform/editor_init_element_' . $columnField['element'],
960 $columnField,
961 $form
962 );
963
964 if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
965 unset($columns[$columnIndex]['fields'][$fieldIndex]);
966 }
967 }
968 }
969
970 $formFields['fields'][$index]['columns'] = array_values($columns);
971 }
972 }
973
974 if (!empty($formFields['stepsWrapper']['stepStart'])) {
975 $stepStart = $formFields['stepsWrapper']['stepStart'];
976
977 $formFields['stepsWrapper']['stepStart'] = apply_filters(
978 'fluentform/editor_init_element_' . $stepStart['element'],
979 $stepStart,
980 $form
981 );
982 }
983
984 $formFields['fields'] = array_values($formFields['fields']);
985 $formFields = json_encode($formFields, true);
986 }
987
988 $form->form_fields = $formFields;
989 }
990
991 $searchTags = fluentformLoadFile('Services/FormBuilder/ElementSearchTags.php');
992
993 $searchTags = apply_filters_deprecated(
994 'fluentform_editor_element_search_tags',
995 [
996 $searchTags
997 ],
998 FLUENTFORM_FRAMEWORK_UPGRADE,
999 'fluentform/editor_element_search_tags',
1000 'Use fluentform/editor_element_search_tags instead of fluent_editor_element_search_tags.'
1001 );
1002 $searchTags = apply_filters('fluentform/editor_element_search_tags', $searchTags, $form);
1003
1004 $elementPlacements = fluentformLoadFile('Services/FormBuilder/ElementSettingsPlacement.php');
1005 $elementPlacements = apply_filters_deprecated(
1006 'fluentform_editor_element_settings_placement',
1007 [
1008 $elementPlacements,
1009 $form
1010 ],
1011 FLUENTFORM_FRAMEWORK_UPGRADE,
1012 'fluentform/editor_element_settings_placement',
1013 'Use fluentform/editor_element_settings_placement instead of fluent_editor_element_settings_placement.'
1014 );
1015
1016 $elementPlacements = apply_filters(
1017 'fluentform/editor_element_settings_placement',
1018 $elementPlacements,
1019 $form
1020 );
1021 $data = [
1022 'plugin' => $pluginSlug,
1023 'form_id' => $formId,
1024 'plugin_public_url' => fluentformMix(),
1025 'preview_url' => Helper::getPreviewUrl($formId),
1026 'form' => $form,
1027 'hasPro' => defined('FLUENTFORMPRO'),
1028 'countries' => getFluentFormCountryList(),
1029 'element_customization_settings' => fluentformLoadFile('Services/FormBuilder/ElementCustomization.php'),
1030 'validation_rule_settings' => fluentformLoadFile('Services/FormBuilder/ValidationRuleSettings.php'),
1031 'supported_conditional_fields' => (new Fields())->supportedConditionalFields(),
1032 'conversational_form_fields' => array_keys(Converter::fieldTypes()),
1033 'form_editor_str' => TranslationString::getEditorI18n(),
1034 'element_search_tags' => $searchTags,
1035 'element_settings_placement' => $elementPlacements,
1036 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
1037 'has_payment_features' => true,
1038 'upgrade_url' => fluentform_upgrade_url(),
1039 'is_conversion_form' => Helper::isConversionForm($formId),
1040 'is_autoload_captcha' => Helper::isAutoloadCaptchaEnabled(),
1041 'autosave_enabled' => Helper::isAutosaveEnabled(),
1042 'used_name_attributes' => $this->usedNameAttributes($formId),
1043 'bulk_options_json' => '{"Countries":["Afghanistan","Albania","Algeria","American Samoa","Andorra","Angola","Anguilla","Antarctica","Antigua and Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bonaire, Sint Eustatius and Saba","Bosnia and Herzegovina","Botswana","Bouvet Island","Brazil","British Indian Ocean Territory","Brunei Darussalam","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central African Republic","Chad","Chile","China","Christmas Island","Cocos Islands","Colombia","Comoros","Congo, Democratic Republic of the","Congo, Republic of the","Cook Islands","Costa Rica","Croatia","Cuba","Cura\u00e7ao","Cyprus","Czech Republic","C\u00f4te d\'Ivoire","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Eswatini (Swaziland)","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Guiana","French Polynesia","French Southern Territories","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guadeloupe","Guam","Guatemala","Guernsey","Guinea","Guinea-Bissau","Guyana","Haiti","Heard and McDonald Islands","Holy See","Honduras","Hong Kong","Hungary","Iceland","India","Indonesia","Iran","Iraq","Ireland","Isle of Man","Israel","Italy","Jamaica","Japan","Jersey","Jordan","Kazakhstan","Kenya","Kiribati","Kuwait","Kyrgyzstan","Lao People\'s Democratic Republic","Latvia","Lebanon","Lesotho","Liberia","Libya","Liechtenstein","Lithuania","Luxembourg","Macau","Macedonia","Madagascar","Malawi","Malaysia","Maldives","Mali","Malta","Marshall Islands","Martinique","Mauritania","Mauritius","Mayotte","Mexico","Micronesia","Moldova","Monaco","Mongolia","Montenegro","Montserrat","Morocco","Mozambique","Myanmar","Namibia","Nauru","Nepal","Netherlands","New Caledonia","New Zealand","Nicaragua","Niger","Nigeria","Niue","Norfolk Island","North Korea","Northern Mariana Islands","Norway","Oman","Pakistan","Palau","Palestine, State of","Panama","Papua New Guinea","Paraguay","Peru","Philippines","Pitcairn","Poland","Portugal","Puerto Rico","Qatar","Romania","Russia","Rwanda","R\u00e9union","Saint Barth\u00e9lemy","Saint Helena","Saint Kitts and Nevis","Saint Lucia","Saint Martin","Saint Pierre and Miquelon","Saint Vincent and the Grenadines","Samoa","San Marino","Sao Tome and Principe","Saudi Arabia","Senegal","Serbia","Seychelles","Sierra Leone","Singapore","Sint Maarten","Slovakia","Slovenia","Solomon Islands","Somalia","South Africa","South Georgia","South Korea","South Sudan","Spain","Sri Lanka","Sudan","Suriname","Svalbard and Jan Mayen Islands","Sweden","Switzerland","Syria","Taiwan","Tajikistan","Tanzania","Thailand","Timor-Leste","Togo","Tokelau","Tonga","Trinidad and Tobago","Tunisia","Türkiye","Turkmenistan","Turks and Caicos Islands","Tuvalu","US Minor Outlying Islands","Uganda","Ukraine","United Arab Emirates","United Kingdom","United States","Uruguay","Uzbekistan","Vanuatu","Venezuela","Vietnam","Virgin Islands, British","Virgin Islands, U.S.","Wallis and Futuna","Western Sahara","Yemen","Zambia","Zimbabwe","\u00c5land Islands"],"U.S. States":["Alabama","Alaska","Arizona","Arkansas","California","Colorado","Connecticut","Delaware","District of Columbia","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming","Armed Forces Americas","Armed Forces Europe","Armed Forces Pacific"],"Canadian Province\/Territory":["Alberta","British Columbia","Manitoba","New Brunswick","Newfoundland and Labrador","Northwest Territories","Nova Scotia","Nunavut","Ontario","Prince Edward Island","Quebec","Saskatchewan","Yukon"],"Continents":["Africa","Antarctica","Asia","Australia","Europe","North America","South America"],"Gender":["Male","Female","Prefer Not to Answer"],"Age":["Under 18","18-24","25-34","35-44","45-54","55-64","65 or Above","Prefer Not to Answer"],"Marital Status":["Single","Married","Divorced","Widowed"],"Employment":["Employed Full-Time","Employed Part-Time","Self-employed","Not employed but looking for work","Not employed and not looking for work","Homemaker","Retired","Student","Prefer Not to Answer"],"Job Type":["Full-Time","Part-Time","Per Diem","Employee","Temporary","Contract","Intern","Seasonal"],"Industry":["Accounting\/Finance","Advertising\/Public Relations","Aerospace\/Aviation","Arts\/Entertainment\/Publishing","Automotive","Banking\/Mortgage","Business Development","Business Opportunity","Clerical\/Administrative","Construction\/Facilities","Consumer Goods","Customer Service","Education\/Training","Energy\/Utilities","Engineering","Government\/Military","Green","Healthcare","Hospitality\/Travel","Human Resources","Installation\/Maintenance","Insurance","Internet","Job Search Aids","Law Enforcement\/Security","Legal","Management\/Executive","Manufacturing\/Operations","Marketing","Non-Profit\/Volunteer","Pharmaceutical\/Biotech","Professional Services","QA\/Quality Control","Real Estate","Restaurant\/Food Service","Retail","Sales","Science\/Research","Skilled Labor","Technology","Telecommunications","Transportation\/Logistics","Other"],"Education":["High School","Associate Degree","Bachelor\'s Degree","Graduate or Professional Degree","Some College","Other","Prefer Not to Answer"],"Days of the Week":["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],"Months of the Year":["January","February","March","April","May","June","July","August","September","October","November","December"],"How Often":["Every day","Once a week","2 to 3 times a week","Once a month","2 to 3 times a month","Less than once a month"],"How Long":["Less than a month","1-6 months","1-3 years","Over 3 years","Never used"],"Satisfaction":["Very Satisfied","Satisfied","Neutral","Unsatisfied","Very Unsatisfied"],"Importance":["Very Important","Important","Somewhat Important","Not Important"],"Agreement":["Strongly Agree","Agree","Disagree","Strongly Disagree"],"Comparison":["Much Better","Somewhat Better","About the Same","Somewhat Worse","Much Worse"],"Would You":["Definitely","Probably","Not Sure","Probably Not","Definitely Not"],"Size":["Extra Small","Small","Medium","Large","Extra Large"],"Timezone":["(GMT -12-00) Eniwetok, Kwajalein:-12","(GMT -11-00) Midway Island, Samoa:-11","(GMT -10-00) Hawaii:-10","(GMT -9-00) Alaska:-9","(GMT -8-00) Pacific Time (US & Canada):-8","(GMT -7-00) Mountain Time (US & Canada):-7","(GMT -6-00) Central Time (US & Canada), Mexico City:-6","(GMT -5-00) Eastern Time (US & Canada), Bogota, Lima:-5","(GMT -4-00) Atlantic Time (Canada), Caracas, La Paz:-4","(GMT -3-30) Newfoundland:-3.5","(GMT -3-00) Brazil, Buenos Aires, Georgetown:-3","(GMT -2-00) Mid-Atlantic:-2","(GMT -1-00) Azores, Cape Verde Islands:-1","(GMT) Western Europe Time, London, Lisbon, Casablanca:0","(GMT +1-00) Brussels, Copenhagen, Madrid, Paris:1","(GMT +2-00) Kaliningrad, South Africa:2","(GMT +3-00) Baghdad, Riyadh, Moscow, St. Petersburg:3","(GMT +3-30) Tehran:3.5","(GMT +4-00) Abu Dhabi, Muscat, Baku, Tbilisi:4","(GMT +4-30) Kabul:4.5","(GMT +5-00) Ekaterinburg, Islamabad, Karachi, Tashkent:5","(GMT +5-30) Bombay, Calcutta, Madras, New Delhi:5.5","(GMT +5-45) Kathmandu:5.75","(GMT +6-00) Almaty, Dhaka, Colombo:6","(GMT +7-00) Bangkok, Hanoi, Jakarta:7","(GMT +8-00) Beijing, Perth, Singapore, Hong Kong:8","(GMT +9-00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk:9","(GMT +9-30) Adelaide, Darwin:9.5","(GMT +10-00) Eastern Australia, Guam, Vladivostok:10","(GMT +11-00) Magadan, Solomon Islands, New Caledonia:11","(GMT +12-00) Auckland, Wellington, Fiji, Kamchatka:12"]}',
1044 ];
1045
1046 // if has pro and payment enable. We will use this filter hook to push custom elements
1047 if (defined('FLUENTFORMPRO')) {
1048 $data['calc_items'] = [
1049 'paymentElements' => [
1050 'multi_payment_component',
1051 'input_number',
1052 'repeater_field',
1053 'net_promoter_score',
1054 'rangeslider',
1055 'custom_payment_component',
1056 'item_quantity_component',
1057 'subscription_payment_component'
1058 ]
1059 ];
1060 }
1061
1062 $data = apply_filters_deprecated(
1063 'fluentform_editor_vars',
1064 [
1065 $data
1066 ],
1067 FLUENTFORM_FRAMEWORK_UPGRADE,
1068 'fluentform/editor_vars',
1069 'Use fluentform/editor_vars instead of fluentform_editor_vars.'
1070 );
1071
1072 wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform/editor_vars', $data));
1073
1074 do_action('fluentform/editor_script_loaded', $form);
1075 }
1076
1077 /**
1078 * Render global settings page.
1079 *
1080 * @throws \Exception
1081 */
1082 public function renderGlobalSettings()
1083 {
1084 if (function_exists('wp_enqueue_editor')) {
1085 add_filter('user_can_richedit', '__return_true');
1086 wp_enqueue_editor();
1087 wp_enqueue_media();
1088 }
1089
1090 // Fire an event letting others know the current component
1091 // that fluentform is rendering for the global settings
1092 // page. So that they can hook and load their custom
1093 // components on this page dynamically & easily.
1094 // N.B. native 'components' will always use
1095 // 'settings' as their current component.
1096 $currentComponent = $this->app->request->get('component', 'settings');
1097
1098 $currentComponent = apply_filters_deprecated('fluentform_global_settings_current_component', [
1099 $currentComponent
1100 ],
1101 FLUENTFORM_FRAMEWORK_UPGRADE,
1102 'fluentform/global_settings_current_component',
1103 'Use fluentform/global_settings_current_component instead of fluentform_global_settings_current_component.'
1104 );
1105
1106 $currentComponent = apply_filters(
1107 'fluentform/global_settings_current_component',
1108 $currentComponent
1109 );
1110
1111 $currentComponent = sanitize_key($currentComponent);
1112 $components = [];
1113 $components = apply_filters_deprecated('fluentform_global_settings_components', [
1114 $components
1115 ],
1116 FLUENTFORM_FRAMEWORK_UPGRADE,
1117 'fluentform/global_settings_components',
1118 'Use fluentform/global_settings_components instead of fluentform_global_settings_components.'
1119 );
1120
1121 $components = apply_filters('fluentform/global_settings_components', $components);
1122
1123 $components['reCAPTCHA'] = [
1124 'hash' => 're_captcha',
1125 'title' => 'reCAPTCHA',
1126 ];
1127
1128 $components['hCAPTCHA'] = [
1129 'hash' => 'h_captcha',
1130 'title' => 'hCaptcha',
1131 ];
1132
1133 $components['Turnstile'] = [
1134 'hash' => 'turnstile',
1135 'title' => 'Turnstile',
1136 ];
1137
1138 $components['CleanTalk'] = [
1139 'hash' => 'cleantalk',
1140 'title' => 'CleanTalk',
1141 ];
1142
1143 $customLinks = apply_filters('fluentform/global_settings_menu', []);
1144 $this->app->view->render('admin.globalSettings.menu', [
1145 'components' => $components,
1146 'customLinks' => $customLinks,
1147 'currentComponent' => $currentComponent,
1148 ]);
1149 }
1150
1151 public function renderTransfer()
1152 {
1153 $allowForms = FormManagerService::getUserAllowedFormsScope();
1154 $forms = wpFluent()->table('fluentform_forms')
1155 ->orderBy('id', 'desc')
1156 ->select(['id', 'title'])
1157 ->when(false !== $allowForms, function ($q) use ($allowForms){
1158 return $q->whereIn('id', $allowForms ?: [0]);
1159 })
1160 ->get();
1161
1162 wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
1163 'plugin' => $this->app->config->get('app.slug'),
1164 'forms' => $forms,
1165 'upgrade_url' => fluentform_upgrade_url(),
1166 'hasPro' => defined('FLUENTFORMPRO'),
1167 'transfer_str' => TranslationString::getTransferModuleI18n(),
1168 'source_query' => sanitize_text_field($this->app->request->get('source')),
1169 'status_query' => sanitize_text_field($this->app->request->get('status')),
1170 'date_start_query' => sanitize_text_field($this->app->request->get('start_date')),
1171 'date_end_query' => sanitize_text_field($this->app->request->get('end_date')),
1172 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
1173 ]);
1174
1175 $this->app->view->render('admin.tools.index');
1176 }
1177
1178 public function addPreviewButton($formId)
1179 {
1180 $previewUrl = Helper::getPreviewUrl($formId);
1181 $previewText = __('Preview & Design', 'fluentform');
1182 $formId = (int)$formId;
1183 if (Helper::isConversionForm($formId)) {
1184 $previewText = __('Preview', 'fluentform');
1185 }
1186 echo '<a target="_blank" class="el-button el-button--info is-plain" href="' . esc_url($previewUrl) . '">' . '<i class="ff-icon ff-icon-eye-filled fs-15"></i> ' . '<span>' . esc_attr($previewText) . '</span>' . '</a>';
1187 }
1188
1189 public function addCopyShortcodeButton($formId)
1190 {
1191 $formId = (int) $formId;
1192 $shortcode = '[fluentform id="' . $formId . '"]';
1193 if (Helper::isConversionForm($formId)) {
1194 $shortcode = '[fluentform type="conversational" id="' . $formId . '"]';
1195 }
1196 echo '<button title="' . esc_attr__('Click to Copy', 'fluentform') . '" class="ff_shortcode_btn ff_shortcode_btn_md copy truncate" data-clipboard-text=\'' . $shortcode . '\'><i class="el-icon el-icon-document-copy"></i> ' . $shortcode . '</button>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- $shortcode is escaped before being passed in.
1197 return;
1198 }
1199
1200 public function commonAction()
1201 {
1202 $fluentFormPages = [
1203 'fluent_forms',
1204 'fluent_forms_transfer',
1205 'fluent_forms_settings',
1206 'fluent_forms_add_ons',
1207 'fluent_forms_docs',
1208 ];
1209
1210 $page = sanitize_text_field($this->app->request->get('page'));
1211
1212 if ($page && in_array($page, $fluentFormPages)) {
1213 // Let's deregister existing vuejs by other devs
1214 // Other devs should not regis
1215 add_action('admin_print_scripts', function () {
1216 wp_dequeue_script('vuejs');
1217 wp_dequeue_script('vue');
1218 wp_deregister_script('elementor-admin-app');
1219 });
1220 }
1221 }
1222
1223 public function renderGlobalMenu()
1224 {
1225 $showPayment = !PaymentHelper::hasPaymentSettings();
1226 if ($showPayment) {
1227 $formCount = wpFluent()->table('fluentform_forms')
1228 ->count();
1229 $showPayment = $formCount > 2;
1230 }
1231 $showPaymentEntry = apply_filters_deprecated('fluentform_show_payment_entries', [
1232 false
1233 ],
1234 FLUENTFORM_FRAMEWORK_UPGRADE,
1235 'fluentform/show_payment_entries',
1236 'Use fluentform/show_payment_entries instead of fluentform/show_payment_entries.'
1237 );
1238
1239 $this->app->view->render('admin.global_menu', [
1240 'logo' => fluentformMix('img/fluentform-logo.svg'),
1241 'show_payment' => $showPayment,
1242 'show_payment_entries' => apply_filters('fluentform/show_payment_entries', $showPaymentEntry),
1243 ]);
1244 }
1245
1246 public function renderPaymentEntries()
1247 {
1248 do_action_deprecated(
1249 'flunetform_render_payment_entries', [],
1250 FLUENTFORM_FRAMEWORK_UPGRADE,
1251 'fluentform/render_payment_entries',
1252 'Use fluentform/render_payment_entries instead of flunetform/render_payment_entries'
1253 );
1254
1255 do_action('fluentform/render_payment_entries');
1256 }
1257
1258 public function renderReports()
1259 {
1260 do_action('fluentform/render_report');
1261 }
1262
1263 private function usedNameAttributes($formId)
1264 {
1265 return wpFluent()->table('fluentform_entry_details')
1266 ->select(['field_name'])
1267 ->where('form_id', $formId)
1268 ->orderBy('submission_id', 'desc')
1269 ->groupBy('field_name')
1270 ->get();
1271 }
1272 }
1273