Polylang - Version 2.0.6

Version Description

(2016-10-17) =

  • Pro: Fix translated paged slug not working on paged static front page
  • Add support for WPML filter 'wpml_language_form_input_field'
  • Fix PHP notice when using the WPML filter 'wpml_current_language'
  • Fix cases where the admin language filter is not correctly taken into account
  • Fix paged static front pages in plain permalinks
  • Fix paged static front pages for multiple domains (#43)
  • Fix warning occuring when a 3rd party plugin attempts to register anything but a string in the strings translations panel
  • Fix cross domain http request for media when using multiple domains or subdomains
  • Fix error 404 on pages when no language has been created yet
Download this release

Release Info

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

Code changes from version 2.0.5 to 2.0.6

admin/admin-base.php CHANGED
@@ -171,18 +171,18 @@ class PLL_Admin_Base extends PLL_Base {
171
  $this->curlang = $this->filter_lang;
172
 
173
  // Edit Post
174
- if ( isset( $_REQUEST['pll_post_id'] ) ) {
175
- $this->curlang = $this->model->post->get_language( (int) $_REQUEST['pll_post_id'] );
176
- } elseif ( 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['post'] ) && is_numeric( $_GET['post'] ) ) {
177
- $this->curlang = $this->model->post->get_language( (int) $_GET['post'] );
178
  } elseif ( 'post-new.php' === $GLOBALS['pagenow'] && ( empty( $_GET['post_type'] ) || $this->model->is_translated_post_type( $_GET['post_type'] ) ) ) {
179
  $this->curlang = empty( $_GET['new_lang'] ) ? $this->pref_lang : $this->model->get_language( $_GET['new_lang'] );
180
  }
181
 
182
  // Edit Term
183
  // FIXME 'edit-tags.php' for backward compatibility with WP < 4.5
184
- elseif ( in_array( $GLOBALS['pagenow'], array( 'edit-tags.php', 'term.php' ) ) && isset( $_GET['tag_ID'] ) ) {
185
- $this->curlang = $this->model->term->get_language( (int) $_GET['tag_ID'] );
186
  } elseif ( 'edit-tags.php' === $GLOBALS['pagenow'] && isset( $_GET['taxonomy'] ) && $this->model->is_translated_taxonomy( $_GET['taxonomy'] ) ) {
187
  if ( ! empty( $_GET['new_lang'] ) ) {
188
  $this->curlang = $this->model->get_language( $_GET['new_lang'] );
171
  $this->curlang = $this->filter_lang;
172
 
173
  // Edit Post
174
+ if ( isset( $_REQUEST['pll_post_id'] ) && $lang = $this->model->post->get_language( (int) $_REQUEST['pll_post_id'] ) ) {
175
+ $this->curlang = $lang;
176
+ } elseif ( 'post.php' === $GLOBALS['pagenow'] && isset( $_GET['post'] ) && is_numeric( $_GET['post'] ) && $lang = $this->model->post->get_language( (int) $_GET['post'] ) ) {
177
+ $this->curlang = $lang;
178
  } elseif ( 'post-new.php' === $GLOBALS['pagenow'] && ( empty( $_GET['post_type'] ) || $this->model->is_translated_post_type( $_GET['post_type'] ) ) ) {
179
  $this->curlang = empty( $_GET['new_lang'] ) ? $this->pref_lang : $this->model->get_language( $_GET['new_lang'] );
180
  }
181
 
182
  // Edit Term
183
  // FIXME 'edit-tags.php' for backward compatibility with WP < 4.5
184
+ elseif ( in_array( $GLOBALS['pagenow'], array( 'edit-tags.php', 'term.php' ) ) && isset( $_GET['tag_ID'] ) && $lang = $this->model->term->get_language( (int) $_GET['tag_ID'] ) ) {
185
+ $this->curlang = $lang;
186
  } elseif ( 'edit-tags.php' === $GLOBALS['pagenow'] && isset( $_GET['taxonomy'] ) && $this->model->is_translated_taxonomy( $_GET['taxonomy'] ) ) {
187
  if ( ! empty( $_GET['new_lang'] ) ) {
188
  $this->curlang = $this->model->get_language( $_GET['new_lang'] );
admin/admin-strings.php CHANGED
@@ -36,9 +36,8 @@ class PLL_Admin_Strings {
36
  $context = 'Polylang';
37
  }
38
 
39
- $to_register = compact( 'name', 'string', 'context', 'multiline' );
40
- if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
41
- self::$strings[ md5( $string ) ] = $to_register;
42
  }
43
  }
44
 
36
  $context = 'Polylang';
37
  }
38
 
39
+ if ( $string && is_scalar( $string ) ) {
40
+ self::$strings[ md5( $string ) ] = compact( 'name', 'string', 'context', 'multiline' );
 
41
  }
42
  }
43
 
frontend/frontend-static-pages.php CHANGED
@@ -175,7 +175,7 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
175
  }
