| 1 |
<?php |
| 2 |
// don't call the file directly. |
| 3 |
if (!defined('ABSPATH')) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/** |
| 8 |
* Update version. |
| 9 |
*/ |
| 10 |
update_option('darkify_version', '1.4.6'); |
| 11 |
update_option('darkify_db_version', '1.4.6'); |
| 12 |
|
| 13 |
/** |
| 14 |
* Convert old data keys to new ones for version 1.4.6 |
| 15 |
*/ |
| 16 |
function darkify_convert_old_to_new_data_1_4_6($options) |
| 17 |
{ |
| 18 |
if (empty($options['show_in_menu'])) { |
| 19 |
return; // Nothing to migrate |
| 20 |
} |
| 21 |
|
| 22 |
$show_in_menu = $options['show_in_menu']; |
| 23 |
|
| 24 |
// Extract old values |
| 25 |
$enable_switch_in_menu = isset($show_in_menu['enable_switch_in_menu']) ? $show_in_menu['enable_switch_in_menu'] : ''; |
| 26 |
$switch_in_menu_location = isset($show_in_menu['switch_in_menu_location']) ? $show_in_menu['switch_in_menu_location'] : ''; |
| 27 |
$darkify_menu_shortcode_helper = isset($show_in_menu['darkify_menu_shortcode_helper']) ? $show_in_menu['darkify_menu_shortcode_helper'] : ''; |
| 28 |
|
| 29 |
// Prepare new structure |
| 30 |
$new_show_in_menu = array( |
| 31 |
'enable_switch_in_menu' => $enable_switch_in_menu, |
| 32 |
); |
| 33 |
|
| 34 |
// If enabled, ensure at least one group item exists |
| 35 |
if ($enable_switch_in_menu) { |
| 36 |
$new_show_in_menu['select_menus'] = array( |
| 37 |
array( |
| 38 |
'switch_in_menu_location' => $switch_in_menu_location, |
| 39 |
'darkify_menu_shortcode_helper' => $darkify_menu_shortcode_helper, |
| 40 |
) |
| 41 |
); |
| 42 |
} |
| 43 |
|
| 44 |
// Replace old structure |
| 45 |
$options['show_in_menu'] = $new_show_in_menu; |
| 46 |
|
| 47 |
// Save updated options |
| 48 |
update_option('darkify', $options); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Update old to new data on load |
| 53 |
*/ |
| 54 |
$options = get_option('darkify'); |
| 55 |
if ($options) { |
| 56 |
darkify_convert_old_to_new_data_1_4_6($options); |
| 57 |
} |
| 58 |
|