| @@ -18,9 +18,8 @@ | ||
| 18 | 18 | add_action('wp_ajax_fluentform-migrator-get-migrator-data', [$this, 'getMigratorData']); |
| 19 | 19 | add_action('wp_ajax_fluentform-migrator-get-forms-by-key', [$this, 'getFormsByKey']); |
| 20 | 20 | add_action('wp_ajax_fluentform-migrator-import-forms', [$this, 'importForms']); |
| 21 | 21 | add_action('wp_ajax_fluentform-migrator-import-entries', [$this, 'importEntries']); |
| 22 | - | |
| 23 | 22 | } |
| 24 | 23 | |
| 25 | 24 | public function availableMigrations() |
| 26 | 25 | { |
| @@ -56,9 +55,8 @@ | ||
| 56 | 55 | 'key' => 'contactform7', |
| 57 | 56 | ]; |
| 58 | 57 | } |
| 59 | 58 | return $migratorLinks; |
| 60 | - | |
| 61 | 59 | } |
| 62 | 60 | |
| 63 | 61 | public function setImporterType() |
| 64 | 62 | { |
| @@ -81,14 +79,12 @@ | ||
| 81 | 79 | $this->importer = new ContactForm7Migrator(); |
| 82 | 80 | break; |
| 83 | 81 | default: |
| 84 | 82 | wp_send_json([ |
| 85 | - 'message' => __('Unsupported Form Type!','fluentform'), | |
| 83 | + 'message' => __('Unsupported Form Type!', 'fluentform'), | |
| 86 | 84 | 'success' => false, |
| 87 | 85 | ]); |
| 88 | 86 | } |
| 89 | - | |
| 90 | - | |
| 91 | 87 | } |
| 92 | 88 | |
| 93 | 89 | public function getMigratorData() |
| 94 | 90 | { |
| @@ -95,9 +91,9 @@ | ||
| 95 | 91 | \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']); |
| 96 | 92 | |
| 97 | 93 | wp_send_json([ |
| 98 | 94 | 'status' => true, |
| 99 | - 'migrator_data' => $this->availableMigrations() | |
| 95 | + 'migrator_data' => $this->availableMigrations(), | |
| 100 | 96 | ], 200); |
| 101 | 97 | } |
| 102 | 98 | |
| 103 | 99 | public function importForms() |
| @@ -102,9 +98,9 @@ | ||
| 102 | 98 | |
| 103 | 99 | public function importForms() |
| 104 | 100 | { |
| 105 | 101 | \FluentForm\App\Modules\Acl\Acl::verify(['fluentform_settings_manager', 'fluentform_forms_manager']); |
| 106 | - | |
| 102 | + | |
| 107 | 103 | $formIds = wpFluentForm('request')->get('form_ids'); |
| 108 | 104 | if (!is_array($formIds)) { |
| 109 | 105 | $formIds = []; |
| 110 | 106 | } |
| @@ -111,17 +107,19 @@ | ||
| 111 | 107 | $formIds = array_map('sanitize_text_field', $formIds); |
| 112 | 108 | |
| 113 | 109 | $this->setImporterType(); |
| 114 | 110 | $this->importer->import_forms($formIds); |
| 115 | - | |
| 116 | 111 | } |
| 117 | 112 | |
| 118 | 113 | public function importEntries() |
| 119 | 114 | { |
| 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')); | |
| 115 | + $fluentFormId = \FluentForm\App\Modules\Acl\Acl::verifyFormId( | |
| 116 | + wpFluentForm('request')->get('imported_fluent_form_id') | |
| 117 | + ); | |
| 118 | + \FluentForm\App\Modules\Acl\Acl::verify( | |
| 119 | + ['fluentform_settings_manager', 'fluentform_forms_manager'], | |
| 120 | + $fluentFormId | |
| 121 | + ); | |
| 124 | 122 | $importFormId = sanitize_text_field(wpFluentForm('request')->get('source_form_id')); |
| 125 | 123 | $this->setImporterType(); |
| 126 | 124 | $this->importer->insertEntries($fluentFormId, $importFormId); |
| 127 | 125 | } |
| @@ -148,7 +146,5 @@ | ||
| 148 | 146 | 'forms' => $forms, |
| 149 | 147 | 'success' => true, |
| 150 | 148 | ]); |
| 151 | 149 | } |
| 152 | - | |
| 153 | - | |
| 154 | 150 | } |