Polylang - Version 1.4.4

Version Description

Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.4.2

=

Download this release

Release Info

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

Code changes from version 1.4.3 to 1.4.4

admin/admin-filters-post.php CHANGED
@@ -59,14 +59,16 @@ class PLL_Admin_Filters_Post {
59
  return;
60
  }
61
 
62
- // filters the list of media (or wp-links) by language when uploading from post
63
- if (isset($qvars['post_type']) && isset($_REQUEST['pll_post_id']) && $lang = $this->model->get_post_language($_REQUEST['pll_post_id']))
64
- $query->set('lang', $lang->slug);
 
65
 
66
- if (isset($qvars['post_type']) && !isset($qvars['lang']) && !empty($this->curlang))
67
- $qvars['lang'] = $this->curlang->slug;
 
68
 
69
- if (isset($qvars['lang']) && $qvars['lang'] == 'all')
70
  unset ($qvars['lang']);
71
  }
72
 
59
  return;
60
  }
61
 
62
+ if (isset($qvars['post_type']) && !isset($qvars['lang'])) {
63
+ // filters the list of media (or wp-links) by language when uploading from post
64
+ if (isset($_REQUEST['pll_post_id']) && $lang = $this->model->get_post_language($_REQUEST['pll_post_id']))
65
+ $query->set('lang', $lang->slug);
66
 
67
+ elseif (!empty($this->curlang))
68
+ $qvars['lang'] = $this->curlang->slug;
69
+ }
70
 
71
+ if (isset($qvars['lang']) && 'all' === $qvars['lang'])
72
  unset ($qvars['lang']);
73
  }
74
 
