Polylang - Version 1.6.5

Version Description

(2015-02-18) =

  • Add new correspondances between WordPress locales and Facebook locales (for WPSEO and Jetpack users)
  • fix: quick draft posts are always assigned the default category in the default language
  • fix: Notice: Undefined offset: 0 in wp-includes/query.php introduced in WP 4.1
  • fix: is_tax and is_archive are not correctly set when a custom taxonomy term is queried
  • fix: conflict introduced by WPSEO 1.7.2+
Download this release

Release Info

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

Code changes from version 1.6.4 to 1.6.5

admin/admin-filters-post.php CHANGED
@@ -270,7 +270,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
270
  // 'post-quickpress-save', 'post-quickpress-publish' = backward compatibility WP < 3.8
271
  elseif (isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('post-quickpress-save', 'post-quickpress-publish', 'post-quickdraft-save'))) {
272
  check_admin_referer('add-' . $post->post_type);
273
- $this->model->set_post_language($post_id, $this->pref_lang); // default language for Quick draft
274
  }
275
 
276
  else
270
  // 'post-quickpress-save', 'post-quickpress-publish' = backward compatibility WP < 3.8
271
  elseif (isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('post-quickpress-save', 'post-quickpress-publish', 'post-quickdraft-save'))) {
272
  check_admin_referer('add-' . $post->post_type);
273
+ $this->model->set_post_language($post_id, $lang = $this->pref_lang); // default language for Quick draft
274
  }
275
 
276
  else
admin/admin.php CHANGED
@@ -72,6 +72,8 @@ class PLL_Admin extends PLL_Base {
72
  // filter admin language for users
73
  // we must not call user info before WordPress defines user roles in wp-settings.php
74
  add_filter('setup_theme', array(&$this, 'init_user'));
 
 
75
 
76
  // adds the languages in admin bar
77
  add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 100); // 100 determines the position