176
 
177
  // Redirect the language page to the homepage when using a static front page
178
- elseif ( ( $this->options['redirect_lang'] || $this->options['hide_default'] ) && ( count( $query->query ) == 1 || ( is_paged() && count( $query->query ) == 2 ) ) && is_tax( 'language' ) ) {
179
  $lang = $this->model->get_language( get_query_var( 'lang' ) );
180
  $query->set( 'page_id', $lang->page_on_front );
181
  $query->is_singular = $query->is_page = true;
@@ -183,6 +183,15 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
183
  unset( $query->query_vars['lang'], $query->queried_object ); // Reset queried object
184
  }
185
 
 
 
 
 
 
 
 
 
 
186
  // Set the language when requesting a static front page
187
  else {
188
  $page_id = $this->get_page_id( $query );
@@ -195,9 +204,11 @@ class PLL_Frontend_Static_Pages extends PLL_Static_Pages {
195
  }
196
 
197
  // Fix <!--nextpage--> for page_on_front
198
- if ( ! empty( $lang ) ) {
199
- $query->set( 'page', $query->query_vars['paged'] );
200
- unset( $query->query_vars['paged'] );
 
 
201
  }
202
 
203
  return $lang;
175
  }
176
 
177
  // Redirect the language page to the homepage when using a static front page
178
+ elseif ( ( $this->options['redirect_lang'] || $this->options['hide_default'] ) && ( count( $query->query ) == 1 || ( ( is_paged() || ! empty( $query->query['page'] ) ) && count( $query->query ) == 2 ) ) && is_tax( 'language' ) ) {
179
  $lang = $this->model->get_language( get_query_var( 'lang' ) );
180
  $query->set( 'page_id', $lang->page_on_front );
181
  $query->is_singular = $query->is_page = true;
183
  unset( $query->query_vars['lang'], $query->queried_object ); // Reset queried object
184
  }
185
 
186
+ // Fix paged static front page in plain permalinks when Settings > Reading doesn't match the default language
187
+ elseif ( ! $this->links_model->using_permalinks && count( $query->query ) === 1 && ! empty( $query->query['page'] ) ) {
188
+ $lang = $this->model->get_language( $this->options['default_lang'] );
189
+ $query->set( 'page_id', $lang->page_on_front );
190
+ $query->is_singular = $query->is_page = true;
191
+ $query->is_archive = $query->is_tax = false;
192
+ unset( $query->query_vars['lang'], $query->queried_object ); // Reset queried object
193
+ }
194
+
195
  // Set the language when requesting a static front page
196
  else {
197
  $page_id = $this->get_page_id( $query );
204
  }
205
 
206
  // Fix <!--nextpage--> for page_on_front
207
+ if ( ( $this->options['force_lang'] < 2 || ! $this->options['redirect_lang'] ) && $this->links_model->using_permalinks && ! empty( $lang ) && isset( $query->query['paged'] ) ) {
208
+ $query->set( 'page', $query->query['paged'] );
209
+ unset( $query->query['paged'] );
210
+ } elseif ( ! $this->links_model->using_permalinks && ! empty( $query->query['page'] ) ) {
211
+ $query->is_paged = true;
212
  }
213
 
