Polylang - Version 2.3.5

Version Description

(2018-05-08) =

  • Pro: Fix translated CPT slugs when one CPT name is a substring of another one. Props Steve Reimer.
  • Pro: Fix canonical redirection for post types archives when the CPT slug is translated
  • Pro: Fix ACF private key uselessly synchronized when the public custom field is not synchronized
  • Add filter 'pll_filter_query_excluded_query_vars'
  • Redirect www. to non www. when using multiple domains
  • Fix Yoast SEO category sitemap not filtered by language when using multiple domains
  • Fix PLL_COOKIE ==
Download this release

Release Info

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

Code changes from version 2.3.4 to 2.3.5

admin/admin-filters-term.php CHANGED
@@ -52,8 +52,8 @@ class PLL_Admin_Filters_Term {
52
 
53
  // Filters categories and post tags by language
54
  add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
55
- add_action( 'parse_query', array( $this, 'set_tax_query_lang' ) );
56
- add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ) );
57
 
58
  // Allows to get the default categories in all languages
59
  add_filter( 'option_default_category', array( $this, 'option_default_category' ) );
52
 
53
  // Filters categories and post tags by language
54
  add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
55
+ add_action( 'pre_get_posts', array( $this, 'set_tax_query_lang' ), 999 );
56
+ add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ), 0 );
57
 
58
  // Allows to get the default categories in all languages
59
  add_filter( 'option_default_category', array( $this, 'option_default_category' ) );
frontend/frontend-filters-links.php CHANGED
@@ -355,10 +355,20 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
355
  $language = $this->model->post->get_language( (int) $id );
356
  }
357
 
 
 
 
 
 
 
 
 
 
 
358
  if ( empty( $language ) ) {
359
  $language = $this->curlang;
360
  $redirect_url = $requested_url;
361
- } else {
362
  // First get the canonical url evaluated by WP
363
  // Workaround a WP bug which removes the port for some urls and get it back at second call to redirect_canonical
364
  $_redirect_url = ( ! $_redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $_redirect_url;
355
  $language = $this->model->post->get_language( (int) $id );
356
  }
357
 
358
+ if ( 3 === $this->options['force_lang'] ) {
359
+ foreach ( $this->options['domains'] as $lang => $domain ) {
360
+ $host = parse_url( $domain, PHP_URL_HOST );
361
+ if ( 'www.' . $_SERVER['HTTP_HOST'] === $host || 'www.' . $host === $_SERVER['HTTP_HOST'] ) {
362
+ $language = $this->model->get_language( $lang );
363
+ $redirect_url = str_replace( '://' . $_SERVER['HTTP_HOST'], '://' . $host, $requested_url );
364
+ }
365
+ }
366
+ }
367
+
368
  if ( empty( $language ) ) {
369
  $language = $this->curlang;
370
  $redirect_url = $requested_url;
371
+ } elseif ( empty( $redirect_url ) ) {
372
  // First get the canonical url evaluated by WP
373
  // Workaround a WP bug which removes the port for some urls and get it back at second call to redirect_canonical
374
  $_redirect_url = ( ! $_redirect_url = redirect_canonical( $requested_url, false ) ) ? $requested_url : $_redirect_url;
frontend/frontend-filters.php CHANGED
@@ -29,8 +29,8 @@ class PLL_Frontend_Filters extends PLL_Filters {
29
 
30
  // Filters categories and post tags by language
31
  add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
32
- add_action( 'parse_query', array( $this, 'set_tax_query_lang' ) );
33
- add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ) );
34
 
35
  // Rewrites archives links to filter them by language
36
  add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
29
 
30
  // Filters categories and post tags by language
31
  add_filter( 'terms_clauses', array( $this, 'terms_clauses' ), 10, 3 );
32
+ add_action( 'pre_get_posts', array( $this, 'set_tax_query_lang' ), 999 );
33
+ add_action( 'posts_selection', array( $this, 'unset_tax_query_lang' ), 0 );
34
 
35
  // Rewrites archives links to filter them by language
36
  add_filter( 'getarchives_join', array( $this, 'getarchives_join' ), 10, 2 );
frontend/frontend-static-pages.php CHANGED
@@ -130,7 +130,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
130
  }
131
 
132
  /**
133
- * Handles canonical redirection if we are on a static front page
134
  *
135
  * @since 1.8
136
  *
@@ -138,24 +138,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
138
  * @return bool|string
139
  */
140
  public function pll_check_canonical_url( $redirect_url ) {
141
- if ( ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ) {
142
- // Redirect www.mysite.fr to mysite.fr
143
- if ( 3 === $this->options['force_lang'] ) {
144
- foreach ( $this->options['domains'] as $lang => $domain ) {
145
- $host = parse_url( $domain, PHP_URL_HOST );
146
- if ( 'www.' . $_SERVER['HTTP_HOST'] === $host || 'www.' . $host === $_SERVER['HTTP_HOST'] ) {
147
- $language = $this->model->get_language( $lang );
148
- return $language->home_url;
149
- }
150
- }
151
- }
152
-
153
- // Prevents canonical redirection made by WP from secondary language to main language
154
- if ( $this->options['redirect_lang'] ) {
155
- return false;
156
- }
157
- }
158
- return $redirect_url;
159
  }
160
 
161
  /**
130
  }
131
 
132
  /**
133
+ * Prevents canonical redirection if we are on a static front page
134
  *
135
  * @since 1.8
136
  *
138
  * @return bool|string
139
  */
140
  public function pll_check_canonical_url( $redirect_url ) {
141
+ return $this->options['redirect_lang'] && ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  }
143
 
