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

1,284 lines 54.9 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\Manager\FormManagerService;
15 use FluentForm\Framework\Foundation\Application;
16 use FluentForm\Framework\Helpers\ArrayHelper;
17
18 class Menu
19 {
20 /**
21 * App instance
22 *
23 * @var \FluentForm\Framework\Foundation\Application
24 */
25 protected $app;
26
27 /**
28 * Menu constructor.
29 *
30 * @param \FluentForm\Framework\Foundation\Application $application
31 */
32 public function __construct(Application $application)
33 {
34 $this->app = $application;
35
36 $this->app->addFilter('fluentform/form_settings_menu', [
37 $this, 'filterFormSettingsMenu',
38 ], 10, 2);
39 }
40
41 public function reisterScripts()
42 {
43 if (!$this->isFluentPages()) {
44 return;
45 }
46
47 $app = $this->app;
48
49 wp_register_script(
50 'fluent_forms_global',
51 fluentFormMix('js/fluent_forms_global.js'),
52 ['jquery'],
53 FLUENTFORM_VERSION,
54 true
55 );
56
57 $settingsGlobalStyle = fluentFormMix('css/settings_global.css');
58 $allFormsStyle = fluentFormMix('css/fluent-all-forms.css');
59 $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass.css');
60 $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin.css');
61 $addOnsCss = fluentFormMix('css/add-ons.css');
62 $adminDocCss = fluentFormMix('css/admin_docs.css');
63 $reportsCss = fluentFormMix('css/fluent-forms-reports.css');
64 if (is_rtl()) {
65 $settingsGlobalStyle = fluentFormMix('css/settings_global_rtl.css');
66 $allFormsStyle = fluentFormMix('css/fluent-all-forms-rtl.css');
67 $fluentFormAdminEditorStyles = fluentFormMix('css/fluent-forms-admin-sass-rtl.css');
68 $fluentFormAdminCSS = fluentFormMix('css/fluent-forms-admin-rtl.css');
69 $addOnsCss = fluentFormMix('css/add-ons-rtl.css');
70 $adminDocCss = fluentFormMix('css/admin_docs_rtl.css');
71 $reportsCss = fluentFormMix('css/fluent-forms-reports-rtl.css');
72 }
73
74 wp_register_style(
75 'fluentform_settings_global',
76 $settingsGlobalStyle,
77 [],
78 FLUENTFORM_VERSION,
79 'all'
80 );
81
82 wp_register_script(
83 'clipboard',
84 fluentFormMix('libs/clipboard.min.js'),
85 [],
86 FLUENTFORM_VERSION,
87 true
88 );
89
90 wp_register_script(
91 'copier',
92 fluentFormMix('js/copier.js'),
93 [],
94 FLUENTFORM_VERSION,
95 true
96 );
97
98 wp_register_script(
99 'fluentform_form_settings',
100 fluentFormMix('js/form_settings_app.js'),
101 ['jquery'],
102 FLUENTFORM_VERSION,
103 true
104 );
105
106 wp_register_script(
107 'fluent_all_forms',
108 fluentFormMix('js/fluent-all-forms-admin.js'),
109 ['jquery'],
110 FLUENTFORM_VERSION,
111 true
112 );
113
114 wp_register_style(
115 'fluent_all_forms',
116 $allFormsStyle,
117 [],
118 FLUENTFORM_VERSION,
119 'all'
120 );
121
122 wp_register_script(
123 'fluentform_editor_script',
124 fluentFormMix('js/fluent-forms-editor.js'),
125 ['jquery'],
126 FLUENTFORM_VERSION,
127 true
128 );
129
130
131 wp_register_style(
132 'fluentform_editor_style',
133 $fluentFormAdminEditorStyles,
134 [],
135 FLUENTFORM_VERSION,
136 'all'
137 );
138
139 wp_register_style(
140 'fluentform_editor_sass',
141 $fluentFormAdminCSS,
142 [],
143 FLUENTFORM_VERSION,
144 'all'
145 );
146
147 wp_register_script(
148 'fluentform-transfer-js',
149 fluentFormMix('js/fluentform-transfer.js'),
150 ['jquery'],
151 FLUENTFORM_VERSION,
152 true
153 );
154
155 wp_register_script(
156 'fluentform-global-settings-js',
157 fluentFormMix('js/fluentform-global-settings.js'),
158 ['jquery'],
159 FLUENTFORM_VERSION,
160 true
161 );
162
163 wp_register_script(
164 'fluentform-modules',
165 fluentFormMix('js/modules.js'),
166 ['jquery'],
167 FLUENTFORM_VERSION,
168 true
169 );
170
171 wp_register_script(
172 'fluentform-docs',
173 fluentFormMix('js/docs.js'),
174 ['jquery'],
175 FLUENTFORM_VERSION,
176 true
177 );
178
179 wp_register_script(
180 'fluentform_form_entries',
181 fluentFormMix('js/form_entries.js'),
182 ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
183 FLUENTFORM_VERSION,
184 true
185 );
186
187 wp_register_script(
188 'fluentform_reports',
189 fluentFormMix('js/reports.js'),
190 ['jquery'],
191 FLUENTFORM_VERSION,
192 true
193 );
194
195 wp_register_style(
196 'fluentform_reports',
197 $reportsCss,
198 [],
199 FLUENTFORM_VERSION,
200 'all'
201 );
202
203 wp_register_script(
204 'fluentform_all_entries',
205 fluentFormMix('js/all_entries.js'),
206 ['jquery', 'fluentform_chart_js', 'fluentform_vue_chart_js'],
207 FLUENTFORM_VERSION,
208 true
209 );
210
211 wp_register_script(
212 'fluentform_chart_js',
213 fluentFormMix('libs/chartjs/chart.min.js'),
214 [],
215 FLUENTFORM_VERSION,
216 true
217 );
218
219 wp_register_script(
220 'fluentform_vue_chart_js',
221 fluentFormMix('libs/chartjs/vue-chartjs.min.js'),
222 [],
223 FLUENTFORM_VERSION,
224 true
225 );
226
227 wp_register_style(
228 'fluentform-add-ons',
229 $addOnsCss,
230 [],
231 FLUENTFORM_VERSION,
232 'all'
233 );
234
235 wp_register_style(
236 'fluentform_doc_style',
237 $adminDocCss,
238 [],
239 FLUENTFORM_VERSION,
240 'all'
241 );
242
243 add_filter('admin_footer_text', function ($text) {
244 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">�
245
246
247
248
249 </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>';
250 });
251
252 add_filter('update_footer', function ($text) {
253 $footerContent = 'Version ' . FLUENTFORM_VERSION;
254 if (defined('FLUENTFORMPRO')) {
255 $footerContent .= ' & Pro ' . FLUENTFORMPRO_VERSION;
256 }
257 return $footerContent;
258 });
259
260 $elementUIStyle = fluentFormMix('css/element-ui-css.css');
261 if (is_rtl()) {
262 $elementUIStyle = fluentFormMix('css/element-ui-css-rtl.css');
263 }
264 wp_enqueue_style(
265 'fluentform_global_elements',
266 $elementUIStyle,
267 [],
268 FLUENTFORM_VERSION,
269 'all'
270 );
271 }
272
273 public function isFluentPages()
274 {
275 return Helper::isFluentAdminPage();
276 }
277
278 public function enqueuePageScripts()
279 {
280 if (!$this->isFluentPages()) {
281 return;
282 }
283
284 $forms = wpFluent()->table('fluentform_forms')
285 ->orderBy('id', 'desc')
286 ->select(['id', 'title'])
287 ->get();
288
289 wp_enqueue_script('fluent_forms_global');
290
291 // Check if default style is enabled
292 $defaultTemplate = get_option('_fluentform_default_style_template');
293 $hasDefaultStyle = false;
294 if ($defaultTemplate && is_array($defaultTemplate)) {
295 $hasDefaultStyle = \FluentForm\Framework\Helpers\ArrayHelper::get($defaultTemplate, 'enabled') === 'yes';
296 }
297
298 $globalVars = [
299 'ajaxurl' => Helper::getAjaxUrl(),
300 'admin_i18n' => TranslationString::getAdminI18n(),
301 'global_search_active' => apply_filters('fluentform/global_search_active', 'yes'),
302 'payments_str' => TranslationString::getPaymentsI18n(),
303 'permissions' => Acl::getCurrentUserPermissions(),
304 'rest' => Helper::getRestInfo(),
305 'card_brands' => [
306 'visa' => fluentformMix('img/card-brand/visa.jpg'),
307 'paypal' => fluentformMix('img/card-brand/paypal.jpg'),
308 'mastercard' => fluentformMix('img/card-brand/mastercard.jpg'),
309 'amex' => fluentformMix('img/card-brand/amex.jpg')
310 ],
311 'payment_icons' => [
312 'offline' => fluentformMix('img/payment/offline.png'),
313 'mollie' => fluentformMix('img/payment/mollie.png'),
314 'paypal' => fluentformMix('img/payment/paypal.png'),
315 'stripe' => fluentformMix('img/payment/stripe.png')
316 ],
317 'forms' => $forms,
318 'hasPro' => defined('FLUENTFORMPRO'),
319 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
320 'disable_time_diff' => Helper::isDefaultWPDateEnabled(),
321 'wp_date_time_format' => Helper::getDefaultDateTimeFormatForMoment(),
322 'server_time' => current_time('mysql'),
323 'has_default_style' => $hasDefaultStyle,
324 ];
325
326 if (Acl::hasAnyFormPermission()) {
327 $globalVars['fluent_forms_admin_nonce'] = wp_create_nonce('fluent_forms_admin_nonce');
328 }
329
330 wp_localize_script('fluent_forms_global', 'fluent_forms_global_var', $globalVars);
331
332 $page = sanitize_text_field($this->app->request->get('page'));
333 $route = sanitize_text_field($this->app->request->get('route'));
334 $formId = intval($this->app->request->get('form_id'));
335
336 if ('fluent_forms' == $page && $route && $formId) {
337 if (true) {
338 wp_enqueue_style('fluentform_settings_global');
339 wp_enqueue_script('clipboard');
340 wp_enqueue_script('copier');
341
342 if (Acl::hasPermission('fluentform_forms_manager', $formId)) {
343 if ('settings' == $route) {
344 if (function_exists('wp_enqueue_editor')) {
345 add_filter('user_can_richedit', function ($status) {
346 return true;
347 });
348
349 wp_enqueue_editor();
350 wp_enqueue_media();
351 }
352 do_action('fluentform/loading_settings_assets', $formId);
353 wp_enqueue_script('fluentform_form_settings');
354 } elseif ('editor' == $route) {
355 $this->enqueueEditorAssets();
356 }
357 }
358 }
359 } elseif ('fluent_forms' == $page) {
360 wp_enqueue_script('fluent_all_forms');
361 wp_enqueue_style('fluent_all_forms');
362 }elseif ('fluent_forms_transfer' == $page) {
363 wp_enqueue_style('fluentform_settings_global');
364 wp_enqueue_script('fluentform-transfer-js');
365 } elseif (
366 'fluent_forms_settings' == $page ||
367 'fluent_forms_payment_entries' == $page ||
368 'fluent_forms_all_entries' == $page
369 ) {
370 wp_enqueue_style('fluentform_settings_global');
371 } elseif ('fluent_forms_add_ons' == $page) {
372 wp_enqueue_style('fluentform-add-ons');
373 } elseif ('fluent_forms_docs' == $page || 'fluent_forms_smtp' == $page) {
374 wp_enqueue_style('fluentform_doc_style');
375 }
376 }
377
378 /**
379 * Register menu and sub-menus.
380 */
381 public function register()
382 {
383 $dashBoardCapability = apply_filters_deprecated(
384 'fluentform_dashboard_capability',
385 [
386 'fluentform_dashboard_access'
387 ],
388 FLUENTFORM_FRAMEWORK_UPGRADE,
389 'fluentform/dashboard_capability',
390 'Use fluentform/dashboard_capability instead of fluentform_dashboard_capability.'
391 );
392
393 $dashBoardCapability = $this->app->applyFilters(
394 'fluentform/dashboard_capability',
395 $dashBoardCapability
396 );
397
398 $settingManager = apply_filters_deprecated(
399 'fluentform_settings_capability',
400 [
401 'fluentform_settings_manager'
402 ],
403 FLUENTFORM_FRAMEWORK_UPGRADE,
404 'fluentform/settings_capability',
405 'Use fluentform/settings_capability instead of fluentform_settings_capability.'
406 );
407
408 $settingsCapability = $this->app->applyFilters(
409 'fluentform/settings_capability',
410 $settingManager
411 );
412
413 $fromRole = false;
414 if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
415 $currentUserCapability = Acl::getCurrentUserCapability();
416
417 if (!$currentUserCapability) {
418 return;
419 } else {
420 $fromRole = true;
421 $dashBoardCapability = $settingsCapability = $currentUserCapability;
422 }
423 }
424
425 if (Acl::isSuperMan()) {
426 $fromRole = true;
427 }
428
429 if (defined('FLUENTFORMPRO')) {
430 $title = __('Fluent Forms Pro', 'fluentform');
431 } else {
432 $title = __('Fluent Forms', 'fluentform');
433 }
434
435 $menuPriority = 25;
436
437 if (defined('FLUENTCRM')) {
438 $menuPriority = 3;
439 }
440
441 add_menu_page(
442 $title,
443 $title,
444 $dashBoardCapability,
445 'fluent_forms',
446 [$this, 'renderFormAdminRoute'],
447 $this->getMenuIcon(),
448 $menuPriority
449 );
450
451 add_submenu_page(
452 'fluent_forms',
453 __('Forms', 'fluentform'),
454 __('Forms', 'fluentform'),
455 $dashBoardCapability,
456 'fluent_forms',
457 [$this, 'renderFormAdminRoute']
458 );
459
460 if ($settingsCapability) {
461 add_submenu_page(
462 'fluent_forms',
463 __('New Form', 'fluentform'),
464 __('New Form', 'fluentform'),
465 $fromRole ? $settingsCapability : 'fluentform_forms_manager',
466 'fluent_forms#add=1',
467 [$this, 'renderAddNewFormRoute']
468 );
469
470 $entriesTitle = __('Entries', 'fluentform');
471
472 if (Helper::isFluentAdminPage()) {
473 $allowForms = FormManagerService::getUserAllowedFormsScope();
474 $entriesCount = wpFluent()->table('fluentform_submissions')
475 ->where('status', 'unread')
476 ->when(false !== $allowForms, function ($q) use ($allowForms){
477 return $q->whereIn('form_id', $allowForms ?: [0]);
478 })
479 ->count();
480
481 if ($entriesCount) {
482 $entriesTitle .= ' <span class="ff_unread_count" style="background: #197efb;color: white;border-radius: 8px;padding: 1px 8px;">' . $entriesCount . '</span>';
483 }
484 }
485
486 // Register entries intermediary page
487 add_submenu_page(
488 'fluent_forms',
489 $entriesTitle,
490 $entriesTitle,
491 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
492 'fluent_forms_all_entries',
493 [$this, 'renderAllEntriesAdminRoute']
494 );
495
496 // Register Reports sub menu page.
497 add_submenu_page(
498 'fluent_forms',
499 __('Reports', 'fluentform'),
500 __('Reports', 'fluentform'),
501 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
502 'fluent_forms_reports',
503 [$this, 'renderReports']
504 );
505
506 $isShowPaymentSubmission = apply_filters_deprecated(
507 'fluentform_show_payment_entries',
508 [
509 false
510 ],
511 FLUENTFORM_FRAMEWORK_UPGRADE,
512 'fluentform/show_payment_entries',
513 'Use fluentform/show_payment_entries instead of fluentform_show_payment_entries.'
514 );
515
516 if (apply_filters('fluentform/show_payment_entries', $isShowPaymentSubmission)) {
517 add_submenu_page(
518 'fluent_forms',
519 __('Payments', 'fluentform'),
520 __('Payments', 'fluentform'),
521 $fromRole ? $settingsCapability : 'fluentform_view_payments',
522 'fluent_forms_payment_entries',
523 [$this, 'renderPaymentEntries']
524 );
525 }
526
527 // Register global settings sub menu page.
528 add_submenu_page(
529 'fluent_forms',
530 __('Global Settings', 'fluentform'),
531 __('Global Settings', 'fluentform'),
532 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
533 'fluent_forms_settings',
534 [$this, 'renderGlobalSettings']
535 );
536
537 // Register import/export sub menu page.
538 add_submenu_page(
539 'fluent_forms',
540 __('Tools', 'fluentform'),
541 __('Tools', 'fluentform'),
542 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
543 'fluent_forms_transfer',
544 [$this, 'renderTransfer']
545 );
546
547 // Register FluentSMTP Sub Menu.
548 add_submenu_page(
549 'fluent_forms',
550 __('SMTP', 'fluentform'),
551 __('SMTP', 'fluentform'),
552 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
553 'fluent_forms_smtp',
554 [$this, 'renderSmtpPromo']
555 );
556
557 // Register Add-Ons
558 add_submenu_page(
559 'fluent_forms',
560 __('Integrations', 'fluentform'),
561 __('Integrations', 'fluentform'),
562 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
563 'fluent_forms_add_ons',
564 [$this, 'renderAddOns']
565 );
566 }
567
568 // Register Documentation
569 add_submenu_page(
570 'fluent_forms',
571 __('Support', 'fluentform'),
572 __('Support', 'fluentform'),
573 $dashBoardCapability,
574 'fluent_forms_docs',
575 [$this, 'renderDocs']
576 );
577
578 $this->commonAction();
579 }
580
581 private function getMenuIcon()
582 {
583 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>');
584 }
585
586 public function renderFormAdminRoute()
587 {
588 $formId = intval($this->app->request->get('form_id'));
589 $route = sanitize_key($this->app->request->get('route'));
590
591 if ($route && $formId) {
592 $formRoutePermissionSet = apply_filters('fluentform/form_inner_route_permission_set', [
593 'editor' => 'fluentform_forms_manager',
594 'settings' => 'fluentform_forms_manager',
595 'entries' => 'fluentform_entries_viewer',
596 'reports' => 'fluentform_entries_viewer',
597 ]);
598
599 $toVerifyPermission = ArrayHelper::get(
600 $formRoutePermissionSet,
601 $route,
602 'fluentform_forms_manager'
603 );
604
605 $hasPermission = apply_filters(
606 'fluentform/inner_route_has_permission',
607 Acl::hasPermission($toVerifyPermission, $formId),
608 $route,
609 $formId
610 );
611
612 if ($hasPermission) {
613 return $this->renderFormInnerPages();
614 } else {
615 return $this->app->view->render('admin.no_permission');
616 }
617 }
618
619 $this->renderForms();
620 }
621
622 public function renderAllEntriesAdminRoute()
623 {
624 wp_enqueue_script('fluentform_all_entries');
625 $this->app->view->render('admin.all_entries', []);
626 }
627
628 public function renderFormInnerPages()
629 {
630 $form_id = intval($this->app->request->get('form_id'));
631
632 $form = wpFluent()->table('fluentform_forms')->find($form_id);
633
634 if (!$form) {
635 echo '<h2>' . esc_html__('No form found', 'fluentform') . '</h2>';
636 return;
637 }
638
639 $formAdminMenus = [];
640
641 if (Acl::hasPermission('fluentform_forms_manager', $form_id)) {
642 $formAdminMenus = [
643 'editor' => [
644 'slug' => 'editor',
645 'title' => __('Editor', 'fluentform'),
646 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor'),
647 ],
648 'settings' => [
649 'slug' => 'settings',
650 'hash' => 'basic_settings',
651 'title' => __('Settings & Integrations', 'fluentform'),
652 'sub_route' => 'form_settings',
653 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings'),
654 ],
655 ];
656 }
657
658 if (Acl::hasPermission('fluentform_entries_viewer', $form_id)) {
659 $formAdminMenus['entries'] = [
660 'slug' => 'entries',
661 'hash' => '/',
662 'title' => __('Entries', 'fluentform'),
663 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries'),
664 ];
665 }
666
667 $formAdminMenus = apply_filters_deprecated(
668 'fluentform_form_admin_menu',
669 [
670 $formAdminMenus,
671 $form_id,
672 $form
673 ],
674 FLUENTFORM_FRAMEWORK_UPGRADE,
675 'fluentform/form_admin_menu',
676 'Use fluentform/form_admin_menu instead of fluentform_form_admin_menu.'
677 );
678
679 $formAdminMenus = apply_filters('fluentform/form_admin_menu', $formAdminMenus, $form_id, $form);
680
681 $route = sanitize_key($this->app->request->get('route'));
682
683 $this->app->view->render('admin.form.form_wrapper', [
684 'route' => $route,
685 'form_id' => $form_id,
686 'form' => $form,
687 'menu_items' => $formAdminMenus,
688 ]);
689 }
690
691 public function renderSettings($form_id)
692 {
693 $settingsMenus = [
694 'form_settings' => [
695 'title' => __('Form Settings', 'fluentform'),
696 'slug' => 'form_settings',
697 'hash' => 'basic_settings',
698 'route' => '/',
699 ],
700 'email_notifications' => [
701 'title' => __('Email Notifications', 'fluentform'),
702 'slug' => 'form_settings',
703 'hash' => 'email_notifications',
704 'route' => '/email-settings',
705 ],
706 'conditional_confirmations' => [
707 'title' => __('Conditional Confirmations', 'fluentform'),
708 'slug' => 'form_settings',
709 'hash' => 'conditional_confirmations',
710 'route' => '/conditional-confirmations',
711 ],
712 'all_integrations' => [
713 'title' => __('Configure Integrations', 'fluentform'),
714 'slug' => 'form_settings',
715 'route' => '/all-integrations',
716 ],
717 ];
718
719 if (Helper::isSlackEnabled()) {
720 $settingsMenus['slack'] = [
721 'title' => __('Slack', 'fluentform'),
722 'slug' => 'form_settings',
723 'hash' => 'slack',
724 'route' => '/slack',
725 ];
726 }
727
728 $settingsMenus = apply_filters_deprecated('fluentform_form_settings_menu', [
729 $settingsMenus,
730 $form_id
731 ],
732 FLUENTFORM_FRAMEWORK_UPGRADE,
733 'fluentform/form_settings_menu',
734 'Use fluentform/form_settings_menu instead of fluentform_form_settings_menu.'
735 );
736
737 $settingsMenus = apply_filters('fluentform/form_settings_menu', $settingsMenus, $form_id);
738
739 $externalMenuItems = [];
740 foreach ($settingsMenus as $key => $menu) {
741 if (empty($menu['hash'])) {
742 unset($settingsMenus[$key]);
743 $externalMenuItems[$key] = $menu;
744 }
745 }
746
747 $settingsMenus['custom_css_js'] = [
748 'title' => __('Custom CSS/JS', 'fluentform'),
749 'slug' => 'form_settings',
750 'hash' => 'custom_css_js',
751 'route' => '/custom-css-js',
752 ];
753
754 $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
755
756 $currentRoute = sanitize_key($this->app->request->get('sub_route', ''));
757
758 $hasDoubleOptinEnable = 'yes' === ArrayHelper::get(get_option('_fluentform_double_optin_settings'), 'enabled');
759
760 $this->app->view->render('admin.form.settings_wrapper', [
761 'form_id' => $form_id,
762 'settings_menus' => $settingsMenus,
763 'current_sub_route' => $currentRoute,
764 'has_double_opt_in' => $hasDoubleOptinEnable
765 ]);
766 }
767
768 /**
769 * Remove the inactive addOn menu items
770 *
771 * @param string $addOn
772 *
773 * @return boolean
774 */
775 public function filterFormSettingsMenu($settingsMenus, $form_id)
776 {
777 if (array_key_exists('mailchimp_integration', $settingsMenus)) {
778 $option = (array) get_option('_fluentform_mailchimp_details');
779 if (!isset($option['status']) || !$option['status']) {
780 unset($settingsMenus['mailchimp_integration']);
781 }
782 }
783
784 return $settingsMenus;
785 }
786
787 public function renderFormSettings($form_id)
788 {
789 wp_localize_script('fluentform_form_settings', 'FluentFormApp', [
790 'form_id' => $form_id,
791 'plugin' => $this->app->config->get('app.slug'),
792 'hasPro' => defined('FLUENTFORMPRO'),
793 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
794 'hasFluentCRM' => defined('FLUENTCRM'),
795 'upgrade_url' => fluentform_upgrade_url(),
796 'ace_path_url' => fluentformMix('libs/ace'),
797 'is_conversion_form' => Helper::isConversionForm($form_id),
798 'has_fluent_smtp' => defined('FLUENTMAIL'),
799 'fluent_smtp_url' => admin_url('admin.php?page=fluent_forms_smtp'),
800 'form_settings_str' => TranslationString::getSettingsI18n(),
801 'integrationsResource' => [
802 'asset_url' => fluentformMix('img/integrations.png'),
803 'list_url' => fluentform_integrations_url(),
804 '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'),
805 ],
806 'countries' => getFluentFormCountryList(),
807 'getIpInfo' => Helper::getIpinfo(),
808 'has_conv_form_save_and_resume' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.12', '>=')
809 ]);
810
811 $this->app->view->render('admin.form.settings', [
812 'form_id' => $form_id,
813 ]);
814 }
815
816 public function renderForms()
817 {
818 if (!get_option('_fluentform_installed_version')) {
819 (new ActivationHandler())->migrate();
820 }
821
822 if (false !== ($allowForms = FormManagerService::getUserAllowedFormsScope())) {
823 $formsCount = wpFluent()->table('fluentform_forms')->whereIn('id', $allowForms ?: [0])->count();
824 } else {
825 $formsCount = wpFluent()->table('fluentform_forms')->count();
826 }
827
828 $isDisabledAnalytics = apply_filters_deprecated(
829 'fluentform-disabled_analytics',
830 [
831 true
832 ],
833 FLUENTFORM_FRAMEWORK_UPGRADE,
834 'fluentform/disabled_analytics',
835 'Use fluentform/disabled_analytics instead of fluentform-disabled_analytics.'
836 );
837
838 $data = [
839 'plugin' => $this->app->config->get('app.slug'),
840 'formsCount' => $formsCount,
841 'hasPro' => defined('FLUENTFORMPRO'),
842 'upgrade_url' => fluentform_upgrade_url(),
843 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
844 'adminUrlWithoutPageHash' => admin_url('admin.php'),
845 'isDisableAnalytics' => $this->app->applyFilters('fluentform/disabled_analytics', $isDisabledAnalytics),
846 'plugin_public_url' => fluentformMix(),
847 'siteUrl' => site_url(),
848 ];
849
850 if (defined('FLUENTFORMPRO')){
851 $data['landing_page_enabled_forms']= Helper::getLandingPageEnabledForms();
852 }
853
854
855 $data = apply_filters_deprecated(
856 'fluent_all_forms_vars',
857 [
858 $data
859 ],
860 FLUENTFORM_FRAMEWORK_UPGRADE,
861 'fluentform/all_forms_vars',
862 'Use fluentform/all_forms_vars instead of fluent_all_forms_vars.'
863 );
864
865 wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluentform/all_forms_vars', $data));
866
867 $this->app->view->render('admin.all_forms', []);
868 }
869
870 public function renderEditor($form_id)
871 {
872 $this->app->view->render('admin.form.editor', [
873 'plugin' => $this->app->config->get('app.slug'),
874 'form_id' => $form_id,
875 ]);
876 }
877
878 public function renderDocs()
879 {
880 (new DocumentationModule())->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --
881 }
882
883 public function renderAddOns()
884 {
885 (new AddOnModule())->render();
886 }
887
888 private function enqueueEditorAssets()
889 {
890 $formId = (int) $this->app->request->get('form_id');
891
892 $form = wpFluent()->table('fluentform_forms')->find($formId);
893
894 do_action_deprecated(
895 'fluentform_loading_editor_assets',
896 [
897 $form
898 ],
899 FLUENTFORM_FRAMEWORK_UPGRADE,
900 'fluentform/loading_editor_assets',
901 'Use fluentform/loading_editor_assets instead of fluentform_loading_editor_assets'
902 );
903
904 do_action('fluentform/loading_editor_assets', $form);
905
906 wp_enqueue_style('fluentform_editor_sass');
907 wp_enqueue_style('fluentform_editor_style');
908
909 $pluginSlug = $this->app->config->get('app.slug');
910
911 if (function_exists('wp_enqueue_editor')) {
912 add_filter('user_can_richedit', '__return_true');
913 wp_enqueue_editor();
914 wp_enqueue_media();
915 }
916
917 wp_enqueue_script('fluentform_editor_script');
918
919 $jsonData = $form->form_fields;
920
921 if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
922 $formFields = $form->form_fields;
923
924 if ($formFields) {
925 $formFields = json_decode($formFields, true);
926
927 foreach ($formFields['fields'] as $index => $formField) {
928 $formField = apply_filters_deprecated(
929 'fluentform_editor_init_element_' . $formField['element'],
930 [
931 $formField,
932 $form
933 ],
934 FLUENTFORM_FRAMEWORK_UPGRADE,
935 'fluentform/editor_init_element_' . $formField['element'],
936 'Use fluentform/editor_init_element_' . $formField['element'] . ' instead of fluentform_editor_init_element_' . $formField['element']
937 );
938
939 $formField = $formFields['fields'][$index] = apply_filters(
940 'fluentform/editor_init_element_' . $formField['element'],
941 $formField,
942 $form
943 );
944
945 if (!$formFields['fields'][$index]) {
946 unset($formFields['fields'][$index]);
947 continue;
948 }
949
950 if ('container' == $formField['element']) {
951 $columns = $formField['columns'];
952 foreach ($columns as $columnIndex => $column) {
953 foreach ($column['fields'] as $fieldIndex => $columnField) {
954 $columnField = apply_filters_deprecated(
955 'fluentform_editor_init_element_' . $columnField['element'],
956 [
957 $columnField,
958 $form
959 ],
960 FLUENTFORM_FRAMEWORK_UPGRADE,
961 'fluentform/editor_init_element_' . $columnField['element'],
962 'Use fluentform/editor_init_element_' . $columnField['element'] . ' instead of fluentform_editor_init_element_' . $columnField['element']
963 );
964
965 $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
966 'fluentform/editor_init_element_' . $columnField['element'],
967 $columnField,
968 $form
969 );
970
971 if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
972 unset($columns[$columnIndex]['fields'][$fieldIndex]);
973 }
974 }
975 }
976
977 $formFields['fields'][$index]['columns'] = array_values($columns);
978 }
979 }
980
981 $formFields['fields'] = array_values($formFields['fields']);
982 $formFields = json_encode($formFields, true);
983 }
984
985 $form->form_fields = $formFields;
986 }
987
988 $searchTags = fluentformLoadFile('Services/FormBuilder/ElementSearchTags.php');
989
990 $searchTags = apply_filters_deprecated(
991 'fluentform_editor_element_search_tags',
992 [
993 $searchTags
994 ],
995 FLUENTFORM_FRAMEWORK_UPGRADE,
996 'fluentform/editor_element_search_tags',
997 'Use fluentform/editor_element_search_tags instead of fluent_editor_element_search_tags.'
998 );
999 $searchTags = apply_filters('fluentform/editor_element_search_tags', $searchTags, $form);
1000
1001 $elementPlacements = fluentformLoadFile('Services/FormBuilder/ElementSettingsPlacement.php');
1002 $elementPlacements = apply_filters_deprecated(
1003 'fluentform_editor_element_settings_placement',
1004 [
1005 $elementPlacements,
1006 $form
1007 ],
1008 FLUENTFORM_FRAMEWORK_UPGRADE,
1009 'fluentform/editor_element_settings_placement',
1010 'Use fluentform/editor_element_settings_placement instead of fluent_editor_element_settings_placement.'
1011 );
1012
1013 $elementPlacements = apply_filters(
1014 'fluentform/editor_element_settings_placement',
1015 $elementPlacements,
1016 $form
1017 );
1018 $data = [
1019 'plugin' => $pluginSlug,
1020 'form_id' => $formId,
1021 'plugin_public_url' => fluentformMix(),
1022 'preview_url' => Helper::getPreviewUrl($formId),
1023 'form' => $form,
1024 'hasPro' => defined('FLUENTFORMPRO'),
1025 'countries' => getFluentFormCountryList(),
1026 'element_customization_settings' => fluentformLoadFile('Services/FormBuilder/ElementCustomization.php'),
1027 'validation_rule_settings' => fluentformLoadFile('Services/FormBuilder/ValidationRuleSettings.php'),
1028 'conversational_form_fields' => array_keys(Converter::fieldTypes()),
1029 'form_editor_str' => TranslationString::getEditorI18n(),
1030 'element_search_tags' => $searchTags,
1031 'element_settings_placement' => $elementPlacements,
1032 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
1033 'has_payment_features' => true,
1034 'upgrade_url' => fluentform_upgrade_url(),
1035 'is_conversion_form' => Helper::isConversionForm($formId),
1036 'is_autoload_captcha' => Helper::isAutoloadCaptchaEnabled(),
1037 'autosave_enabled' => Helper::isAutosaveEnabled(),
1038 'used_name_attributes' => $this->usedNameAttributes($formId),
1039 '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"]}',
1040 ];
1041
1042 // if has pro and payment enable. We will use this filter hook to push custom elements
1043 if (defined('FLUENTFORMPRO')) {
1044 $data['calc_items'] = [
1045 'paymentElements' => [
1046 'multi_payment_component',
1047 'input_number',
1048 'repeater_field',
1049 'net_promoter_score',
1050 'rangeslider',
1051 'custom_payment_component',
1052 'item_quantity_component',
1053 'subscription_payment_component'
1054 ]
1055 ];
1056 }
1057
1058 $data = apply_filters_deprecated(
1059 'fluentform_editor_vars',
1060 [
1061 $data
1062 ],
1063 FLUENTFORM_FRAMEWORK_UPGRADE,
1064 'fluentform/editor_vars',
1065 'Use fluentform/editor_vars instead of fluentform_editor_vars.'
1066 );
1067
1068 wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform/editor_vars', $data));
1069
1070 do_action('fluentform/editor_script_loaded', $form);
1071 }
1072
1073 /**
1074 * Render global settings page.
1075 *
1076 * @throws \Exception
1077 */
1078 public function renderGlobalSettings()
1079 {
1080 if (function_exists('wp_enqueue_editor')) {
1081 add_filter('user_can_richedit', '__return_true');
1082 wp_enqueue_editor();
1083 wp_enqueue_media();
1084 }
1085
1086 // Fire an event letting others know the current component
1087 // that fluentform is rendering for the global settings
1088 // page. So that they can hook and load their custom
1089 // components on this page dynamically & easily.
1090 // N.B. native 'components' will always use
1091 // 'settings' as their current component.
1092 $currentComponent = $this->app->request->get('component', 'settings');
1093
1094 $currentComponent = apply_filters_deprecated('fluentform_global_settings_current_component', [
1095 $currentComponent
1096 ],
1097 FLUENTFORM_FRAMEWORK_UPGRADE,
1098 'fluentform/global_settings_current_component',
1099 'Use fluentform/global_settings_current_component instead of fluentform_global_settings_current_component.'
1100 );
1101
1102 $currentComponent = apply_filters(
1103 'fluentform/global_settings_current_component',
1104 $currentComponent
1105 );
1106
1107 $currentComponent = sanitize_key($currentComponent);
1108 $components = [];
1109 $components = apply_filters_deprecated('fluentform_global_settings_components', [
1110 $components
1111 ],
1112 FLUENTFORM_FRAMEWORK_UPGRADE,
1113 'fluentform/global_settings_components',
1114 'Use fluentform/global_settings_components instead of fluentform_global_settings_components.'
1115 );
1116
1117 $components = apply_filters('fluentform/global_settings_components', $components);
1118
1119 $components['reCAPTCHA'] = [
1120 'hash' => 're_captcha',
1121 'title' => 'reCAPTCHA',
1122 ];
1123
1124 $components['hCAPTCHA'] = [
1125 'hash' => 'h_captcha',
1126 'title' => 'hCaptcha',
1127 ];
1128
1129 $components['Turnstile'] = [
1130 'hash' => 'turnstile',
1131 'title' => 'Turnstile',
1132 ];
1133
1134 $components['CleanTalk'] = [
1135 'hash' => 'cleantalk',
1136 'title' => 'CleanTalk',
1137 ];
1138
1139 $customLinks = apply_filters('fluentform/global_settings_menu', []);
1140 $this->app->view->render('admin.globalSettings.menu', [
1141 'components' => $components,
1142 'customLinks' => $customLinks,
1143 'currentComponent' => $currentComponent,
1144 ]);
1145 }
1146
1147 public function renderTransfer()
1148 {
1149 $allowForms = FormManagerService::getUserAllowedFormsScope();
1150 $forms = wpFluent()->table('fluentform_forms')
1151 ->orderBy('id', 'desc')
1152 ->select(['id', 'title'])
1153 ->when(false !== $allowForms, function ($q) use ($allowForms){
1154 return $q->whereIn('id', $allowForms ?: [0]);
1155 })
1156 ->get();
1157
1158 wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
1159 'plugin' => $this->app->config->get('app.slug'),
1160 'forms' => $forms,
1161 'upgrade_url' => fluentform_upgrade_url(),
1162 'hasPro' => defined('FLUENTFORMPRO'),
1163 'transfer_str' => TranslationString::getTransferModuleI18n(),
1164 'source_query' => sanitize_text_field($this->app->request->get('source')),
1165 'status_query' => sanitize_text_field($this->app->request->get('status')),
1166 'date_start_query' => sanitize_text_field($this->app->request->get('start_date')),
1167 'date_end_query' => sanitize_text_field($this->app->request->get('end_date')),
1168 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
1169 ]);
1170
1171 $this->app->view->render('admin.tools.index');
1172 }
1173
1174 public function addPreviewButton($formId)
1175 {
1176 $previewUrl = Helper::getPreviewUrl($formId);
1177 $previewText = __('Preview & Design', 'fluentform');
1178 $formId = (int)$formId;
1179 if (Helper::isConversionForm($formId)) {
1180 $previewText = __('Preview', 'fluentform');
1181 }
1182 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>';
1183 }
1184
1185 public function addCopyShortcodeButton($formId)
1186 {
1187 $formId = (int) $formId;
1188 $shortcode = '[fluentform id="' . $formId . '"]';
1189 if (Helper::isConversionForm($formId)) {
1190 $shortcode = '[fluentform type="conversational" id="' . $formId . '"]';
1191 }
1192 echo '<button title="Click to Copy" 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.
1193 return;
1194 }
1195
1196 public function commonAction()
1197 {
1198 $fluentFormPages = [
1199 'fluent_forms',
1200 'fluent_forms_transfer',
1201 'fluent_forms_settings',
1202 'fluent_forms_add_ons',
1203 'fluent_forms_docs',
1204 'fluent_forms_smtp',
1205 ];
1206
1207 $page = sanitize_text_field($this->app->request->get('page'));
1208
1209 if ($page && in_array($page, $fluentFormPages)) {
1210 // Let's deregister existing vuejs by other devs
1211 // Other devs should not regis
1212 add_action('admin_print_scripts', function () {
1213 wp_dequeue_script('vuejs');
1214 wp_dequeue_script('vue');
1215 wp_deregister_script('elementor-admin-app');
1216 });
1217 }
1218 }
1219
1220 public function renderGlobalMenu()
1221 {
1222 $showPayment = !PaymentHelper::hasPaymentSettings();
1223 if ($showPayment) {
1224 $formCount = wpFluent()->table('fluentform_forms')
1225 ->count();
1226 $showPayment = $formCount > 2;
1227 }
1228 $showPaymentEntry = apply_filters_deprecated('fluentform_show_payment_entries', [
1229 false
1230 ],
1231 FLUENTFORM_FRAMEWORK_UPGRADE,
1232 'fluentform/show_payment_entries',
1233 'Use fluentform/show_payment_entries instead of fluentform/show_payment_entries.'
1234 );
1235
1236 $this->app->view->render('admin.global_menu', [
1237 'logo' => fluentformMix('img/fluentform-logo.svg'),
1238 'show_payment' => $showPayment,
1239 'show_payment_entries' => apply_filters('fluentform/show_payment_entries', $showPaymentEntry),
1240 ]);
1241 }
1242
1243 public function renderPaymentEntries()
1244 {
1245 do_action_deprecated(
1246 'flunetform_render_payment_entries', [],
1247 FLUENTFORM_FRAMEWORK_UPGRADE,
1248 'fluentform/render_payment_entries',
1249 'Use fluentform/render_payment_entries instead of flunetform/render_payment_entries'
1250 );
1251
1252 do_action('fluentform/render_payment_entries');
1253 }
1254
1255 public function renderSmtpPromo()
1256 {
1257 wp_enqueue_script('fluentform_admin_notice', fluentformMix('js/admin_notices.js'), [
1258 'jquery',
1259 ], FLUENTFORM_VERSION, true);
1260
1261 $this->app->view->render('admin.smtp.index', [
1262 'logo' => fluentformMix('img/fluentsmtp.svg'),
1263 'banner_image' => fluentformMix('img/fluentsmtp-banner.png'),
1264 'is_installed' => defined('FLUENTMAIL'),
1265 'setup_url' => admin_url('options-general.php?page=fluent-mail#/connections'),
1266 ]);
1267 }
1268
1269 public function renderReports()
1270 {
1271 do_action('fluentform/render_report');
1272 }
1273
1274 private function usedNameAttributes($formId)
1275 {
1276 return wpFluent()->table('fluentform_entry_details')
1277 ->select(['field_name'])
1278 ->where('form_id', $formId)
1279 ->orderBy('submission_id', 'desc')
1280 ->groupBy('field_name')
1281 ->get();
1282 }
1283 }
1284