admin/admin-filters.php CHANGED
@@ -19,7 +19,7 @@ class PLL_Admin_Filters extends PLL_Filters {
19
  parent::__construct($links_model, $curlang);
20
 
21
  // widgets languages filter
22
- add_action('in_widget_form', array(&$this, 'in_widget_form'));
23
  add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
24
 
25
  // language management for users
@@ -39,7 +39,7 @@ class PLL_Admin_Filters extends PLL_Filters {
39
  *
40
  * @param object $widget
41
  */
42
- public function in_widget_form($widget) {
43
  $dropdown = new PLL_Walker_Dropdown();
44
  printf('<p><label for="%1$s">%2$s %3$s</label></p>',
45
  esc_attr( $widget->id.'_lang_choice'),
@@ -52,7 +52,7 @@ class PLL_Admin_Filters extends PLL_Filters {
52
  array(
53
  'name' => $widget->id.'_lang_choice',
54
  'class' => 'tags-input',
55
- 'selected' => empty($this->options['widgets'][$widget->id]) ? '' : $this->options['widgets'][$widget->id]
56
  )
57
  )
58
  );
@@ -64,15 +64,15 @@ class PLL_Admin_Filters extends PLL_Filters {
64
  *
65
  * @since 0.3
66
  *
67
- * @param array $instance not used
68
  * @param array $new_instance not used
69
  * @param array $old_instance not used
70
  * @param object $widget WP_Widget object
71
- * @return array unmodified $instance
72
  */
73
  public function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
74
- $this->options['widgets'][$widget->id] = $_POST[$widget->id.'_lang_choice'];
75
- update_option('polylang', $this->options);
76
  return $instance;
77
  }
78
 
19
  parent::__construct($links_model, $curlang);
20
 
21
  // widgets languages filter
22
+ add_action('in_widget_form', array(&$this, 'in_widget_form'), 10, 3);
23
  add_filter('widget_update_callback', array(&$this, 'widget_update_callback'), 10, 4);
24
 
25
  // language management for users
39
  *
40
  * @param object $widget
41
  */
42
+ public function in_widget_form($widget, $return, $instance) {
43
  $dropdown = new PLL_Walker_Dropdown();
44
  printf('<p><label for="%1$s">%2$s %3$s</label></p>',
45
  esc_attr( $widget->id.'_lang_choice'),
52
  array(
53
  'name' => $widget->id.'_lang_choice',
54
  'class' => 'tags-input',
55
+ 'selected' => empty($instance['pll_lang']) ? '' : $instance['pll_lang']
56
  )
57
  )
58
  );
64
  *
65
  * @since 0.3
66
  *
67
+ * @param array $instance widget options
68
  * @param array $new_instance not used
69
  * @param array $old_instance not used
70
  * @param object $widget WP_Widget object
71
+ * @return array widget options
72
  */
73
  public function widget_update_callback($instance, $new_instance, $old_instance, $widget) {
74
+ if (!empty($_POST[$widget->id.'_lang_choice']))
75
+ $instance['pll_lang'] = $_POST[$widget->id.'_lang_choice'];
76
  return $instance;
77
  }
78
 
admin/admin-model.php CHANGED
@@ -116,10 +116,17 @@ class PLL_Admin_Model extends PLL_Model {
116
  $this->update_translations($lang->slug);
117
 
118
  // delete language option in widgets
119
- if (!empty($this->options['widgets'])) {
120
- foreach ($this->options['widgets'] as $key => $slug) {
121
- if ($slug == $lang->slug)
122
- unset($this->options['widgets'][$key]);
 
 
 
 
 
 
 
123
  }
124
  }
125
 
@@ -202,10 +209,17 @@ class PLL_Admin_Model extends PLL_Model {
202
  $this->update_translations($old_slug, $slug);
203
 
204
  // update language option in widgets
205
- if (!empty($this->options['widgets'])) {
206
- foreach ($this->options['widgets'] as $key => $lg) {
207
- if ($lg == $old_slug)
208
- $this->options['widgets'][$key] = $slug;
 
 
 
 
 
 
 
209
  }
210
  }
211
 
116
  $this->update_translations($lang->slug);
117
 
118
  // delete language option in widgets
119
+ foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
120
+ if (!empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
121
+ $obj = $widget['callback'][0];
122
+ $number = $widget['params'][0]['number'];
123
+ if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
124
+ $settings = $obj->get_settings();
125
+ if (isset($settings[$number]['pll_lang']) && $settings[$number]['pll_lang'] == $lang->slug) {
126
+ unset($settings[$number]['pll_lang']);
127
+ $obj->save_settings($settings);
128
+ }
129
+ }
130
  }
131
  }
132
 
209
  $this->update_translations($old_slug, $slug);
210
 
211
  // update language option in widgets
212
+ foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
213
+ if (!empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
214
+ $obj = $widget['callback'][0];
215
+ $number = $widget['params'][0]['number'];
216
+ if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
217
+ $settings = $obj->get_settings();
218
+ if (isset($settings[$number]['pll_lang']) && $settings[$number]['pll_lang'] == $old_slug) {
219
+ $settings[$number]['pll_lang'] = $slug;
220
+ $obj->save_settings($settings);
221
+ }
222
+ }
223
  }
224
  }
225
 
admin/admin.php CHANGED
@@ -118,6 +118,7 @@ class PLL_Admin extends PLL_Base {
118
  $str = 'pll_ajax_backend=1&';
119
  $arr = 'pll_ajax_backend: true';
120
 
 
121
  if (!empty($post_ID)) {
122
  $str .= 'pll_post_id=' . (int) $post_ID . '&';
123
  $arr .= ', pll_post_id: ' . (int) $post_ID;
118
  $str = 'pll_ajax_backend=1&';
119
  $arr = 'pll_ajax_backend: true';
120
 
121
+ // FIXME Can I directly send the language from post.js rather than pll_post_id from here?
122
  if (!empty($post_ID)) {
123
  $str .= 'pll_post_id=' . (int) $post_ID . '&';
124
  $arr .= ', pll_post_id: ' . (int) $post_ID;
admin/settings.php CHANGED
@@ -334,7 +334,7 @@ class PLL_Settings {
334
  $widget_settings = $wp_registered_widgets[$widget]['callback'][0]->get_settings();
335
  $number = $wp_registered_widgets[$widget]['params'][0]['number'];
336
  // don't enable widget title translation if the widget is visible in only one language or if there is no title
337
- if (empty($this->options['widgets'][$widget]) && isset($widget_settings[$number]['title']) && $title = $widget_settings[$number]['title'])
338
  $this->register_string(__('Widget title', 'polylang'), $title, 'Widget');
339
  }
340
  }
334
  $widget_settings = $wp_registered_widgets[$widget]['callback'][0]->get_settings();
335
  $number = $wp_registered_widgets[$widget]['params'][0]['number'];
336
  // don't enable widget title translation if the widget is visible in only one language or if there is no title
337
+ if (empty($widget_settings[$number]['pll_lang']) && isset($widget_settings[$number]['title']) && $title = $widget_settings[$number]['title'])
338
  $this->register_string(__('Widget title', 'polylang'), $title, 'Widget');
339
  }
340
  }
frontend/choose-lang-url.php CHANGED
@@ -69,19 +69,24 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
69
  * @since 0.9.6
70
  */
71
  public function check_language_code_in_url() {
 
 
72
  if (is_single() || is_page()) {
73
- global $post;
74
  if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type))
75
  $language = $this->model->get_post_language((int)$post->ID);
76
  }