214
  return $lang;
include/links-abstract-domain.php CHANGED
@@ -20,6 +20,7 @@ abstract class PLL_Links_Abstract_Domain extends PLL_Links_Permalinks {
20
  // Avoid cross domain requests ( mainly for custom fonts )
21
  add_filter( 'content_url', array( $this, 'site_url' ) );
22
  add_filter( 'plugins_url', array( $this, 'site_url' ) );
 
23
  }
24
 
25
  /**
@@ -35,4 +36,20 @@ abstract class PLL_Links_Abstract_Domain extends PLL_Links_Permalinks {
35
  $lang = $this->model->get_language( $lang );
36
  return $this->add_language_to_link( $url, $lang );
37
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
20
  // Avoid cross domain requests ( mainly for custom fonts )
21
  add_filter( 'content_url', array( $this, 'site_url' ) );
22
  add_filter( 'plugins_url', array( $this, 'site_url' ) );
23
+ add_filter( 'upload_dir', array( $this, 'upload_dir' ) );
24
  }
25
 
26
  /**
36
  $lang = $this->model->get_language( $lang );
37
  return $this->add_language_to_link( $url, $lang );
38
  }
39
+
40
+ /**
41
+ * Fix the domain for upload directory
42
+ *
43
+ * @since 2.0.6
44
+ *
45
+ * @param array $uploads
46
+ * @return array
47
+ */
48
+ public function upload_dir( $uploads ) {
49
+ $lang = $this->get_language_from_url();
50
+ $lang = $this->model->get_language( $lang );
51
+ $uploads['url'] = $this->add_language_to_link( $uploads['url'], $lang );
52
+ $uploads['baseurl'] = $this->add_language_to_link( $uploads['baseurl'], $lang );
53
+ return $uploads;
54
+ }
55
  }
