| 1 |
<?php |
| 2 |
|
| 3 |
namespace forge12\contactform7\CF7DoubleOptIn; |
| 4 |
|
| 5 |
use Forge12\Shared\Logger; |
| 6 |
|
| 7 |
if ( ! defined( 'ABSPATH' ) ) { |
| 8 |
exit; |
| 9 |
} |
| 10 |
|
| 11 |
function onUpdate() { |
| 12 |
$logger = Logger::getInstance(); |
| 13 |
|
| 14 |
$logger->info( 'Running onUpdate routine', [ |
| 15 |
'plugin' => 'double-opt-in', |
| 16 |
'class' => __CLASS__ ?? null, |
| 17 |
'method' => __FUNCTION__, |
| 18 |
] ); |
| 19 |
|
| 20 |
$currentVersion = get_site_option( FORGE12_OPTIN_SLUG . '_version' ); |
| 21 |
|
| 22 |
if ( version_compare( $currentVersion, '1.7' ) < 0 ) { |
| 23 |
$logger->info( 'Updating to version 1.7', [ |
| 24 |
'plugin' => 'double-opt-in', |
| 25 |
'current' => $currentVersion, |
| 26 |
'target' => '1.7', |
| 27 |
] ); |
| 28 |
|
| 29 |
createTableOptinCategories(); |
| 30 |
$logger->debug( 'createTableOptinCategories executed', [ |
| 31 |
'plugin' => 'double-opt-in', |
| 32 |
] ); |
| 33 |
|
| 34 |
createTableOptin(); |
| 35 |
$logger->debug( 'createTableOptin executed', [ |
| 36 |
'plugin' => 'double-opt-in', |
| 37 |
] ); |
| 38 |
|
| 39 |
update_option( FORGE12_OPTIN_SLUG . '_version', '1.7' ); |
| 40 |
$logger->info( 'Version updated to 1.7', [ |
| 41 |
'plugin' => 'double-opt-in', |
| 42 |
] ); |
| 43 |
} |
| 44 |
|
| 45 |
if ( version_compare( $currentVersion, '2.0' ) < 0 ) { |
| 46 |
$logger->info( 'Updating to version 2.0', [ |
| 47 |
'plugin' => 'double-opt-in', |
| 48 |
'current' => $currentVersion, |
| 49 |
'target' => '2.0', |
| 50 |
] ); |
| 51 |
|
| 52 |
createTableOptin(); |
| 53 |
$logger->debug( 'createTableOptin executed', [ |
| 54 |
'plugin' => 'double-opt-in', |
| 55 |
] ); |
| 56 |
|
| 57 |
update_option( FORGE12_OPTIN_SLUG . '_version', '2.0' ); |
| 58 |
$logger->info( 'Version updated to 2.0', [ |
| 59 |
'plugin' => 'double-opt-in', |
| 60 |
] ); |
| 61 |
} |
| 62 |
|
| 63 |
if ( version_compare( $currentVersion, '3.0.1' ) < 0 ) { |
| 64 |
$logger->info( 'Updating to version 3.0.1', [ |
| 65 |
'plugin' => 'double-opt-in', |
| 66 |
'current' => $currentVersion, |
| 67 |
'target' => '3.0.1', |
| 68 |
] ); |
| 69 |
|
| 70 |
createTableOptin(); |
| 71 |
$logger->debug( 'createTableOptin executed', [ |
| 72 |
'plugin' => 'double-opt-in', |
| 73 |
] ); |
| 74 |
|
| 75 |
update_option( FORGE12_OPTIN_SLUG . '_version', '3.0.1' ); |
| 76 |
$logger->info( 'Version updated to 3.0.1', [ |
| 77 |
'plugin' => 'double-opt-in', |
| 78 |
] ); |
| 79 |
} |
| 80 |
|
| 81 |
$logger->info( 'onUpdate routine finished', [ |
| 82 |
'plugin' => 'double-opt-in', |
| 83 |
] ); |
| 84 |
} |
| 85 |
|
| 86 |
onUpdate(); |
| 87 |
|