77
  elseif (is_category() || is_tag() || is_tax()) {
78
- $obj = $GLOBALS['wp_query']->get_queried_object();
79
  if ($this->model->is_translated_taxonomy($obj->taxonomy))
80
  $language = $this->model->get_term_language((int)$obj->term_id);
81
  }
 
 
 
 
82
 
83
  // the language is not correctly set so let's redirect to the correct url for this object
84
- if (!empty($language) && (empty($this->curlang) || $language->slug != $this->curlang->slug)) {
85
  $requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
86
  $redirect_url = $this->links_model->remove_language_from_link($requested_url);
87
  $redirect_url = $this->links_model->add_language_to_link($redirect_url, $language);
69
  * @since 0.9.6
70
  */
71
  public function check_language_code_in_url() {
72
+ global $wp_query, $post;
73
+
74
  if (is_single() || is_page()) {
 
75
  if (isset($post->ID) && $this->model->is_translated_post_type($post->post_type))
76
  $language = $this->model->get_post_language((int)$post->ID);
77
  }
78
  elseif (is_category() || is_tag() || is_tax()) {
79
+ $obj = $wp_query->get_queried_object();
80
  if ($this->model->is_translated_taxonomy($obj->taxonomy))
81
  $language = $this->model->get_term_language((int)$obj->term_id);
82
  }
83
+ elseif ($wp_query->is_posts_page) {
84
+ $obj = $wp_query->get_queried_object();
85
+ $language = $this->model->get_post_language((int)$obj->ID);
86
+ }
87
 
88
  // the language is not correctly set so let's redirect to the correct url for this object
89
+ if (!empty($language)) {
90
  $requested_url = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
91
  $redirect_url = $this->links_model->remove_language_from_link($requested_url);
92
  $redirect_url = $this->links_model->add_language_to_link($redirect_url, $language);
frontend/choose-lang.php CHANGED
@@ -51,7 +51,8 @@ abstract class PLL_Choose_Lang {
51
 
52
  // set a cookie to remember the language. check headers have not been sent to avoid ugly error
53
  // possibility to set PLL_COOKIE to false will disable cookie although it will break some functionalities
54
- if (!headers_sent() && PLL_COOKIE !== false && (!isset($_COOKIE[PLL_COOKIE]) || $_COOKIE[PLL_COOKIE] != $curlang->slug)) {
 
55
  $cookie_domain = 2 == $this->options['force_lang'] ? $this->domain : COOKIE_DOMAIN;
56
  setcookie(PLL_COOKIE, $curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, $cookie_domain);
57
  }
@@ -68,6 +69,10 @@ abstract class PLL_Choose_Lang {
68
  * @return object browser preferred language or default language
69
  */
70
  public function get_preferred_language() {
 
 
 
 
71
  // check first if the user was already browsing this site
72
  if (isset($_COOKIE[PLL_COOKIE]))
73
  return $this->model->get_language($_COOKIE[PLL_COOKIE]);
51
 
52
  // set a cookie to remember the language. check headers have not been sent to avoid ugly error
53
  // possibility to set PLL_COOKIE to false will disable cookie although it will break some functionalities
54
+ // don't set cookie when using multiple domains
55
+ if ($this->options['force_lang'] < 3 && !headers_sent() && PLL_COOKIE !== false && (!isset($_COOKIE[PLL_COOKIE]) || $_COOKIE[PLL_COOKIE] != $curlang->slug)) {
56
  $cookie_domain = 2 == $this->options['force_lang'] ? $this->domain : COOKIE_DOMAIN;
57
  setcookie(PLL_COOKIE, $curlang->slug, time() + 31536000 /* 1 year */, COOKIEPATH, $cookie_domain);
58
  }
69
  * @return object browser preferred language or default language
70
  */
71
  public function get_preferred_language() {
72
+ // multiple domains
73
+ if (3 == $this->options['force_lang'])
74
+ return $this->model->get_language($this->links_model->get_language_from_url());
75
+
76
  // check first if the user was already browsing this site
77
  if (isset($_COOKIE[PLL_COOKIE]))
78
  return $this->model->get_language($_COOKIE[PLL_COOKIE]);
frontend/frontend-filters.php CHANGED
@@ -163,7 +163,7 @@ class PLL_Frontend_Filters extends PLL_Filters{
163
  * @return bool|array false if we hide the widget, unmodified $instance otherwise
164
  */
165
  public function widget_display_callback($instance, $widget) {
166
- return !empty($this->options['widgets'][$widget->id]) && $this->options['widgets'][$widget->id] != $this->curlang->slug ? false : $instance;
167
  }
168
 
169
  /*
163
  * @return bool|array false if we hide the widget, unmodified $instance otherwise
164
  */
165
  public function widget_display_callback($instance, $widget) {
166
+ return !empty($instance['pll_lang']) && $instance['pll_lang'] != $this->curlang->slug ? false : $instance;
167
  }
168
 
169
  /*
include/links-domain.php CHANGED
@@ -81,6 +81,8 @@ class PLL_Links_Domain {
81
  foreach ($this->options['domains'] as $key => $domain)
82
  if ($domain == (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'])
83
  return $key;
 
 
84
  }
85
 
86
  /*
81
  foreach ($this->options['domains'] as $key => $domain)
82
  if ($domain == (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'])
83
  return $key;
84
+
85
+ return $this->options['default_lang'];
86
  }
87
 
88
  /*
include/upgrade.php CHANGED
@@ -88,7 +88,7 @@ class PLL_Upgrade {
88
  * @since 1.2
89
  */
90
  public function _upgrade() {
91
- foreach (array('0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1') as $version)
92
  if (version_compare($this->options['version'], $version, '<'))
93
  call_user_func(array(&$this, 'upgrade_' . str_replace('.', '_', $version)));
94
 
@@ -386,6 +386,25 @@ class PLL_Upgrade {
386
  $this->options['browser'] = $this->options['hide_default'] = 0;
387
  }
388
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
 
390
  /*
391
  * old data were not deleted in 1.2, just in case...
88
  * @since 1.2
89
  */
90
  public function _upgrade() {
91
+ foreach (array('0.9', '1.0', '1.1', '1.2', '1.2.1', '1.2.3', '1.3', '1.4', '1.4.1', '1.4.4') as $version)
92
  if (version_compare($this->options['version'], $version, '<'))
93
  call_user_func(array(&$this, 'upgrade_' . str_replace('.', '_', $version)));
94
 
386
  $this->options['browser'] = $this->options['hide_default'] = 0;
387
  }
388
 
389
+ /*
390
+ * upgrades if the previous version is < 1.4.4
391
+ * uprades widgets options for language filter
392
+ *
393
+ * @since 1.4.4
394
+ */
395
+ protected function upgrade_1_4_4() {
396
+ foreach ($GLOBALS['wp_registered_widgets'] as $widget) {
397
+ if (!empty($this->options['widgets'][$widget['id']]) && !empty($widget['callback'][0]) && !empty($widget['params'][0]['number'])) {
398
+ $obj = $widget['callback'][0];
399
+ if (is_object($obj) && method_exists($obj, 'get_settings') && method_exists($obj, 'save_settings')) {
400
+ $settings = $obj->get_settings();
401
+ $settings[$widget['params'][0]['number']]['pll_lang'] = $this->options['widgets'][$widget['id']];
402
+ $obj->save_settings($settings);
403
+ }
404
+ }
405
+ }
406
+ unset($this->options['widgets']);
407
+ }
408
 
409
  /*
410
  * old data were not deleted in 1.2, just in case...
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
- Version: 1.4.3
6
  Author: Frédéric Demarle
7
  Description: Adds multilingual capability to WordPress
8
  Text Domain: polylang
@@ -29,7 +29,7 @@ Domain Path: /languages
29
  *
30
  */
31
 
32
- define('POLYLANG_VERSION', '1.4.3');
33
  define('PLL_MIN_WP_VERSION', '3.5');
34
 
35
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
+ Version: 1.4.4
6
  Author: Frédéric Demarle
7
  Description: Adds multilingual capability to WordPress
8
  Text Domain: polylang
29
  *
30
  */
31
 
32
+ define('POLYLANG_VERSION', '1.4.4');
33
  define('PLL_MIN_WP_VERSION', '3.5');
34
 
35
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
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, international, localization
5
  Requires at least: 3.5
6
- Tested up to: 3.8
7
- Stable tag: 1.4.3
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
@@ -64,11 +64,18 @@ See http://polylang.wordpress.com/documentation/contribute/
64
 
65
  == Upgrade Notice ==
66
 
67
- = 1.4.2 =
68
  Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.4.2
69
 
70
  == Changelog ==
71
 
 
 
 
 
 
 
 
72
  = 1.4.3 (2014-03-22) =
73
 
74
  * Add: Serbian translation contributed by Sinisa
@@ -77,7 +84,7 @@ Polylang 1.2 introduced major internal changes. More than ever, make a database
77
  * Fix: fatal error with old versions of PHP (tested on PHP 5.2.4)
78
  * Fix: Bad gateway experienced by users hosted by wpengine.com
79
  * Fix: links got from tiny MCE link button are filtered with admin language filter instead of current post language
80
- * Fix: possibly wrong redirection in check_language_code_in_url when using domains or subdomains
81
 
82
  = 1.4.2 (2014-02-24) =
83
 
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, international, localization
5
  Requires at least: 3.5
6
+ Tested up to: 3.9
7
+ Stable tag: 1.4.4
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
64
 
65
  == Upgrade Notice ==
66
 
67
+ = 1.4.4 =
68
  Polylang 1.2 introduced major internal changes. More than ever, make a database backup before upgrading from 1.1.6 or older! If you are using a version older than 0.8, please ugrade to 0.9.8 before ugrading to 1.4.2
69
 
70
  == Changelog ==
71
 
72
+ = 1.4.4 (2014-04-09) =
73
+
74
+ * Add: Compatibility with widgets customizer introduced in WP 3.9
75
+ * Fix: No post in translation dropdown after switching the language in edit post (introduced in 1.4.3)
76
+ * Fix: No canonical redirection when there is no language code in url and the language code is not hidden for the default language
77
+ * Fix: Suppress language cookie when using multiple domains
78
+
79
  = 1.4.3 (2014-03-22) =
80
 
81
  * Add: Serbian translation contributed by Sinisa
84
  * Fix: fatal error with old versions of PHP (tested on PHP 5.2.4)
85
  * Fix: Bad gateway experienced by users hosted by wpengine.com
86
  * Fix: links got from tiny MCE link button are filtered with admin language filter instead of current post language
87
+ * Fix: possibly wrong redirection in check_language_code_in_url when using multiple domains or subdomains
88
 
89
  = 1.4.2 (2014-02-24) =
90