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

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