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

1,275 lines 55.0 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 $globalVars['i18n_rest_404'] = __('Fluent Forms REST endpoints are unreachable on this site. This sometimes happens after a plugin update try reloading the page, clearing your site cache, or asking your host to clear PHP OpCache. If the issue persists, check whether a security plugin is blocking REST requests.', 'fluentform');
332
333 wp_localize_script('fluent_forms_global', 'fluent_forms_global_var', $globalVars);
334
335 $page = sanitize_text_field($this->app->request->get('page'));
336 $route = sanitize_text_field($this->app->request->get('route'));
337 $formId = intval($this->app->request->get('form_id'));
338
339 if ('fluent_forms' == $page && $route && $formId) {
340 if (true) {
341 wp_enqueue_style('fluentform_settings_global');
342 wp_enqueue_script('clipboard');
343 wp_enqueue_script('copier');
344
345 if (Acl::hasPermission('fluentform_forms_manager', $formId)) {
346 if ('settings' == $route) {
347 if (function_exists('wp_enqueue_editor')) {
348 add_filter('user_can_richedit', function ($status) {
349 return true;
350 });
351
352 wp_enqueue_editor();
353 wp_enqueue_media();
354 }
355 do_action('fluentform/loading_settings_assets', $formId);
356 wp_enqueue_script('fluentform_form_settings');
357 } elseif ('editor' == $route) {
358 $this->enqueueEditorAssets();
359 }
360 }
361 }
362 } elseif ('fluent_forms' == $page) {
363 wp_enqueue_script('fluent_all_forms');
364 wp_enqueue_style('fluent_all_forms');
365 }elseif ('fluent_forms_transfer' == $page) {
366 wp_enqueue_style('fluentform_settings_global');
367 wp_enqueue_script('fluentform-transfer-js');
368 } elseif (
369 'fluent_forms_settings' == $page ||
370 'fluent_forms_payment_entries' == $page ||
371 'fluent_forms_all_entries' == $page
372 ) {
373 wp_enqueue_style('fluentform_settings_global');
374 } elseif ('fluent_forms_add_ons' == $page) {
375 wp_enqueue_style('fluentform-add-ons');
376 } elseif ('fluent_forms_docs' == $page) {
377 wp_enqueue_style('fluentform_doc_style');
378 }
379 }
380
381 /**
382 * Register menu and sub-menus.
383 */
384 public function register()
385 {
386 $dashBoardCapability = apply_filters_deprecated(
387 'fluentform_dashboard_capability',
388 [
389 'fluentform_dashboard_access'
390 ],
391 FLUENTFORM_FRAMEWORK_UPGRADE,
392 'fluentform/dashboard_capability',
393 'Use fluentform/dashboard_capability instead of fluentform_dashboard_capability.'
394 );
395
396 $dashBoardCapability = $this->app->applyFilters(
397 'fluentform/dashboard_capability',
398 $dashBoardCapability
399 );
400
401 $settingManager = apply_filters_deprecated(
402 'fluentform_settings_capability',
403 [
404 'fluentform_settings_manager'
405 ],
406 FLUENTFORM_FRAMEWORK_UPGRADE,
407 'fluentform/settings_capability',
408 'Use fluentform/settings_capability instead of fluentform_settings_capability.'
409 );
410
411 $settingsCapability = $this->app->applyFilters(
412 'fluentform/settings_capability',
413 $settingManager
414 );
415
416 $fromRole = false;
417 if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
418 $currentUserCapability = Acl::getCurrentUserCapability();
419
420 if (!$currentUserCapability) {
421 return;
422 } else {
423 $fromRole = true;
424 $dashBoardCapability = $settingsCapability = $currentUserCapability;
425 }
426 }
427
428 if (Acl::isSuperMan()) {
429 $fromRole = true;
430 }
431
432 if (defined('FLUENTFORMPRO')) {
433 $title = __('Fluent Forms Pro', 'fluentform');
434 } else {
435 $title = __('Fluent Forms', 'fluentform');
436 }
437
438 $menuPriority = 25;
439
440 if (defined('FLUENTCRM')) {
441 $menuPriority = 3;
442 }
443
444 add_menu_page(
445 $title,
446 $title,
447 $dashBoardCapability,
448 'fluent_forms',
449 [$this, 'renderFormAdminRoute'],
450 $this->getMenuIcon(),
451 $menuPriority
452 );
453
454 add_submenu_page(
455 'fluent_forms',
456 __('Forms', 'fluentform'),
457 __('Forms', 'fluentform'),
458 $dashBoardCapability,
459 'fluent_forms',
460 [$this, 'renderFormAdminRoute']
461 );
462
463 if ($settingsCapability) {
464 add_submenu_page(
465 'fluent_forms',
466 __('New Form', 'fluentform'),
467 __('New Form', 'fluentform'),
468 $fromRole ? $settingsCapability : 'fluentform_forms_manager',
469 'fluent_forms#add=1',
470 [$this, 'renderAddNewFormRoute']
471 );
472
473 $entriesTitle = __('Entries', 'fluentform');
474
475 if (Helper::isFluentAdminPage()) {
476 $allowForms = FormManagerService::getUserAllowedFormsScope();
477 $entriesCount = wpFluent()->table('fluentform_submissions')
478 ->where('status', 'unread')
479 ->when(false !== $allowForms, function ($q) use ($allowForms){
480 return $q->whereIn('form_id', $allowForms ?: [0]);
481 })
482 ->count();
483
484 if ($entriesCount) {
485 $entriesTitle .= ' <span class="ff_unread_count" style="background: #197efb;color: white;border-radius: 8px;padding: 1px 8px;">' . $entriesCount . '</span>';
486 }
487 }
488
489 // Register entries intermediary page
490 add_submenu_page(
491 'fluent_forms',
492 $entriesTitle,
493 $entriesTitle,
494 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
495 'fluent_forms_all_entries',
496 [$this, 'renderAllEntriesAdminRoute']
497 );
498
499 // Register Reports sub menu page.
500 add_submenu_page(
501 'fluent_forms',
502 __('Reports', 'fluentform'),
503 __('Reports', 'fluentform'),
504 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
505 'fluent_forms_reports',
506 [$this, 'renderReports']
507 );
508
509 $isShowPaymentSubmission = apply_filters_deprecated(
510 'fluentform_show_payment_entries',
511 [
512 false
513 ],
514 FLUENTFORM_FRAMEWORK_UPGRADE,
515 'fluentform/show_payment_entries',
516 'Use fluentform/show_payment_entries instead of fluentform_show_payment_entries.'
517 );
518
519 if (apply_filters('fluentform/show_payment_entries', $isShowPaymentSubmission)) {
520 add_submenu_page(
521 'fluent_forms',
522 __('Payments', 'fluentform'),
523 __('Payments', 'fluentform'),
524 $fromRole ? $settingsCapability : 'fluentform_view_payments',
525 'fluent_forms_payment_entries',
526 [$this, 'renderPaymentEntries']
527 );
528 }
529
530 // Register global settings sub menu page.
531 add_submenu_page(
532 'fluent_forms',
533 __('Global Settings', 'fluentform'),
534 __('Global Settings', 'fluentform'),
535 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
536 'fluent_forms_settings',
537 [$this, 'renderGlobalSettings']
538 );
539
540 // Register import/export sub menu page.
541 add_submenu_page(
542 'fluent_forms',
543 __('Tools', 'fluentform'),
544 __('Tools', 'fluentform'),
545 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
546 'fluent_forms_transfer',
547 [$this, 'renderTransfer']
548 );
549
550 // Register Add-Ons
551 add_submenu_page(
552 'fluent_forms',
553 __('Integrations', 'fluentform'),
554 __('Integrations', 'fluentform'),
555 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
556 'fluent_forms_add_ons',
557 [$this, 'renderAddOns']
558 );
559 }
560
561 // Register Documentation
562 add_submenu_page(
563 'fluent_forms',
564 __('Support', 'fluentform'),
565 __('Support', 'fluentform'),
566 $dashBoardCapability,
567 'fluent_forms_docs',
568 [$this, 'renderDocs']
569 );
570
571 $this->commonAction();
572 }
573
574 private function getMenuIcon()
575 {
576 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>');
577 }
578
579 public function renderFormAdminRoute()
580 {
581 $formId = intval($this->app->request->get('form_id'));
582 $route = sanitize_key($this->app->request->get('route'));
583
584 if ($route && $formId) {
585 $formRoutePermissionSet = apply_filters('fluentform/form_inner_route_permission_set', [
586 'editor' => 'fluentform_forms_manager',
587 'settings' => 'fluentform_forms_manager',
588 'entries' => 'fluentform_entries_viewer',
589 'reports' => 'fluentform_entries_viewer',
590 ]);
591
592 $toVerifyPermission = ArrayHelper::get(
593 $formRoutePermissionSet,
594 $route,
595 'fluentform_forms_manager'
596 );
597
598 $hasPermission = apply_filters(
599 'fluentform/inner_route_has_permission',
600 Acl::hasPermission($toVerifyPermission, $formId),
601 $route,
602 $formId
603 );
604
605 if ($hasPermission) {
606 return $this->renderFormInnerPages();
607 } else {
608 return $this->app->view->render('admin.no_permission');
609 }
610 }
611
612 $this->renderForms();
613 }
614
615 public function renderAllEntriesAdminRoute()
616 {
617 wp_enqueue_script('fluentform_all_entries');
618 $this->app->view->render('admin.all_entries', []);
619 }
620
621 public function renderFormInnerPages()
622 {
623 $form_id = intval($this->app->request->get('form_id'));
624
625 $form = wpFluent()->table('fluentform_forms')->find($form_id);
626
627 if (!$form) {
628 echo '<h2>' . esc_html__('No form found', 'fluentform') . '</h2>';
629 return;
630 }
631
632 $formAdminMenus = [];
633
634 if (Acl::hasPermission('fluentform_forms_manager', $form_id)) {
635 $formAdminMenus = [
636 'editor' => [
637 'slug' => 'editor',
638 'title' => __('Editor', 'fluentform'),
639 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor'),
640 ],
641 'settings' => [
642 'slug' => 'settings',
643 'hash' => 'basic_settings',
644 'title' => __('Settings & Integrations', 'fluentform'),
645 'sub_route' => 'form_settings',
646 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings'),
647 ],
648 ];
649 }
650
651 if (Acl::hasPermission('fluentform_entries_viewer', $form_id)) {
652 $formAdminMenus['entries'] = [
653 'slug' => 'entries',
654 'hash' => '/',
655 'title' => __('Entries', 'fluentform'),
656 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries'),
657 ];
658 }
659
660 $formAdminMenus = apply_filters_deprecated(
661 'fluentform_form_admin_menu',
662 [
663 $formAdminMenus,
664 $form_id,
665 $form
666 ],
667 FLUENTFORM_FRAMEWORK_UPGRADE,
668 'fluentform/form_admin_menu',
669 'Use fluentform/form_admin_menu instead of fluentform_form_admin_menu.'
670 );
671
672 $formAdminMenus = apply_filters('fluentform/form_admin_menu', $formAdminMenus, $form_id, $form);
673
674 $route = sanitize_key($this->app->request->get('route'));
675
676 $this->app->view->render('admin.form.form_wrapper', [
677 'route' => $route,
678 'form_id' => $form_id,
679 'form' => $form,
680 'menu_items' => $formAdminMenus,
681 ]);
682 }
683
684 public function renderSettings($form_id)
685 {
686 $settingsMenus = [
687 'form_settings' => [
688 'title' => __('Form Settings', 'fluentform'),
689 'slug' => 'form_settings',
690 'hash' => 'basic_settings',
691 'route' => '/',
692 ],
693 'email_notifications' => [
694 'title' => __('Email Notifications', 'fluentform'),
695 'slug' => 'form_settings',
696 'hash' => 'email_notifications',
697 'route' => '/email-settings',
698 ],
699 'conditional_confirmations' => [
700 'title' => __('Conditional Confirmations', 'fluentform'),
701 'slug' => 'form_settings',
702 'hash' => 'conditional_confirmations',
703 'route' => '/conditional-confirmations',
704 ],
705 'all_integrations' => [
706 'title' => __('Configure Integrations', 'fluentform'),
707 'slug' => 'form_settings',
708 'route' => '/all-integrations',
709 ],
710 ];
711
712 if (Helper::isSlackEnabled()) {
713 $settingsMenus['slack'] = [
714 'title' => __('Slack', 'fluentform'),
715 'slug' => 'form_settings',
716 'hash' => 'slack',
717 'route' => '/slack',
718 ];
719 }
720
721 $settingsMenus = apply_filters_deprecated('fluentform_form_settings_menu', [
722 $settingsMenus,
723 $form_id
724 ],
725 FLUENTFORM_FRAMEWORK_UPGRADE,
726 'fluentform/form_settings_menu',
727 'Use fluentform/form_settings_menu instead of fluentform_form_settings_menu.'
728 );
729
730 $settingsMenus = apply_filters('fluentform/form_settings_menu', $settingsMenus, $form_id);
731
732 $externalMenuItems = [];
733 foreach ($settingsMenus as $key => $menu) {
734 if (empty($menu['hash'])) {
735 unset($settingsMenus[$key]);
736 $externalMenuItems[$key] = $menu;
737 }
738 }
739
740 $settingsMenus['custom_css_js'] = [
741 'title' => __('Custom CSS/JS', 'fluentform'),
742 'slug' => 'form_settings',
743 'hash' => 'custom_css_js',
744 'route' => '/custom-css-js',
745 ];
746
747 $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
748
749 $currentRoute = sanitize_key($this->app->request->get('sub_route', ''));
750
751 $hasDoubleOptinEnable = 'yes' === ArrayHelper::get(get_option('_fluentform_double_optin_settings'), 'enabled');
752
753 $this->app->view->render('admin.form.settings_wrapper', [
754 'form_id' => $form_id,
755 'settings_menus' => $settingsMenus,
756 'current_sub_route' => $currentRoute,
757 'has_double_opt_in' => $hasDoubleOptinEnable
758 ]);
759 }
760
761 /**
762 * Remove the inactive addOn menu items
763 *
764 * @param string $addOn
765 *
766 * @return boolean
767 */
768 public function filterFormSettingsMenu($settingsMenus, $form_id)
769 {
770 if (array_key_exists('mailchimp_integration', $settingsMenus)) {
771 $option = (array) get_option('_fluentform_mailchimp_details');
772 if (!isset($option['status']) || !$option['status']) {
773 unset($settingsMenus['mailchimp_integration']);
774 }
775 }
776
777 return $settingsMenus;
778 }
779
780 public function renderFormSettings($form_id)
781 {
782 wp_localize_script('fluentform_form_settings', 'FluentFormApp', [
783 'form_id' => $form_id,
784 'plugin' => $this->app->config->get('app.slug'),
785 'hasPro' => defined('FLUENTFORMPRO'),
786 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
787 'hasFluentCRM' => defined('FLUENTCRM'),
788 'upgrade_url' => fluentform_upgrade_url(),
789 'ace_path_url' => fluentformMix('libs/ace'),
790 'is_conversion_form' => Helper::isConversionForm($form_id),
791 'has_fluent_smtp' => defined('FLUENTMAIL'),
792 'fluent_smtp_url' => defined('FLUENTMAIL')
793 ? admin_url('options-general.php?page=fluent-mail#/connections')
794 : admin_url('admin.php?page=fluent_forms_add_ons&sub_page=suggested_plugins'),
795 'form_settings_str' => TranslationString::getSettingsI18n(),
796 'integrationsResource' => [
797 'asset_url' => fluentformMix('img/integrations.png'),
798 'list_url' => fluentform_integrations_url(),
799 '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'),
800 ],
801 'countries' => getFluentFormCountryList(),
802 'getIpInfo' => Helper::getIpinfo(),
803 'has_conv_form_save_and_resume' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.12', '>=')
804 ]);
805
806 $this->app->view->render('admin.form.settings', [
807 'form_id' => $form_id,
808 ]);
809 }
810
811 public function renderForms()
812 {
813 if (!get_option('_fluentform_installed_version')) {
814 (new ActivationHandler())->migrate();
815 }
816
817 if (false !== ($allowForms = FormManagerService::getUserAllowedFormsScope())) {
818 $formsCount = wpFluent()->table('fluentform_forms')->whereIn('id', $allowForms ?: [0])->count();
819 } else {
820 $formsCount = wpFluent()->table('fluentform_forms')->count();
821 }
822
823 $isDisabledAnalytics = apply_filters_deprecated(
824 'fluentform-disabled_analytics',
825 [
826 true
827 ],
828 FLUENTFORM_FRAMEWORK_UPGRADE,
829 'fluentform/disabled_analytics',
830 'Use fluentform/disabled_analytics instead of fluentform-disabled_analytics.'
831 );
832
833 $data = [
834 'plugin' => $this->app->config->get('app.slug'),
835 'formsCount' => $formsCount,
836 'hasPro' => defined('FLUENTFORMPRO'),
837 'upgrade_url' => fluentform_upgrade_url(),
838 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
839 'adminUrlWithoutPageHash' => admin_url('admin.php'),
840 'isDisableAnalytics' => $this->app->applyFilters('fluentform/disabled_analytics', $isDisabledAnalytics),
841 'plugin_public_url' => fluentformMix(),
842 'siteUrl' => site_url(),
843 ];
844
845 if (defined('FLUENTFORMPRO')){
846 $data['landing_page_enabled_forms']= Helper::getLandingPageEnabledForms();
847 }
848
849
850 $data = apply_filters_deprecated(
851 'fluent_all_forms_vars',
852 [
853 $data
854 ],
855 FLUENTFORM_FRAMEWORK_UPGRADE,
856 'fluentform/all_forms_vars',
857 'Use fluentform/all_forms_vars instead of fluent_all_forms_vars.'
858 );
859
860 wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluentform/all_forms_vars', $data));
861
862 $this->app->view->render('admin.all_forms', []);
863 }
864
865 public function renderEditor($form_id)
866 {
867 $this->app->view->render('admin.form.editor', [
868 'plugin' => $this->app->config->get('app.slug'),
869 'form_id' => $form_id,
870 ]);
871 }
872
873 public function renderDocs()
874 {
875 (new DocumentationModule())->render(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped --
876 }
877
878 public function renderAddOns()
879 {
880 (new AddOnModule())->render();
881 }
882
883 private function enqueueEditorAssets()
884 {
885 $formId = (int) $this->app->request->get('form_id');
886
887 $form = wpFluent()->table('fluentform_forms')->find($formId);
888
889 do_action_deprecated(
890 'fluentform_loading_editor_assets',
891 [
892 $form
893 ],
894 FLUENTFORM_FRAMEWORK_UPGRADE,
895 'fluentform/loading_editor_assets',
896 'Use fluentform/loading_editor_assets instead of fluentform_loading_editor_assets'
897 );
898
899 do_action('fluentform/loading_editor_assets', $form);
900
901 wp_enqueue_style('fluentform_editor_sass');
902 wp_enqueue_style('fluentform_editor_style');
903
904 $pluginSlug = $this->app->config->get('app.slug');
905
906 if (function_exists('wp_enqueue_editor')) {
907 add_filter('user_can_richedit', '__return_true');
908 wp_enqueue_editor();
909 wp_enqueue_media();
910 }
911
912 wp_enqueue_script('fluentform_editor_script');
913
914 $jsonData = $form->form_fields;
915
916 if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
917 $formFields = $form->form_fields;
918
919 if ($formFields) {
920 $formFields = json_decode($formFields, true);
921
922 foreach ($formFields['fields'] as $index => $formField) {
923 $formField = apply_filters_deprecated(
924 'fluentform_editor_init_element_' . $formField['element'],
925 [
926 $formField,
927 $form
928 ],
929 FLUENTFORM_FRAMEWORK_UPGRADE,
930 'fluentform/editor_init_element_' . $formField['element'],
931 'Use fluentform/editor_init_element_' . $formField['element'] . ' instead of fluentform_editor_init_element_' . $formField['element']
932 );
933
934 $formField = $formFields['fields'][$index] = apply_filters(
935 'fluentform/editor_init_element_' . $formField['element'],
936 $formField,
937 $form
938 );
939
940 if (!$formFields['fields'][$index]) {
941 unset($formFields['fields'][$index]);
942 continue;
943 }
944
945 if ('container' == $formField['element']) {
946 $columns = $formField['columns'];
947 foreach ($columns as $columnIndex => $column) {
948 foreach ($column['fields'] as $fieldIndex => $columnField) {
949 $columnField = apply_filters_deprecated(
950 'fluentform_editor_init_element_' . $columnField['element'],
951 [
952 $columnField,
953 $form
954 ],
955 FLUENTFORM_FRAMEWORK_UPGRADE,
956 'fluentform/editor_init_element_' . $columnField['element'],
957 'Use fluentform/editor_init_element_' . $columnField['element'] . ' instead of fluentform_editor_init_element_' . $columnField['element']
958 );
959
960 $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
961 'fluentform/editor_init_element_' . $columnField['element'],
962 $columnField,
963 $form
964 );
965
966 if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
967 unset($columns[$columnIndex]['fields'][$fieldIndex]);
968 }
969 }
970 }
971
972 $formFields['fields'][$index]['columns'] = array_values($columns);
973 }
974 }
975
976 if (!empty($formFields['stepsWrapper']['stepStart'])) {
977 $stepStart = $formFields['stepsWrapper']['stepStart'];
978
979 $formFields['stepsWrapper']['stepStart'] = apply_filters(
980 'fluentform/editor_init_element_' . $stepStart['element'],
981 $stepStart,
982 $form
983 );
984 }
985
986 $formFields['fields'] = array_values($formFields['fields']);
987 $formFields = json_encode($formFields, true);
988 }
989
990 $form->form_fields = $formFields;
991 }
992
993 $searchTags = fluentformLoadFile('Services/FormBuilder/ElementSearchTags.php');
994
995 $searchTags = apply_filters_deprecated(
996 'fluentform_editor_element_search_tags',
997 [
998 $searchTags
999 ],
1000 FLUENTFORM_FRAMEWORK_UPGRADE,
1001 'fluentform/editor_element_search_tags',
1002 'Use fluentform/editor_element_search_tags instead of fluent_editor_element_search_tags.'
1003 );
1004 $searchTags = apply_filters('fluentform/editor_element_search_tags', $searchTags, $form);
1005
1006 $elementPlacements = fluentformLoadFile('Services/FormBuilder/ElementSettingsPlacement.php');
1007 $elementPlacements = apply_filters_deprecated(
1008 'fluentform_editor_element_settings_placement',
1009 [
1010 $elementPlacements,
1011 $form
1012 ],
1013 FLUENTFORM_FRAMEWORK_UPGRADE,
1014 'fluentform/editor_element_settings_placement',
1015 'Use fluentform/editor_element_settings_placement instead of fluent_editor_element_settings_placement.'
1016 );
1017
1018 $elementPlacements = apply_filters(
1019 'fluentform/editor_element_settings_placement',
1020 $elementPlacements,
1021 $form
1022 );
1023 $data = [
1024 'plugin' => $pluginSlug,
1025 'form_id' => $formId,
1026 'plugin_public_url' => fluentformMix(),
1027 'preview_url' => Helper::getPreviewUrl($formId),
1028 'form' => $form,
1029 'hasPro' => defined('FLUENTFORMPRO'),
1030 'countries' => getFluentFormCountryList(),
1031 'element_customization_settings' => fluentformLoadFile('Services/FormBuilder/ElementCustomization.php'),
1032 'validation_rule_settings' => fluentformLoadFile('Services/FormBuilder/ValidationRuleSettings.php'),
1033 'supported_conditional_fields' => (new Fields())->supportedConditionalFields(),
1034 'conversational_form_fields' => array_keys(Converter::fieldTypes()),
1035 'form_editor_str' => TranslationString::getEditorI18n(),
1036 'element_search_tags' => $searchTags,
1037 'element_settings_placement' => $elementPlacements,
1038 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
1039 'has_payment_features' => true,
1040 'upgrade_url' => fluentform_upgrade_url(),
1041 'is_conversion_form' => Helper::isConversionForm($formId),
1042 'is_autoload_captcha' => Helper::isAutoloadCaptchaEnabled(),
1043 'autosave_enabled' => Helper::isAutosaveEnabled(),
1044 'used_name_attributes' => $this->usedNameAttributes($formId),
1045 '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"]}',
1046 ];
1047
1048 // if has pro and payment enable. We will use this filter hook to push custom elements
1049 if (defined('FLUENTFORMPRO')) {
1050 $data['calc_items'] = [
1051 'paymentElements' => [
1052 'multi_payment_component',
1053 'input_number',
1054 'repeater_field',
1055 'net_promoter_score',
1056 'rangeslider',
1057 'custom_payment_component',
1058 'item_quantity_component',
1059 'subscription_payment_component'
1060 ]
1061 ];
1062 }
1063
1064 $data = apply_filters_deprecated(
1065 'fluentform_editor_vars',
1066 [
1067 $data
1068 ],
1069 FLUENTFORM_FRAMEWORK_UPGRADE,
1070 'fluentform/editor_vars',
1071 'Use fluentform/editor_vars instead of fluentform_editor_vars.'
1072 );
1073
1074 wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform/editor_vars', $data));
1075
1076 do_action('fluentform/editor_script_loaded', $form);
1077 }
1078
1079 /**
1080 * Render global settings page.
1081 *
1082 * @throws \Exception
1083 */
1084 public function renderGlobalSettings()
1085 {
1086 if (function_exists('wp_enqueue_editor')) {
1087 add_filter('user_can_richedit', '__return_true');
1088 wp_enqueue_editor();
1089 wp_enqueue_media();
1090 }
1091
1092 // Fire an event letting others know the current component
1093 // that fluentform is rendering for the global settings
1094 // page. So that they can hook and load their custom
1095 // components on this page dynamically & easily.
1096 // N.B. native 'components' will always use
1097 // 'settings' as their current component.
1098 $currentComponent = $this->app->request->get('component', 'settings');
1099
1100 $currentComponent = apply_filters_deprecated('fluentform_global_settings_current_component', [
1101 $currentComponent
1102 ],
1103 FLUENTFORM_FRAMEWORK_UPGRADE,
1104 'fluentform/global_settings_current_component',
1105 'Use fluentform/global_settings_current_component instead of fluentform_global_settings_current_component.'
1106 );
1107
1108 $currentComponent = apply_filters(
1109 'fluentform/global_settings_current_component',
1110 $currentComponent
1111 );
1112
1113 $currentComponent = sanitize_key($currentComponent);
1114 $components = [];
1115 $components = apply_filters_deprecated('fluentform_global_settings_components', [
1116 $components
1117 ],
1118 FLUENTFORM_FRAMEWORK_UPGRADE,
1119 'fluentform/global_settings_components',
1120 'Use fluentform/global_settings_components instead of fluentform_global_settings_components.'
1121 );
1122
1123 $components = apply_filters('fluentform/global_settings_components', $components);
1124
1125 $components['reCAPTCHA'] = [
1126 'hash' => 're_captcha',
1127 'title' => 'reCAPTCHA',
1128 ];
1129
1130 $components['hCAPTCHA'] = [
1131 'hash' => 'h_captcha',
1132 'title' => 'hCaptcha',
1133 ];
1134
1135 $components['Turnstile'] = [
1136 'hash' => 'turnstile',
1137 'title' => 'Turnstile',
1138 ];
1139
1140 $components['CleanTalk'] = [
1141 'hash' => 'cleantalk',
1142 'title' => 'CleanTalk',
1143 ];
1144
1145 $customLinks = apply_filters('fluentform/global_settings_menu', []);
1146 $this->app->view->render('admin.globalSettings.menu', [
1147 'components' => $components,
1148 'customLinks' => $customLinks,
1149 'currentComponent' => $currentComponent,
1150 ]);
1151 }
1152
1153 public function renderTransfer()
1154 {
1155 $allowForms = FormManagerService::getUserAllowedFormsScope();
1156 $forms = wpFluent()->table('fluentform_forms')
1157 ->orderBy('id', 'desc')
1158 ->select(['id', 'title'])
1159 ->when(false !== $allowForms, function ($q) use ($allowForms){
1160 return $q->whereIn('id', $allowForms ?: [0]);
1161 })
1162 ->get();
1163
1164 wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
1165 'plugin' => $this->app->config->get('app.slug'),
1166 'forms' => $forms,
1167 'upgrade_url' => fluentform_upgrade_url(),
1168 'hasPro' => defined('FLUENTFORMPRO'),
1169 'transfer_str' => TranslationString::getTransferModuleI18n(),
1170 'source_query' => sanitize_text_field($this->app->request->get('source')),
1171 'status_query' => sanitize_text_field($this->app->request->get('status')),
1172 'date_start_query' => sanitize_text_field($this->app->request->get('start_date')),
1173 'date_end_query' => sanitize_text_field($this->app->request->get('end_date')),
1174 'has_entries_import' => defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.1.7', '>='),
1175 ]);
1176
1177 $this->app->view->render('admin.tools.index');
1178 }
1179
1180 public function addPreviewButton($formId)
1181 {
1182 $previewUrl = Helper::getPreviewUrl($formId);
1183 $previewText = __('Preview & Design', 'fluentform');
1184 $formId = (int)$formId;
1185 if (Helper::isConversionForm($formId)) {
1186 $previewText = __('Preview', 'fluentform');
1187 }
1188 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>';
1189 }
1190
1191 public function addCopyShortcodeButton($formId)
1192 {
1193 $formId = (int) $formId;
1194 $shortcode = '[fluentform id="' . $formId . '"]';
1195 if (Helper::isConversionForm($formId)) {
1196 $shortcode = '[fluentform type="conversational" id="' . $formId . '"]';
1197 }
1198 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.
1199 return;
1200 }
1201
1202 public function commonAction()
1203 {
1204 $fluentFormPages = [
1205 'fluent_forms',
1206 'fluent_forms_transfer',
1207 'fluent_forms_settings',
1208 'fluent_forms_add_ons',
1209 'fluent_forms_docs',
1210 ];
1211
1212 $page = sanitize_text_field($this->app->request->get('page'));
1213
1214 if ($page && in_array($page, $fluentFormPages)) {
1215 // Let's deregister existing vuejs by other devs
1216 // Other devs should not regis
1217 add_action('admin_print_scripts', function () {
1218 wp_dequeue_script('vuejs');
1219 wp_dequeue_script('vue');
1220 wp_deregister_script('elementor-admin-app');
1221 });
1222 }
1223 }
1224
1225 public function renderGlobalMenu()
1226 {
1227 $showPayment = !PaymentHelper::hasPaymentSettings();
1228 if ($showPayment) {
1229 $formCount = wpFluent()->table('fluentform_forms')
1230 ->count();
1231 $showPayment = $formCount > 2;
1232 }
1233 $showPaymentEntry = apply_filters_deprecated('fluentform_show_payment_entries', [
1234 false
1235 ],
1236 FLUENTFORM_FRAMEWORK_UPGRADE,
1237 'fluentform/show_payment_entries',
1238 'Use fluentform/show_payment_entries instead of fluentform/show_payment_entries.'
1239 );
1240
1241 $this->app->view->render('admin.global_menu', [
1242 'logo' => fluentformMix('img/fluentform-logo.svg'),
1243 'show_payment' => $showPayment,
1244 'show_payment_entries' => apply_filters('fluentform/show_payment_entries', $showPaymentEntry),
1245 ]);
1246 }
1247
1248 public function renderPaymentEntries()
1249 {
1250 do_action_deprecated(
1251 'flunetform_render_payment_entries', [],
1252 FLUENTFORM_FRAMEWORK_UPGRADE,
1253 'fluentform/render_payment_entries',
1254 'Use fluentform/render_payment_entries instead of flunetform/render_payment_entries'
1255 );
1256
1257 do_action('fluentform/render_payment_entries');
1258 }
1259
1260 public function renderReports()
1261 {
1262 do_action('fluentform/render_report');
1263 }
1264
1265 private function usedNameAttributes($formId)
1266 {
1267 return wpFluent()->table('fluentform_entry_details')
1268 ->select(['field_name'])
1269 ->where('form_id', $formId)
1270 ->orderBy('submission_id', 'desc')
1271 ->groupBy('field_name')
1272 ->get();
1273 }
1274 }
1275