PluginProbe
Polylang / 2.6.3
Polylang v2.6.3
3.8.9 3.8.8 3.8.7 3.8.6 3.8.5 3.8.4 3.8.3 2.7 2.7.0.1 2.7.1 2.7.2 2.7.3 2.7.4 2.8 2.8.1 2.8.2 2.8.3 2.8.4 2.9 2.9.1 2.9.2 3.0 3.0.1 3.0.2 3.0.3 All 233 releases
← All changes | install/upgrade.php +13 -53 2.92.6.3 View file →
@@ -1,8 +1,5 @@
1 1 <?php
2 -/**
3 - * @package Polylang
4 - */
5 2
6 3 /**
7 4 * Manages Polylang upgrades
8 5 *
@@ -72,9 +69,9 @@
72 69 *
73 70 * @since 1.0
74 71 */
75 72 public function admin_notices() {
76 - load_plugin_textdomain( 'polylang' );
73 + load_plugin_textdomain( 'polylang', false, basename( POLYLANG_DIR ) . '/languages' );
77 74 printf(
78 75 '<div class="error"><p>%s</p><p>%s</p></div>',
79 76 esc_html__( 'Polylang has been deactivated because you upgraded from a too old version.', 'polylang' ),
80 77 sprintf(
@@ -91,9 +88,9 @@
91 88 *
92 89 * @since 1.2
93 90 */
94 91 public function _upgrade() {
95 - 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.7', '2.8.1' ) 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 ) {
96 93 if ( version_compare( $this->options['version'], $version, '<' ) ) {
97 94 call_user_func( array( $this, 'upgrade_' . str_replace( '.', '_', $version ) ) );
98 95 }
99 96 }
@@ -145,9 +142,9 @@
145 142 protected function upgrade_1_1() {
146 143 // Update strings register with icl_register_string
147 144 $strings = get_option( 'polylang_wpml_strings' );
148 145 if ( $strings ) {
149 - foreach ( array_keys( $strings ) as $key ) {
146 + foreach ( $strings as $key => $string ) {
150 147 $strings[ $key ]['icl'] = 1;
151 148 }
152 149 update_option( 'polylang_wpml_strings', $strings );
153 150 }
@@ -181,10 +178,9 @@
181 178
182 179 // Upgrade old model based on metas to new model based on taxonomies
183 180 global $wpdb;
184 181 $wpdb->termmeta = $wpdb->prefix . 'termmeta'; // Registers the termmeta table in wpdb
185 - $languages = get_terms( 'language', array( 'hide_empty' => 0 ) ); // Don't use get_languages_list which can't work with the old model
186 - $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
187 183
188 184 foreach ( $languages as $lang ) {
189 185 // First update language with new storage for locale and text direction
190 186 $text_direction = get_metadata( 'term', $lang->term_id, '_rtl', true );
@@ -211,14 +207,10 @@
211 207 }
212 208
213 209 // Translations
214 210 foreach ( array( 'post', 'term' ) as $type ) {
215 - $table = $type . 'meta';
216 - $terms = array();
217 - $slugs = array();
218 - $tts = array();
219 - $trs = array();
220 - $description = array();
211 + $table = $type . 'meta';
212 + $terms = $slugs = $tts = $trs = array();
221 213
222 214 // Get all translated objects
223 215 // PHPCS:ignore WordPress.DB.PreparedSQL
224 216 $objects = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->$table} WHERE meta_key = '_translations'" );
@@ -314,10 +306,8 @@
314 306 // Old version < 1.1
315 307 // Multilingal locations and switcher item were stored in a dedicated option
316 308 if ( version_compare( $this->options['version'], '1.1', '<' ) ) {
317 309 if ( $menu_lang = get_option( 'polylang_nav_menus' ) ) {
318 - $locations = array();
319 -
320 310 foreach ( $menu_lang as $location => $arr ) {
321 311 if ( ! in_array( $location, array_keys( get_registered_nav_menus() ) ) ) {
322 312 continue;
323 313 }
@@ -364,9 +354,9 @@
364 354 // If old version < 1.2
365 355 // Clean the WP option as it was a bad idea to pollute it
366 356 if ( version_compare( $this->options['version'], '1.2', '<' ) ) {
367 357 foreach ( $menus as $loc => $menu ) {
368 - if ( strpos( $loc, '#' ) ) {
358 + if ( $pos = strpos( $loc, '#' ) ) {
369 359 unset( $menus[ $loc ] );
370 360 }
371 361 }
372 362
@@ -527,10 +517,8 @@
527 517 if ( ! $translations ) {
528 518 return;
529 519 }
530 520
531 - $translations_to_load = array();
532 -
533 521 foreach ( $translations as $translation ) {
534 522 if ( in_array( $translation['language'], $languages ) ) {
535 523 $translation['type'] = 'core';
536 524 $translations_to_load[] = (object) $translation;
@@ -560,9 +548,9 @@
560 548 * @since 1.8
561 549 */
562 550 protected function upgrade_1_8() {
563 551 // Adds the flag code in languages stored in DB
564 - $languages = include POLYLANG_DIR . '/settings/languages.php';
552 + $languages = include PLL_SETTINGS_INC . '/languages.php';
565 553
566 554 $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
567 555
568 556 foreach ( $terms as $lang ) {
@@ -609,43 +597,15 @@
609 597 }
610 598 }
611 599
612 600 /**
613 - * Upgrades if the previous version is < 2.7
614 - * Replace numeric keys by hashes in WPML registered strings
615 - * Dismiss the wizard notice for existing sites
601 + * Upgrades if the previous version is < 2.3
616 602 *
617 - * @since 2.7
618 - */
619 - protected function upgrade_2_7() {
620 - $strings = get_option( 'polylang_wpml_strings' );
621 - if ( is_array( $strings ) ) {
622 - $new_strings = array();
623 -
624 - foreach ( $strings as $string ) {
625 - $context = $string['context'];
626 - $name = $string['name'];
627 -
628 - $key = md5( "$context | $name" );
629 - $new_strings[ $key ] = $string;
630 - }
631 - update_option( 'polylang_wpml_strings', $new_strings );
632 - }
633 -
634 - PLL_Admin_Notices::dismiss( 'wizard' );
635 - }
636 -
637 - /**
638 - * Upgrades if the previous version is < 2.8.1
603 + * Deletes language cache due to 'redirect_lang' option removed for subdomains and multiple domains in 2.2
604 + * and W3C and Facebook locales added to PLL_Language objects in 2.3
639 605 *
640 - * Deletes language cache due to:
641 - * - 'redirect_lang' option removed for subdomains and multiple domains in 2.2
642 - * - W3C and Facebook locales added to PLL_Language objects in 2.3
643 - * - flags moved to a different directory in Polylang Pro 2.8
644 - * - bug of flags url returning html fixed in 2.8.1
645 - *
646 - * @since 2.8.1
606 + * @since 2.3
647 607 */
648 - protected function upgrade_2_8_1() {
608 + protected function upgrade_2_3() {
649 609 delete_transient( 'pll_languages_list' );
650 610 }
651 611 }