@@ -214,6 +216,23 @@ class PLL_Admin extends PLL_Base {
214
  else
215
  do_action('pll_no_language_defined'); // to load overriden textdomains
216
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
 
218
  /*
219
  * get the locale based on user preference
72
  // filter admin language for users
73
  // we must not call user info before WordPress defines user roles in wp-settings.php
74
  add_filter('setup_theme', array(&$this, 'init_user'));
75
+ add_filter('request', array(&$this, 'request'));
76
+
77
 
78
  // adds the languages in admin bar
79
  add_action('admin_bar_menu', array(&$this, 'admin_bar_menu'), 100); // 100 determines the position
216
  else
217
  do_action('pll_no_language_defined'); // to load overriden textdomains
218
  }
219
+
220
+ /*
221
+ * avoids parsing a tax query when all languages are requested
222
+ * fixes https://wordpress.org/support/topic/notice-undefined-offset-0-in-wp-includesqueryphp-on-line-3877 introduced in WP 4.1
223
+ * @see the suggestion of @boonebgorges, https://core.trac.wordpress.org/ticket/31246
224
+ *
225
+ * @since 1.6.5
226
+ *
227
+ * @param array $qvars
228
+ * @return array
229
+ */
230
+ public function request($qvars) {
231
+ if (isset($qvars['lang']) && 'all' === $qvars['lang'])
232
+ unset($qvars['lang']);
233
+
234
+ return $qvars;
235
+ }
236
 
237
  /*
238
  * get the locale based on user preference
admin/settings.php CHANGED
@@ -340,7 +340,8 @@ class PLL_Settings {
340
  set_transient('settings_errors', $errors, 30);
341
  $args['settings-updated'] = 1;
342
  }
343
- wp_redirect(add_query_arg($args, wp_get_referer() ));
 
344
  exit;
345
  }
346
  }
340
  set_transient('settings_errors', $errors, 30);
341
  $args['settings-updated'] = 1;
342
  }
343
+ // remove possible 'pll_action' and 'lang' query args from the referer before redirecting
344
+ wp_redirect(add_query_arg($args, remove_query_arg( array('pll_action', 'lang'), wp_get_referer() )));
345
  exit;
346
  }
347
  }
frontend/frontend.php CHANGED
@@ -102,16 +102,32 @@ class PLL_Frontend extends PLL_Base {
102
  if (empty($qv['post_type']) && !$query->is_search)
103
  $query->set('post_type', 'post');
104
 
 
 
 
105
  // unset the is_archive flag for language pages to prevent loading the archive template
106
  // keep archive flag for comment feed otherwise the language filter does not work
107
- if (!$query->is_comment_feed && !$query->is_post_type_archive && !$query->is_date && !$query->is_author && !$query->is_category && !$query->is_tag && !$query->is_tax('post_format'))
108
  $query->is_archive = false;
109
 
110
- // unset the is_tax flag for authors pages and post types archives
111
- // FIXME Should I do this for other cases?
112
- if ($query->is_author || $query->is_post_type_archive || $query->is_date || $query->is_search) {
113
  $query->is_tax = false;
114
  unset($query->queried_object);
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  }
116
  }
117
  }
102
  if (empty($qv['post_type']) && !$query->is_search)
103
  $query->set('post_type', 'post');
104
 
105
+ // do we query another custom taxonomy?
106
+ $taxonomies = array_diff(wp_list_pluck($query->tax_query->queries, 'taxonomy'), array('language', 'category', 'post_tag'));
107
+
108
  // unset the is_archive flag for language pages to prevent loading the archive template
109
  // keep archive flag for comment feed otherwise the language filter does not work
110
+ if (empty($taxonomies) && !$query->is_comment_feed && !$query->is_post_type_archive && !$query->is_date && !$query->is_author && !$query->is_category && !$query->is_tag)
111
  $query->is_archive = false;
112
 
113
+ // unset the is_tax flag except if another custom tax is queried
114
+ // reset the queried object
115
+ if (empty($taxonomies) && ($query->is_author || $query->is_post_type_archive || $query->is_date || $query->is_search)) {
116
  $query->is_tax = false;
117
  unset($query->queried_object);
118
+ get_queried_object();
119
+ }
120
+
121
+ // move the language tax_query at the end to avoid it being the queried object
122
+ if (!empty($taxonomies)) {
123
+ $tax_query_in_and = wp_list_filter( $query->tax_query->queried_terms, array( 'operator' => 'NOT IN' ), 'NOT' );
124
+ $queried_taxonomies = array_keys( $tax_query_in_and );
125
+
126
+ if ('language' == reset( $queried_taxonomies )) {
127
+ $query->tax_query->queried_terms['language'] = array_shift($query->tax_query->queried_terms);
128
+ unset($query->queried_object);
129
+ get_queried_object();
130
+ }
131
  }
132
  }
133
  }
include/plugins-compat.php CHANGED
@@ -83,7 +83,13 @@ class PLL_Plugins_Compat {
83
  // reloads options once the language has been defined to enable translations
84
  // useful only when the language is set from content
85
  if (did_action('wp_loaded')) {
86
- global $wpseo_front;
 
 
 
 
 
 
87
  $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
88
  foreach ( $options as $opt )
89
  $wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
@@ -324,7 +330,9 @@ class PLL_Plugins_Compat {
324
  }
325
 
326
  /*
327
- * correspondance between WordPress locales and Facebook locales according to GP_Locales class in Jetpack 3.1.1
 
 
328
  *
329
  * @since 1.6
330
  *
@@ -333,19 +341,21 @@ class PLL_Plugins_Compat {
333
  */
334
  static public function get_fb_locale($language) {
335
  static $facebook_locales = array(
336
- 'af' => 'af_ZA', 'ar' => 'ar_AR', 'az' => 'az_AZ', 'bg_BG' => 'bg_BG', 'bn_BD' => 'bn_IN', 'bs_BA' => 'bs_BA',
337
- 'ca' => 'ca_ES', 'cs_CZ' => 'cs_CZ', 'cy' => 'cy_GB', 'da_DK' => 'da_DK', 'de_DE' => 'de_DE', 'el' => 'el_GR',
338
- 'en_US' => 'en_US', 'en_GB' => 'en_GB', 'eo' => 'eo_EO', 'es_CL' => 'es_LA', 'es_PE' => 'es_LA', 'es_PR' => 'es_LA',
339
- 'es_VE' => 'es_LA', 'es_CO' => 'es_LA', 'es_ES' => 'es_ES', 'et' => 'et_EE', 'eu' => 'eu_ES', 'fa_IR' => 'fa_IR',
340
- 'fi' => 'fi_FI', 'fo' => 'fo_FO', 'fr_FR' => 'fr_FR', 'fy' => 'fy_NL', 'ga' => 'ga_IE', 'gl_ES' => 'gl_ES',
 
341
  'he_IL' => 'he_IL', 'hi_IN' => 'hi_IN', 'hr' => 'hr_HR', 'hu_HU' => 'hu_HU', 'hy' => 'hy_AM', 'id_ID' => 'id_ID',
342
- 'is_IS' => 'is_IS', 'it_IT' => 'it_IT', 'ja' => 'ja_JP', 'ka_GE' => 'ka_GE', 'ko_KR' => 'ko_KR', 'lt_LT' => 'lt_LT',
343
- 'lv' => 'lv_LV', 'mk_MK' => 'mk_MK', 'ml_IN' => 'ml_IN', 'ms_MY' => 'ms_MY', 'ne_NP' => 'ne_NP', 'nb_NO' => 'nb_NO',
344
- 'nl_NL' => 'nl_NL', 'nn_NO' => 'nn_NO', 'pa_IN' => 'pa_IN', 'pl_PL' => 'pl_PL', 'pt_BR' => 'pt_BR', 'pt_PT' => 'pt_PT',
345
- 'ps' => 'ps_AF', 'ro_RO' => 'ro_RO', 'ru_RU' => 'ru_RU', 'sk_SK' => 'sk_SK', 'sl_SI' => 'sl_SI', 'sq' => 'sq_AL',
346
- 'sr_RS' => 'sr_RS', 'sv_SE' => 'sv_SE', 'sw' => 'sw_KE', 'ta_IN' => 'ta_IN', 'te' => 'te_IN', 'th' => 'th_TH',
347
- 'ph' => 'tl_PH', 'tr_TR' => 'tr_TR', 'uk' => 'uk_UA', 'vi' => 'vi_VN', 'zh_CN' => 'zh_CN', 'zh_HK' => 'zh_HK',
348
- 'zh_TW' => 'zh_TW'
 
349
  );
350
 
351
  return isset($facebook_locales[$language->locale]) ? $facebook_locales[$language->locale] : false;
83
  // reloads options once the language has been defined to enable translations
84
  // useful only when the language is set from content
85
  if (did_action('wp_loaded')) {
86
+ if (version_compare(WPSEO_VERSION, '1.7.2', '<')) {
87
+ global $wpseo_front;
88
+ }
89
+ else {
90
+ $wpseo_front = WPSEO_Frontend::get_instance();
91
+ }
92
+
93
  $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
94
  foreach ( $options as $opt )
95
  $wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
330
  }
331
 
332
  /*
333
+ * correspondance between WordPress locales and Facebook locales
334
+ * @see http://wpcentral.io/internationalization/
335
+ * @see https://www.facebook.com/translations/FacebookLocales.xml
336
  *
337
  * @since 1.6
338
  *
341
  */
342
  static public function get_fb_locale($language) {
343
  static $facebook_locales = array(
344
+ 'af' => 'af_ZA', 'ar' => 'ar_AR', 'az' => 'az_AZ', 'bel' => 'be_BY', 'bg_BG' => 'bg_BG', 'bn_BD' => 'bn_IN',
345
+ 'bs_BA' => 'bs_BA', 'ca' => 'ca_ES', 'ckb' => 'ku_TR', 'cs_CZ' => 'cs_CZ', 'cy' => 'cy_GB', 'da_DK' => 'da_DK',
346
+ 'de_DE' => 'de_DE', 'el' => 'el_GR', 'en_US' => 'en_US', 'en_GB' => 'en_GB', 'eo' => 'eo_EO', 'es_CL' => 'es_LA',
347
+ 'es_CO' => 'es_LA', 'es_MX' => 'es_LA', 'es_PE' => 'es_LA', 'es_PR' => 'es_LA', 'es_VE' => 'es_LA', 'es_ES' => 'es_ES',
348
+ 'et' => 'et_EE', 'eu' => 'eu_ES', 'fa_IR' => 'fa_IR', 'fi' => 'fi_FI', 'fo' => 'fo_FO', 'fr_CA' => 'fr_CA',
349
+ 'fr_FR' => 'fr_FR', 'fy' => 'fy_NL', 'ga' => 'ga_IE', 'gl_ES' => 'gl_ES', 'gn' => 'gn_PY', 'gu_IN' => 'gu_IN',
350
  'he_IL' => 'he_IL', 'hi_IN' => 'hi_IN', 'hr' => 'hr_HR', 'hu_HU' => 'hu_HU', 'hy' => 'hy_AM', 'id_ID' => 'id_ID',
351
+ 'is_IS' => 'is_IS', 'it_IT' => 'it_IT', 'ja' => 'ja_JP', 'jv_ID' => 'jv_ID', 'ka_GE' => 'ka_GE', 'kk' => 'kk_KZ',
352
+ 'km' => 'km_kH', 'kn' => 'kn_IN', 'ko_KR' => 'ko_KR', 'lt_LT' => 'lt_LT', 'lv' => 'lv_LV', 'mk_MK' => 'mk_MK',
353
+ 'ml_IN' => 'ml_IN', 'mn' => 'mn_MN', 'mr' => 'mr_IN', 'ms_MY' => 'ms_MY', 'ne_NP' => 'ne_NP', 'nb_NO' => 'nb_NO',
354
+ 'nl_NL' => 'nl_NL', 'nn_NO' => 'nn_NO', 'pa_IN' => 'pa_IN', 'pl_PL' => 'pl_PL', 'ps' => 'ps_AF', 'pt_BR' => 'pt_BR',
355
+ 'pt_PT' => 'pt_PT', 'ps' => 'ps_AF', 'ro_RO' => 'ro_RO', 'ru_RU' => 'ru_RU', 'si_LK' => 'si_LK', 'sk_SK' => 'sk_SK',
356
+ 'sl_SI' => 'sl_SI', 'sq' => 'sq_AL', 'sr_RS' => 'sr_RS', 'sv_SE' => 'sv_SE', 'sw' => 'sw_KE', 'ta_IN' => 'ta_IN',
357
+ 'te' => 'te_IN', 'tg' => 'tg_TJ', 'th' => 'th_TH', 'ph' => 'tl_PH', 'tr_TR' => 'tr_TR', 'uk' => 'uk_UA',
358
+ 'ur' => 'ur_PK', 'uz_UZ' => 'uz_UZ', 'vi' => 'vi_VN', 'zh_CN' => 'zh_CN', 'zh_HK' => 'zh_HK', 'zh_TW' => 'zh_TW'
359
  );
360
 
361
  return isset($facebook_locales[$language->locale]) ? $facebook_locales[$language->locale] : false;
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
- Version: 1.6.4
6
  Author: Frédéric Demarle
7
  Description: Adds multilingual capability to WordPress
8
  Text Domain: polylang
@@ -33,7 +33,7 @@ Domain Path: /languages
33
  if (!function_exists('add_action'))
34
  exit();
35
 
36
- define('POLYLANG_VERSION', '1.6.4');
37
  define('PLL_MIN_WP_VERSION', '3.5');
38
 
39
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
@@ -51,13 +51,6 @@ if (!defined('PLL_LOCAL_DIR'))
51
  if (file_exists(PLL_LOCAL_DIR . '/pll-config.php'))
52
  include_once(PLL_LOCAL_DIR . '/pll-config.php');
53
 
54
- // our url. Don't use WP_PLUGIN_URL http://wordpress.org/support/topic/ssl-doesnt-work-properly
55
- define('POLYLANG_URL', plugins_url('', __FILE__));
56
-
57
- // default url to access user data such as custom flags
58
- if (!defined('PLL_LOCAL_URL'))
59
- define('PLL_LOCAL_URL', content_url('/polylang'));
60
-
61
  /*
62
  * controls the plugin, as well as activation, and deactivation
63
  *
@@ -249,6 +242,13 @@ class Polylang {
249
  * @since 1.6
250
  */
251
  protected function define_constants() {
 
 
 
 
 
 
 
252
  // cookie name. no cookie will be used if set to false
253
  if (!defined('PLL_COOKIE'))
254
  define('PLL_COOKIE', 'pll_language');
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
+ Version: 1.6.5
6
  Author: Frédéric Demarle
7
  Description: Adds multilingual capability to WordPress
8
  Text Domain: polylang
33
  if (!function_exists('add_action'))
34
  exit();
35
 
36
+ define('POLYLANG_VERSION', '1.6.5');
37
  define('PLL_MIN_WP_VERSION', '3.5');
38
 
39
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
51
  if (file_exists(PLL_LOCAL_DIR . '/pll-config.php'))
52
  include_once(PLL_LOCAL_DIR . '/pll-config.php');
53
 
 
 
 
 
 
 
 
54
  /*
55
  * controls the plugin, as well as activation, and deactivation
56
  *
242
  * @since 1.6
243
  */
244
  protected function define_constants() {
245
+ // our url. Don't use WP_PLUGIN_URL http://wordpress.org/support/topic/ssl-doesnt-work-properly
246
+ define('POLYLANG_URL', plugins_url('', __FILE__));
247
+
248
+ // default url to access user data such as custom flags
249
+ if (!defined('PLL_LOCAL_URL'))
250
+ define('PLL_LOCAL_URL', content_url('/polylang'));
251
+
252
  // cookie name. no cookie will be used if set to false
253
  if (!defined('PLL_COOKIE'))
254
  define('PLL_COOKIE', 'pll_language');
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 3.5
6
  Tested up to: 4.1
7
- Stable tag: 1.6.4
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
@@ -63,6 +63,14 @@ See http://polylang.wordpress.com/documentation/contribute/
63
 
64
  == Changelog ==
65
 
 
 
 
 
 
 
 
 
66
  = 1.6.4 (2015-02-01) =
67
 
68
  * Add es_MX to predefined languages list
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 3.5
6
  Tested up to: 4.1
7
+ Stable tag: 1.6.5
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
63
 
64
  == Changelog ==
65
 
66
+ = 1.6.5 (2015-02-18) =
67
+
68
+ * Add new correspondances between WordPress locales and Facebook locales (for WPSEO and Jetpack users)
69
+ * fix: quick draft posts are always assigned the default category in the default language
70
+ * fix: Notice: Undefined offset: 0 in wp-includes/query.php introduced in WP 4.1
71
+ * fix: is_tax and is_archive are not correctly set when a custom taxonomy term is queried
72
+ * fix: conflict introduced by WPSEO 1.7.2+
73
+
74
  = 1.6.4 (2015-02-01) =
75
 
76
  * Add es_MX to predefined languages list