Polylang - Version 0.8.8

Version Description

(2012-07-18) =

  • Add Portuguese translation contributed by Vitor Carvalho
  • Validation improvement thanks to kg69design
  • Bug correction: custom post types rewrite rules are broken when registered with query_var=>false
  • Bug correction: user admin language not deleted when uninstalling the plugin
  • Bug correction: pll_current_language('name') returns locale instead of language name
  • Bug correction: ajax on frontend does not work
  • Bug correction: homepage pagination broken when redirecting the language page to a static front page
  • Bug correction: taxonomies conflicts on custom post types
  • Bug correction: the admin language is not updated when edited by other users
Download this release

Release Info

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

Code changes from version 0.8.7 to 0.8.8

doc/documentation-en.odt CHANGED
Binary file
doc/documentation-en.pdf CHANGED
Binary file
include/about.php CHANGED
@@ -6,7 +6,7 @@ printf(
6
  echo ' ';
7
  printf(
8
  __("You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic.", 'polylang'),
9
- '<a href="http://wordpress.org/tags/polylang?forum_id=10">',
10
  '</a>');?>
11
  </p>
12
  <p><?php
6
  echo ' ';
7
  printf(
8
  __("You will also find useful information in the %ssupport forum%s. However don't forget to make a search before posting a new topic.", 'polylang'),
9
+ '<a href="http://wordpress.org/support/plugin/polylang">',
10
  '</a>');?>
11
  </p>
12
  <p><?php
include/admin-filters.php CHANGED
@@ -89,6 +89,7 @@ class Polylang_Admin_Filters extends Polylang_Admin_Base {
89
 
90
  // language management for users
91
  add_action('personal_options_update', array(&$this, 'personal_options_update'));
 
92
  add_action('personal_options', array(&$this, 'personal_options'));
93
 
94
  //modifies posts and terms links when needed
89
 
90
  // language management for users
91
  add_action('personal_options_update', array(&$this, 'personal_options_update'));
92
+ add_action('edit_user_profile_update', array(&$this, 'personal_options_update'));
93
  add_action('personal_options', array(&$this, 'personal_options'));
94
 
95
  //modifies posts and terms links when needed
include/core.php CHANGED
@@ -26,6 +26,7 @@ class Polylang_Core extends Polylang_base {
26
  add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
27
  add_action('wp', array(&$this, 'load_textdomains'));
28
  add_action('login_init', array(&$this, 'load_textdomains'));
 
29
 
30
  // filters posts according to the language
31
  add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
@@ -159,6 +160,10 @@ class Polylang_Core extends Polylang_base {
159
  if ($var = get_query_var('lang'))
160
  $lang = $this->get_language($var);
161
 
 
 
 
 
162
  elseif ((is_single() || is_page()) && ( ($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) ))
163
  $lang = $this->get_post_language($var);
164
 
@@ -288,9 +293,9 @@ class Polylang_Core extends Polylang_base {
288
  }
289
 
290
  // redirect the language page to the homepage
291
- if ($this->options['redirect_lang'] && is_tax('language') && count($query->query) == 1 && $this->page_on_front) {
292
- $this->curlang = $this->get_language(get_query_var('lang'));
293
- $query->parse_query('page_id='.$this->get_post($this->page_on_front, $this->curlang));
294
  return;
295
  }
296
 
@@ -322,11 +327,14 @@ class Polylang_Core extends Polylang_base {
322
  }
323
  }
324
 
 
 
 
325
  // FIXME to generalize as I probably forget things
326
  $is_archive = (count($query->query) == 1 && isset($qvars['paged']) && $qvars['paged']) ||
327
  (isset($qvars['m']) && $qvars['m']) ||
328
  (isset($qvars['author']) && $qvars['author']) ||
329
- (isset($qvars['post_type']) && is_post_type_archive() && in_array($qvars['post_type'], $this->post_types));
330
 
331
  // sets 404 when the language is not set for archives needing the language in the url
332
  if (!$this->options['hide_default'] && !isset($qvars['lang']) && !$GLOBALS['wp_rewrite']->using_permalinks() && $is_archive)
@@ -338,8 +346,7 @@ class Polylang_Core extends Polylang_base {
338
 
339
  // allow filtering recent posts and secondary queries by the current language
340
  // take care not to break queries for non visible post types such as nav_menu_items, attachments...
341
- if (/*$query->is_home && */$this->curlang && (!isset($qvars['post_type']) || in_array($qvars['post_type'], $this->post_types) ||
342
- (is_array($qvars['post_type']) && array_intersect($qvars['post_type'], $this->post_types)) ))
343
  $query->set('lang', $this->curlang->slug);
344
 
345
  // remove pages query when the language is set unless we do a search
@@ -364,6 +371,12 @@ class Polylang_Core extends Polylang_base {
364
  if ($qvars['preview'])
365
  $query->set('lang', $this->curlang->slug);
366
 
 
 
 
 
 
 
367
  if (PLL_DISPLAY_ALL) {
368
  // add posts with no language set
369
  $query->query_vars['tax_query'] = array(
@@ -431,7 +444,8 @@ class Polylang_Core extends Polylang_base {
431
  // http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
432
 
433
  $lang = esc_js($this->curlang->slug);
434
- $js = "e = document.getElementsByName('s');
 
435
  for (i = 0; i < e.length; i++) {
436
  if (e[i].tagName.toUpperCase() == 'INPUT') {
437
  s = e[i].parentNode.parentNode.children;
@@ -449,7 +463,8 @@ class Polylang_Core extends Polylang_base {
449
  e[i].parentNode.appendChild(ih);
450
  }
451
  }
452
- }";
 
453
  echo "<script type='text/javascript'>" .$js. "</script>";
454
  }
455
 
@@ -721,9 +736,9 @@ class Polylang_Core extends Polylang_base {
721
  // just returns the current language for API
722
  function current_language($args) {
723
  return !isset($this->curlang) ? false :
724
- $args == 'name' ? $this->curlang->name :
725
- $args == 'locale' ? $this->curlang->description :
726
- $this->curlang->slug;
727
  }
728
  }
729
  ?>
26
  add_filter('override_load_textdomain', array(&$this, 'mofile'), 10, 3);
27
  add_action('wp', array(&$this, 'load_textdomains'));
28
  add_action('login_init', array(&$this, 'load_textdomains'));
29
+ add_action('admin_init', array(&$this, 'load_textdomains')); // Ajax thanks to g100g
30
 
31
  // filters posts according to the language
32
  add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
160
  if ($var = get_query_var('lang'))
161
  $lang = $this->get_language($var);
162
 
163
+ // Ajax thanks to g100g
164
+ elseif (isset($_REQUEST['pll_load_front']))
165
+ $lang = isset($_REQUEST['lang']) && $_REQUEST['lang'] ? $this->get_language($_REQUEST['lang']) : $this->get_preferred_language();
166
+
167
  elseif ((is_single() || is_page()) && ( ($var = get_queried_object_id()) || ($var = get_query_var('p')) || ($var = get_query_var('page_id')) ))
168
  $lang = $this->get_post_language($var);
169
 
293
  }
294
 
295
  // redirect the language page to the homepage
296
+ if ($this->options['redirect_lang'] && is_tax('language') && $this->page_on_front && (count($query->query) == 1 || (is_paged() && count($query->query) == 2))) {
297
+ $qvars['page_id'] = $this->get_post($this->page_on_front, $this->get_language(get_query_var('lang')));
298
+ $query->parse_query($qvars);
299
  return;
300
  }
301
 
327
  }
328
  }
329
 
330
+ $is_post_type = isset($qvars['post_type']) && (in_array($qvars['post_type'], $this->post_types) ||
331
+ (is_array($qvars['post_type']) && array_intersect($qvars['post_type'], $this->post_types)) );
332
+
333
  // FIXME to generalize as I probably forget things
334
  $is_archive = (count($query->query) == 1 && isset($qvars['paged']) && $qvars['paged']) ||
335
  (isset($qvars['m']) && $qvars['m']) ||
336
  (isset($qvars['author']) && $qvars['author']) ||
337
+ (isset($qvars['post_type']) && is_post_type_archive() && $is_post_type);
338
 
339
  // sets 404 when the language is not set for archives needing the language in the url
340
  if (!$this->options['hide_default'] && !isset($qvars['lang']) && !$GLOBALS['wp_rewrite']->using_permalinks() && $is_archive)
346
 
347
  // allow filtering recent posts and secondary queries by the current language
348
  // take care not to break queries for non visible post types such as nav_menu_items, attachments...
349
+ if (/*$query->is_home && */$this->curlang && (!isset($qvars['post_type']) || $is_post_type ))
 
350
  $query->set('lang', $this->curlang->slug);
351
 
352
  // remove pages query when the language is set unless we do a search
371
  if ($qvars['preview'])
372
  $query->set('lang', $this->curlang->slug);
373
 
374
+ // to avoid conflict beetwen taxonomies
375
+ if (isset($query->tax_query->queries))
376
+ foreach ($query->tax_query->queries as $tax)
377
+ if (in_array($tax['taxonomy'], $this->taxonomies))
378
+ unset ($query->query_vars['lang']);
379
+
380
  if (PLL_DISPLAY_ALL) {
381
  // add posts with no language set
382
  $query->query_vars['tax_query'] = array(
444
  // http://wordpress.org/support/topic/development-of-polylang-version-08?replies=6#post-2645559
445
 
446
  $lang = esc_js($this->curlang->slug);
447
+ $js = "//<![CDATA[
448
+ e = document.getElementsByName('s');
449
  for (i = 0; i < e.length; i++) {
450
  if (e[i].tagName.toUpperCase() == 'INPUT') {
451
  s = e[i].parentNode.parentNode.children;
463
  e[i].parentNode.appendChild(ih);
464
  }
465
  }
466
+ }
467
+ //]]>";
468
  echo "<script type='text/javascript'>" .$js. "</script>";
469
  }
470
 
736
  // just returns the current language for API
737
  function current_language($args) {
738
  return !isset($this->curlang) ? false :
739
+ ($args == 'name' ? $this->curlang->name :
740
+ ($args == 'locale' ? $this->curlang->description :
741
+ $this->curlang->slug));
742
  }
743
  }
744
  ?>
include/widget.php CHANGED
@@ -38,6 +38,7 @@ class Polylang_Widget extends WP_Widget {
38
 
39
  $js = "
40
  <script type='text/javascript'>
 
41
  var urls = {{$urls}};
42
  var d = document.getElementById('lang_choice');
43
  d.onchange = function() {
@@ -46,6 +47,7 @@ class Polylang_Widget extends WP_Widget {
46
  location.href = urls[i];
47
  }
48
  }
 
49
  </script>";
50
 
51
  echo $js;
38
 
39
  $js = "
40
  <script type='text/javascript'>
41
+ //<![CDATA[
42
  var urls = {{$urls}};
43
  var d = document.getElementById('lang_choice');
44
  d.onchange = function() {
47
  location.href = urls[i];
48
  }
49
  }
50
+ //]]>
51
  </script>";
52
 
53
  echo $js;
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
- Version: 0.8.7
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
@@ -24,7 +24,7 @@ Description: Adds multilingual capability to Wordpress
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
- define('POLYLANG_VERSION', '0.8.7');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
@@ -283,8 +283,8 @@ class Polylang extends Polylang_Base {
283
  $options['redirect_lang'] = 0; // option introduced in 0.8
284
  }
285
 
286
- if (version_compare($options['version'], '0.8.2', '<'))
287
- flush_rewrite_rules(); // rewrite rules have been modified in 0.7.1 & 0.7.2 & 0.8 & 0.8.1 & 0.8.2
288
 
289
  $options['version'] = POLYLANG_VERSION;
290
  update_option('polylang', $options);
@@ -375,7 +375,7 @@ class Polylang extends Polylang_Base {
375
  }
376
 
377
  // rewrite rules filtered by language
378
- elseif ($always_rewrite || strpos($rule, 'post_type=') || ($current_filter != 'rewrite_rules_array' && $options['force_lang'])) {
379
  if (isset($slug))
380
  $newrules[$slug.str_replace($wp_rewrite->root, '', $key)] = str_replace(array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?'),
381
  array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&'), $rule); // hopefully it is sufficient !
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.8.8
6
  Author: F. Demarle
7
  Description: Adds multilingual capability to Wordpress
8
  */
24
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25
  */
26
 
27
+ define('POLYLANG_VERSION', '0.8.8');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
283
  $options['redirect_lang'] = 0; // option introduced in 0.8
284
  }
285
 
286
+ if (version_compare($options['version'], '0.8.8', '<'))
287
+ flush_rewrite_rules(); // rewrite rules have been modified in 0.8.8
288
 
289
  $options['version'] = POLYLANG_VERSION;
290
  update_option('polylang', $options);
375
  }
376
 
377
  // rewrite rules filtered by language
378
+ elseif ($always_rewrite || (strpos($rule, 'post_type=') && !strpos($rule, 'name=')) || ($current_filter != 'rewrite_rules_array' && $options['force_lang'])) {
379
  if (isset($slug))
380
  $newrules[$slug.str_replace($wp_rewrite->root, '', $key)] = str_replace(array('[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '[1]', '?'),
381
  array('[9]', '[8]', '[7]', '[6]', '[5]', '[4]', '[3]', '[2]', '?lang=$matches[1]&'), $rule); // hopefully it is sufficient !
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Chouby
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CCWWYUUQV8F4E
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, i18n, international, l10n, localization
5
  Requires at least: 3.1
6
- Tested up to: 3.4
7
- Stable tag: 0.8.7
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
@@ -38,6 +38,7 @@ The plugin admin interface is currently available in:
38
  * Italian contributed by [Luca Barbetti](http://wordpress.org/support/profile/lucabarbetti)
39
  * Danish contributed by [Compute](http://wordpress.org/support/profile/compute)
40
  * Spanish contributed by Curro
 
41
 
42
  Special thanks to [@AndyDeGroo](http://twitter.com/AndyDeGroo) and [RavanH](http://4visions.nl/) for their help in debugging and improving Polylang !
43
 
@@ -45,7 +46,7 @@ Other [contributions](http://wordpress.org/extend/plugins/polylang/other_notes/)
45
 
46
  = Feedback or ideas =
47
 
48
- Don't hesitate to [give your feedback](http://wordpress.org/tags/polylang?forum_id=10). It will help making the plugin better. Don't hesitate to rate the plugin too.
49
 
50
  == Installation ==
51
 
@@ -64,8 +65,8 @@ Don't hesitate to [give your feedback](http://wordpress.org/tags/polylang?forum_
64
  = Where to find help ? =
65
 
66
  * Read the [documentation](http://plugins.svn.wordpress.org/polylang/trunk/doc/documentation-en.pdf) supplied whith the plugin (in the doc directory). It includes guidelines to start working with Polylang, a much bigger FAQ than here and the API documentation for programmers.
67
- * Search the [support forum](http://wordpress.org/tags/polylang?forum_id=10). I know that searching in the WordPress forum is not very convenient, but please give it a try. You can use generic search engines such as Google too as the WordPress forum SEO is very good. You will most probably find your answer here.
68
- * If you still have a problem, open a new thread in the [support forum](http://wordpress.org/tags/polylang?forum_id=10).
69
 
70
  = Is Polylang compatible with multisite ? =
71
 
@@ -85,11 +86,11 @@ If you wonder how you can help Polylang, here are some ideas. As you will read,
85
 
86
  = Help other users of Polylang =
87
 
88
- The [support forum](http://wordpress.org/tags/polylang?forum_id=10) is here so that users of the plugin can get help when they need it. However, I will not always be available to answer questions. You don't need to be a developer to help out. Very often similar questions have been answered in the past. You can subscribe to the tag ['polylang'](http://wordpress.org/tags/polylang) (emails or RSS feed, see just below the topic list) to know when a new topic has been posted.
89
 
90
  = Report bugs =
91
 
92
- Don't hesitate to report bugs on the [support forum](http://wordpress.org/tags/polylang?forum_id=10).
93
 
94
  = Test new versions =
95
 
@@ -97,7 +98,7 @@ You can subscribe to the tag ['polylang-dev'](http://wordpress.org/tags/polylang
97
 
98
  = Translate the admin interface =
99
 
100
- Polylang is already available in 12 languages. It's very easy to add a new one ! Download [poedit](http://www.poedit.net/download.php) (available for Windows, Mac OS X and Linux). Rename the file polylang.pot found in the polylang/languages directory into something like polylang-your_locale.po. Open the file with poedit and start translating (keeping strange codes such as %s, %1$s as is). Once done, just save and you will get two files polylang-your_locale.po and polylang-your_locale.mo that you can send to the author. The translation will be included with the next release.
101
 
102
  = Communicate =
103
 
@@ -109,6 +110,18 @@ Every suggestions are welcome.
109
 
110
  == Changelog ==
111
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  = 0.8.7 (2012-06-10) =
113
 
114
  * Add the possibility to load Polylang API for ajax requests on frontend
@@ -145,7 +158,7 @@ Every suggestions are welcome.
145
 
146
  = 0.8.3 (2012-04-10) =
147
 
148
- * Add Danish translation contributed by [Compute]((http://wordpress.org/support/profile/compute)
149
  * Add Spanish translation contributed by Curro
150
  * Add the possibility to add a content in a different language than the current one by setting explicitely the lang parameter in the secondary query
151
  * Add support of PATHINFO permalinks
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CCWWYUUQV8F4E
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, i18n, international, l10n, localization
5
  Requires at least: 3.1
6
+ Tested up to: 3.4.1
7
+ Stable tag: 0.8.8
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
38
  * Italian contributed by [Luca Barbetti](http://wordpress.org/support/profile/lucabarbetti)
39
  * Danish contributed by [Compute](http://wordpress.org/support/profile/compute)
40
  * Spanish contributed by Curro
41
+ * Portuguese contributed by [Vitor Carvalho](http://vcarvalho.com/)
42
 
43
  Special thanks to [@AndyDeGroo](http://twitter.com/AndyDeGroo) and [RavanH](http://4visions.nl/) for their help in debugging and improving Polylang !
44
 
46
 
47
  = Feedback or ideas =
48
 
49
+ Don't hesitate to [give your feedback](http://wordpress.org/support/plugin/polylang). It will help making the plugin better. Don't hesitate to rate the plugin too.
50
 
51
  == Installation ==
52
 
65
  = Where to find help ? =
66
 
67
  * Read the [documentation](http://plugins.svn.wordpress.org/polylang/trunk/doc/documentation-en.pdf) supplied whith the plugin (in the doc directory). It includes guidelines to start working with Polylang, a much bigger FAQ than here and the API documentation for programmers.
68
+ * Search the [support forum](http://wordpress.org/support/plugin/polylang). I know that searching in the WordPress forum is not very convenient, but please give it a try. You can use generic search engines such as Google too as the WordPress forum SEO is very good. You will most probably find your answer here.
69
+ * If you still have a problem, open a new thread in the [support forum](http://wordpress.org/support/plugin/polylang).
70
 
71
  = Is Polylang compatible with multisite ? =
72
 
86
 
87
  = Help other users of Polylang =
88
 
89
+ The [support forum]http://wordpress.org/support/plugin/polylang) is here so that users of the plugin can get help when they need it. However, I will not always be available to answer questions. You don't need to be a developer to help out. Very often similar questions have been answered in the past. You can subscribe to the tag ['polylang'](http://wordpress.org/tags/polylang) (emails or RSS feed, see just below the topic list) to know when a new topic has been posted.
90
 
91
  = Report bugs =
92
 
93
+ Don't hesitate to report bugs on the [support forum](http://wordpress.org/support/plugin/polylang).
94
 
95
  = Test new versions =
96
 
98
 
99
  = Translate the admin interface =
100
 
101
+ Polylang is already available in 13 languages. It's very easy to add a new one ! Download [poedit](http://www.poedit.net/download.php) (available for Windows, Mac OS X and Linux). Rename the file polylang.pot found in the polylang/languages directory into something like polylang-your_locale.po. Open the file with poedit and start translating (keeping strange codes such as %s, %1$s as is). Once done, just save and you will get two files polylang-your_locale.po and polylang-your_locale.mo that you can send to the author. The translation will be included with the next release.
102
 
103
  = Communicate =
104
 
110
 
111
  == Changelog ==
112
 
113
+ = 0.8.8 (2012-07-18) =
114
+
115
+ * Add Portuguese translation contributed by [Vitor Carvalho](http://vcarvalho.com/)
116
+ * Validation improvement thanks to kg69design
117
+ * Bug correction: custom post types rewrite rules are broken when registered with query_var=>false
118
+ * Bug correction: user admin language not deleted when uninstalling the plugin
119
+ * Bug correction: pll_current_language('name') returns locale instead of language name
120
+ * Bug correction: ajax on frontend does not work
121
+ * Bug correction: homepage pagination broken when redirecting the language page to a static front page
122
+ * Bug correction: taxonomies conflicts on custom post types
123
+ * Bug correction: the admin language is not updated when edited by other users
124
+
125
  = 0.8.7 (2012-06-10) =
126
 
127
  * Add the possibility to load Polylang API for ajax requests on frontend
158
 
159
  = 0.8.3 (2012-04-10) =
160
 
161
+ * Add Danish translation contributed by [Compute](http://wordpress.org/support/profile/compute)
162
  * Add Spanish translation contributed by Curro
163
  * Add the possibility to add a content in a different language than the current one by setting explicitely the lang parameter in the secondary query
164
  * Add support of PATHINFO permalinks
uninstall.php CHANGED
@@ -53,6 +53,10 @@ class Polylang_Uninstall {
53
  unset($wpdb->termmeta);
54
  }
55
 
 
 
 
 
56
  // delete options
57
  delete_option('polylang');
58
  delete_option('polylang_nav_menus');
53
  unset($wpdb->termmeta);
54
  }
55
 
56
+ // delete users options
57
+ foreach (get_users(array('fields' => 'ID')) as $user_id)
58
+ delete_user_meta($user_id, 'user_lang');
59
+
60
  // delete options
61
  delete_option('polylang');
62
  delete_option('polylang_nav_menus');