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

819 lines 26.4 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\Activator;
7 use FluentForm\App\Modules\AddOnModule;
8 use FluentForm\App\Modules\DocumentationModule;
9 use FluentForm\Framework\Foundation\Application;
10 use FluentForm\View;
11
12 class Menu
13 {
14 /**
15 * @var \FluentForm\Framework\Foundation\Application
16 */
17 protected $app;
18
19 /**
20 * Menu constructor.
21 *
22 * @param \FluentForm\Framework\Foundation\Application $application
23 */
24 public function __construct(Application $application)
25 {
26 $this->app = $application;
27
28 $this->app->addFilter('fluentform_form_settings_menu', array(
29 $this, 'filterFormSettingsMenu'
30 ), 10, 2);
31 }
32
33 public function reisterScripts()
34 {
35 if (!$this->isFluentPages()) {
36 return;
37 }
38
39 $app = $this->app;
40
41 wp_register_style(
42 'fluentform_settings_global',
43 $app->publicUrl("css/settings_global.css"),
44 array(),
45 FLUENTFORM_VERSION,
46 'all'
47 );
48
49 wp_register_script(
50 'clipboard',
51 $app->publicUrl('libs/clipboard.min.js'),
52 array(),
53 false,
54 true
55 );
56
57 wp_register_script(
58 'copier',
59 $app->publicUrl('js/copier.js'),
60 array(),
61 false,
62 true
63 );
64
65 wp_register_script(
66 'fluentform_form_settings',
67 $app->publicUrl("js/form_settings_app.js"),
68 array('jquery'),
69 FLUENTFORM_VERSION,
70 true
71 );
72
73 wp_register_script(
74 'fluent_all_forms',
75 $app->publicUrl("js/fluent-all-forms-admin.js"),
76 array('jquery'),
77 FLUENTFORM_VERSION,
78 true
79 );
80
81 wp_register_style(
82 'fluent_all_forms',
83 $app->publicUrl("css/fluent-all-forms.css"),
84 array(),
85 FLUENTFORM_VERSION,
86 'all'
87 );
88
89 wp_register_script(
90 'fluentform_editor_script',
91 $app->publicUrl("js/fluent-forms-editor.js"),
92 array('jquery'),
93 FLUENTFORM_VERSION,
94 true
95 );
96
97 wp_register_style(
98 'fluentform_editor_style',
99 $app->publicUrl("css/fluent-forms-admin-sass.css"),
100 [],
101 FLUENTFORM_VERSION,
102 'all'
103 );
104
105 wp_register_style(
106 'fluentform_editor_sass',
107 $app->publicUrl("css/fluent-forms-admin.css"),
108 [],
109 FLUENTFORM_VERSION,
110 'all'
111 );
112
113 wp_register_script(
114 'fluentform-transfer-js',
115 $app->publicUrl("js/fluentform-transfer.js"),
116 ['jquery'],
117 FLUENTFORM_VERSION,
118 true
119 );
120
121 wp_register_script(
122 'fluentform-global-settings-js',
123 $app->publicUrl("js/fluentform-global-settings.js"),
124 ['jquery'],
125 FLUENTFORM_VERSION,
126 true
127 );
128
129 wp_register_script(
130 'fluentform-modules',
131 $app->publicUrl('js/modules.js'),
132 ['jquery'],
133 FLUENTFORM_VERSION,
134 true
135 );
136
137 wp_register_script(
138 'fluentform_form_entries',
139 $app->publicUrl('js/form_entries.js'),
140 array('jquery'),
141 FLUENTFORM_VERSION,
142 true
143 );
144
145 wp_register_script(
146 'fluentform_all_entries',
147 $app->publicUrl('js/all_entries.js'),
148 array('jquery'),
149 FLUENTFORM_VERSION,
150 true
151 );
152
153 wp_register_style(
154 'fluentform-add-ons',
155 $app->publicUrl('css/add-ons.css'),
156 [],
157 FLUENTFORM_VERSION,
158 'all'
159 );
160
161 wp_register_style(
162 'fluentform_doc_style',
163 $app->publicUrl('css/admin_docs.css'),
164 [],
165 FLUENTFORM_VERSION,
166 'all'
167 );
168
169 }
170
171 public function isFluentPages()
172 {
173 return Helper::isFluentAdminPage();
174 }
175
176 public function enqueuePageScripts()
177 {
178 if (!$this->isFluentPages()) {
179 return;
180 }
181
182 $page = sanitize_text_field($_GET['page']);
183
184 if ($page == 'fluent_forms' && isset($_GET['route']) && isset($_GET['form_id'])) {
185 wp_enqueue_style('fluentform_settings_global');
186 wp_enqueue_script('clipboard');
187 wp_enqueue_script('copier');
188
189 if ($_GET['route'] == 'settings') {
190 if (function_exists('wp_enqueue_editor')) {
191 add_filter('user_can_richedit', function ($status) {
192 return true;
193 });
194
195 wp_enqueue_editor();
196 wp_enqueue_media();
197 }
198
199 wp_enqueue_script('fluentform_form_settings');
200
201 } else if ($_GET['route'] == 'editor') {
202 $this->enqueueEditorAssets();
203 }
204 } else if ($page == 'fluent_forms') {
205 wp_enqueue_script('fluent_all_forms');
206 wp_enqueue_style('fluent_all_forms');
207 } else if ($page == 'fluent_forms_transfer') {
208 wp_enqueue_style('fluentform_settings_global');
209 wp_enqueue_script('fluentform-transfer-js');
210 } else if (
211 $page == 'fluent_forms_settings' ||
212 $page == 'fluent_form_payment_entries' ||
213 $page == 'fluent_forms_all_entries'
214 ) {
215 wp_enqueue_style('fluentform_settings_global');
216 } else if ($page == 'fluent_form_add_ons') {
217 wp_enqueue_style('fluentform-add-ons');
218 } else if ($page == 'fluent_forms_docs' || $page == 'fluent_forms_smtp') {
219 wp_enqueue_style('fluentform_doc_style');
220 }
221 }
222
223 /**
224 * Register menu and sub-menus.
225 */
226 public function register()
227 {
228 $dashBoardCapability = apply_filters(
229 'fluentform_dashboard_capability', 'fluentform_settings_manager'
230 );
231
232 $settingsCapability = apply_filters(
233 'fluentform_settings_capability', 'fluentform_settings_manager'
234 );
235
236 if (!current_user_can($dashBoardCapability) && !current_user_can($settingsCapability)) {
237 $customRoles = get_option('_fluentform_form_permission');
238
239 if (is_string($customRoles)) {
240 $customRoles = [];
241 }
242
243 if (!$customRoles) {
244 return;
245 }
246
247 $hasAccess = false;
248 foreach ($customRoles as $roleName) {
249 if (current_user_can($roleName)) {
250 $hasAccess = true;
251 $dashBoardCapability = $roleName;
252 $settingsCapability = $roleName;
253 }
254 }
255
256 if (!$hasAccess) {
257 return;
258 }
259 }
260
261 if (defined('FLUENTFORMPRO')) {
262 $title = __('Fluent Forms Pro', 'fluentform');
263 } else {
264 $title = __('Fluent Forms', 'fluentform');
265 }
266
267 add_menu_page(
268 $title,
269 $title,
270 $dashBoardCapability,
271 'fluent_forms',
272 array($this, 'renderFormAdminRoute'),
273 $this->getMenuIcon(),
274 25
275 );
276
277
278 add_submenu_page(
279 'fluent_forms',
280 __('All Forms', 'fluentform'),
281 __('All Forms', 'fluentform'),
282 $dashBoardCapability,
283 'fluent_forms',
284 array($this, 'renderFormAdminRoute')
285 );
286
287 if ($settingsCapability) {
288 add_submenu_page(
289 'fluent_forms',
290 __('New Form', 'fluentform'),
291 __('New Form', 'fluentform'),
292 $settingsCapability,
293 'fluent_forms#add=1',
294 array($this, 'renderFormAdminRoute')
295 );
296
297 $entriesTitle = __('Entries', 'fluentform');
298
299 if(Helper::isFluentAdminPage()) {
300 $entriesCount = wpFluent()->table('fluentform_submissions')
301 ->where('status', 'unread')
302 ->count();
303 if($entriesCount) {
304 $entriesTitle .= ' <span class="ff_unread_count" style="background: #ca4a20;color: white;border-radius: 8px;padding: 1px 8px;">'.$entriesCount.'</span>';
305 }
306 }
307
308 // Register entries intermediary page
309 add_submenu_page(
310 'fluent_forms',
311 $entriesTitle,
312 $entriesTitle,
313 $settingsCapability,
314 'fluent_forms_all_entries',
315 array($this, 'renderAllEntriesAdminRoute')
316 );
317
318 if (apply_filters('fluentform_show_payment_entries', false)) {
319 add_submenu_page(
320 'fluent_forms',
321 __('Payments', 'fluentform'),
322 __('Payments', 'fluentform'),
323 $settingsCapability,
324 'fluent_form_payment_entries',
325 array($this, 'renderPaymentEntries')
326 );
327 }
328
329 }
330
331
332 // Register Add-Ons
333 add_submenu_page(
334 'fluent_forms',
335 __('Integration Modules', 'fluentform'),
336 __('Integration Modules', 'fluentform'),
337 $dashBoardCapability,
338 'fluent_form_add_ons',
339 array($this, 'renderAddOns')
340 );
341
342 if ($settingsCapability) {
343 // Register global settings sub menu page.
344 add_submenu_page(
345 'fluent_forms',
346 __('Global Settings', 'fluentform'),
347 __('Global Settings', 'fluentform'),
348 $settingsCapability,
349 'fluent_forms_settings',
350 array($this, 'renderGlobalSettings')
351 );
352
353 // Register import/export sub menu page.
354 add_submenu_page(
355 'fluent_forms',
356 __('Tools', 'fluentform'),
357 __('Tools', 'fluentform'),
358 $settingsCapability,
359 'fluent_forms_transfer',
360 array($this, 'renderTransfer')
361 );
362
363 // Register import/export sub menu page.
364 add_submenu_page(
365 'fluent_forms',
366 __('SMTP', 'fluentform'),
367 __('SMTP', 'fluentform'),
368 $settingsCapability,
369 'fluent_forms_smtp',
370 array($this, 'renderSmtpPromo')
371 );
372 }
373
374
375 // Register Documentation
376 add_submenu_page(
377 'fluent_forms',
378 __('Get Help', 'fluentform'),
379 __('Get Help', 'fluentform'),
380 $dashBoardCapability,
381 'fluent_forms_docs',
382 array($this, 'renderDocs')
383 );
384
385 $this->commonAction();
386
387 }
388
389 private function getMenuIcon()
390 {
391 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>');
392 }
393
394 public function renderFormAdminRoute()
395 {
396 if (isset($_GET['route']) && isset($_GET['form_id'])) {
397 return $this->renderFormInnerPages();
398 }
399
400 $this->renderForms();
401 }
402
403 public function renderAllEntriesAdminRoute()
404 {
405 wp_enqueue_script('fluentform_all_entries');
406 View::render('admin.all_entries', array());
407 }
408
409 private function renderFormInnerPages()
410 {
411 $form_id = intval($_GET['form_id']);
412
413 $form = wpFluent()->table('fluentform_forms')->find($form_id);
414
415 $formAdminMenus = array(
416 'editor' => array(
417 'slug' => 'editor',
418 'title' => __('Editor', 'fluentform'),
419 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=editor')
420 ),
421 'settings' => array(
422 'slug' => 'settings',
423 'hash' => 'basic_settings',
424 'title' => __('Settings & Integrations', 'fluentform'),
425 'sub_route' => 'form_settings',
426 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=settings&sub_route=form_settings')
427 ),
428 'entries' => array(
429 'slug' => 'entries',
430 'hash' => '/',
431 'title' => __('Entries', 'fluentform'),
432 'url' => admin_url('admin.php?page=fluent_forms&form_id=' . $form_id . '&route=entries')
433 )
434 );
435
436 $formAdminMenus = apply_filters('fluentform_form_admin_menu', $formAdminMenus, $form_id, $form);
437
438 $form = wpFluent()->table('fluentform_forms')->find($form_id);
439
440 if (!$form) {
441 echo __("<h2>No form found</h2>", 'fluentform');
442 return;
443 }
444
445 View::render('admin.form.form_wrapper', array(
446 'route' => sanitize_text_field($_GET['route']),
447 'form_id' => $form_id,
448 'form' => $form,
449 'menu_items' => $formAdminMenus
450 ));
451 }
452
453 public function renderSettings($form_id)
454 {
455 $settingsMenus = array(
456 'form_settings' => array(
457 'title' => __('Form Settings', 'fluentform'),
458 'slug' => 'form_settings',
459 'hash' => 'basic_settings',
460 'route' => '/'
461 ),
462 'email_notifications' => array(
463 'title' => __('Email Notifications', 'fluentform'),
464 'slug' => 'form_settings',
465 'hash' => 'email_notifications',
466 'route' => '/email-settings'
467 ),
468 'other_confirmations' => array(
469 'title' => __('Other Confirmations', 'fluentform'),
470 'slug' => 'form_settings',
471 'hash' => 'other_confirmations',
472 'route' => '/other-confirmations'
473 ),
474 'all_integrations' => array(
475 'title' => __('Marketing & CRM Integrations', 'fluentform'),
476 'slug' => 'form_settings',
477 'route' => '/all-integrations'
478 )
479 );
480
481 if (Helper::isSlackEnabled()) {
482 $settingsMenus['slack'] = array(
483 'title' => __('Slack', 'fluentform'),
484 'slug' => 'form_settings',
485 'hash' => 'slack',
486 'route' => '/slack'
487 );
488 }
489
490 $settingsMenus = apply_filters('fluentform_form_settings_menu', $settingsMenus, $form_id);
491
492 $externalMenuItems = [];
493 foreach ($settingsMenus as $key => $menu) {
494 if (empty($menu['hash'])) {
495 unset($settingsMenus[$key]);
496 $externalMenuItems[$key] = $menu;
497 }
498 }
499
500 $settingsMenus['custom_css_js'] = array(
501 'title' => __('Custom CSS/JS', 'fluentform'),
502 'slug' => 'form_settings',
503 'hash' => 'custom_css_js',
504 'route' => '/custom-css-js'
505 );
506
507 $settingsMenus = array_filter(array_merge($settingsMenus, $externalMenuItems));
508
509 $currentRoute = sanitize_text_field($this->app->request->get('sub_route', ''));
510
511 View::render('admin.form.settings_wrapper', array(
512 'form_id' => $form_id,
513 'settings_menus' => $settingsMenus,
514 'current_sub_route' => $currentRoute
515 ));
516 }
517
518 /**
519 * Remove the inactive addOn menu items
520 * @param string $addOn
521 * @return boolean
522 */
523 public function filterFormSettingsMenu($settingsMenus, $form_id)
524 {
525 if (array_key_exists('mailchimp_integration', $settingsMenus)) {
526 $option = (array)get_option('_fluentform_mailchimp_details');
527 if (!isset($option['status']) || !$option['status']) {
528 unset($settingsMenus['mailchimp_integration']);
529 }
530 }
531
532 return $settingsMenus;
533 }
534
535 public function renderFormSettings($form_id)
536 {
537 wp_localize_script('fluentform_form_settings', 'FluentFormApp', array(
538 'form_id' => $form_id,
539 'plugin' => $this->app->getSlug(),
540 'hasPro' => defined('FLUENTFORMPRO'),
541 'hasPDF' => defined('FLUENTFORM_PDF_VERSION'),
542 'hasFluentCRM' => defined('FLUENTCRM'),
543 'upgrade_url' => fluentform_upgrade_url(),
544 'ace_path_url' => $this->app->publicUrl('libs/ace')
545 ));
546
547 View::render('admin.form.settings', array(
548 'form_id' => $form_id
549 ));
550 }
551
552 public function renderForms()
553 {
554 if (!get_option('_fluentform_installed_version')) {
555 (new Activator())->migrate();
556 }
557
558 $formsCount = wpFluent()->table('fluentform_forms')->count();
559
560 wp_localize_script('fluent_all_forms', 'FluentFormApp', apply_filters('fluent_all_forms_vars', array(
561 'plugin' => $this->app->getSlug(),
562 'formsCount' => $formsCount,
563 'hasPro' => defined('FLUENTFORMPRO'),
564 'upgrade_url' => fluentform_upgrade_url(),
565 'adminUrl' => admin_url('admin.php?page=fluent_forms'),
566 'isDisableAnalytics' => apply_filters('fluentform-disabled_analytics', false)
567 )));
568
569 View::render('admin.all_forms', array());
570 }
571
572 public function renderEditor($form_id)
573 {
574 View::render('admin.form.editor', array(
575 'plugin' => $this->app->getSlug(),
576 'form_id' => $form_id
577 ));
578 }
579
580 public function renderDocs()
581 {
582 echo (new DocumentationModule())->render();
583 }
584
585 public function renderAddOns()
586 {
587 echo (new AddOnModule())->render();
588 }
589
590 private function enqueueEditorAssets()
591 {
592 $formId = intval($_GET['form_id']);
593
594 $form = wpFluent()->table('fluentform_forms')->find($formId);
595
596 do_action('fluentform_loading_editor_assets', $form);
597
598 wp_enqueue_style('fluentform_editor_sass');
599 wp_enqueue_style('fluentform_editor_style');
600
601 $pluginSlug = $this->app->getSlug();
602
603 if (function_exists('wp_enqueue_editor')) {
604 add_filter('user_can_richedit', '__return_true');
605 wp_enqueue_editor();
606 wp_enqueue_media();
607 }
608
609 wp_enqueue_script('fluentform_editor_script');
610
611 $jsonData = $form->form_fields;
612
613 if (!defined('FLUENTFORM_DISABLE_EDITOR_FILED_HOOOK')) {
614 $formFields = $form->form_fields;
615
616 if ($formFields) {
617 $formFields = json_decode($formFields, true);
618
619 foreach ($formFields['fields'] as $index => $formField) {
620 $formFields['fields'][$index] = apply_filters(
621 'fluentform_editor_init_element_' . $formField['element'], $formField, $form
622 );
623
624 if (!$formFields['fields'][$index]) {
625 unset($formFields['fields'][$index]);
626 continue;
627 }
628
629 if ($formField['element'] == 'container') {
630 $columns = $formField['columns'];
631 foreach ($columns as $columnIndex => $column) {
632 foreach ($column['fields'] as $fieldIndex => $columnField) {
633 $columns[$columnIndex]['fields'][$fieldIndex] = apply_filters(
634 'fluentform_editor_init_element_' . $columnField['element'],
635 $columnField, $form
636 );
637
638 if (!$columns[$columnIndex]['fields'][$fieldIndex]) {
639 unset($columns[$columnIndex]['fields'][$fieldIndex]);
640 }
641 }
642 }
643
644 $formFields['fields'][$index]['columns'] = array_values($columns);
645 }
646 }
647
648 $formFields['fields'] = array_values($formFields['fields']);
649 $formFields = json_encode($formFields, true);
650 }
651
652
653 $form->form_fields = $formFields;
654 }
655
656 $searchTags = $this->app->load(
657 $this->app->appPath('Services/FormBuilder/ElementSearchTags.php')
658 );
659
660 $searchTags = apply_filters( 'fluent_editor_element_search_tags', $searchTags, $form );
661
662 wp_localize_script('fluentform_editor_script', 'FluentFormApp', apply_filters('fluentform_editor_vars', array(
663 'plugin' => $pluginSlug,
664 'form_id' => $formId,
665 'plugin_public_url' => $this->app->publicUrl(),
666 'preview_url' => $this->getFormPreviewUrl($formId),
667 'form' => $form,
668 'hasPro' => defined('FLUENTFORMPRO'),
669 'countries' => $this->app->load(
670 $this->app->appPath('Services/FormBuilder/CountryNames.php')
671 ),
672 'element_customization_settings' => $this->app->load(
673 $this->app->appPath('Services/FormBuilder/ElementCustomization.php')
674 ),
675
676 'validation_rule_settings' => $this->app->load(
677 $this->app->appPath('Services/FormBuilder/ValidationRuleSettings.php')
678 ),
679
680 'element_search_tags' => $searchTags,
681
682 'element_settings_placement' => $this->app->load(
683 $this->app->appPath('Services/FormBuilder/ElementSettingsPlacement.php')
684 ),
685 'all_forms_url' => admin_url('admin.php?page=fluent_forms'),
686 'has_payment_features' => !defined('FLUENTFORMPRO'),
687 'upgrade_url' => fluentform_upgrade_url(),
688 )));
689 }
690
691 /**
692 * Render global settings page.
693 *
694 * @throws \Exception
695 */
696 public function renderGlobalSettings()
697 {
698 if (function_exists('wp_enqueue_editor')) {
699 add_filter('user_can_richedit', '__return_true');
700 wp_enqueue_editor();
701 wp_enqueue_media();
702 }
703
704 // Fire an event letting others know the current component
705 // that fluentform is rendering for the global settings
706 // page. So that they can hook and load their custom
707 // components on this page dynamically & easily.
708 // N.B. native 'components' will always use
709 // 'settings' as their current component.
710 $currentComponent = apply_filters('fluentform_global_settings_current_component',
711 $this->app->request->get('component', 'settings')
712 );
713
714 $components = apply_filters('fluentform_global_settings_components', []);
715
716 $components['reCAPTCHA'] = [
717 'hash' => 're_captcha',
718 'title' => 'reCAPTCHA',
719 ];
720
721 View::render('admin.settings.index', [
722 'components' => $components,
723 'currentComponent' => $currentComponent
724 ]);
725 }
726
727 public function renderTransfer()
728 {
729 $forms = wpFluent()->table('fluentform_forms')
730 ->orderBy('id', 'desc')
731 ->select(['id', 'title'])
732 ->get();
733
734 wp_localize_script('fluentform-transfer-js', 'FluentFormApp', [
735 'plugin' => $this->app->getSlug(),
736 'forms' => $forms,
737 'upgrade_url' => fluentform_upgrade_url(),
738 'hasPro' => defined('FLUENTFORMPRO'),
739 ]);
740
741 View::render('admin.transfer.index');
742 }
743
744
745 private function getFormPreviewUrl($form_id)
746 {
747 return site_url('?fluentform_pages=1&design_mode=1&preview_id=' . $form_id) . '#ff_preview';
748 }
749
750 public function addPreviewButton($formId)
751 {
752 echo '<a target="_blank" class="el-button el-button--small" href="' . $this->getFormPreviewUrl($formId) . '">Preview & Design</a>';
753 }
754
755 public function addCopyShortcodeButton($formId)
756 {
757 echo '<button style="background:#dedede;color:#545454;padding:5px;" title="Click to Copy" class="btn copy" data-clipboard-text=\'[fluentform id="' . $formId . '"]\'><i class="dashicons dashicons-admin-page" style="color:#eee;text-shadow:#000 -1px 1px 1px;"></i> [fluentform id="' . $formId . '"]</button>';
758 return;
759 }
760
761 public function commonAction()
762 {
763 $fluentFormPages = array(
764 'fluent_forms',
765 'fluent_forms_transfer',
766 'fluent_forms_settings',
767 'fluent_form_add_ons',
768 'fluent_forms_docs',
769 'fluent_forms_smtp'
770 );
771
772 if (isset($_GET['page']) && in_array($_GET['page'], $fluentFormPages)) {
773 // Let's deregister existing vuejs by other devs
774 // Other devs should not regis
775 add_action('admin_print_scripts', function () {
776 wp_dequeue_script('vuejs');
777 wp_dequeue_script('vue');
778 wp_deregister_script('elementor-admin-app');
779 });
780 }
781 }
782
783 public function renderGlobalMenu()
784 {
785 $showPayment = false;
786 if(defined('FLUENTFORMPRO')) {
787 $showPayment = !get_option('__fluentform_payment_module_settings');
788 if($showPayment) {
789 $formCount = wpFluent()->table('fluentform_forms')
790 ->count();
791 $showPayment = $formCount > 2;
792 }
793 }
794 View::render('admin.global_menu', array(
795 'show_payment' => $showPayment,
796 'show_payment_entries' => apply_filters('fluentform_show_payment_entries', false)
797 ));
798 }
799
800 public function renderPaymentEntries()
801 {
802 do_action('flunetform_render_payment_entries');
803 }
804
805 public function renderSmtpPromo()
806 {
807 wp_enqueue_script('fluentform_admin_notice', fluentformMix('js/admin_notices.js'), array(
808 'jquery'
809 ), FLUENTFORM_VERSION);
810
811 View::render('admin.smtp.index', [
812 'logo' => $this->app->publicUrl('img/fluentsmtp.svg'),
813 'banner_image' => $this->app->publicUrl('img/fluentsmtp-banner.png'),
814 'is_installed' => defined('FLUENTMAIL'),
815 'setup_url' => admin_url('options-general.php?page=fluent-mail#/connections')
816 ]);
817 }
818 }
819