| 1 |
<?php |
| 2 |
/** |
| 3 |
* Upgrade routine for 3.1.4. |
| 4 |
* |
| 5 |
* Renames legacy ma_* popup data to the jltma_* prefix: |
| 6 |
* - custom table {$prefix}ma_popups -> {$prefix}jltma_popups |
| 7 |
* - option ma_popup_settings -> jltma_popup_settings |
| 8 |
* |
| 9 |
* Idempotent: safe if the legacy names are already absent. |
| 10 |
*/ |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
global $wpdb; |
| 17 |
|
| 18 |
$old_table = $wpdb->prefix . 'ma_popups'; |
| 19 |
$new_table = $wpdb->prefix . 'jltma_popups'; |
| 20 |
$old_exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $old_table)); |
| 21 |
$new_exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $new_table)); |
| 22 |
|
| 23 |
if ($old_exists === $old_table && $new_exists !== $new_table) { |
| 24 |
// Identifiers cannot be bound; both names are server-generated (prefix + literal), not user input. |
| 25 |
$wpdb->query("RENAME TABLE `{$old_table}` TO `{$new_table}`"); |
| 26 |
} |
| 27 |
|
| 28 |
$legacy_settings = get_option('ma_popup_settings', null); |
| 29 |
if (null !== $legacy_settings && false === get_option('jltma_popup_settings', false)) { |
| 30 |
update_option('jltma_popup_settings', $legacy_settings); |
| 31 |
delete_option('ma_popup_settings'); |
| 32 |
} |
| 33 |
|