PluginProbe
PayPlug for WooCommerce (Official) / 2.18.0
PayPlug for WooCommerce (Official) v2.18.0
3.0.0 2.18.0 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.0 1.10.0 1.10.1 1.2.1 1.2.10 1.2.11 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 All 101 releases
payplug / src / Service / Upgrade.php

Upgrade.php in PayPlug for WooCommerce (Official) 2.18.0, at src/Service/Upgrade.php

54 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Payplug\PayplugWoocommerce\Service;
4
5 use Payplug\PayplugWoocommerce\Traits\GatewayGetter;
6 use Payplug\PayplugWoocommerce\Traits\ServiceGetter;
7
8 class Upgrade
9 {
10 use ServiceGetter;
11 use GatewayGetter;
12
13 public function run_upgrade()
14 {
15 // Check if new options need to be setted
16 $configuration = $this->get_service('configuration');
17
18 if (empty($configuration->get_option('email'))) {
19 return;
20 }
21
22 $version = $configuration->get_option('version');
23
24 if (!empty($version) && version_compare($version, PAYPLUG_MAX_VERSION_FOR_UPGRADE, '>=')) {
25 return;
26 }
27
28 $options = $configuration->validate_configuration();
29
30 if (empty($options)) {
31 return;
32 }
33
34 // set the current version
35 $options['version'] = PAYPLUG_GATEWAY_VERSION;
36
37 // replace current option by new one
38 $configuration->clean_option();
39 $configuration->update_options($options);
40
41 // then refresh the permissions
42 $account_gateway = $this->get_gateway('account');
43
44 // then get permissions
45 $formated_account_permissions = $account_gateway->get_permissions();
46
47 // and update options
48 $configuration->update_options($formated_account_permissions['global']);
49 $configuration->update_payment_permissions($formated_account_permissions['payment_methods']);
50
51 return;
52 }
53 }
54