class-wcs-upgrade-1-3.php
1.32 KB
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
<?php
/**
* Update Subscriptions to 1.3.0
*
* Upgrade cron lock values to be options rather than transients to work around potential early deletion by W3TC
* and other caching plugins. Also add the Variable Subscription product type (if it doesn't exist).
*
* @author Prospress
* @category Admin
* @package WooCommerce Subscriptions/Admin/Upgrades
* @version 1.3.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
class WCS_Upgrade_1_3 {
public function init() {
global $wpdb;
// Change transient timeout entries to be a vanilla option
$wpdb->query( " UPDATE $wpdb->options
SET option_name = TRIM(LEADING '_transient_timeout_' FROM option_name)
WHERE option_name LIKE '_transient_timeout_wcs_blocker_%'" );
// Change transient keys from the < 1.1.5 format to new format
$wpdb->query( " UPDATE $wpdb->options
SET option_name = CONCAT('wcs_blocker_', TRIM(LEADING '_transient_timeout_block_scheduled_subscription_payments_' FROM option_name))
WHERE option_name LIKE '_transient_timeout_block_scheduled_subscription_payments_%'" );
// Delete old transient values
$wpdb->query( " DELETE FROM $wpdb->options
WHERE option_name LIKE '_transient_wcs_blocker_%'
OR option_name LIKE '_transient_block_scheduled_subscription_payments_%'" );
}
}
WCS_Upgrade_1_3::init();