PluginProbe
Polylang / 2.5
Polylang v2.5
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 +17 -51 2.72.5 View file →
@@ -27,9 +27,9 @@
27 27 public function can_activate() {
28 28 if ( ! $this->can_upgrade() ) {
29 29 ob_start();
30 30 $this->admin_notices(); // FIXME the error message is displayed two times
31 - die( ob_get_contents() ); // phpcs:ignore WordPress.Security.EscapeOutput
31 + die( ob_get_contents() );
32 32 }
33 33 }
34 34
35 35 /**
@@ -75,11 +75,11 @@
75 75 '<div class="error"><p>%s</p><p>%s</p></div>',
76 76 esc_html__( 'Polylang has been deactivated because you upgraded from a too old version.', 'polylang' ),
77 77 sprintf(
78 78 /* translators: %1$s and %2$s are Polylang version numbers */
79 - esc_html__( 'Before upgrading to %2$s, please upgrade to %1$s.', 'polylang' ),
79 + esc_html__( 'Please upgrade first to %1$s before ugrading to %2$s.', 'polylang' ),
80 80 '<strong>0.9.8</strong>',
81 - POLYLANG_VERSION // phpcs:ignore WordPress.Security.EscapeOutput
81 + POLYLANG_VERSION
82 82 )
83 83 );
84 84 }
85 85
@@ -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,15 +178,14 @@
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 );
188 - $desc = maybe_serialize( array( 'locale' => $lang->description, 'rtl' => $text_direction ) );
187 + $desc = serialize( array( 'locale' => $lang->description, 'rtl' => $text_direction ) );
189 188 wp_update_term( (int) $lang->term_id, 'language', array( 'description' => $desc ) );
190 189
191 190 // Add language to new 'term_language' taxonomy
192 191 $term_lang = wp_insert_term( $lang->name, 'term_language', array( 'slug' => 'pll_' . $lang->slug ) );
@@ -208,17 +207,13 @@
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 - // PHPCS:ignore WordPress.DB.PreparedSQL
215 + // PHPCS:ignore WordPress.DB.PreparedSQL.NotPrepared
221 216 $objects = $wpdb->get_col( "SELECT DISTINCT meta_value FROM {$wpdb->$table} WHERE meta_key = '_translations'" );
222 217
223 218 if ( empty( $objects ) ) {
224 219 continue;
@@ -227,10 +222,10 @@
227 222 foreach ( $objects as $obj ) {
228 223 $term = uniqid( 'pll_' ); // The term name
229 224 $terms[] = $wpdb->prepare( '( %s, %s )', $term, $term );
230 225 $slugs[] = $wpdb->prepare( '%s', $term );
231 - $translations = maybe_unserialize( maybe_unserialize( $obj ) ); // 2 maybe_unserialize due to an old storage bug
232 - $description[ $term ] = maybe_serialize( $translations );
226 + $translations = maybe_unserialize( maybe_unserialize( $obj ) ); // 2 unserialize due to an old storage bug
227 + $description[ $term ] = serialize( $translations );
233 228 }
234 229
235 230 $terms = array_unique( $terms );
236 231
@@ -261,9 +256,9 @@
261 256 $terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
262 257
263 258 // Prepare objects relationships
264 259 foreach ( $terms as $term ) {
265 - $translations = maybe_unserialize( $term->description );
260 + $translations = unserialize( $term->description );
266 261 foreach ( $translations as $object_id ) {
267 262 if ( ! empty( $object_id ) ) {
268 263 $trs[] = $wpdb->prepare( '( %d, %d )', $object_id, $term->term_taxonomy_id );
269 264 }
@@ -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;
@@ -557,9 +548,9 @@
557 548 * @since 1.8
558 549 */
559 550 protected function upgrade_1_8() {
560 551 // Adds the flag code in languages stored in DB
561 - $languages = include PLL_SETTINGS_INC . '/languages.php';
552 + include PLL_SETTINGS_INC . '/languages.php';
562 553
563 554 $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
564 555
565 556 foreach ( $terms as $lang ) {
@@ -565,9 +556,9 @@
565 556 foreach ( $terms as $lang ) {
566 557 $description = maybe_unserialize( $lang->description );
567 558 if ( isset( $languages[ $description['locale'] ] ) ) {
568 559 $description['flag_code'] = $languages[ $description['locale'] ]['flag'];
569 - $description = maybe_serialize( $description );
560 + $description = serialize( $description );
570 561 wp_update_term( (int) $lang->term_id, 'language', array( 'description' => $description ) );
571 562 }
572 563 }
573 564
@@ -597,9 +588,9 @@
597 588 $meta = get_post_meta( $mo_id, '_pll_strings_translations', true );
598 589
599 590 if ( empty( $meta ) ) {
600 591 $post = get_post( $mo_id, OBJECT );
601 - $strings = maybe_unserialize( $post->post_content );
592 + $strings = unserialize( $post->post_content );
602 593 if ( is_array( $strings ) ) {
603 594 update_post_meta( $mo_id, '_pll_strings_translations', $strings );
604 595 }
605 596 }
@@ -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 }