Polylang - Version 2.1.4

Version Description

(2017-05-16) =

  • Pro: fix user not logged in on secondary domain when previewing changes
  • Pro: fix archive links without language code in ACF link field (ACF 5.4.0+)
  • Fix redirection from www subdomain to wrong language domain.
  • Fix: selecting "Front page displays latest posts" in the customizer not cleaning the languages cache
  • Fix accessibility of the admin language switcher
Download this release

Release Info

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

Code changes from version 2.1.3 to 2.1.4

admin/admin-base.php CHANGED
@@ -326,15 +326,17 @@ class PLL_Admin_Base extends PLL_Base {
326
  $selected = empty( $this->filter_lang ) ? $all_item : $this->filter_lang;
327
 
328
  $title = sprintf(
329
- '<span class="ab-label"%s>%s</span>',
330
  'all' === $selected->slug ? '' : sprintf( ' lang="%s"', esc_attr( $selected->get_locale( 'display' ) ) ),
 
331
  esc_html( $selected->name )
332
  );
333
 
334
  $wp_admin_bar->add_menu( array(
335
  'id' => 'languages',
336
  'title' => $selected->flag . $title,
337
- 'meta' => array( 'title' => __( 'Filters content by language', 'polylang' ) ),
 
338
  ) );
339
 
340
  foreach ( array_merge( array( $all_item ), $this->model->get_languages_list() ) as $lang ) {
326
  $selected = empty( $this->filter_lang ) ? $all_item : $this->filter_lang;
327
 
328
  $title = sprintf(
329
+ '<span class="ab-label"%1$s><span class="screen-reader-text">%2$s</span>%3$s</span>',
330
  'all' === $selected->slug ? '' : sprintf( ' lang="%s"', esc_attr( $selected->get_locale( 'display' ) ) ),
331
+ __( 'Filters content by language', 'polylang' ),
332
  esc_html( $selected->name )
333
  );
334
 
335
  $wp_admin_bar->add_menu( array(
336
  'id' => 'languages',
337
  'title' => $selected->flag . $title,
338
+ 'href' => esc_url( add_query_arg( 'lang', $selected->slug, remove_query_arg( 'paged', $url ) ) ),
339
+ 'meta' => array( 'title' => __( 'Filters content by language', 'polylang' ) ),
340
  ) );
341
 
342
  foreach ( array_merge( array( $all_item ), $this->model->get_languages_list() ) as $lang ) {
frontend/frontend-filters-links.php CHANGED
@@ -6,7 +6,6 @@
6
  * @since 1.8
7
  */
8
  class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
9
- public $curlang;
10
  public $cache; // Our internal non persistent cache object
11
 
12
  /**
@@ -29,9 +28,6 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
29
  add_filter( $filter, array( $this, 'archive_link' ), 20 );
30
  }
31
 
32
- // Rewrites post types archives links to filter them by language
33
- add_filter( 'post_type_archive_link', array( $this, 'post_type_archive_link' ), 20, 2 );
34
-
35
  // Meta in the html head section
36
  add_action( 'wp_head', array( $this, 'wp_head' ) );
37
 
@@ -65,20 +61,6 @@ class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
65
  return $this->links_model->add_language_to_link( $link, $this->curlang );
66
  }
67
 
68
- /**
69
- * Modifies the post type archive links to add the language parameter
70
- * only if the post type is translated
71
- *
72
- * @since 1.7.6
73
- *
74
- * @param string $link
75
- * @param string $post_type
76
- * @return string modified link
77
- */
78
- public function post_type_archive_link( $link, $post_type ) {
79
- return $this->model->is_translated_post_type( $post_type ) && 'post' !== $post_type ? $this->links_model->add_language_to_link( $link, $this->curlang ) : $link;
80
- }
81
-
82
  /**
83
  * Modifies post & page links
84
  * and caches the result
6
  * @since 1.8
7
  */
8
  class PLL_Frontend_Filters_Links extends PLL_Filters_Links {
 
9
  public $cache; // Our internal non persistent cache object
10
 
11
  /**
28
  add_filter( $filter, array( $this, 'archive_link' ), 20 );
29
  }
30
 
 
 
 
31
  // Meta in the html head section
32
  add_action( 'wp_head', array( $this, 'wp_head' ) );
33
 
61
  return $this->links_model->add_language_to_link( $link, $this->curlang );
62
  }
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  /**
65
  * Modifies post & page links
66
  * and caches the result
frontend/frontend-static-pages.php CHANGED
@@ -144,7 +144,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
144
  }
145
 
146
  /**
147
- * Prevents canonical redirection if we are on a static front page
148
  *
149
  * @since 1.8
150
  *
@@ -152,7 +152,24 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
152
  * @return bool|string
153
  */
154
  public function pll_check_canonical_url( $redirect_url ) {
155
- return $this->options['redirect_lang'] && ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ? false : $redirect_url;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
 
158
  /**
144
  }
145
 
146
  /**
147
+ * Handles canonical redirection if we are on a static front page
148
  *
149
  * @since 1.8
150
  *
152
  * @return bool|string
153
  */
154
  public function pll_check_canonical_url( $redirect_url ) {
155
+ if ( ! empty( $this->curlang->page_on_front ) && is_page( $this->curlang->page_on_front ) ) {
156
+ // Redirect www.mysite.fr to mysite.fr
157
+ if ( 3 === $this->options['force_lang'] ) {
158
+ foreach ( $this->options['domains'] as $lang => $domain ) {
159
+ $host = parse_url( $domain, PHP_URL_HOST );
160
+ if ( 'www.' . $_SERVER['HTTP_HOST'] === $host || 'www.' . $host === $_SERVER['HTTP_HOST'] ) {
161
+ $language = $this->model->get_language( $lang );
162
+ return $language->home_url;
163
+ }
164
+ }
165
+ }
166
+
167
+ // Prevents canonical redirection made by WP from secondary language to main language
168
+ if ( $this->options['redirect_lang'] ) {
169
+ return false;
170
+ }
171
+ }
172
+ return $redirect_url;
173
  }
174
 
175
  /**
include/filters-links.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
 
3
  /**
4
- * manages links filters needed on both frontend and admin
5
  *
6
  * @since 1.8
7
  */
8
  class PLL_Filters_Links {
9
- public $links, $links_model, $model, $options;
10
 
11
  /**
12
- * constructor
13
  *
14
  * @since 1.8
15
  *
@@ -20,8 +20,9 @@ class PLL_Filters_Links {
20
  $this->links_model = &$polylang->links_model;
21
  $this->model = &$polylang->model;
22
  $this->options = &$polylang->options;
 
23
 
24
- // low priority on links filters to come after any other modifications
25
  if ( $this->options['force_lang'] ) {
26
  add_filter( 'post_link', array( $this, 'post_type_link' ), 20, 2 );
27
  add_filter( '_get_page_link', array( $this, '_get_page_link' ), 20, 2 );
@@ -37,10 +38,13 @@ class PLL_Filters_Links {
37
  if ( 3 === $this->options['force_lang'] ) {
38
  add_filter( 'preview_post_link', array( $this, 'preview_post_link' ), 20 );
39
  }
 
 
 
40
  }
41
 
42
  /**
43
- * modifies page links
44
  *
45
  * @since 1.7
46
  *
@@ -54,7 +58,7 @@ class PLL_Filters_Links {
54
  }
55
 
56
  /**
57
- * modifies attachment links
58
  *
59
  * @since 1.6.2
60
  *
@@ -67,7 +71,7 @@ class PLL_Filters_Links {
67
  }
68
 
69
  /**
70
- * modifies custom posts links
71
  *
72
  * @since 1.6
73
  *
@@ -97,7 +101,7 @@ class PLL_Filters_Links {
97
  }
98
 
99
  /**
100
- * modifies term link
101
  *
102
  * @since 0.7
103
  *
@@ -142,5 +146,22 @@ class PLL_Filters_Links {
142
  public function preview_post_link( $url ) {
143
  return $this->links_model->remove_language_from_link( $url );
144
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
 
1
  <?php
2
 
3
  /**
4
+ * Manages links filters needed on both frontend and admin
5
  *
6
  * @since 1.8
7
  */
8
  class PLL_Filters_Links {
9
+ public $links, $links_model, $model, $options, $curlang;
10
 
11
  /**
12
+ * Constructor
13
  *
14
  * @since 1.8
15
  *
20
  $this->links_model = &$polylang->links_model;
21
  $this->model = &$polylang->model;
22
  $this->options = &$polylang->options;
23
+ $this->curlang = &$polylang->curlang;
24
 
25
+ // Low priority on links filters to come after any other modifications
26
  if ( $this->options['force_lang'] ) {
27
  add_filter( 'post_link', array( $this, 'post_type_link' ), 20, 2 );
28
  add_filter( '_get_page_link', array( $this, '_get_page_link' ), 20, 2 );
38
  if ( 3 === $this->options['force_lang'] ) {
39
  add_filter( 'preview_post_link', array( $this, 'preview_post_link' ), 20 );
40
  }
41
+
42
+ // Rewrites post types archives links to filter them by language
43
+ add_filter( 'post_type_archive_link', array( $this, 'post_type_archive_link' ), 20, 2 );
44
  }
45
 
46
  /**
47
+ * Modifies page links
48
  *
49
  * @since 1.7
50
  *
58
  }
59
 
60
  /**
61
+ * Modifies attachment links
62
  *
63
  * @since 1.6.2
64
  *
71
  }
72
 
73
  /**
74
+ * Modifies custom posts links
75
  *
76
  * @since 1.6
77
  *
101
  }
102
 
103
  /**
104
+ * Modifies term link
105
  *
106
  * @since 0.7
107
  *
146
  public function preview_post_link( $url ) {
147
  return $this->links_model->remove_language_from_link( $url );
148
  }
149
+
150
+ /**
151
+ * Modifies the post type archive links to add the language parameter
152
+ * only if the post type is translated
153
+ *
154
+ * The filter was originally only on frontend but is needed on admin too for
155
+ * compatibility with the archive link of the ACF link field since ACF 5.4.0
156
+ *
157
+ * @since 1.7.6
158
+ *
159
+ * @param string $link
160
+ * @param string $post_type
161
+ * @return string modified link
162
+ */
163
+ public function post_type_archive_link( $link, $post_type ) {
164
+ return $this->model->is_translated_post_type( $post_type ) && 'post' !== $post_type ? $this->links_model->add_language_to_link( $link, $this->curlang ) : $link;
165
+ }
166
  }
167
 
include/static-pages.php CHANGED
@@ -26,6 +26,7 @@ abstract class PLL_Static_Pages {
26
  add_filter( 'page_link', array( $this, 'page_link' ), 20, 2 );
27
 
28
  // clean the languages cache when editing page of front, page for posts
 
29
  add_action( 'update_option_page_on_front', array( $this->model, 'clean_languages_cache' ) );
30
  add_action( 'update_option_page_for_posts', array( $this->model, 'clean_languages_cache' ) );
31
 
@@ -75,9 +76,11 @@ abstract class PLL_Static_Pages {
75
  * @param object $model
76
  */
77
  public static function pll_languages_list( $languages, $model ) {
78
- foreach ( $languages as $k => $language ) {
79
- $languages[ $k ]->page_on_front = $model->post->get( get_option( 'page_on_front' ), $language );
80
- $languages[ $k ]->page_for_posts = $model->post->get( get_option( 'page_for_posts' ), $language );
 
 
81
  }
82
 
83
  return $languages;
26
  add_filter( 'page_link', array( $this, 'page_link' ), 20, 2 );
27
 
28
  // clean the languages cache when editing page of front, page for posts
29
+ add_action( 'update_option_show_on_front', array( $this->model, 'clean_languages_cache' ) );
30
  add_action( 'update_option_page_on_front', array( $this->model, 'clean_languages_cache' ) );
31
  add_action( 'update_option_page_for_posts', array( $this->model, 'clean_languages_cache' ) );
32
 
76
  * @param object $model
77
  */
78
  public static function pll_languages_list( $languages, $model ) {
79
+ if ( 'page' === get_option( 'show_on_front' ) ) {
80
+ foreach ( $languages as $k => $language ) {
81
+ $languages[ $k ]->page_on_front = $model->post->get( get_option( 'page_on_front' ), $language );
82
+ $languages[ $k ]->page_for_posts = $model->post->get( get_option( 'page_for_posts' ), $language );
83
+ }
84
  }
85
 
86
  return $languages;
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.1.3
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  exit; // don't access directly
36
  };
37
 
38
- define( 'POLYLANG_VERSION', '2.1.3' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.1.4
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
35
  exit; // don't access directly
36
  };
37
 
38
+ define( 'POLYLANG_VERSION', '2.1.4' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  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.7
7
- Stable tag: 2.1.3
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,10 +76,18 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
79
  = 2.1.3 (2017-04-11) =
80
 
81
  * Pro: Fix translated slug of 'page' if it is translated to an empty string
82
- * Update plugin udpater class to 1.6.11
83
  * Strings registered with a wpml-config.xml file or WPML functions are now multiline by default
84
  * Translate the site title in emails sent to the user
85
  * Fix sanitize_user for specific locales
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.7
7
+ Stable tag: 2.1.4
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.1.4 (2017-05-16) =
80
+
81
+ * Pro: fix user not logged in on secondary domain when previewing changes
82
+ * Pro: fix archive links without language code in ACF link field (ACF 5.4.0+)
83
+ * Fix redirection from www subdomain to wrong language domain.
84
+ * Fix: selecting "Front page displays latest posts" in the customizer not cleaning the languages cache
85
+ * Fix accessibility of the admin language switcher
86
+
87
  = 2.1.3 (2017-04-11) =
88
 
89
  * Pro: Fix translated slug of 'page' if it is translated to an empty string
90
+ * Update plugin updater class to 1.6.11
91
  * Strings registered with a wpml-config.xml file or WPML functions are now multiline by default
92
  * Translate the site title in emails sent to the user
93
  * Fix sanitize_user for specific locales