Polylang - Version 1.4.5

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.5

=

Download this release

Release Info

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

Code changes from version 1.4.4 to 1.4.5

admin/admin-filters.php CHANGED
@@ -73,6 +73,9 @@ class PLL_Admin_Filters extends PLL_Filters {
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
 
@@ -142,7 +145,7 @@ class PLL_Admin_Filters extends PLL_Filters {
142
  public function upgrade_languages($version) {
143
  apply_filters('update_feedback', __('Upgrading language files…', 'polylang'));
144
  foreach ($this->model->get_languages_list() as $language)
145
- if ($language->locale != $_POST['locale']) // do not (re)update the language files of a localized WordPress
146
  PLL_Admin::download_mo($language->locale, $version);
147
  }
148
  }
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
+ else
77
+ unset($instance['pll_lang']);
78
+
79
  return $instance;
80
  }
81
 
145
  public function upgrade_languages($version) {
146
  apply_filters('update_feedback', __('Upgrading language files…', 'polylang'));
147
  foreach ($this->model->get_languages_list() as $language)
148
+ if (!empty($_POST['locale']) && $language->locale != $_POST['locale']) // do not (re)update the language files of a localized WordPress
149
  PLL_Admin::download_mo($language->locale, $version);
150
  }
151
  }
admin/settings.php CHANGED
@@ -238,10 +238,11 @@ class PLL_Settings {
238
  $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0;
239
 
240
  // FIXME : TODO error message if not a valid url
241
- if (isset($_POST['domains']) && is_array($_POST['domains'])) {
242
  foreach ($_POST['domains'] as $key => $domain) {
243
  $this->options['domains'][$key] = esc_url_raw(trim($domain));
244
  }
 
245
  }
246
 
247
  foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key)
238
  $this->options[$key] = isset($_POST[$key]) ? (int) $_POST[$key] : 0;
239
 
240
  // FIXME : TODO error message if not a valid url
241
+ if (3 == $this->options['force_lang'] && isset($_POST['domains']) && is_array($_POST['domains'])) {
242
  foreach ($_POST['domains'] as $key => $domain) {
243
  $this->options['domains'][$key] = esc_url_raw(trim($domain));
244
  }
245
+ $this->options['domains'][$this->options['default_lang']] = get_option('home');
246
  }
247
 
248
  foreach (array('browser', 'hide_default', 'redirect_lang', 'media_support') as $key)
frontend/choose-lang-url.php CHANGED
@@ -36,8 +36,10 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
36
  // http://wordpress.org/support/topic/plugin-polylang-language-homepage-redirection-problem-and-solution-but-incomplete?replies=4#post-2729566
