| 1 |
<?php |
| 2 |
/** |
| 3 |
* 1.3.0 Upgrades |
| 4 |
* |
| 5 |
* @package AutomatorWP\Admin\Upgrades\1.3.0 |
| 6 |
* @since 1.3.0 |
| 7 |
*/ |
| 8 |
// Exit if accessed directly |
| 9 |
if( !defined( 'ABSPATH' ) ) exit; |
| 10 |
|
| 11 |
/** |
| 12 |
* Return 1.3.0 as last required upgrade |
| 13 |
* |
| 14 |
* @return string |
| 15 |
*/ |
| 16 |
function automatorwp_130_is_last_required_upgrade() { |
| 17 |
|
| 18 |
return '1.3.0'; |
| 19 |
|
| 20 |
} |
| 21 |
add_filter( 'automatorwp_get_last_required_upgrade', 'automatorwp_130_is_last_required_upgrade', 130 ); |
| 22 |
|
| 23 |
/** |
| 24 |
* Process 1.3.0 upgrades |
| 25 |
* |
| 26 |
* @param string $stored_version |
| 27 |
* |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
function automatorwp_130_upgrades( $stored_version ) { |
| 31 |
|
| 32 |
// Already upgrade |
| 33 |
if ( version_compare( $stored_version, '1.3.0', '>=' ) ) { |
| 34 |
return $stored_version; |
| 35 |
} |
| 36 |
|
| 37 |
// Ensure that AutomatorWP tables have been created |
| 38 |
if( automatorwp_database_table_exists( AutomatorWP()->db->automations ) ) { |
| 39 |
// Process 1.3.0 upgrade |
| 40 |
automatorwp_process_130_upgrade(); |
| 41 |
|
| 42 |
// There is nothing to update, so upgrade |
| 43 |
$stored_version = '1.3.0'; |
| 44 |
} |
| 45 |
|
| 46 |
return $stored_version; |
| 47 |
|
| 48 |
} |
| 49 |
add_filter( 'automatorwp_process_upgrades', 'automatorwp_130_upgrades', 130 ); |
| 50 |
|
| 51 |
/** |
| 52 |
* Process 1.3.0 upgrades |
| 53 |
*/ |
| 54 |
function automatorwp_process_130_upgrade() { |
| 55 |
|
| 56 |
global $wpdb; |
| 57 |
|
| 58 |
ignore_user_abort( true ); |
| 59 |
set_time_limit( 0 ); |
| 60 |
|
| 61 |
// Bail if AutomatorWP tables haven't been created yet |
| 62 |
if( ! automatorwp_database_table_exists( AutomatorWP()->db->automations ) ) { |
| 63 |
return; |
| 64 |
} |
| 65 |
|
| 66 |
$automations = AutomatorWP()->db->automations; |
| 67 |
|
| 68 |
// Update old automations type |
| 69 |
$wpdb->query( "UPDATE {$automations} AS a SET a.type = 'user' WHERE a.type = ''" ); |
| 70 |
|
| 71 |
// Updated stored version |
| 72 |
update_option( 'automatorwp_version', '1.3.0' ); |
| 73 |
|
| 74 |
} |