Polylang - Version 1.9.3

Version Description

(2016-06-28) =

  • Pro: Allow to add slashes in url slugs translations
  • Pro: Fix archive links not using translated slugs
  • Pro: Fix visitor being redirected to 404 if his browser preference is set to an inactive language
  • Fix strings translations table always back to page 1 when submitting the form (#14)
  • Fix get_pages( array( 'lang' => '' ) ) not querying all the languages
  • Fix switching the admin language filter can override the static front page settings (#16)
Download this release

Release Info

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

Code changes from version 1.9.2 to 1.9.3

admin/admin-static-pages.php CHANGED
@@ -25,6 +25,9 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
25
 
26
  // checks if chosen page on front is translated
27
  add_filter( 'pre_update_option_page_on_front', array( &$this, 'update_page_on_front' ), 10, 2 );
 
 
 
28
  }
29
 
30
  /**
@@ -86,4 +89,20 @@ class PLL_Admin_Static_Pages extends PLL_Static_Pages {
86
 
87
  return $page_id;
88
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
25
 
26
  // checks if chosen page on front is translated
27
  add_filter( 'pre_update_option_page_on_front', array( &$this, 'update_page_on_front' ), 10, 2 );
28
+
29
+ // Prevents WP resetting the option
30
+ add_filter( 'pre_update_option_show_on_front', array( $this, 'update_show_on_front' ), 10, 2 );
31
  }
32
 
33
  /**
89
 
90
  return $page_id;
91
  }
92
+
93
+ /**
94
+ * Prevents WP resetting the option if the admin language filter is active for a language with no pages
95
+ *
96
+ * @since 1.9.3
97
+ *
98
+ * @param string $value
99
+ * @param string $old_value
100
+ * @return string
101
+ */
102
+ public function update_show_on_front( $value, $old_value ) {
103
+ if ( ! empty( $GLOBALS['pagenow'] ) && 'options-reading.php' === $GLOBALS['pagenow'] && 'posts' === $value && ! get_pages() && get_pages( array( 'lang' => '' ) ) ) {
104
+ $value = $old_value;
105
+ }
106
+ return $value;
107
+ }
108
  }
frontend/choose-lang.php CHANGED
@@ -151,19 +151,28 @@ abstract class PLL_Choose_Lang {
151
  }
152
  }
153
 
154
- // looks through sorted list and use first one that matches our language list
155
- $listlanguages = $this->model->get_languages_list( array( 'hide_empty' => true ) ); // hides languages with no post
156
 
 
 
 
 
 
 
 
 
 
 
157
  foreach ( array_keys( $accept_langs ) as $accept_lang ) {
158
  // first loop to match the exact locale
159
- foreach ( $listlanguages as $language ) {
160
  if ( 0 === strcasecmp( $accept_lang, $language->get_locale( 'display' ) ) ) {
161
  return $language->slug;
162
  }
163
  }
164
 
165
  // second loop to match the language set
166
- foreach ( $listlanguages as $language ) {
167
  if ( 0 === stripos( $accept_lang, $language->slug ) || 0 === stripos( $language->get_locale( 'display' ), $accept_lang ) ) {
168
  return $language->slug;
169
  }
151
  }
152
  }
153
 
154
+ $languages = $this->model->get_languages_list( array( 'hide_empty' => true ) ); // hides languages with no post
 
155
 