include/links-directory.php CHANGED
@@ -19,10 +19,14 @@ class PLL_Links_Directory extends PLL_Links_Permalinks {
19
  public function __construct( &$model ) {
20
  parent::__construct( $model );
21
 
22
- if ( did_action( 'pll_init' ) ) {
23
- $this->init();
24
- } else {
25
- add_action( 'pll_init', array( $this, 'init' ) );
 
 
 
 
26
  }
27
  }
28
 
19
  public function __construct( &$model ) {
20
  parent::__construct( $model );
21
 
22
+ // Don't modify rewrite rules if no language is created yet
23
+ // Especially don't call add_permastruct which removes the /language/ rewrite base and lead to 404 for pages
24
+ if ( $model->get_languages_list() ) {
25
+ if ( did_action( 'pll_init' ) ) {
26
+ $this->init();
27
+ } else {
28
+ add_action( 'pll_init', array( $this, 'init' ) );
29
+ }
30
  }
31
  }
32
 
include/links-permalinks.php CHANGED
@@ -7,7 +7,7 @@
7
  */
8
  abstract class PLL_Links_Permalinks extends PLL_Links_Model {
9
  public $using_permalinks = true;
10
- protected $index = 'index.php'; // need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
11
  protected $root, $use_trailing_slashes;
12
  protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
13
 
@@ -36,7 +36,15 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
36
  * @return string modified url
37
  */
38
  public function remove_paged_from_link( $url ) {
39
- return preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url );
 
 
 
 
 
 
 
 
40
  }
41
 
42
  /**
@@ -49,7 +57,16 @@ abstract class PLL_Links_Permalinks extends PLL_Links_Model {
49
  * @return string modified url
50
  */
51
  public function add_paged_to_link( $url, $page ) {
52
- return user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' );
 
 
 
 
 
 
 
 
 
53
  }
54
 
55
  /**
7
  */
8
  abstract class PLL_Links_Permalinks extends PLL_Links_Model {
9
  public $using_permalinks = true;
10
+ protected $index = 'index.php'; // Need this before $wp_rewrite is created, also harcoded in wp-includes/rewrite.php
11
  protected $root, $use_trailing_slashes;
12
  protected $always_rewrite = array( 'date', 'root', 'comments', 'search', 'author' );
13
 
36
  * @return string modified url
37
  */
38
  public function remove_paged_from_link( $url ) {
39
+ /**
40
+ * Filter an url after the paged part has been removed
41
+ *
42
+ * @since 2.0.6
43
+ *
44
+ * @param string $modified_url The link to the first page
45
+ * @param string $orginal_url The link to the original paged page
46
+ */
47
+ return apply_filters( 'pll_remove_paged_from_link', preg_replace( '#\/page\/[0-9]+\/?#', $this->use_trailing_slashes ? '/' : '', $url ), $url );
48
  }
49
 
50
  /**
57
  * @return string modified url
58
  */
59
  public function add_paged_to_link( $url, $page ) {
60
+ /**
61
+ * Filter an url after the paged part has been added
62
+ *
63
+ * @since 2.0.6
64
+ *
65
+ * @param string $modified_url The link to the paged page
66
+ * @param string $orginal_url The link to the original first page
67
+ * @param int $page The page number
68
+ */
69
+ return apply_filters( 'pll_add_paged_to_link', user_trailingslashit( trailingslashit( $url ) . 'page/' . $page, 'paged' ), $url, $page );
70
  }
71
 
72
  /**
modules/wpml/wpml-api.php CHANGED
@@ -20,14 +20,14 @@ class PLL_WPML_API {
20
  add_filter( 'wpml_active_languages', array( $this, 'wpml_active_languages' ), 10, 2 );
21
  // wpml_display_language_names => not implemented
22
  // wpml_translated_language_name => not applicable
23
- add_filter( 'wpml_current_language', 'pll_current_language' );
24
- add_filter( 'wpml_default_language', 'pll_default_language' );
25
  // wpml_add_language_selector => not implemented
26
  // wpml_footer_language_selector => not applicable
27
  add_action( 'wpml_add_language_form_field', array( $this, 'wpml_add_language_form_field' ) );
28
  add_filter( 'wpml_language_is_active', array( $this, 'wpml_language_is_active' ), 10, 2 );
29
  add_filter( 'wpml_is_rtl' , array( $this, 'wpml_is_rtl' ) );
30
- // wpml_language_form_input_field => not implemented
31
  // wpml_language_has_switched => not implemented
32
 
33
  // Retrieving Language Information for Content
@@ -39,7 +39,7 @@ class PLL_WPML_API {
39
 
40
  // Retrieving Localized Content
41
 
42
- add_filter( 'wpml_home_url', 'pll_home_url' );
43
  add_filter( 'wpml_element_link', 'icl_link_to_element' , 10, 7 );
44
  add_filter( 'wpml_object_id', 'icl_object_id', 10, 4 );
45
  add_filter( 'wpml_translate_single_string', array( $this, 'wpml_translate_single_string' ), 10, 4 );
@@ -104,7 +104,10 @@ class PLL_WPML_API {
104
  * @since 2.0
105
  */
106
  public function wpml_add_language_form_field() {
107
- printf( '<input type="hidden" name="lang" value="%s" />', esc_attr( pll_current_language() ) );
 
 
 
108
  }
109
 
110
  /**
20
  add_filter( 'wpml_active_languages', array( $this, 'wpml_active_languages' ), 10, 2 );
21
  // wpml_display_language_names => not implemented
22
  // wpml_translated_language_name => not applicable
23
+ add_filter( 'wpml_current_language', 'pll_current_language', 10, 0 );
24
+ add_filter( 'wpml_default_language', 'pll_default_language', 10, 0 );
25
  // wpml_add_language_selector => not implemented
26
  // wpml_footer_language_selector => not applicable
27
  add_action( 'wpml_add_language_form_field', array( $this, 'wpml_add_language_form_field' ) );
28
  add_filter( 'wpml_language_is_active', array( $this, 'wpml_language_is_active' ), 10, 2 );
29
  add_filter( 'wpml_is_rtl' , array( $this, 'wpml_is_rtl' ) );
30
+ // wpml_language_form_input_field => See wpml_add_language_form_field
31
  // wpml_language_has_switched => not implemented
32
 
33
  // Retrieving Language Information for Content
39
 
40
  // Retrieving Localized Content
41
 
42
+ add_filter( 'wpml_home_url', 'pll_home_url', 10, 0 );
43
  add_filter( 'wpml_element_link', 'icl_link_to_element' , 10, 7 );
44
  add_filter( 'wpml_object_id', 'icl_object_id', 10, 4 );
45
  add_filter( 'wpml_translate_single_string', array( $this, 'wpml_translate_single_string' ), 10, 4 );
104
  * @since 2.0
105
  */
106
  public function wpml_add_language_form_field() {
107
+ $lang = pll_current_language();
108
+ $field = sprintf( '<input type="hidden" name="lang" value="%s" />', esc_attr( $lang ) );
109
+ $field = apply_filters( 'wpml_language_form_input_field', $field, $lang );
110
+ echo $field;
111
  }
112
 
113
  /**
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.0.5
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.0.5' );
39
  define( 'PLL_MIN_WP_VERSION', '4.0' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.0.6
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.0.6' );
39
  define( 'PLL_MIN_WP_VERSION', '4.0' );
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.0
6
  Tested up to: 4.6
7
- Stable tag: 2.0.5
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -77,6 +77,18 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  = 2.0.5 (2016-09-22) Five years after! =
81
 
82
  * Pro: Fix conflict with WPBakery Visual Composer
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.0
6
  Tested up to: 4.6
7
+ Stable tag: 2.0.6
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
77
 
78
  == Changelog ==
79
 
80
+ = 2.0.6 (2016-10-17) =
81
+
82
+ * Pro: Fix translated paged slug not working on paged static front page
83
+ * Add support for WPML filter 'wpml_language_form_input_field'
84
+ * Fix PHP notice when using the WPML filter 'wpml_current_language'
85
+ * Fix cases where the admin language filter is not correctly taken into account
86
+ * Fix paged static front pages in plain permalinks
87
+ * Fix paged static front pages for multiple domains (#43)
88
+ * Fix warning occuring when a 3rd party plugin attempts to register anything but a string in the strings translations panel
89
+ * Fix cross domain http request for media when using multiple domains or subdomains
90
+ * Fix error 404 on pages when no language has been created yet
91
+
92
  = 2.0.5 (2016-09-22) Five years after! =
93
 
94
  * Pro: Fix conflict with WPBakery Visual Composer
settings/languages.php CHANGED
@@ -23,7 +23,7 @@ $languages = array(
23
  'bel' => array( 'be', 'bel', 'Беларуская мова', 'ltr', 'by' ),
24
  'bg_BG' => array( 'bg', 'bg_BG', 'български', 'ltr', 'bg' ),
25
  'bn_BD' => array( 'bn', 'bn_BD', 'বাংলা', 'ltr', 'bd' ),
26
- 'bo' => array( 'bo', 'bo', 'བོད་སྐད', 'ltr', 'tibet' ),
27
  'bs_BA' => array( 'bs', 'bs_BA', 'Bosanski', 'ltr', 'ba' ),
28
  'ca' => array( 'ca', 'ca', 'Català', 'ltr', 'catalonia' ),
29
  'ceb' => array( 'ceb', 'ceb', 'Cebuano', 'ltr', 'ph' ),
23
  'bel' => array( 'be', 'bel', 'Беларуская мова', 'ltr', 'by' ),
24
  'bg_BG' => array( 'bg', 'bg_BG', 'български', 'ltr', 'bg' ),
25
  'bn_BD' => array( 'bn', 'bn_BD', 'বাংলা', 'ltr', 'bd' ),
26
+ 'bo' => array( 'bo', 'bo', 'བོད་ཡིག', 'ltr', 'tibet' ),
27
  'bs_BA' => array( 'bs', 'bs_BA', 'Bosanski', 'ltr', 'ba' ),
28
  'ca' => array( 'ca', 'ca', 'Català', 'ltr', 'catalonia' ),
29
  'ceb' => array( 'ceb', 'ceb', 'Cebuano', 'ltr', 'ph' ),