forked from awesomemotive/WP-Mail-SMTP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUpgrade.php
71 lines (56 loc) · 1.16 KB
/
Upgrade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
namespace WPMailSMTP;
/**
* Class Upgrade helps upgrade plugin options and similar tasks when the
* occasion arises.
*
* @since 1.1.0
*/
class Upgrade {
/**
* Upgrade constructor.
*
* @since 1.1.0
*/
public function __construct() {
$upgrades = $this->upgrades();
if ( empty( $upgrades ) ) {
return;
}
// Run any available upgrades.
foreach ( $upgrades as $upgrade ) {
$this->{$upgrade}();
}
// Update version post upgrade(s).
update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER );
}
/**
* Whether we need to perform an upgrade.
*
* @since 1.1.0
*
* @return array
*/
protected function upgrades() {
$version = get_option( 'wp_mail_smtp_version' );
$upgrades = array();
// Version 1.1.0 upgrade; prior to this the option was not available.
if ( empty( $version ) ) {
$upgrades[] = 'v110_upgrade';
}
return $upgrades;
}
/**
* Upgrade routine for v1.1.0.
*
* Set SMTPAutoTLS to true.
*
* @since 1.1.0
*/
public function v110_upgrade() {
$values = Options::init()->get_all();
// Enable SMTPAutoTLS option.
$values['smtp']['autotls'] = true;
Options::init()->set( $values );
}
}