| @@ -1,0 +1,85 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * 1.1.6 Upgrades | |
| 4 | + * | |
| 5 | + * @package AutomatorWP\Admin\Upgrades\1.1.6 | |
| 6 | + * @since 1.1.6 | |
| 7 | + */ | |
| 8 | +// Exit if accessed directly | |
| 9 | +if( !defined( 'ABSPATH' ) ) exit; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * Return 1.1.6 as last required upgrade | |
| 13 | + * | |
| 14 | + * @return string | |
| 15 | + */ | |
| 16 | +function automatorwp_116_is_last_required_upgrade() { | |
| 17 | + | |
| 18 | + return '1.1.6'; | |
| 19 | + | |
| 20 | +} | |
| 21 | +add_filter( 'automatorwp_get_last_required_upgrade', 'automatorwp_116_is_last_required_upgrade', 116 ); | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * Process 1.1.6 upgrades | |
| 25 | + * | |
| 26 | + * @param string $stored_version | |
| 27 | + * | |
| 28 | + * @return string | |
| 29 | + */ | |
| 30 | +function automatorwp_116_upgrades( $stored_version ) { | |
| 31 | + | |
| 32 | + // Already upgrade | |
| 33 | + if ( version_compare( $stored_version, '1.1.6', '>=' ) ) { | |
| 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.1.6 upgrade | |
| 40 | + automatorwp_process_116_upgrade(); | |
| 41 | + | |
| 42 | + // There is nothing to update, so upgrade | |
| 43 | + $stored_version = '1.1.6'; | |
| 44 | + } | |
| 45 | + | |
| 46 | + return $stored_version; | |
| 47 | + | |
| 48 | +} | |
| 49 | +add_filter( 'automatorwp_process_upgrades', 'automatorwp_116_upgrades', 116 ); | |
| 50 | + | |
| 51 | +/** | |
| 52 | + * Process 1.1.6 upgrades | |
| 53 | + */ | |
| 54 | +function automatorwp_process_116_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 | + // Setup tables to update | |
| 67 | + $tables = array( | |
| 68 | + AutomatorWP()->db->automations, | |
| 69 | + AutomatorWP()->db->automations_meta, | |
| 70 | + AutomatorWP()->db->triggers, | |
| 71 | + AutomatorWP()->db->triggers_meta, | |
| 72 | + AutomatorWP()->db->actions, | |
| 73 | + AutomatorWP()->db->actions_meta, | |
| 74 | + AutomatorWP()->db->logs, | |
| 75 | + AutomatorWP()->db->logs_meta, | |
| 76 | + ); | |
| 77 | + foreach( $tables as $table ) { | |
| 78 | + // Alter table to use InnoDB | |
| 79 | + $wpdb->query( "ALTER TABLE {$table} ENGINE = InnoDB;" ); | |
| 80 | + } | |
| 81 | + | |
| 82 | + // Updated stored version | |
| 83 | + update_option( 'automatorwp_version', '1.1.6' ); | |
| 84 | + | |
| 85 | +} | |