Polylang - Version 2.2.1

Version Description

(2017-08-30) =

  • Pro: partially refactor REST API classes
  • Pro: Fix duplicate content user meta not removed from DB when uninstalling the plugin
  • Fix strings translations not removed from DB when uninstalling the plugin
  • Fix incorrect translation files loaded in ajax on front when the user is logged in (WP 4.7+)
  • Fix widget language dropdown removed when saving a widget (introduced in 2.2)
  • Fix queries with negative values for the 'cat' parameter (introduced in 2.2 for queries made on frontend)
  • Fix performance issue in combination with some plugins when the language is set from the content (introduced in 2.2)
Download this release

Release Info

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

Code changes from version 2.2 to 2.2.1

admin/admin-filters.php CHANGED
@@ -57,7 +57,8 @@ class PLL_Admin_Filters extends PLL_Filters {
57
  $screen = get_current_screen();
58
 
59
  // Test the Widgets screen and the Customizer to avoid displaying the option in page builders
60
- if ( ( isset( $screen ) && 'widgets' === $screen->base ) || isset( $GLOBALS['wp_customize'] ) ) {
 
61
  $dropdown = new PLL_Walker_Dropdown();
62
  printf( '<p><label for="%1$s">%2$s %3$s</label></p>',
63
  esc_attr( $widget->id . '_lang_choice' ),
57
  $screen = get_current_screen();
58
 
59
  // Test the Widgets screen and the Customizer to avoid displaying the option in page builders
60
+ // Saving the widget reloads the form. And curiously the action is in $_REQUEST but neither in $_POST, not in $_GET.
61
+ if ( ( isset( $screen ) && 'widgets' === $screen->base ) || ( isset( $_REQUEST['action'] ) && 'save-widget' === $_REQUEST['action'] ) || isset( $GLOBALS['wp_customize'] ) ) {
62
  $dropdown = new PLL_Walker_Dropdown();
63
  printf( '<p><label for="%1$s">%2$s %3$s</label></p>',
64
  esc_attr( $widget->id . '_lang_choice' ),
frontend/frontend-filters.php CHANGED
@@ -296,17 +296,31 @@ class PLL_Frontend_Filters extends PLL_Filters {
296
 
297
  /**
298
  * Translates biography
 
299
  *
300
  * @since 0.9
301
  *
302
- * @param null $null
303
  * @param int $id User id
304
  * @param string $meta_key
305
  * @param bool $single Whether to return only the first value of the specified $meta_key
306
  * @return null|string
307
  */
308
- public function get_user_metadata( $null, $id, $meta_key, $single ) {
309
- return 'description' === $meta_key && $this->curlang->slug !== $this->options['default_lang'] ? get_user_meta( $id, 'description_' . $this->curlang->slug, $single ) : $null;
 
 
 
 
 
 
 
 
 
 
 
 
 
310
  }
311
 
312
  /**
296
 
297
  /**
298
  * Translates biography
299
+ * Makes sure that the correct locale is used for ajax calls when the user is logged in
300
  *
301
  * @since 0.9
302
  *
303
+ * @param null $return
304
  * @param int $id User id
305
  * @param string $meta_key
306
  * @param bool $single Whether to return only the first value of the specified $meta_key
307
  * @return null|string
308
  */
309
+ public function get_user_metadata( $return, $id, $meta_key, $single ) {
310
+ switch ( $meta_key ) {
311
+ case 'description':
312
+ if ( $this->curlang->slug !== $this->options['default_lang'] ) {
313
+ $return = get_user_meta( $id, 'description_' . $this->curlang->slug, $single );
314
+ }
315
+ break;
316
+ case 'locale':
317
+ if ( Polylang::is_ajax_on_front() ) {
318
+ $return = get_locale();
319
+ }
320
+ break;
321
+ }
322
+
323
+ return $return;
324
  }
325
 
326
  /**
include/olt-manager.php CHANGED
@@ -160,7 +160,12 @@ class PLL_OLT_Manager {
160
  * @return bool
161
  */
162
  public function load_textdomain_mofile( $mofile, $domain ) {
163
- $this->list_textdomains[] = array( 'mo' => $mofile, 'domain' => $domain );
 
 
 
 
 
164
  return ''; // Hack to prevent WP loading text domains as we will load them all later
165
  }
166
 
160
  * @return bool
161
  */
162
  public function load_textdomain_mofile( $mofile, $domain ) {
163
+ // On multisite, 2 files are sharing the same domain so we need to distinguish them
164
+ if ( 'default' === $domain && false !== strpos( $mofile, '/ms-' ) ) {
165
+ $this->list_textdomains['ms-default'] = array( 'mo' => $mofile, 'domain' => $domain );
166
+ } else {
167
+ $this->list_textdomains[ $domain ] = array( 'mo' => $mofile, 'domain' => $domain );
168
+ }
169
  return ''; // Hack to prevent WP loading text domains as we will load them all later
170
  }
171
 
include/query.php CHANGED
@@ -17,7 +17,6 @@ class PLL_Query {
17
  'page_id',
18
  'category_name',
19
  'tag',
20
- 'cat',
21
  'tag_id',
22
  'category__in',
23
  'category__and',
@@ -107,14 +106,23 @@ class PLL_Query {
107
  public function filter_query( $lang ) {
108
  $qvars = &$this->query->query_vars;
109
 
110
- // Do not filter the query if the language is already specified in another way
111
  if ( ! isset( $qvars['lang'] ) ) {
 
112
  foreach ( self::$excludes as $k ) {
113
  if ( ! empty( $qvars[ $k ] ) ) {
114
  return;
115
  }
116
  }
117
 
 
 
 
 
 
 
 
 
 
118
  $taxonomies = array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) );
119
 
120
  foreach ( $taxonomies as $tax ) {
17
  'page_id',
18
  'category_name',
19
  'tag',
 
20
  'tag_id',
21
  'category__in',
22
  'category__and',
106
  public function filter_query( $lang ) {
107
  $qvars = &$this->query->query_vars;
108
 
 
109
  if ( ! isset( $qvars['lang'] ) ) {
110
+ // Do not filter the query if the language is already specified in another way
111
  foreach ( self::$excludes as $k ) {
112
  if ( ! empty( $qvars[ $k ] ) ) {
113
  return;
114
  }
115
  }
116
 
117
+ // Specific case for 'cat' as it can contain negative values
118
+ if ( ! empty( $qvars['cat'] ) ) {
119
+ foreach ( explode( ',', $qvars['cat'] ) as $cat ) {
120
+ if ( $cat > 0 ) {
121
+ return;
122
+ }
123
+ }
124
+ }
125
+
126
  $taxonomies = array_intersect( $this->model->get_translated_taxonomies(), get_taxonomies( array( '_builtin' => false ) ) );
127
 
128
  foreach ( $taxonomies as $tax ) {
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.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', '2.2' );
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.2.1
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.2.1' );
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.8
7
- Stable tag: 2.2
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,16 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
 
 
79
  = 2.2 (2017-08-16) =
80
 
81
  * Pro: Add support for the REST API
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
  Tested up to: 4.8
7
+ Stable tag: 2.2.1
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.2.1 (2017-08-30) =
80
+
81
+ * Pro: partially refactor REST API classes
82
+ * Pro: Fix duplicate content user meta not removed from DB when uninstalling the plugin
83
+ * Fix strings translations not removed from DB when uninstalling the plugin
84
+ * Fix incorrect translation files loaded in ajax on front when the user is logged in (WP 4.7+)
85
+ * Fix widget language dropdown removed when saving a widget (introduced in 2.2)
86
+ * Fix queries with negative values for the 'cat' parameter (introduced in 2.2 for queries made on frontend)
87
+ * Fix performance issue in combination with some plugins when the language is set from the content (introduced in 2.2)
88
+
89
  = 2.2 (2017-08-16) =
90
 
91
  * Pro: Add support for the REST API
uninstall.php CHANGED
@@ -70,6 +70,7 @@ class PLL_Uninstall {
70
  // Delete users options
71
  foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
72
  delete_user_meta( $user_id, 'pll_filter_content' );
 
73
  foreach ( $languages as $lang ) {
74
  delete_user_meta( $user_id, 'description_' . $lang->slug );
75
  }
@@ -98,6 +99,7 @@ class PLL_Uninstall {
98
  register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false ) );
99
  $ids = get_posts( array(
100
  'post_type' => 'polylang_mo',
 
101
  'numberposts' => -1,
102
  'nopaging' => true,
103
  'fields' => 'ids',
70
  // Delete users options
71
  foreach ( get_users( array( 'fields' => 'ID' ) ) as $user_id ) {
72
  delete_user_meta( $user_id, 'pll_filter_content' );
73
+ delete_user_meta( $user_id, 'pll_duplicate_content' );
74
  foreach ( $languages as $lang ) {
75
  delete_user_meta( $user_id, 'description_' . $lang->slug );
76
  }
99
  register_post_type( 'polylang_mo', array( 'rewrite' => false, 'query_var' => false ) );
100
  $ids = get_posts( array(
101
  'post_type' => 'polylang_mo',
102
+ 'post_status' => 'any',
103
  'numberposts' => -1,
104
  'nopaging' => true,
105
  'fields' => 'ids',