PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.14
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 / MigrationNotice.php

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

103 lines 3.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 defined('ABSPATH') or die;
6
7 use FluentForm\App\Models\Form;
8 use FluentForm\App\Http\Controllers\AdminNoticeController;
9 use FluentForm\App\Helpers\Helper;
10
11 class MigrationNotice
12 {
13 public static function register()
14 {
15 if (static::shouldRegister()) {
16 add_action('fluentform/global_menu', [static::class, 'show'], 99);
17 }
18 }
19
20 protected static function shouldRegister()
21 {
22 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Checking admin page parameter
23 if (isset($_GET['page']) && sanitize_text_field(wp_unslash($_GET['page'])) === 'fluent_forms_transfer') {
24 return false;
25 }
26
27 if (Helper::isFluentAdminPage() && !wp_doing_ajax()) {
28 return static::hasActiveCompatiblePlugins();
29 }
30
31 return false;
32 }
33
34 public static function show()
35 {
36 $notice = new AdminNoticeController();
37 $msg = static::getMessage();
38 $notice->addNotice($msg);
39 $notice->showNotice();
40 }
41
42 private static function hasActiveCompatiblePlugins()
43 {
44 $activePlugins = static::getActiveCompatiblePlugins();
45 return !empty($activePlugins);
46 }
47
48 private static function getActiveCompatiblePlugins()
49 {
50 $supportedPlugins = [
51 'wpforms/wpforms.php' => 'WPForms',
52 'wpforms-lite/wpforms.php' => 'WPForms',
53 'contact-form-7/wp-contact-form-7.php' => 'Contact Form 7',
54 'ninja-forms/ninja-forms.php' => 'Ninja Forms',
55 'gravityforms/gravityforms.php' => 'Gravity Forms',
56 'caldera-forms/caldera-core.php' => 'Caldera Forms'
57 ];
58
59 $activePlugins = [];
60 foreach ($supportedPlugins as $plugin => $name) {
61 if (is_plugin_active($plugin)) {
62 $activePlugins[] = $name;
63 }
64 }
65
66 return $activePlugins;
67 }
68
69 private static function getMessage()
70 {
71 $activePlugins = static::getActiveCompatiblePlugins();
72 $pluginNames = implode(', ', $activePlugins);
73
74 $message = sprintf(
75 'We noticed you have <strong>%s</strong> installed. You can easily migrate your existing forms to <strong>Fluent Forms</strong> with just a few clicks.',
76 $pluginNames ?: 'compatible plugins'
77 );
78
79 return [
80 'name' => 'migration_notice', //ff_notice_migration_notice
81 'title' => '',
82 'message' => $message,
83 'links' => [
84 [
85 'href' => admin_url('admin.php?page=fluent_forms_transfer#migrator'),
86 'btn_text' => 'Migrate Now',
87 'btn_atts' => 'class="mr-1 el-button--success el-button--mini"',
88 ],
89 [
90 'href' => admin_url('admin.php?page=fluent_forms'),
91 'btn_text' => 'Maybe Later',
92 'btn_atts' => 'class="mr-1 el-button--info el-button--soft el-button--mini ff_nag_cross" data-notice_type="temp" data-notice_name="migration_notice"',
93 ],
94 [
95 'href' => admin_url('admin.php?page=fluent_forms'),
96 'btn_text' => 'Don\'t show again',
97 'btn_atts' => 'class="text-button el-button--mini ff_nag_cross" data-notice_type="permanent" data-notice_name="migration_notice"',
98 ],
99 ],
100 ];
101 }
102 }
103