Admin
1 year ago
Compatibility
1 year ago
Helpers
1 year ago
Providers
1 year ago
Queue
1 year ago
Reports
1 year ago
Tasks
1 year ago
UsageTracking
1 year ago
AbstractConnection.php
1 year ago
Conflicts.php
1 year ago
Connect.php
1 year ago
Connection.php
1 year ago
ConnectionInterface.php
1 year ago
ConnectionsManager.php
1 year ago
Core.php
1 year ago
DBRepair.php
1 year ago
Debug.php
1 year ago
Geo.php
1 year ago
MailCatcher.php
1 year ago
MailCatcherInterface.php
1 year ago
MailCatcherTrait.php
1 year ago
MailCatcherV6.php
1 year ago
Migration.php
1 year ago
MigrationAbstract.php
1 year ago
Migrations.php
1 year ago
OptimizedEmailSending.php
1 year ago
Options.php
1 year ago
Processor.php
1 year ago
SiteHealth.php
1 year ago
Upgrade.php
1 year ago
Uploads.php
1 year ago
WP.php
1 year ago
WPMailArgs.php
1 year ago
WPMailInitiator.php
1 year ago
Upgrade.php
81 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 | /** |
| 21 | * Run upgrades. |
| 22 | * |
| 23 | * @since 4.0.0 |
| 24 | */ |
| 25 | public function run() { |
| 26 | |
| 27 | $upgrades = $this->upgrades(); |
| 28 | |
| 29 | if ( empty( $upgrades ) ) { |
| 30 | return; |
| 31 | } |
| 32 | |
| 33 | // Run any available upgrades. |
| 34 | foreach ( $upgrades as $upgrade ) { |
| 35 | $this->{$upgrade}(); |
| 36 | } |
| 37 | |
| 38 | // Update version post upgrade(s). |
| 39 | update_option( 'wp_mail_smtp_version', WPMS_PLUGIN_VER ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Whether we need to perform an upgrade. |
| 44 | * |
| 45 | * @since 1.1.0 |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | protected function upgrades() { |
| 50 | |
| 51 | $version = get_option( 'wp_mail_smtp_version' ); |
| 52 | $upgrades = array(); |
| 53 | |
| 54 | // Version 1.1.0 upgrade; prior to this the option was not available. |
| 55 | if ( empty( $version ) ) { |
| 56 | $upgrades[] = 'v110_upgrade'; |
| 57 | } |
| 58 | |
| 59 | return $upgrades; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Upgrade routine for v1.1.0. |
| 64 | * |
| 65 | * Set SMTPAutoTLS to true. |
| 66 | * |
| 67 | * @since 1.1.0 |
| 68 | */ |
| 69 | public function v110_upgrade() { |
| 70 | |
| 71 | // Enable SMTPAutoTLS option. |
| 72 | $values = [ |
| 73 | 'smtp' => [ |
| 74 | 'autotls' => true, |
| 75 | ], |
| 76 | ]; |
| 77 | |
| 78 | Options::init()->set( $values, false, false ); |
| 79 | } |
| 80 | } |
| 81 |