156
+ /**
157
+ * Filter the list of languages to use to match the browser preferences
158
+ *
159
+ * @since 1.9.3
160
+ *
161
+ * @param array $languages array of PLL_Language objects
162
+ */
163
+ $languages = apply_filters( 'pll_languages_for_browser_preferences', $languages );
164
+
165
+ // looks through sorted list and use first one that matches our language list
166
  foreach ( array_keys( $accept_langs ) as $accept_lang ) {
167
  // first loop to match the exact locale
168
+ foreach ( $languages as $language ) {
169
  if ( 0 === strcasecmp( $accept_lang, $language->get_locale( 'display' ) ) ) {
170
  return $language->slug;
171
  }
172
  }
173
 
174
  // second loop to match the language set
175
+ foreach ( $languages as $language ) {
176
  if ( 0 === stripos( $accept_lang, $language->slug ) || 0 === stripos( $language->get_locale( 'display' ), $accept_lang ) ) {
177
  return $language->slug;
178
  }
include/filters.php CHANGED
@@ -80,6 +80,10 @@ class PLL_Filters {
80
  * @return array modified list of pages
81
  */
82
  public function get_pages( $pages, $args ) {
 
 
 
 
83
  $language = empty( $args['lang'] ) ? $this->curlang : $this->model->get_language( $args['lang'] );
84
 
85
  if ( empty( $language ) || empty( $pages ) || ! $this->model->is_translated_post_type( $args['post_type'] ) ) {
80
  * @return array modified list of pages
81
  */
82
  public function get_pages( $pages, $args ) {
83
+ if ( isset( $args['lang'] ) && empty( $args['lang'] ) ) {
84
+ return $pages;
85
+ }
86
+
87
  $language = empty( $args['lang'] ) ? $this->curlang : $this->model->get_language( $args['lang'] );
88
 
89
  if ( empty( $language ) || empty( $pages ) || ! $this->model->is_translated_post_type( $args['post_type'] ) ) {
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 1.9.2
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', '1.9.2' );
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: 1.9.3
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', '1.9.3' );
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.5
7
- Stable tag: 1.9.2
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -77,6 +77,15 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
 
 
80
  = 1.9.2 (2016-06-06) =
81
 
82
  * Pro: fix unreachable hierarchical custom post type posts when they are sharing slugs across languages
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.0
6
  Tested up to: 4.5
7
+ Stable tag: 1.9.3
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
77
 
78
  == Changelog ==
79
 
80
+ = 1.9.3 (2016-06-28) =
81
+
82
+ * Pro: Allow to add slashes in url slugs translations
83
+ * Pro: Fix archive links not using translated slugs
84
+ * Pro: Fix visitor being redirected to 404 if his browser preference is set to an inactive language
85
+ * Fix strings translations table always back to page 1 when submitting the form (#14)
86
+ * Fix get_pages( array( 'lang' => '' ) ) not querying all the languages
87
+ * Fix switching the admin language filter can override the static front page settings (#16)
88
+
89
  = 1.9.2 (2016-06-06) =
90
 
91
  * Pro: fix unreachable hierarchical custom post type posts when they are sharing slugs across languages
settings/table-string.php CHANGED
@@ -317,8 +317,11 @@ class PLL_Table_String extends WP_List_Table {
317
  }
318
  }
319
 
320
- // to refresh the page ( possible thanks to the $_GET['noheader']=true )
321
- $args = array_intersect_key( $_REQUEST, array_flip( array( 's', 'paged', 'group' ) ) );
 
 
 
322
  if ( ! empty( $args['s'] ) ) {
323
  $args['s'] = urlencode( $args['s'] ); // searched string needs to be encoded as it comes from $_POST
324
  }
317
  }
318
  }
319
 
320
+ // To refresh the page ( possible thanks to the $_GET['noheader']=true )
321
+ $args = array_intersect_key( $_REQUEST, array_flip( array( 's', 'group' ) ) );
322
+ if ( ! empty( $_GET['paged'] ) ) {
323
+ $args['paged'] = (int) $_GET['paged']; // Don't rely on $_REQUEST['paged'] or $_POST['paged']. See #14
324
+ }
325
  if ( ! empty( $args['s'] ) ) {
326
  $args['s'] = urlencode( $args['s'] ); // searched string needs to be encoded as it comes from $_POST
327
  }
settings/view-tab-strings.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'ABSPATH' ) ) {
9
  };
10
  ?>
11
  <div class="form-wrap">
12
- <form id="string-translation" method="post" action="options-general.php?page=mlang&amp;tab=strings&amp;noheader=true">
13
  <input type="hidden" name="pll_action" value="string-translation" /><?php
14
  $string_table->search_box( __( 'Search translations', 'polylang' ), 'translations' );
15
  wp_nonce_field( 'string-translation', '_wpnonce_string-translation' );
9
  };
10
  ?>
11
  <div class="form-wrap">
12
+ <form id="string-translation" method="post" action="<?php echo esc_url( add_query_arg( 'noheader', 'true' ) ); ?>">
13
  <input type="hidden" name="pll_action" value="string-translation" /><?php
14
  $string_table->search_box( __( 'Search translations', 'polylang' ), 'translations' );
15
  wp_nonce_field( 'string-translation', '_wpnonce_string-translation' );