Merged in feature/from-pantheon (pull request #16)
code from pantheon * code from pantheon
This commit is contained in:
73
wp/wp-content/plugins/wp-mail-smtp/src/Upgrade.php
Normal file
73
wp/wp-content/plugins/wp-mail-smtp/src/Upgrade.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?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() {
|
||||
|
||||
// Enable SMTPAutoTLS option.
|
||||
$values = [
|
||||
'smtp' => [
|
||||
'autotls' => true,
|
||||
],
|
||||
];
|
||||
|
||||
Options::init()->set( $values, false, false );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user