144
  /**
include/query.php CHANGED
@@ -18,6 +18,7 @@ class PLL_Query {
18
  'category_name',
19
  'tag',
20
  'tag_id',
 
21
  'category__in',
22
  'category__and',
23
  'post__in',
@@ -121,17 +122,28 @@ class PLL_Query {
121
  $qvars = &$this->query->query_vars;
122
 
123
  if ( ! isset( $qvars['lang'] ) ) {
 
 
 
 
 
 
 
 
 
 
 
124
  // Do not filter the query if the language is already specified in another way
125
- foreach ( self::$excludes as $k ) {
126
  if ( ! empty( $qvars[ $k ] ) ) {
127
- return;
128
- }
129
- }
130
-
131
- // Specific case for 'cat' as it can contain negative values
132
- if ( ! empty( $qvars['cat'] ) ) {
133
- foreach ( explode( ',', $qvars['cat'] ) as $cat ) {
134
- if ( $cat > 0 ) {
135
  return;
136
  }
137
  }
18
  'category_name',
19
  'tag',
20
  'tag_id',
21
+ 'cat',
22
  'category__in',
23
  'category__and',
24
  'post__in',
122
  $qvars = &$this->query->query_vars;
123
 
124
  if ( ! isset( $qvars['lang'] ) ) {
125
+ /**
126
+ * Filter the query vars which disable the language filter in a query
127
+ *
128
+ * @since 2.3.5
129
+ *
130
+ * @param array $excludes Query vars excluded from the language filter
131
+ * @param object $query WP Query
132
+ * @param object $lang Language
133
+ */
134
+ $excludes = apply_filters( 'pll_filter_query_excluded_query_vars', self::$excludes, $this->query, $lang );
135
+
136
  // Do not filter the query if the language is already specified in another way
137
+ foreach ( $excludes as $k ) {
138
  if ( ! empty( $qvars[ $k ] ) ) {
139
+ // Specific case for 'cat' as it can contain negative values
140
+ if ( 'cat' === $k ) {
141
+ foreach ( explode( ',', $qvars['cat'] ) as $cat ) {
142
+ if ( $cat > 0 ) {
143
+ return;
144
+ }
145
+ }
146
+ } else {
147
  return;
148
  }
149
  }
modules/plugins/cache-compat.php CHANGED
@@ -13,7 +13,9 @@ class PLL_Cache_Compat {
13
  * @since 2.3
14
  */
15
  public function init() {
16
- add_action( 'wp_print_footer_scripts', array( $this, 'add_cookie_script' ) );
 
 
17
  add_action( 'wp', array( $this, 'do_not_cache_site_home' ) );
18
  }
19
 
13
  * @since 2.3
14
  */
15
  public function init() {
16
+ if ( PLL_COOKIE ) {
17
+ add_action( 'wp_print_footer_scripts', array( $this, 'add_cookie_script' ) );
18
+ }
19
  add_action( 'wp', array( $this, 'do_not_cache_site_home' ) );
20
  }
21
 
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.3.4
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
53
  }
54
  } else {
55
  // Go on loading the plugin
56
- define( 'POLYLANG_VERSION', '2.3.4' );
57
  define( 'PLL_MIN_WP_VERSION', '4.4' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.3.5
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
53
  }
54
  } else {
55
  // Go on loading the plugin
56
+ define( 'POLYLANG_VERSION', '2.3.5' );
57
  define( 'PLL_MIN_WP_VERSION', '4.4' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
- Stable tag: 2.3.4
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,17 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
 
 
 
79
  = 2.3.4 (2018-03-27) =
80
 
81
  * Pro: Fix conflict with Pods related to translated slugs for custom post types
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.9
7
+ Stable tag: 2.3.5
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.3.5 (2018-05-08) =
80
+
81
+ * Pro: Fix translated CPT slugs when one CPT name is a substring of another one. Props Steve Reimer.
82
+ * Pro: Fix canonical redirection for post types archives when the CPT slug is translated
83
+ * Pro: Fix ACF private key uselessly synchronized when the public custom field is not synchronized
84
+ * Add filter 'pll_filter_query_excluded_query_vars'
85
+ * Redirect www. to non www. when using multiple domains
86
+ * Fix Yoast SEO category sitemap not filtered by language when using multiple domains
87
+ * Fix PLL_COOKIE === false not honored when using a cache plugin. #248
88
+ * Fix empty predefined languages list
89
+
90
  = 2.3.4 (2018-03-27) =
91
 
92
  * Pro: Fix conflict with Pods related to translated slugs for custom post types
settings/settings.php CHANGED
@@ -326,10 +326,14 @@ class PLL_Settings extends PLL_Admin_Base {
326
  require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
327
  include PLL_SETTINGS_INC . '/languages.php';
328
 
329
- // Keep only languages with existing WP language pack
330
  $translations = wp_get_available_translations();
331
- $translations['en_US'] = ''; // Languages packs don't include en_US
332
- $languages = array_intersect_key( $languages, $translations );
 
 
 
 
 
333
 
334
  /**
335
  * Filter the list of predefined languages
326
  require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
327
  include PLL_SETTINGS_INC . '/languages.php';
328
 
 
329
  $translations = wp_get_available_translations();
330
+
331
+ // Keep only languages with existing WP language pack
332
+ // Unless the transient has expired and we don't have an internet connection to refresh it
333
+ if ( ! empty( $translations ) ) {
334
+ $translations['en_US'] = ''; // Languages packs don't include en_US
335
+ $languages = array_intersect_key( $languages, $translations );
336
+ }
337
 
338
  /**
339
  * Filter the list of predefined languages