| @@ -88,9 +88,9 @@ | ||
| 88 | 88 | * |
| 89 | 89 | * @since 1.2 |
| 90 | 90 | */ |
| 91 | 91 | public function _upgrade() { |
| 92 | - foreach ( array( '0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4', '1.8', '2.0.8', '2.1', '2.3', '2.7' ) as $version ) { | |
| 92 | + foreach ( array( '0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4', '1.5', '1.6', '1.7.4', '1.8', '2.0.8', '2.1', '2.3' ) as $version ) { | |
| 93 | 93 | if ( version_compare( $this->options['version'], $version, '<' ) ) { |
| 94 | 94 | call_user_func( array( $this, 'upgrade_' . str_replace( '.', '_', $version ) ) ); |
| 95 | 95 | } |
| 96 | 96 | } |
| @@ -142,9 +142,9 @@ | ||
| 142 | 142 | protected function upgrade_1_1() { |
| 143 | 143 | // Update strings register with icl_register_string |
| 144 | 144 | $strings = get_option( 'polylang_wpml_strings' ); |
| 145 | 145 | if ( $strings ) { |
| 146 | - foreach ( array_keys( $strings ) as $key ) { | |
| 146 | + foreach ( $strings as $key => $string ) { | |
| 147 | 147 | $strings[ $key ]['icl'] = 1; |
| 148 | 148 | } |
| 149 | 149 | update_option( 'polylang_wpml_strings', $strings ); |
| 150 | 150 | } |
| @@ -178,10 +178,9 @@ | ||
| 178 | 178 | |
| 179 | 179 | // Upgrade old model based on metas to new model based on taxonomies |
| 180 | 180 | global $wpdb; |
| 181 | 181 | $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // Registers the termmeta table in wpdb |
| 182 | - $languages = get_terms( 'language', array( 'hide_empty' => 0 ) ); // Don't use get_languages_list which can't work with the old model | |
| 183 | - $lang_tt_ids = array(); | |
| 182 | + $languages = get_terms( 'language', array( 'hide_empty' => 0 ) ); // Don't use get_languages_list which can't work with the old model | |
| 184 | 183 | |
| 185 | 184 | foreach ( $languages as $lang ) { |
| 186 | 185 | // First update language with new storage for locale and text direction |
| 187 | 186 | $text_direction = get_metadata( 'term', $lang->term_id, '_rtl', true ); |
| @@ -208,14 +207,10 @@ | ||
| 208 | 207 | } |
| 209 | 208 | |
| 210 | 209 | // Translations |
| 211 | 210 | foreach ( array( 'post', 'term' ) as $type ) { |
| 212 | - $table = $type . 'meta'; | |
| 213 | - $terms = array(); | |
| 214 | - $slugs = array(); | |
| 215 | - $tts = array(); | |
| 216 | - $trs = array(); | |
| 217 | - $description = array(); | |
| 211 | + $table = $type . 'meta'; | |
| 212 | + $terms = $slugs = $tts = $trs = array(); | |
| 218 | 213 | |
| 219 | 214 | // Get all translated objects |
| 220 | 215 | // PHPCS:ignore WordPress.DB.PreparedSQL |
| 221 | 216 | $objects = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->$table} WHERE meta_key = '_translations'" ); |
| @@ -311,10 +306,8 @@ | ||
| 311 | 306 | // Old version < 1.1 |
| 312 | 307 | // Multilingal locations and switcher item were stored in a dedicated option |
| 313 | 308 | if ( version_compare( $this->options['version'], '1.1', '<' ) ) { |
| 314 | 309 | if ( $menu_lang = get_option( 'polylang_nav_menus' ) ) { |
| 315 | - $locations = array(); | |
| 316 | - | |
| 317 | 310 | foreach ( $menu_lang as $location => $arr ) { |
| 318 | 311 | if ( ! in_array( $location, array_keys( get_registered_nav_menus() ) ) ) { |
| 319 | 312 | continue; |
| 320 | 313 | } |
| @@ -361,9 +354,9 @@ | ||
| 361 | 354 | // If old version < 1.2 |
| 362 | 355 | // Clean the WP option as it was a bad idea to pollute it |
| 363 | 356 | if ( version_compare( $this->options['version'], '1.2', '<' ) ) { |
| 364 | 357 | foreach ( $menus as $loc => $menu ) { |
| 365 | - if ( strpos( $loc, '#' ) ) { | |
| 358 | + if ( $pos = strpos( $loc, '#' ) ) { | |
| 366 | 359 | unset( $menus[ $loc ] ); |
| 367 | 360 | } |
| 368 | 361 | } |
| 369 | 362 | |
| @@ -524,10 +517,8 @@ | ||
| 524 | 517 | if ( ! $translations ) { |
| 525 | 518 | return; |
| 526 | 519 | } |
| 527 | 520 | |
| 528 | - $translations_to_load = array(); | |
| 529 | - | |
| 530 | 521 | foreach ( $translations as $translation ) { |
| 531 | 522 | if ( in_array( $translation['language'], $languages ) ) { |
| 532 | 523 | $translation['type'] = 'core'; |
| 533 | 524 | $translations_to_load[] = (object) $translation; |
| @@ -615,31 +606,6 @@ | ||
| 615 | 606 | * @since 2.3 |
| 616 | 607 | */ |
| 617 | 608 | protected function upgrade_2_3() { |
| 618 | 609 | delete_transient( 'pll_languages_list' ); |
| 619 | - } | |
| 620 | - | |
| 621 | - /** | |
| 622 | - * Upgrades if the previous version is < 2.7 | |
| 623 | - * Replace numeric keys by hashes in WPML registered strings | |
| 624 | - * Dismiss the wizard notice for existing sites | |
| 625 | - * | |
| 626 | - * @since 2.7 | |
| 627 | - */ | |
| 628 | - protected function upgrade_2_7() { | |
| 629 | - $strings = get_option( 'polylang_wpml_strings' ); | |
| 630 | - if ( is_array( $strings ) ) { | |
| 631 | - $new_strings = array(); | |
| 632 | - | |
| 633 | - foreach ( $strings as $string ) { | |
| 634 | - $context = $string['context']; | |
| 635 | - $name = $string['name']; | |
| 636 | - | |
| 637 | - $key = md5( "$context | $name" ); | |
| 638 | - $new_strings[ $key ] = $string; | |
| 639 | - } | |
| 640 | - update_option( 'polylang_wpml_strings', $new_strings ); | |
| 641 | - } | |
| 642 | - | |
| 643 | - PLL_Admin_Notices::dismiss( 'wizard' ); | |
| 644 | 610 | } |
| 645 | 611 | } |