PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / 2.17.6
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder v2.17.6
V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 2.10.2 All 137 releases
bit-form / includes / Core / Migration / MigrateForms.php

MigrateForms.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder 2.17.6, at includes/Core/Migration/MigrateForms.php

69 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace BitCode\BitForm\Core\Migration;
4
5 use BitCode\BitForm\Core\Database\IntegrationModel;
6 use BitCode\BitForm\Core\Integration\IntegrationHandler;
7
8 final class MigrateForms
9 {
10 public function migrateToV2()
11 {
12 $v1FormContents = get_transient('bitforms_v1_form_contents');
13 $newFormContents = [];
14 foreach ($v1FormContents as $formContents) {
15 $migrationHandler = new Migration(json_decode(wp_json_encode($formContents)));
16 $newFormContents[] = $migrationHandler->migrate();
17 }
18 self::migratePaypal();
19 $config = (object) [];
20 $config->delete_table = true;
21 update_option('bitform_app_config', $config);
22 set_transient('bitforms_v1_form_contents', $newFormContents);
23 return $newFormContents;
24 }
25
26 private static function migratePaypal()
27 {
28 $integrationHandler = new IntegrationHandler(0);
29 $formIntegrations = $integrationHandler->getAllIntegration('app', 'payments');
30 if (!is_wp_error($formIntegrations)) {
31 return false;
32 }
33 $integrationModel = new IntegrationModel();
34
35 foreach ($formIntegrations as $payment) {
36 $integrationDetails = json_decode($payment->integration_details);
37 if ('PayPal' === $integrationDetails->type) {
38 $integrationDetails->mode = 'live';
39 $integrationDetails->clientSecret = '';
40 $integrationModel->update([
41 'integration_details' => wp_json_encode($integrationDetails),
42 ], [
43 'id' => $payment->id,
44 ]);
45 }
46 }
47 return true;
48 }
49
50 private function dropTableAndRename($deletedTableName, $renamedTableName)
51 {
52 global $wpdb;
53 $deleteTable = "{$wpdb->prefix}bitforms_{$deletedTableName}";
54 $renameTable = "{$wpdb->prefix}bitforms_{$renamedTableName}";
55 // $wpdb->query("DROP TABLE IF EXISTS $deleteTable");
56 // $wpdb->query("RENAME TABLE $renameTable TO $deleteTable");
57 $wpdb->query(
58 $wpdb->prepare(
59 "DROP TABLE IF EXISTS $deleteTable"
60 )
61 );
62 $wpdb->query(
63 $wpdb->prepare(
64 "RENAME TABLE $renameTable TO $deleteTable"
65 )
66 );
67 }
68 }
69