37
  if (str_replace('www.', '', home_url('/')) == trailingslashit((is_ssl() ? 'https://' : 'http://').str_replace('www.', '', $_SERVER['HTTP_HOST']).str_replace(array($this->index, '?'.$_SERVER['QUERY_STRING']), array('', ''), $_SERVER['REQUEST_URI']))) {
38
  // take care to post & page preview http://wordpress.org/support/topic/static-frontpage-url-parameter-url-language-information
39
- if (isset($_GET['preview']) && ( (isset($_GET['p']) && $id = $_GET['p']) || (isset($_GET['page_id']) && $id = $_GET['page_id']) ))
40
- $curlang = ($lg = $this->model->get_post_language($id)) ? $lg : $this->model->get_language($this->options['default_lang']);
 
 
41
 
42
  // take care to (unattached) attachments
43
  elseif (isset($_GET['attachment_id']) && $id = $_GET['attachment_id'])
@@ -64,7 +66,7 @@ class PLL_Choose_Lang_Url extends PLL_Choose_lang {
64
 
65
  /*
66
  * if the language code is not in agreement with the language of the content
67
- * redirects incoming links to the proper URL
68
  *
69
  * @since 0.9.6
70
  */
36
  // http://wordpress.org/support/topic/plugin-polylang-language-homepage-redirection-problem-and-solution-but-incomplete?replies=4#post-2729566
37
  if (str_replace('www.', '', home_url('/')) == trailingslashit((is_ssl() ? 'https://' : 'http://').str_replace('www.', '', $_SERVER['HTTP_HOST']).str_replace(array($this->index, '?'.$_SERVER['QUERY_STRING']), array('', ''), $_SERVER['REQUEST_URI']))) {
38
  // take care to post & page preview http://wordpress.org/support/topic/static-frontpage-url-parameter-url-language-information
39
+ if (isset($_GET['preview']) && ( (isset($_GET['p']) && $id = $_GET['p']) || (isset($_GET['page_id']) && $id = $_GET['page_id']) )) {
40
+ $this->set_language(($lg = $this->model->get_post_language($id)) ? $lg : $this->model->get_language($this->options['default_lang']));
41
+ return; // don't check the language code in url
42
+ }
43
 
44
  // take care to (unattached) attachments
45
  elseif (isset($_GET['attachment_id']) && $id = $_GET['attachment_id'])
66
 
67
  /*
68
  * if the language code is not in agreement with the language of the content
69
+ * redirects incoming links to the proper URL to avoid duplicate content
70
  *
71
  * @since 0.9.6
72
  */
include/links-directory.php CHANGED
@@ -70,7 +70,7 @@ class PLL_Links_Directory {
70
 
71
  if (!empty($languages)) {
72
  global $wp_rewrite;
73
- $pattern = '#' . ($this->options['rewrite'] ? '' : '\/language') . '\/('.implode('|', $languages).')\/#';
74
  $url = preg_replace($pattern, $wp_rewrite->root . '/', $url);
75
  }
76
  return $url;
@@ -99,7 +99,7 @@ class PLL_Links_Directory {
99
  */
100
  public function get_language_from_url() {
101
  $root = $this->options['rewrite'] ? '' : 'language/';
102
- $pattern = '#\/'.$root.'('.implode('|', $this->model->get_languages_list(array('fields' => 'slug'))).')\/#';
103
  return preg_match($pattern, trailingslashit($_SERVER['REQUEST_URI']), $matches) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
104
  }
105
 
70
 
71
  if (!empty($languages)) {
72
  global $wp_rewrite;
73
+ $pattern = '#' . ($this->options['rewrite'] ? '' : '\/language') . '\/('.implode('|', $languages).')(\/|$)#';
74
  $url = preg_replace($pattern, $wp_rewrite->root . '/', $url);
75
  }
76
  return $url;
99
  */
100
  public function get_language_from_url() {
101
  $root = $this->options['rewrite'] ? '' : 'language/';
102
+ $pattern = '#\/'.$root.'('.implode('|', $this->model->get_languages_list(array('fields' => 'slug'))).')(\/|$)#';
103
  return preg_match($pattern, trailingslashit($_SERVER['REQUEST_URI']), $matches) ? $matches[1] : ''; // $matches[1] is the slug of the requested language
104
  }
105
 
include/links-domain.php CHANGED
@@ -36,8 +36,8 @@ class PLL_Links_Domain {
36
  * @return string modified url
37
  */
38
  public function add_language_to_link($url, $lang) {
39
- if (!empty($lang))
40
- $url = $this->options['default_lang'] == $lang->slug ? $url : str_replace($this->home, $this->options['domains'][$lang->slug], $url);
41
  return $url;
42
  }
43
 
@@ -95,11 +95,6 @@ class PLL_Links_Domain {
95
  * @return string
96
  */
97
  function home_url($lang) {
98
- if ($lang->slug == $this->options['default_lang'])
99
- return $this->home;
100
-
101
- if (!empty($this->options['domains'][$lang->slug]))
102
- return $this->options['domains'][$lang->slug];
103
-
104
  }
105
  }
36
  * @return string modified url
37
  */
38
  public function add_language_to_link($url, $lang) {
39
+ if (!empty($lang) && !empty($this->options['domains'][$lang->slug]))
40
+ $url = str_replace($this->home, $this->options['domains'][$lang->slug], $url);
41
  return $url;
42
  }
43
 
95
  * @return string
96
  */
97
  function home_url($lang) {
98
+ return empty($this->options['domains'][$lang->slug]) ? $this->home : $this->options['domains'][$lang->slug];
 
 
 
 
 
99
  }
100
  }
include/plugins-compat.php CHANGED
@@ -78,7 +78,8 @@ class PLL_Plugins_Compat {
78
  public function wpseo_translate_options() {
79
  if (defined('WPSEO_VERSION') && !PLL_ADMIN && did_action('wp_loaded')) {
80
  global $wpseo_front;
81
- foreach ( get_wpseo_options_arr() as $opt )
 
82
  $wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
83
  }
84
  }
@@ -179,8 +180,8 @@ class PLL_Plugins_Compat {
179
  */
180
  public function twenty_fourteen_widgets_init() {
181
  // overwrites the Twenty Fourteen Ephemera widget to allow translating strings when setting the language by content
182
- // FIXME should be removed when WP >= 3.9 See http://core.trac.wordpress.org/ticket/27069
183
- if (class_exists('Twenty_Fourteen_Ephemera_Widget')) {
184
  unregister_widget('Twenty_Fourteen_Ephemera_Widget');
185
  register_widget('PLL_Widget_Twenty_Fourteen_Ephemera');
186
  }
78
  public function wpseo_translate_options() {
79
  if (defined('WPSEO_VERSION') && !PLL_ADMIN && did_action('wp_loaded')) {
80
  global $wpseo_front;
81
+ $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names();
82
+ foreach ( $options as $opt )
83
  $wpseo_front->options = array_merge( $wpseo_front->options, (array) get_option( $opt ) );
84
  }
85
  }
180
  */
181
  public function twenty_fourteen_widgets_init() {
182
  // overwrites the Twenty Fourteen Ephemera widget to allow translating strings when setting the language by content
183
+ // removed when WP >= 3.9 See http://core.trac.wordpress.org/ticket/27069 & https://core.trac.wordpress.org/ticket/27843
184
+ if (class_exists('Twenty_Fourteen_Ephemera_Widget') && !current_theme_supports( 'html5', 'gallery' )) {
185
  unregister_widget('Twenty_Fourteen_Ephemera_Widget');
186
  register_widget('PLL_Widget_Twenty_Fourteen_Ephemera');
187
  }
polylang.php CHANGED
@@ -2,7 +2,7 @@
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,7 +29,7 @@ Domain Path: /languages
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
@@ -85,8 +85,9 @@ class Polylang {
85
  return;
86
 
87
  // avoid loading polylang admin for frontend ajax requests
 
88
  if (!defined('PLL_AJAX_ON_FRONT'))
89
- define('PLL_AJAX_ON_FRONT', defined('DOING_AJAX') && DOING_AJAX && empty($_REQUEST['pll_ajax_backend']));
90
 
91
  if (!defined('PLL_ADMIN'))
92
  define('PLL_ADMIN', defined('DOING_CRON') || (is_admin() && !PLL_AJAX_ON_FRONT));
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
+ Version: 1.4.5
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.5');
33
  define('PLL_MIN_WP_VERSION', '3.5');
34
 
35
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
85
  return;
86
 
87
  // avoid loading polylang admin for frontend ajax requests
88
+ // special test for plupload which does not use jquery ajax and thus does not pass our ajax prefilter
89
  if (!defined('PLL_AJAX_ON_FRONT'))
90
+ define('PLL_AJAX_ON_FRONT', defined('DOING_AJAX') && DOING_AJAX && empty($_REQUEST['pll_ajax_backend']) && !(isset( $_REQUEST['action'] ) && 'upload-attachment' === $_REQUEST['action']));
91
 
92
  if (!defined('PLL_ADMIN'))
93
  define('PLL_ADMIN', defined('DOING_CRON') || (is_admin() && !PLL_AJAX_ON_FRONT));
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: 3.9
7
- Stable tag: 1.4.4
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
@@ -64,11 +64,21 @@ See http://polylang.wordpress.com/documentation/contribute/
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
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.5
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
64
 
65
  == Upgrade Notice ==
66
 
67
+ = 1.4.5 =
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.5
69
 
70
  == Changelog ==
71
 
72
+ = 1.4.5 (2014-04-19) =
73
+
74
+ * Fix: Notice when combined with WPSEO 1.5+
75
+ * Fix: Impossible to disable a widget language filter once set (introduced in 1.4.4)
76
+ * Fix: Unexpected redirection of the homepage with language code when permalink structure has no trailing slash (introduced in 1.4.4)
77
+ * Fix: Some installs lead to wrong redirection when using domains (introduced in 1.4.4)
78
+ * Fix: Possible infinite redirection while previewing posts (introduced in 1.4.4)
79
+ * Fix: Uploaded medias don't get a language since WP 3.9
80
+ * Fix: Compatibility with Twenty Fourteen Ephemera widget in the version shipped with WP 3.9
81
+
82
  = 1.4.4 (2014-04-09) =
83
 
84
  * Add: Compatibility with widgets customizer introduced in WP 3.9