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

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