Admin
3 years ago
Compatibility
3 years ago
Helpers
3 years ago
Providers
3 years ago
Reports
3 years ago
Tasks
3 years ago
UsageTracking
3 years ago
Conflicts.php
3 years ago
Connect.php
3 years ago
Core.php
3 years ago
Debug.php
3 years ago
Geo.php
3 years ago
MailCatcher.php
3 years ago
MailCatcherInterface.php
3 years ago
MailCatcherV6.php
3 years ago
Migration.php
3 years ago
MigrationAbstract.php
3 years ago
Options.php
3 years ago
Processor.php
3 years ago
SiteHealth.php
3 years ago
Upgrade.php
3 years ago
Uploads.php
3 years ago
WP.php
3 years ago
Upgrade.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WPMailSMTP; |
| 4 | |
| 5 | /** |
| 6 | * Class Upgrade helps upgrade plugin options and similar tasks when the |
| 7 | * occasion arises. |
| 8 | * |
| 9 | * @since 1.1.0 |
| 10 | */ |
| 11 | class Upgrade { |
| 12 | |
| 13 | /** |
| 14 | * Upgrade constructor. |
| 15 | * |
| 16 | * @since 1.1.0 |
| 17 | */ |
| 18 | public function __construct() { |
| 19 | |
| 20 | $upgrades = $this->upgrades(); |
| 21 | |
| 22 | if ( empty( $upgrades ) ) { |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | // Run any available upgrades. |
| 27 | foreach ( $upgrades as $upgrade ) { |
| 28 | $this->{$upgrade}(); |
| 29 | } |
| 30 | |
| 31 | // Update version post upgrade(s). |
| 32 | update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER ); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Whether we need to perform an upgrade. |
| 37 | * |
| 38 | * @since 1.1.0 |
| 39 | * |
| 40 | * @return array |
| 41 | */ |
| 42 | protected function upgrades() { |
| 43 | |
| 44 | $version = get_option( 'wp_mail_smtp_version' ); |
| 45 | $upgrades = array(); |
| 46 | |
| 47 | // Version 1.1.0 upgrade; prior to this the option was not available. |
| 48 | if ( empty( $version ) ) { |
| 49 | $upgrades[] = 'v110_upgrade'; |
| 50 | } |
| 51 | |
| 52 | return $upgrades; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Upgrade routine for v1.1.0. |
| 57 | * |
| 58 | * Set SMTPAutoTLS to true. |
| 59 | * |
| 60 | * @since 1.1.0 |
| 61 | */ |
| 62 | public function v110_upgrade() { |
| 63 | |
| 64 | // Enable SMTPAutoTLS option. |
| 65 | $values = [ |
| 66 | 'smtp' => [ |
| 67 | 'autotls' => true, |
| 68 | ], |
| 69 | ]; |
| 70 | |
| 71 | Options::init()->set( $values, false, false ); |
| 72 | } |
| 73 | } |
| 74 |