Polylang - Version 0.8.6

Version Description

(2012-05-23) =

  • Add the possibility to use a local config file to set options
  • Improve robustness (less PHP notices)
  • Bug correction: Menus not showing in preview mode
  • Bug correction: fatal error when customizing a theme in WP 3.4 beta 4
  • Bug correction: second page of search results returns 404 when using pretty permalinks
Download this release

Release Info

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

Code changes from version 0.8.4 to 0.8.6

doc/documentation-en.odt CHANGED
Binary file
doc/documentation-en.pdf CHANGED
Binary file
include/admin-filters.php CHANGED
@@ -301,6 +301,9 @@ class Polylang_Admin_Filters extends Polylang_Admin_Base {
301
  // filters the pages by language in the parent dropdown list in the page attributes metabox
302
  function page_attributes_dropdown_pages_args($dropdown_args, $post) {
303
  $lang = isset($_POST['lang']) ? $this->get_language($_POST['lang']) : $this->get_post_language($post->ID); // ajax or not ?
 
 
 
304
  $pages = implode(',', $this->exclude_pages($lang->term_id));
305
  $dropdown_args['exclude'] = isset($dropdown_args['exclude']) ? $dropdown_args['exclude'].','.$pages : $pages;
306
  return $dropdown_args;
@@ -404,7 +407,7 @@ class Polylang_Admin_Filters extends Polylang_Admin_Base {
404
 
405
  // save translations after checking the translated post is in the right language
406
  foreach ($_POST['post_tr_lang'] as $lang=>$tr_id)
407
- $translations[$lang] = $this->get_post_language((int) $tr_id)->slug == $lang ? (int) $tr_id : 0;
408
 
409
  $this->save_translations('post', $post_id, $translations);
410
 
@@ -744,7 +747,7 @@ class Polylang_Admin_Filters extends Polylang_Admin_Base {
744
 
745
  // FIXME remove the customize menu section as it is currently unusable with Polylang
746
  function customize_register() {
747
- $GLOBALS['customize']->remove_section('nav'); // since WP 3.4
748
  }
749
 
750
  // modifies the widgets forms to add our language dropdwown list
301
  // filters the pages by language in the parent dropdown list in the page attributes metabox
302
  function page_attributes_dropdown_pages_args($dropdown_args, $post) {
303
  $lang = isset($_POST['lang']) ? $this->get_language($_POST['lang']) : $this->get_post_language($post->ID); // ajax or not ?
304
+ if (!$lang)
305
+ $lang = $this->get_language($this->options['default_lang']);
306
+
307
  $pages = implode(',', $this->exclude_pages($lang->term_id));
308
  $dropdown_args['exclude'] = isset($dropdown_args['exclude']) ? $dropdown_args['exclude'].','.$pages : $pages;
309
  return $dropdown_args;
407
 
408
  // save translations after checking the translated post is in the right language
409
  foreach ($_POST['post_tr_lang'] as $lang=>$tr_id)
410
+ $translations[$lang] = ($tr_id && $this->get_post_language((int) $tr_id)->slug == $lang) ? (int) $tr_id : 0;
411
 
412
  $this->save_translations('post', $post_id, $translations);
413
 
747
 
748
  // FIXME remove the customize menu section as it is currently unusable with Polylang
749
  function customize_register() {
750
+ $GLOBALS['wp_customize']->remove_section('nav'); // since WP 3.4
751
  }
752
 
753
  // modifies the widgets forms to add our language dropdwown list
include/base.php CHANGED
@@ -142,11 +142,12 @@ abstract class Polylang_Base {
142
 
143
  // among the term and its translations, returns the id of the term which is in $lang
144
  function get_term($term_id, $lang) {
145
- if (!$lang)
 
146
  return '';
147
 
148
  $lang = $this->get_language($lang);
149
- return $this->get_term_language($term_id)->term_id == $lang->term_id ? $term_id : $this->get_translation('term', $term_id, $lang);
150
  }
151
 
152
  // adds language information to a link when using pretty permalinks
142
 
143
  // among the term and its translations, returns the id of the term which is in $lang
144
  function get_term($term_id, $lang) {
145
+ $lg = $this->get_term_language($term_id);
146
+ if (!$lang || !$lg || $lg == null) // FIXME should be more consistent in returned values
147
  return '';
148
 
149
  $lang = $this->get_language($lang);
150
+ return $lg->term_id == $lang->term_id ? $term_id : $this->get_translation('term', $term_id, $lang);
151
  }
152
 
153
  // adds language information to a link when using pretty permalinks
include/core.php CHANGED
@@ -256,16 +256,14 @@ class Polylang_Core extends Polylang_base {
256
  isset($qvars['tax_query'][0]['operator']) && $qvars['tax_query'][0]['operator'] == 'NOT IN')
257
  return;
258
 
259
- // homepage is requested, let's set the language
260
- if (is_home() && !$this->curlang) {
261
- // special case for wp-signup.php & wp-activate.php for which WP set is_home to true
262
- if (false === strpos($_SERVER['SCRIPT_NAME'], 'index.php')) {
263
- $this->curlang = $this->get_preferred_language();
264
- return;
265
- }
266
 
267
- // now, it should be the true homepage
268
- // find out the language
269
  if ($this->options['hide_default'] && isset($_COOKIE['wordpress_polylang']))
270
  $this->curlang = $this->get_language($this->options['default_lang']);
271
  else
@@ -359,8 +357,8 @@ class Polylang_Core extends Polylang_base {
359
  }
360
 
361
  // sets a language for theme preview
362
- if (isset($_GET['preview']))
363
- $query->set('lang', $this->options['default_lang']);
364
 
365
  if (PLL_DISPLAY_ALL) {
366
  // add posts with no language set
@@ -619,7 +617,10 @@ class Polylang_Core extends Polylang_base {
619
  $theme = get_theme_root();
620
  foreach (debug_backtrace() as $trace) {
621
  $ok = $trace['function'] == 'wp_nav_menu' ||
 
 
622
  // direct call from the theme
 
623
  (isset($trace['file']) && !strpos($trace['file'], 'searchform.php') && strpos($trace['file'], $theme) !== false &&
624
  in_array($trace['function'], array('home_url', 'bloginfo', 'get_bloginfo')) );
625
 
256
  isset($qvars['tax_query'][0]['operator']) && $qvars['tax_query'][0]['operator'] == 'NOT IN')
257
  return;
258
 
259
+ // special case for wp-signup.php & wp-activate.php
260
+ if (is_home() && false === strpos($_SERVER['SCRIPT_NAME'], 'index.php')) {
261
+ $this->curlang = $this->get_preferred_language();
262
+ return;
263
+ }
 
 
264
 
265
+ // homepage is requested, let's set the language
266
+ if (!$this->curlang && ((is_home() && !$this->page_for_posts) || (empty($query->query) && is_page() && $qvars['page_id'] == $this->page_on_front))) {
267
  if ($this->options['hide_default'] && isset($_COOKIE['wordpress_polylang']))
268
  $this->curlang = $this->get_language($this->options['default_lang']);
269
  else
357
  }
358
 
359
  // sets a language for theme preview
360
+ if ($qvars['preview'])
361
+ $query->set('lang', $this->curlang->slug);
362
 
363
  if (PLL_DISPLAY_ALL) {
364
  // add posts with no language set
617
  $theme = get_theme_root();
618
  foreach (debug_backtrace() as $trace) {
619
  $ok = $trace['function'] == 'wp_nav_menu' ||
620
+ // search form when using pretty permalinks
621
+ ($trace['function'] == 'get_search_form' || (isset($trace['file']) && strpos($trace['file'], 'searchform.php'))) ||
622
  // direct call from the theme
623
+ // FIXME is test of searchform.php necessary now ?
624
  (isset($trace['file']) && !strpos($trace['file'], 'searchform.php') && strpos($trace['file'], $theme) !== false &&
625
  in_array($trace['function'], array('home_url', 'bloginfo', 'get_bloginfo')) );
626
 
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.4
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.4');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
@@ -38,6 +38,9 @@ if (!defined('PLL_LOCAL_DIR'))
38
  if (!defined('PLL_LOCAL_URL'))
39
  define('PLL_LOCAL_URL', WP_CONTENT_URL.'/polylang'); // default url to access user data such as custom flags
40
 
 
 
 
41
  if (!defined('PLL_DISPLAY_ABOUT'))
42
  define('PLL_DISPLAY_ABOUT', true); // displays the "About Polylang" metabox by default
43
 
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://wordpress.org/extend/plugins/polylang/
5
+ Version: 0.8.6
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.6');
28
  define('PLL_MIN_WP_VERSION', '3.1');
29
 
30
  define('POLYLANG_DIR', dirname(__FILE__)); // our directory
38
  if (!defined('PLL_LOCAL_URL'))
39
  define('PLL_LOCAL_URL', WP_CONTENT_URL.'/polylang'); // default url to access user data such as custom flags
40
 
41
+ if (file_exists(PLL_LOCAL_DIR.'/pll-config.php'))
42
+ include_once(PLL_LOCAL_DIR.'/pll-config.php'); // includes local config file if exists
43
+
44
  if (!defined('PLL_DISPLAY_ABOUT'))
45
  define('PLL_DISPLAY_ABOUT', true); // displays the "About Polylang" metabox by default
46
 
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, i18n, international, l10n, localization
5
  Requires at least: 3.1
6
  Tested up to: 3.4
7
- Stable tag: 0.8.4
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
@@ -36,7 +36,7 @@ The plugin admin interface is currently available in:
36
  * Polish contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
37
  * Latvian contributed by [@AndyDeGroo](http://twitter.com/AndyDeGroo)
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 !
@@ -109,6 +109,18 @@ Every suggestions are welcome.
109
 
110
  == Changelog ==
111
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  = 0.8.4 (2012-05-13) =
113
 
114
  * Add a new argument 'post_id' to the function pll_the_languages to display posts translations within the loop
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.6
8
 
9
  Polylang adds multilingual content management support to WordPress.
10
 
36
  * Polish contributed by [Peter Paciorkiewicz](http://www.paciorkiewicz.pl)
37
  * Latvian contributed by [@AndyDeGroo](http://twitter.com/AndyDeGroo)
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 !
109
 
110
  == Changelog ==
111
 
112
+ = 0.8.6 (2012-05-23) =
113
+
114
+ * Add the possibility to use a local config file to set options
115
+ * Improve robustness (less PHP notices)
116
+ * Bug correction: Menus not showing in preview mode
117
+ * Bug correction: fatal error when customizing a theme in WP 3.4 beta 4
118
+ * Bug correction: second page of search results returns 404 when using pretty permalinks
119
+
120
+ = 0.8.5 (2012-05-14) =
121
+
122
+ * Bug correction : sites using static front page are messed in v0.8.4
123
+
124
  = 0.8.4 (2012-05-13) =
125
 
126
  * Add a new argument 'post_id' to the function pll_the_languages to display posts translations within the loop