PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 6.2.7
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v6.2.7
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Services / Migrator / Bootstrap.php

Bootstrap.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 6.2.7, at app/Services/Migrator/Bootstrap.php

155 lines 4.6 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\Services\Migrator;
4
5 defined('ABSPATH') or die;
6
7 use FluentForm\App\Services\Migrator\Classes\NinjaFormsMigrator;
8 use FluentForm\App\Services\Migrator\Classes\CalderaMigrator;
9 use FluentForm\App\Services\Migrator\Classes\GravityFormsMigrator;
10 use FluentForm\App\Services\Migrator\Classes\WpFormsMigrator;
11 use FluentForm\App\Services\Migrator\Classes\ContactForm7Migrator;
12 class Bootstrap
13 {
14 protected $importer;
15
16 public function boot()
17 {
18 add_action('wp_ajax_fluentform-migrator-get-migrator-data', [$this, 'getMigratorData']);
19 add_action('wp_ajax_fluentform-migrator-get-forms-by-key', [$this, 'getFormsByKey']);
20 add_action('wp_ajax_fluentform-migrator-import-forms', [$this, 'importForms']);
21 add_action('wp_ajax_fluentform-migrator-import-entries', [$this, 'importEntries']);
22
23 }
24
25 public function availableMigrations()
26 {
27 $migratorLinks = [];
28
29 if ((new CalderaMigrator())->exist()) {
30 $migratorLinks[] = [
31 'name' => 'Caldera Forms',
32 'key' => 'caldera',
33 ];
34 }
35 if ((new NinjaFormsMigrator())->exist()) {
36 $migratorLinks[] = [
37 'name' => 'Ninja Forms',
38 'key' => 'ninja_forms',
39 ];
40 }
41 if ((new GravityFormsMigrator())->exist()) {
42 $migratorLinks[] = [
43 'name' => 'Gravity Forms',
44 'key' => 'gravityform',
45 ];
46 }
47 if ((new WpFormsMigrator())->exist()) {
48 $migratorLinks[] = [
49 'name' => 'WPForms',
50 'key' => 'wpforms',
51 ];
52 }
53 if ((new ContactForm7Migrator())->exist()) {
54 $migratorLinks[] = [
55 'name' => 'Contact Form 7',
56 'key' => 'contactform7',
57 ];
58 }
59 return $migratorLinks;
60
61 }
62
63 public function setImporterType()
64 {
65 $formType = sanitize_text_field(wpFluentForm('request')->get('form_type'));
66
67 switch ($formType) {
68 case 'caldera':
69 $this->importer = new CalderaMigrator();
70 break;
71 case 'ninja_forms':
72 $this->importer = new NinjaFormsMigrator();
73 break;
74 case 'gravityform':
75 $this->importer = new GravityFormsMigrator();
76 break;
77 case 'wpforms':
78 $this->importer = new WpFormsMigrator();
79 break;
80 case 'contactform7':
81 $this->importer = new ContactForm7Migrator();
82 break;
83 default:
84 wp_send_json([
85 'message' => __('Unsupported Form Type!','fluentform'),
86 'success' => false,
87 ]);
88 }
89
90
91 }
92
93 public function getMigratorData()
94 {
95 \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
96
97 wp_send_json([
98 'status' => true,
99 'migrator_data' => $this->availableMigrations()
100 ], 200);
101 }
102
103 public function importForms()
104 {
105 \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
106
107 $formIds = wpFluentForm('request')->get('form_ids');
108 if (!is_array($formIds)) {
109 $formIds = [];
110 }
111 $formIds = array_map('sanitize_text_field', $formIds);
112
113 $this->setImporterType();
114 $this->importer->import_forms($formIds);
115
116 }
117
118 public function importEntries()
119 {
120 \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
121
122
123 $fluentFormId = intval(wpFluentForm('request')->get('imported_fluent_form_id'));
124 $importFormId = sanitize_text_field(wpFluentForm('request')->get('source_form_id'));
125 $this->setImporterType();
126 $this->importer->insertEntries($fluentFormId, $importFormId);
127 }
128
129 public function hasOtherForms()
130 {
131 \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
132
133 $migrationData = $this->availableMigrations();
134 if (is_array($migrationData) && !empty($migrationData)) {
135 return true;
136 }
137 return false;
138 }
139
140 public function getFormsByKey()
141 {
142 \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']);
143
144 $this->setImporterType();
145 $forms = $this->importer->getFormsFormatted();
146
147 wp_send_json([
148 'forms' => $forms,
149 'success' => true,
150 ]);
151 }
152
153
154 }
155