direct-checkout.php
3 years ago
lang-migration.php
3 years ago
migration.php
3 years ago
temp-migration.php
3 years ago
lang-migration.php
40 lines
| 1 | <?php |
| 2 | |
| 3 | namespace ShopEngine\Compatibility\Migrations; |
| 4 | |
| 5 | use ShopEngine\Core\Builders\Action; |
| 6 | use ShopEngine\Traits\Singleton; |
| 7 | |
| 8 | class LangMigration |
| 9 | { |
| 10 | const COOKIE_KEY = 'shopengine_wishlist_offline'; |
| 11 | |
| 12 | use Singleton; |
| 13 | |
| 14 | public function init() |
| 15 | { |
| 16 | $shopengine_activated_templates = get_option(Action::ACTIVATED_TEMPLATES); |
| 17 | if (!$shopengine_activated_templates) { |
| 18 | |
| 19 | global $wpdb; |
| 20 | |
| 21 | $options = $wpdb->get_results("SELECT * FROM {$wpdb->base_prefix}options WHERE option_name LIKE '%shopengine_template__post_meta__%'"); |
| 22 | $activated_templates = []; |
| 23 | foreach ($options as $option) { |
| 24 | $template_type_and_category = explode('__', str_replace('shopengine_template__post_meta__', '', $option->option_name)); |
| 25 | if (0 != $option->option_value) { |
| 26 | $value = [ |
| 27 | 'template_id' => $option->option_value, |
| 28 | 'status' => true, |
| 29 | 'category_id' => isset($template_type_and_category[1]) ? intval($template_type_and_category[1]) : 0 |
| 30 | ]; |
| 31 | update_post_meta($option->option_value, 'language_code', 'en'); |
| 32 | $activated_templates[$template_type_and_category[0]]['default'] = 'en'; |
| 33 | $activated_templates[$template_type_and_category[0]]['lang']['en'][] = $value; |
| 34 | } |
| 35 | } |
| 36 | Action::set_activated_templates($activated_templates); |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 |