Polylang - Version 3.2.2

Version Description

(2022-04-25) =

  • Pro: Fix redirect occuring for tags sharing the same slug as their translations
  • Fix quick edit allowing to modify the language of the default category when it should not #1018
Download this release

Release Info

Developer Chouby
Plugin Icon 128x128 Polylang
Version 3.2.2
Comparing to
See all releases

Code changes from version 3.2.1 to 3.2.2

admin/admin-filters-columns.php CHANGED
@@ -301,7 +301,7 @@ class PLL_Admin_Filters_Columns {
301
  }
302
 
303
  if ( $column == $this->get_first_language_column() ) {
304
- $out = sprintf( '<div class="hidden" id="lang_%d">%s</div>', intval( $term_id ), esc_html( $lang->slug ) );
305
  }
306
 
307
  // Link to edit term ( or a translation )
301
  }
302
 
303
  if ( $column == $this->get_first_language_column() ) {
304
+ $out .= sprintf( '<div class="hidden" id="lang_%d">%s</div>', intval( $term_id ), esc_html( $lang->slug ) );
305
  }
306
 
307
  // Link to edit term ( or a translation )
frontend/frontend-filters-links.php CHANGED
@@ -395,7 +395,7 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
395
 
396
  elseif ( is_category() || is_tag() || is_tax() ) {
397
  if ( $this->model->is_translated_taxonomy( $this->get_queried_taxonomy( $this->wp_query()->tax_query ) ) ) {
398
- if ( $this->links_model->using_permalinks && ( ! empty( $this->wp_query()->query['cat'] ) || ! empty( $this->wp_query()->query['tag'] ) ) ) {
399
  // When we receive a plain permalink with a cat or tag query var, we need to redirect to the pretty permalink.
400
  $term_id = $this->get_queried_term_id( $this->wp_query()->tax_query );
401
  if ( is_feed() ) {
@@ -518,13 +518,14 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
518
  }
519
  $field = $queried_terms[ $taxonomy ]['field'];
520
  $term = reset( $queried_terms[ $taxonomy ]['terms'] );
 
521
 
522
  // We can get a term_id when requesting a plain permalink, eg /?cat=1.
523
  if ( 'term_id' === $field ) {
524
  return $term;
525
  }
526
 
527
- // We get a slug when requesting a pretty permalink with the wrong language.
528
  $args = array(
529
  'lang' => '',
530
  'taxonomy' => $taxonomy,
@@ -533,6 +534,24 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
533
  'fields' => 'ids',
534
  );
535
  $terms = get_terms( $args );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
536
  return reset( $terms );
537
  }
538
 
395
 
396
  elseif ( is_category() || is_tag() || is_tax() ) {
397
  if ( $this->model->is_translated_taxonomy( $this->get_queried_taxonomy( $this->wp_query()->tax_query ) ) ) {
398
+ if ( $this->links_model->using_permalinks && ( ! empty( $this->wp_query()->query['cat'] ) || ! empty( $this->wp_query()->query['tag'] ) || ! empty( $this->wp_query()->query['category_name'] ) ) ) {
399
  // When we receive a plain permalink with a cat or tag query var, we need to redirect to the pretty permalink.
400
  $term_id = $this->get_queried_term_id( $this->wp_query()->tax_query );
401
  if ( is_feed() ) {
518
  }
519
  $field = $queried_terms[ $taxonomy ]['field'];
520
  $term = reset( $queried_terms[ $taxonomy ]['terms'] );
521
+ $lang = isset( $queried_terms['language']['terms'] ) ? reset( $queried_terms['language']['terms'] ) : '';
522
 
523
  // We can get a term_id when requesting a plain permalink, eg /?cat=1.
524
  if ( 'term_id' === $field ) {
525
  return $term;
526
  }
527
 
528
+ // We get a slug when requesting a pretty permalink. Let's query all corresponding terms.
529
  $args = array(
530
  'lang' => '',
531
  'taxonomy' => $taxonomy,
534
  'fields' => 'ids',
535
  );
536
  $terms = get_terms( $args );
537
+
538
+ $filtered_terms_by_lang = array_filter(
539
+ $terms,
540
+ function ( $term ) use ( $lang ) {
541
+ $term_lang = $this->model->term->get_language( $term );
542
+
543
+ return ! empty( $term_lang ) && $term_lang->slug === $lang;
544
+ }
545
+ );
546
+
547
+ $tr_term = reset( $filtered_terms_by_lang );
548
+
549
+ if ( ! empty( $tr_term ) ) {
550
+ // The queried term exists in the desired language.
551
+ return $tr_term;
552
+ }
553
+
554
+ // The queried term doesn't exist in the desired language, let's return the first one retrieved.
555
  return reset( $terms );
556
  }
557
 
polylang.php CHANGED
@@ -10,7 +10,7 @@
10
  * Plugin Name: Polylang
11
  * Plugin URI: https://polylang.pro
12
  * Description: Adds multilingual capability to WordPress
13
- * Version: 3.2.1
14
  * Requires at least: 5.6
15
  * Requires PHP: 5.6
16
  * Author: WP SYNTEX
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_VERSION' ) ) {
53
  }
54
  } else {
55
  // Go on loading the plugin
56
- define( 'POLYLANG_VERSION', '3.2.1' );
57
  define( 'PLL_MIN_WP_VERSION', '5.6' );
58
  define( 'PLL_MIN_PHP_VERSION', '5.6' );
59
 
10
  * Plugin Name: Polylang
11
  * Plugin URI: https://polylang.pro
12
  * Description: Adds multilingual capability to WordPress
13
+ * Version: 3.2.2
14
  * Requires at least: 5.6
15
  * Requires PHP: 5.6
16
  * Author: WP SYNTEX
53
  }
54
  } else {
55
  // Go on loading the plugin
56
+ define( 'POLYLANG_VERSION', '3.2.2' );
57
  define( 'PLL_MIN_WP_VERSION', '5.6' );
58
  define( 'PLL_MIN_PHP_VERSION', '5.6' );
59
 
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: multilingual, bilingual, translate, translation, language, multilanguage,
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 5.6
8
- Stable tag: 3.2.1
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -97,6 +97,11 @@ Wherever third party code has been used, credit has been given in the code’s c
97
 
98
  == Changelog ==
99
 
 
 
 
 
 
100
  = 3.2.1 (2022-04-14) =
101
 
102
  * Pro: Fix users with editor role not able to save or publish posts
5
  Requires at least: 5.6
6
  Tested up to: 5.9
7
  Requires PHP: 5.6
8
+ Stable tag: 3.2.2
9
  License: GPLv3 or later
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
97
 
98
  == Changelog ==
99
 
100
+ = 3.2.2 (2022-04-25) =
101
+
102
+ * Pro: Fix redirect occuring for tags sharing the same slug as their translations
103
+ * Fix quick edit allowing to modify the language of the default category when it should not #1018
104
+
105
  = 3.2.1 (2022-04-14) =
106
 
107
  * Pro: Fix users with editor role not able to save or publish posts