PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / PaymentGateways / Migrations / CopyV2GatewaysSettingsToV3.php

CopyV2GatewaysSettingsToV3.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/PaymentGateways/Migrations/CopyV2GatewaysSettingsToV3.php

65 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\PaymentGateways\Migrations;
4
5 use Give\Framework\Migrations\Contracts\Migration;
6
7 /**
8 * @since 3.0.0
9 */
10 class CopyV2GatewaysSettingsToV3 extends Migration
11 {
12
13 /**
14 * @inerhitDoc
15 */
16 public static function id()
17 {
18 return 'copy-v2-gateways-settings-to-v3';
19 }
20
21 /**
22 * @inerhitDoc
23 */
24 public static function timestamp()
25 {
26 return strtotime('2023-09-11');
27 }
28
29 /**
30 * @inerhitDoc
31 */
32 public function run()
33 {
34 $v3Gateways = give_get_option('gateways_v3', null);
35 if (is_null($v3Gateways)) {
36 $v2Gateways = give_get_option('gateways', []);
37 $v3Gateways = array_intersect_key($v2Gateways, give()->gateways->getPaymentGateways(3));
38 give_update_option('gateways_v3', $v3Gateways);
39 }
40
41 $v3GatewaysLabels = give_get_option('gateways_label_v3', null);
42 if (is_null($v3GatewaysLabels)) {
43 $v2GatewaysLabels = give_get_option('gateways_label', []);
44 $v3GatewaysLabels = array_intersect_key($v2GatewaysLabels, $v3Gateways);
45 give_update_option('gateways_label_v3', $v3GatewaysLabels);
46 }
47
48 if (is_null(give_get_option('default_gateway_v3', null))) {
49 $v2DefaultGateway = give_get_option('default_gateway', '');
50 $v3DefaultGateway = array_key_exists($v2DefaultGateway, $v3Gateways) ? $v2DefaultGateway : current(
51 array_keys($v3Gateways)
52 );
53 give_update_option('default_gateway_v3', $v3DefaultGateway);
54 }
55 }
56
57 /**
58 * @inerhitDoc
59 */
60 public static function title()
61 {
62 return 'Copy v2 Gateways Settings to v3';
63 }
64 }
65