PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.6
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.6
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 3.6.66 All 195 releases
fluentform / app / Modules / Registerer / Menu.php

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

990 lines 43.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\Modules\Acl\Acl;
7 use FluentForm\App\Modules\Activator;
8 use FluentForm\App\Modules\AddOnModule;
9 use FluentForm\App\Modules\DocumentationModule;
10 use FluentForm\Framework\Foundation\Application;
11 use FluentForm\Framework\Helpers\ArrayHelper;
12 use FluentForm\View;
13
14 class Menu
15 {
16 /**
17 * @var \FluentForm\Framework\Foundation\Application
18 */
19 protected $app;
20
21 /**
22 * Menu constructor.
23 *
24 * @param \FluentForm\Framework\Foundation\Application $application
25 */
26 public function __construct(Application $application)
27 {
28 $this->app = $application;
29
30 $this->app->addFilter('fluentform_form_settings_menu', array(
31 $this, 'filterFormSettingsMenu'
32 ), 10, 2);
33 }
34
35 public function reisterScripts()
36 {
37 if (!$this->isFluentPages()) {
38 return;
39 }
40
41 $app = $this->app;
42
43 wp_register_script(
44 'fluent_forms_global',
45 $app->publicUrl('js/fluent_forms_global.js'),
46 array('jquery'),
47 FLUENTFORM_VERSION,
48 true
49 );
50
51 $settingsGlobalStyle = $app->publicUrl('css/settings_global.css');
52 $allFormsStyle = $app->publicUrl("css/fluent-all-forms.css");
53 $fluentFormAdminEditorStyles = $app->publicUrl("css/fluent-forms-admin-sass.css");
54 $fluentFormAdminCSS = $app->publicUrl("css/fluent-forms-admin.css");
55 $addOnsCss = $app->publicUrl("css/add-ons.css");
56 $adminDocCss = $app->publicUrl("css/admin_docs.css");
57 if (is_rtl()) {
58 $settingsGlobalStyle = $app->publicUrl('css/settings_global_rtl.css');
59 $allFormsStyle = $app->publicUrl("css/fluent-all-forms-rtl.css");
60 $fluentFormAdminEditorStyles = $app->publicUrl("css/fluent-forms-admin-sass-rtl.css");
61 $fluentFormAdminCSS = $app->publicUrl("css/fluent-forms-admin-rtl.css");
62 $addOnsCss = $app->publicUrl("css/add-ons-rtl.css");
63 $adminDocCss = $app->publicUrl("css/admin_docs_rtl.css");
64 }
65
66 wp_register_style(
67 'fluentform_settings_global',
68 $settingsGlobalStyle,
69 array(),
70 FLUENTFORM_VERSION,
71 'all'
72 );
73
74 wp_register_script(
75 'clipboard',
76 $app->publicUrl('libs/clipboard.min.js'),
77 array(),
78 false,
79 true
80 );
81
82 wp_register_script(
83 'copier',
84 $app->publicUrl('js/copier.js'),
85 array(),
86 false,
87 true
88 );
89
90 wp_register_script(
91 'fluentform_form_settings',
92 $app->publicUrl("js/form_settings_app.js"),
93 array('jquery'),
94 FLUENTFORM_VERSION,
95 true
96 );
97
98 wp_register_script(
99 'fluent_all_forms',
100 $app->publicUrl("js/fluent-all-forms-admin.js"),
101 array('jquery'),
102 FLUENTFORM_VERSION,
103 true
104 );
105
106 wp_register_style(
107 'fluent_all_forms',
108 $allFormsStyle,
109 array(),
110 FLUENTFORM_VERSION,
111 'all'
112 );
113
114 wp_register_script(
115 'fluentform_editor_script',
116 $app->publicUrl("js/fluent-forms-editor.js"),
117 array('jquery'),
118 FLUENTFORM_VERSION,
119 true
120 );
121
122 wp_register_style(
123 'fluentform_editor_style',
124 $fluentFormAdminEditorStyles,
125 [],
126 FLUENTFORM_VERSION,
127 'all'
128 );
129
130 wp_register_style(
131 'fluentform_editor_sass',
132 $fluentFormAdminCSS,
133 [],
134 FLUENTFORM_VERSION,
135 'all'
136 );
137
138 wp_register_script(
139 'fluentform-transfer-js',
140 $app->publicUrl("js/fluentform-transfer.js"),
141 ['jquery'],
142 FLUENTFORM_VERSION,
143 true
144 );
145
146 wp_register_script(
147 'fluentform-global-settings-js',
148 $app->publicUrl("js/fluentform-global-settings.js"),
149 ['jquery'],
150 FLUENTFORM_VERSION,
151 true
152 );
153
154 wp_register_script(
155 'fluentform-modules',
156 $app->publicUrl('js/modules.js'),
157 ['jquery'],
158 FLUENTFORM_VERSION,
159 true
160 );
161
162 wp_register_script(
163 'fluentform_form_entries',
164 $app->publicUrl('js/form_entries.js'),
165 array('jquery'),
166 FLUENTFORM_VERSION,
167 true
168 );
169
170 wp_register_script(
171 'fluentform_all_entries',
172 $app->publicUrl('js/all_entries.js'),
173 array('jquery'),
174 FLUENTFORM_VERSION,
175 true
176 );
177
178 wp_register_style(
179 'fluentform-add-ons',
180 $addOnsCss,
181 [],
182 FLUENTFORM_VERSION,
183 'all'
184 );
185
186 wp_register_style(
187 'fluentform_doc_style',
188 $adminDocCss,
189 [],
190 FLUENTFORM_VERSION,
191 'all'
192 );
193
194 add_filter('admin_footer_text', function ($text) {
195 return '<span id="footer-thankyou">Thanks for using <a target="_blank" rel="nofollow" href="https://wordpress.org/plugins/fluentform">Fluent Forms</a>.</span>';
196 });
197
198 $elementUIStyle = $app->publicUrl('css/element-ui-css.css');
199 if (is_rtl()) {
200 $elementUIStyle = $app->publicUrl('css/element-ui-css-rtl.css');
201 }
202 wp_enqueue_style(
203 'fluentform_global_elements',
204 $elementUIStyle,
205 [],
206 FLUENTFORM_VERSION,
207 'all'
208 );
209 }
210
211 public function isFluentPages()
212 {
213 return Helper::isFluentAdminPage();
214 }
215
216 public function enqueuePageScripts()
217 {
218 if (!$this->isFluentPages()) {
219 return;
220 }
221
222 wp_enqueue_script('fluent_forms_global');
223 wp_localize_script('fluent_forms_global', 'fluent_forms_global_var', [
224 'fluent_forms_admin_nonce' => wp_create_nonce('fluent_forms_admin_nonce'),
225 'ajaxurl' => admin_url('admin-ajax.php'),
226 'admin_i18n'=> $this->getAdminI18n(),
227 'permissions' => Acl::getCurrentUserPermissions()
228 ]);
229
230 $page = sanitize_text_field($_GET['page']);
231
232 if ($page == 'fluent_forms' && isset($_GET['route']) && isset($_GET['form_id'])) {
233 if (true) {
234 wp_enqueue_style('fluentform_settings_global');
235 wp_enqueue_script('clipboard');
236 wp_enqueue_script('copier');
237
238 if (Acl::hasPermission('fluentform_forms_manager')) {
239 if ($_GET['route'] == 'settings') {
240 if (function_exists('wp_enqueue_editor')) {
241 add_filter('user_can_richedit', function ($status) {
242 return true;
243 });
244
245 wp_enqueue_editor();
246 wp_enqueue_media();
247 }
248
249 wp_enqueue_script('fluentform_form_settings');
250 } elseif ($_GET['route'] == 'editor') {
251 $this->enqueueEditorAssets();
252 }
253 }
254 }
255 } else if ($page == 'fluent_forms') {
256 wp_enqueue_script('fluent_all_forms');
257 wp_enqueue_style('fluent_all_forms');
258 } else if ($page == 'fluent_forms_transfer') {
259 wp_enqueue_style('fluentform_settings_global');
260 wp_enqueue_script('fluentform-transfer-js');
261 } else if (
262 $page == 'fluent_forms_settings' ||
263 $page == 'fluent_forms_payment_entries' ||
264 $page == 'fluent_forms_all_entries'
265 ) {
266 wp_enqueue_style('fluentform_settings_global');
267 } else if ($page == 'fluent_forms_add_ons') {
268 wp_enqueue_style('fluentform-add-ons');
269 } else if ($page == 'fluent_forms_docs' || $page == 'fluent_forms_smtp') {
270 wp_enqueue_style('fluentform_doc_style');
271 }
272 }
273
274 /**
275 * Register menu and sub-menus.
276 */
277 public function register()
278 {
279 $dashBoardCapability = apply_filters(
280 'fluentform_dashboard_capability', 'fluentform_dashboard_access'
281 );
282
283 $settingsCapability = apply_filters(
284 'fluentform_settings_capability', 'fluentform_settings_manager'
285 );
286
287 $fromRole = false;
288 if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
289 $currentUserCapability = Acl::getCurrentUserCapability();
290
291 if (!$currentUserCapability) {
292 return;
293 } else {
294 $fromRole = true;
295 $dashBoardCapability = $settingsCapability = $currentUserCapability;
296 }
297 }
298
299 if (Acl::isSuperMan()) {
300 $fromRole = true;
301 }
302
303 if (defined('FLUENTFORMPRO')) {
304 $title = __('Fluent Forms Pro', 'fluentform');
305 } else {
306 $title = __('Fluent Forms', 'fluentform');
307 }
308
309 $menuPriority = 25;
310
311 if (defined('FLUENTCRM')) {
312 $menuPriority = 3;
313 }
314
315 add_menu_page(
316 $title,
317 $title,
318 $dashBoardCapability,
319 'fluent_forms',
320 array($this, 'renderFormAdminRoute'),
321 $this->getMenuIcon(),
322 $menuPriority
323 );
324
325
326 add_submenu_page(
327 'fluent_forms',
328 __('All Forms', 'fluentform'),
329 __('All Forms', 'fluentform'),
330 $dashBoardCapability,
331 'fluent_forms',
332 array($this, 'renderFormAdminRoute')
333 );
334
335 if ($settingsCapability) {
336 add_submenu_page(
337 'fluent_forms',
338 __('New Form', 'fluentform'),
339 __('New Form', 'fluentform'),
340 $fromRole ? $settingsCapability : 'fluentform_forms_manager',
341 'fluent_forms#add=1',
342 array($this, 'renderFormAdminRoute')
343 );
344
345 $entriesTitle = __('Entries', 'fluentform');
346
347 if (Helper::isFluentAdminPage()) {
348 $entriesCount = wpFluent()->table('fluentform_submissions')
349 ->where('status', 'unread')
350 ->count();
351
352 if ($entriesCount) {
353 $entriesTitle .= ' <span class="ff_unread_count" style="background: #ca4a20;color: white;border-radius: 8px;padding: 1px 8px;">'.$entriesCount.'</span>';
354 }
355 }
356
357 // Register entries intermediary page
358 add_submenu_page(
359 'fluent_forms',
360 $entriesTitle,
361 $entriesTitle,
362 $fromRole ? $settingsCapability : 'fluentform_entries_viewer',
363 'fluent_forms_all_entries',
364 array($this, 'renderAllEntriesAdminRoute')
365 );
366
367 if (apply_filters('fluentform_show_payment_entries', false)) {
368 add_submenu_page(
369 'fluent_forms',
370 __('Payments', 'fluentform'),
371 __('Payments', 'fluentform'),
372 $fromRole ? $settingsCapability : 'fluentform_view_payments',
373 'fluent_forms_payment_entries',
374 array($this, 'renderPaymentEntries')
375 );
376 }
377
378 // Register global settings sub menu page.
379 add_submenu_page(
380 'fluent_forms',
381 __('Global Settings', 'fluentform'),
382 __('Global Settings', 'fluentform'),
383 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
384 'fluent_forms_settings',
385 array($this, 'renderGlobalSettings')
386 );
387
388 // Register import/export sub menu page.
389 add_submenu_page(
390 'fluent_forms',
391 __('Tools', 'fluentform'),
392 __('Tools', 'fluentform'),
393 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
394 'fluent_forms_transfer',
395 array($this, 'renderTransfer')
396 );
397
398 // Register FluentSMTP Sub Menu.
399 add_submenu_page(
400 'fluent_forms',
401 __('SMTP', 'fluentform'),
402 __('SMTP', 'fluentform'),
403 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
404 'fluent_forms_smtp',
405 array($this, 'renderSmtpPromo')
406 );
407
408 // Register Add-Ons
409 add_submenu_page(
410 'fluent_forms',
411 __('Integration Modules', 'fluentform'),
412 __('Integration Modules', 'fluentform'),
413 $fromRole ? $settingsCapability : 'fluentform_settings_manager',
414 'fluent_forms_add_ons',
415 array($this, 'renderAddOns')
416 );
417 }
418
419 // Register Documentation
420 add_submenu_page(
421 'fluent_forms',
422 __('Get Help', 'fluentform'),
423 __('Get Help', 'fluentform'),
424 $dashBoardCapability,
425 'fluent_forms_docs',
426 array($this, 'renderDocs')
427 );
428
429 $this->commonAction();
430 }
431
432 private function getMenuIcon()
433 {
434 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>');
435 }
436
437 public function renderFormAdminRoute()
438 {
439 if (isset($_GET['route']) && isset($_GET['form_id'])) {
440 $route = sanitize_key($_GET['route']);
441
442 $formRoutePermissionSet = apply_filters('fluentform/form_inner_route_permission_set', [
443 'editor' => 'fluentform_forms_manager',
444 'settings' => 'fluentform_forms_manager',
445 'entries' => 'fluentform_entries_viewer',
446 ]);
447
448 $toVerifyPermission = ArrayHelper::get(
449 $formRoutePermissionSet,
450 $route,
451 'fluentform_forms_manager'
452 );
453
454 $hasPermission = apply_filters(
455 'fluentform_inner_route_has_permission',
456 Acl::hasPermission($toVerifyPermission),
457 $route,
458 intval($_GET['form_id'])
459 );
460
461 if ($hasPermission) {
462 return $this->renderFormInnerPages();
463 } else {
464 return View::render('admin.no_permission');
465 }
466 }
467
468 $this->renderForms();
469 }
470
471 public function renderAllEntriesAdminRoute()
472 {
473 wp_enqueue_script('fluentform_all_entries');
474 View::render('admin.all_entries', array());
475 }
476
477 public function renderFormInnerPages()
478 {
479 $form_id = intval($_GET['form_id']);
480 $form = wpFluent()->table('fluentform_forms')->find($form_id);
481
482 if (!$form) {
483 echo __("<h2>No form found</h2>", 'fluentform');
484 return;
485 }
486
487 $formAdminMenus = [];
488
489 if (Acl::hasPermission('fluentform_forms_manager')) {
490 $formAdminMenus = [
491 'editor' => array(
492 'slug' => 'editor',
493 'title' => __('Editor', 'fluentform'),
494 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor')
495 ),
496 'settings' => array(
497 'slug' => 'settings',
498 'hash' => 'basic_settings',
499 'title' => __('Settings & Integrations', 'fluentform'),
500 'sub_route' => 'form_settings',
501 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings')
502 )
503 ];
504 }
505
506 if (Acl::hasPermission('fluentform_entries_viewer')) {
507 $formAdminMenus['entries'] = [
508 'slug' => 'entries',
509 'hash' => '/',
510 'title' => __('Entries', 'fluentform'),
511 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries')
512 ];
513 }
514
515 $formAdminMenus = apply_filters('fluentform_form_admin_menu', $formAdminMenus, $form_id, $form);
516
517 $route = sanitize_key($_GET['route']);
518
519 View::render('admin.form.form_wrapper', array(
520 'route' => $route,
521 'form_id' => $form_id,
522 'form' => $form,
523 'menu_items' => $formAdminMenus
524 ));
525 }
526
527 public function renderSettings($form_id)
528 {
529 $settingsMenus = array(
530 'form_settings' => array(
531 'title' => __('Form Settings', 'fluentform'),
532 'slug' => 'form_settings',
533 'hash' => 'basic_settings',
534 'route' => '/'
535 ),
536 'email_notifications' => array(
537 'title' => __('Email Notifications', 'fluentform'),
538 'slug' => 'form_settings',
539 'hash' => 'email_notifications',
540 'route' => '/email-settings'
541 ),
542 'other_confirmations' => array(
543 'title' => __('Other Confirmations', 'fluentform'),
544 'slug' => 'form_settings',
545 'hash' => 'other_confirmations',
546 'route' => '/other-confirmations'
547 ),
548 'all_integrations' => array(
549 'title' => __('Marketing & CRM Integrations', 'fluentform'),
550 'slug' => 'form_settings',
551 'route' => '/all-integrations'
552 )
553 );
554
555 if (Helper::isSlackEnabled()) {
556 $settingsMenus['slack'] = array(
557 'title' => __('Slack', 'fluentform'),
558 'slug' => 'form_settings',
559 'hash' => 'slack',
560 'route' => '/slack'
561 );
562 }
563
564 $settingsMenus = apply_filters('fluentform_form_settings_menu', $settingsMenus, $form_id);
565
566 $externalMenuItems = [];
567 foreach ($settingsMenus as $key => $menu) {
568 if (empty($menu['hash'])) {
569 unset($settingsMenus[$key]);
570 $externalMenuItems[$key] = $menu;
571 }
572 }
573
574 $settingsMenus['custom_css_js'] = array(
575 'title' => __('Custom CSS/JS', 'fluentform'),
576 'slug' => 'form_settings',
577 'hash' => 'custom_css_js',
578 'route' => '/custom-css-js'
579 );
580
581 $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
582
583 $currentRoute = sanitize_key($this->app->request->get('sub_route', ''));
584
585 View::render('admin.form.settings_wrapper', array(
586 'form_id' => $form_id,
587 'settings_menus' => $settingsMenus,
588 'current_sub_route' => $currentRoute
589 ));
590 }
591
592 /**
593 * Remove the inactive addOn menu items
594 * @param string $addOn
595 * @return boolean
596 */
597 public function filterFormSettingsMenu($settingsMenus, $form_id)
598 {
599 if (array_key_exists('mailchimp_integration', $settingsMenus)) {
600 $option = (array)get_option('_fluentform_mailchimp_details');
601 if (!isset($option['status']) || !$option['status']) {
602 unset($settingsMenus['mailchimp_integration']);
603 }
604 }
605
606 return $settingsMenus;
607 }
608
609 public function renderFormSettings($form_id)
610 {
611 wp_localize_script('fluentform_form_settings', 'FluentFormApp', array(
612 'form_id' => $form_id,
613 'plugin' => $this->app->getSlug(),
614 'hasPro' => defined('FLUENTFORMPRO'),
615 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
616 'hasFluentCRM' => defined('FLUENTCRM'),
617 'upgrade_url' => fluentform_upgrade_url(),
618 'ace_path_url' => $this->app->publicUrl('libs/ace'),
619 'is_conversion_form' => Helper::isConversionForm($form_id),
620 'has_fluent_smtp' => defined('FLUENTMAIL'),
621 'fluent_smtp_url' => admin_url('admin.php?page=fluent_forms_smtp')
622 ));
623
624 View::render('admin.form.settings', array(
625 'form_id' => $form_id
626 ));
627 }
628
629 public function renderForms()
630 {
631 if (!get_option('_fluentform_installed_version')) {
632 (new Activator())->migrate();
633 }
634
635 $formsCount = wpFluent()->table('fluentform_forms')->count();
636
637 wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluent_all_forms_vars', array(
638 'plugin' => $this->app->getSlug(),
639 'formsCount' => $formsCount,
640 'hasPro' => defined('FLUENTFORMPRO'),
641 'upgrade_url' => fluentform_upgrade_url(),
642 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
643 'isDisableAnalytics' => apply_filters('fluentform-disabled_analytics', false)
644 )));
645
646 View::render('admin.all_forms', array());
647 }
648
649 public function renderEditor($form_id)
650 {
651 View::render('admin.form.editor', array(
652 'plugin' => $this->app->getSlug(),
653 'form_id' => $form_id
654 ));
655 }
656
657 public function renderDocs()
658 {
659 echo (new DocumentationModule())->render();
660 }
661
662 public function renderAddOns()
663 {
664 echo (new AddOnModule())->render();
665 }
666
667 private function enqueueEditorAssets()
668 {
669 $formId = intval($_GET['form_id']);
670
671 $form = wpFluent()->table('fluentform_forms')->find($formId);
672
673 do_action('fluentform_loading_editor_assets', $form);
674
675 wp_enqueue_style('fluentform_editor_sass');
676 wp_enqueue_style('fluentform_editor_style');
677
678 $pluginSlug = $this->app->getSlug();
679
680 if (function_exists('wp_enqueue_editor')) {
681 add_filter('user_can_richedit', '__return_true');
682 wp_enqueue_editor();
683 wp_enqueue_media();
684 }
685
686 wp_enqueue_script('fluentform_editor_script');
687
688 $jsonData = $form->form_fields;
689
690 if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
691 $formFields = $form->form_fields;
692
693 if ($formFields) {
694 $formFields = json_decode($formFields, true);
695
696 foreach ($formFields['fields'] as $index => $formField) {
697 $formFields['fields'][$index] = apply_filters(
698 'fluentform_editor_init_element_' . $formField['element'], $formField, $form
699 );
700
701 if (!$formFields['fields'][$index]) {
702 unset($formFields['fields'][$index]);
703 continue;
704 }
705
706 if ($formField['element'] == 'container') {
707 $columns = $formField['columns'];
708 foreach ($columns as $columnIndex => $column) {
709 foreach ($column['fields'] as $fieldIndex => $columnField) {
710 $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
711 'fluentform_editor_init_element_' . $columnField['element'],
712 $columnField, $form
713 );
714
715 if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
716 unset($columns[$columnIndex]['fields'][$fieldIndex]);
717 }
718 }
719 }
720
721 $formFields['fields'][$index]['columns'] = array_values($columns);
722 }
723 }
724
725 $formFields['fields'] = array_values($formFields['fields']);
726 $formFields = json_encode($formFields, true);
727 }
728
729
730 $form->form_fields = $formFields;
731 }
732
733 $searchTags = $this->app->load(
734 $this->app->appPath('Services/FormBuilder/ElementSearchTags.php')
735 );
736
737 $searchTags = apply_filters( 'fluent_editor_element_search_tags', $searchTags, $form );
738
739 $elementPlacements = apply_filters('fluent_editor_element_settings_placement',
740 $this->app->load( $this->app->appPath('Services/FormBuilder/ElementSettingsPlacement.php') ), $form
741 );
742
743 wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform_editor_vars', array(
744 'plugin' => $pluginSlug,
745 'form_id' => $formId,
746 'plugin_public_url' => $this->app->publicUrl(),
747 'preview_url' => Helper::getPreviewUrl($formId),
748 'form' => $form,
749 'hasPro' => defined('FLUENTFORMPRO'),
750 'countries' => $this->app->load(
751 $this->app->appPath('Services/FormBuilder/CountryNames.php')
752 ),
753 'element_customization_settings' => $this->app->load(
754 $this->app->appPath('Services/FormBuilder/ElementCustomization.php')
755 ),
756
757 'validation_rule_settings' => $this->app->load(
758 $this->app->appPath('Services/FormBuilder/ValidationRuleSettings.php')
759 ),
760
761 'element_search_tags' => $searchTags,
762
763 'element_settings_placement' => $elementPlacements,
764 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
765 'has_payment_features' => !defined('FLUENTFORMPRO'),
766 'upgrade_url' => fluentform_upgrade_url(),
767 'is_conversion_form' => Helper::isConversionForm($formId),
768 '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"]}'
769 )));
770 }
771
772 /**
773 * Render global settings page.
774 *
775 * @throws \Exception
776 */
777 public function renderGlobalSettings()
778 {
779 if (function_exists('wp_enqueue_editor')) {
780 add_filter('user_can_richedit', '__return_true');
781 wp_enqueue_editor();
782 wp_enqueue_media();
783 }
784
785 // Fire an event letting others know the current component
786 // that fluentform is rendering for the global settings
787 // page. So that they can hook and load their custom
788 // components on this page dynamically & easily.
789 // N.B. native 'components' will always use
790 // 'settings' as their current component.
791 $currentComponent = apply_filters('fluentform_global_settings_current_component',
792 $this->app->request->get('component', 'settings')
793 );
794
795
796 $currentComponent = sanitize_key($currentComponent);
797
798 $components = apply_filters('fluentform_global_settings_components', []);
799
800 $components['reCAPTCHA'] = [
801 'hash' => 're_captcha',
802 'title' => 'reCAPTCHA',
803 ];
804
805 $components['hCAPTCHA'] = [
806 'hash' => 'h_captcha',
807 'title' => 'hCaptcha',
808 ];
809
810 View::render('admin.settings.index', [
811 'components' => $components,
812 'currentComponent' => $currentComponent
813 ]);
814 }
815
816 public function renderTransfer()
817 {
818 $forms = wpFluent()->table('fluentform_forms')
819 ->orderBy('id', 'desc')
820 ->select(['id', 'title'])
821 ->get();
822
823 wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
824 'plugin' => $this->app->getSlug(),
825 'forms' => $forms,
826 'upgrade_url' => fluentform_upgrade_url(),
827 'hasPro' => defined('FLUENTFORMPRO'),
828 ]);
829
830 View::render('admin.transfer.index');
831 }
832
833 public function addPreviewButton($formId)
834 {
835 $previewText = __('Preview & Design', 'fluent-form');
836 $previewUrl = Helper::getPreviewUrl($formId);
837 if($isConversational = Helper::isConversionForm($formId)) {
838 $previewText = __('Preview', 'fluent-form');
839 }
840
841 echo '<a target="_blank" class="el-button el-button--small" href="' . esc_url($previewUrl) . '">'.esc_attr($previewText).'</a>';
842 }
843
844 public function addCopyShortcodeButton($formId)
845 {
846 $shortcode = '[fluentform id="' . $formId . '"]';
847 if(Helper::isConversionForm($formId)) {
848 $shortcode = '[fluentform type="conversational" id="' . $formId . '"]';
849 }
850 echo '<button style="background:#dedede;color:#545454;padding:5px;max-width: 200px;overflow: hidden;" title="Click to Copy" class="btn copy" data-clipboard-text=\''.$shortcode.'\'><i class="dashicons dashicons-admin-page" style="color:#eee;text-shadow:#000 -1px 1px 1px;"></i> '.$shortcode.'</button>';
851 return;
852 }
853
854 public function commonAction()
855 {
856 $fluentFormPages = array(
857 'fluent_forms',
858 'fluent_forms_transfer',
859 'fluent_forms_settings',
860 'fluent_forms_add_ons',
861 'fluent_forms_docs',
862 'fluent_forms_smtp'
863 );
864
865 if (isset($_GET['page']) && in_array($_GET['page'], $fluentFormPages)) {
866 // Let's deregister existing vuejs by other devs
867 // Other devs should not regis
868 add_action('admin_print_scripts', function () {
869 wp_dequeue_script('vuejs');
870 wp_dequeue_script('vue');
871 wp_deregister_script('elementor-admin-app');
872 });
873 }
874 }
875
876 public function renderGlobalMenu()
877 {
878 $showPayment = false;
879 if(defined('FLUENTFORMPRO')) {
880 $showPayment = !get_option('__fluentform_payment_module_settings');
881 if($showPayment) {
882 $formCount = wpFluent()->table('fluentform_forms')
883 ->count();
884 $showPayment = $formCount > 2;
885 }
886 }
887 View::render('admin.global_menu', array(
888 'show_payment' => $showPayment,
889 'show_payment_entries' => apply_filters('fluentform_show_payment_entries', false)
890 ));
891 }
892
893 public function renderPaymentEntries()
894 {
895 do_action('flunetform_render_payment_entries');
896 }
897
898 public function renderSmtpPromo()
899 {
900 wp_enqueue_script('fluentform_admin_notice', fluentformMix('js/admin_notices.js'), array(
901 'jquery'
902 ), FLUENTFORM_VERSION);
903
904 View::render('admin.smtp.index', [
905 'logo' => $this->app->publicUrl('img/fluentsmtp.svg'),
906 'banner_image' => $this->app->publicUrl('img/fluentsmtp-banner.png'),
907 'is_installed' => defined('FLUENTMAIL'),
908 'setup_url' => admin_url('options-general.php?page=fluent-mail#/connections')
909 ]);
910 }
911
912 private function getAdminI18n()
913 {
914 $i18n = array(
915 'All Forms' => __('All Forms', 'fluentform'),
916 'Add a New Form' => __('Add a New Form', 'fluentform'),
917 'Conversational Form' => __('Conversational Form', 'fluentform'),
918 'Create Conversational Form' => __('Create Conversational Form', 'fluentform'),
919 'ID' => __('ID', 'fluentform'),
920 'Title' => __('Title', 'fluentform'),
921 'Edit' => __('Edit', 'fluentform'),
922 'Settings' => __('Settings', 'fluentform'),
923 'Entries' => __('Entries', 'fluentform'),
924 'Conversational Preview' => __('Conversational Preview', 'fluentform'),
925 'Preview' => __('Preview', 'fluentform'),
926 'Duplicate' => __('Duplicate', 'fluentform'),
927 'Delete' => __('Delete', 'fluentform'),
928 'Short Code' => __('Short Code', 'fluentform'),
929 'Conversion' => __('Conversion', 'fluentform'),
930 'Views' => __('Views', 'fluentform'),
931 'Search Forms' => __('Search Forms', 'fluentform'),
932 'Search' => __('Search', 'fluentform'),
933 'Click Here to Create Your First Form' => __('Click Here to Create Your First Form', 'fluentform'),
934 'Check the video intro' => __('Check the video intro', 'fluentform'),
935 'All Form Entries' => __('All Form Entries', 'fluentform'),
936 'Browser' => __('Browser', 'fluentform'),
937 'Date' => __('Date', 'fluentform'),
938 'Hide Chart' => __('Hide Chart', 'fluentform'),
939 'Show Chart' => __('Show Chart', 'fluentform'),
940 'All' => __('All', 'fluentform'),
941 'Unread Only' => __('Unread Only', 'fluentform'),
942 'Read Only' => __('Read Only', 'fluentform'),
943 'Submission ID' => __('Submission ID', 'fluentform'),
944 'Form' => __('Form', 'fluentform'),
945 'Status' => __('Status', 'fluentform'),
946 'Read' => __('Read', 'fluentform'),
947 'Unread' => __('Unread', 'fluentform'),
948 'ago' => __('ago', 'fluentform'),
949 'Click to copy shortcode' => __('Click to copy shortcode', 'fluentform'),
950 'Back to Entries' => __('Back to Entries', 'fluentform'),
951 'Previous' => __('Previous', 'fluentform'),
952 'Next' => __('Next', 'fluentform'),
953 'Entry Details' => __('Entry Details', 'fluentform'),
954 'Form Entry Data' => __('Form Entry Data', 'fluentform'),
955 'Remove from Favorites' => __('Remove from Favorites', 'fluentform'),
956 'Mark as Favorite' => __('Mark as Favorite', 'fluentform'),
957 'Submission Info' => __('Submission Info', 'fluentform'),
958 'Entity ID' => __('Entity ID', 'fluentform'),
959 'User IP' => __('User IP', 'fluentform'),
960 'Device' => __('Device', 'fluentform'),
961 'User' => __('User', 'fluentform'),
962 'Guest' => __('Guest', 'fluentform'),
963 'Submitted On' => __('Submitted On', 'fluentform'),
964 'Change status to' => __('Change status to', 'fluentform'),
965 'Show empty fields' => __('Show empty fields', 'fluentform'),
966 'Submission Notes' => __('Submission Notes', 'fluentform'),
967 'Please Provide Note Content' => __('Please Provide Note Content', 'fluentform'),
968 'No Notes found' => __('No Notes found', 'fluentform'),
969 'All Types' => __('All Types', 'fluentform'),
970 'Export' => __('Export', 'fluentform'),
971 'Export as' => __('Export as', 'fluentform'),
972 'Advanced Filter' => __('Advanced Filter', 'fluentform'),
973 'Filter By Date Range' => __('Filter By Date Range', 'fluentform'),
974 'Favorites Entries only' => __('Favorites Entries only', 'fluentform'),
975 'Amount' => __('Amount', 'fluentform'),
976 'Actions' => __('Actions', 'fluentform'),
977 'Submitted at' => __('Submitted at', 'fluentform'),
978 'Submission Logs' => __('Submission Logs', 'fluentform'),
979 'General' => __('General', 'fluentform'),
980 'API Calls' => __('API Calls', 'fluentform'),
981 'No Logs found' => __('No Logs found', 'fluentform'),
982 'Submission Notes' => __('Submission Notes', 'fluentform'),
983 'Add Note' => __('Add Note', 'fluentform'),
984 'No Notes found' => __('No Notes found', 'fluentform'),
985 );
986
987 return apply_filters('fluentform/admin_i18n', $i18n);
988 }
989 }
990