Polylang - Version 1.5.6

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

=

Download this release

Release Info

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

Code changes from version 1.5.5 to 1.5.6

admin/admin-filters-columns.php CHANGED
@@ -36,7 +36,7 @@ class PLL_Admin_Filters_Columns {
36
  // adds the language column in the 'Categories' and 'Post Tags' tables
37
  foreach ($this->model->get_translated_taxonomies() as $tax) {
38
  add_filter('manage_edit-'.$tax.'_columns', array(&$this, 'add_term_column'));
39
- add_action('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);
40
  }
41
 
42
  }
@@ -195,26 +195,26 @@ class PLL_Admin_Filters_Columns {
195
  *
196
  * @since 0.1
197
  *
198
- * @param string $empty not used
199
  * @param string $column column name
200
  * @param int term_id
201
  */
202
- public function term_column($empty, $column, $term_id) {
203
  $inline = defined('DOING_AJAX') && $_REQUEST['action'] == 'inline-save-tax' && isset($_POST['inline_lang_choice']);
204
  if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id)))
205
- return;
206
 
207
  $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit
208
  $taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy'];
209
  $language = $this->model->get_language(substr($column, 9));
210
 
211
  if ($column == $this->get_first_language_column())
212
- printf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($term_id), esc_html($lang->slug));
213
 
214
  $id = ($inline && $lang->slug != $_POST['old_lang']) ? ($language->slug == $lang->slug ? $term_id : 0) : $this->model->get_term($term_id, $language);
215
  // link to edit term (or a translation)
216
  if ($id && $term = get_term($id, $taxonomy)) {
217
- printf('<a class="%1$s" title="%2$s" href="%3$s"></a>',
218
  $id == $term_id ? 'pll_icon_tick' : 'pll_icon_edit',
219
  esc_attr($term->name),
220
  esc_url(get_edit_term_link($id, $taxonomy, $post_type))
@@ -223,10 +223,12 @@ class PLL_Admin_Filters_Columns {
223
 
224
  // link to add a new translation
225
  else {
226
- printf('<a class="pll_icon_add" title="%1$s" href="%2$s"></a>',
227
  __('Add new translation', 'polylang'),
228
  esc_url($this->links->get_new_term_translation_link($term_id, $taxonomy, $post_type, $language))
229
  );
230
  }
 
 
231
  }
232
  }
36
  // adds the language column in the 'Categories' and 'Post Tags' tables
37
  foreach ($this->model->get_translated_taxonomies() as $tax) {
38
  add_filter('manage_edit-'.$tax.'_columns', array(&$this, 'add_term_column'));
39
+ add_filter('manage_'.$tax.'_custom_column', array(&$this, 'term_column'), 10, 3);
40
  }
41
 
42
  }
195
  *
196
  * @since 0.1
197
  *
198
+ * @param string $out
199
  * @param string $column column name
200
  * @param int term_id
201
  */
202
+ public function term_column($out, $column, $term_id) {
203
  $inline = defined('DOING_AJAX') && $_REQUEST['action'] == 'inline-save-tax' && isset($_POST['inline_lang_choice']);
204
  if (false === strpos($column, 'language_') || !($lang = $inline ? $this->model->get_language($_POST['inline_lang_choice']) : $this->model->get_term_language($term_id)))
205
+ return $out;
206
 
207
  $post_type = isset($GLOBALS['post_type']) ? $GLOBALS['post_type'] : $_REQUEST['post_type']; // 2nd case for quick edit
208
  $taxonomy = isset($GLOBALS['taxonomy']) ? $GLOBALS['taxonomy'] : $_REQUEST['taxonomy'];
209
  $language = $this->model->get_language(substr($column, 9));
210
 
211
  if ($column == $this->get_first_language_column())
212
+ $out = sprintf('<div class="hidden" id="lang_%d">%s</div>', esc_attr($term_id), esc_html($lang->slug));
213
 
214
  $id = ($inline && $lang->slug != $_POST['old_lang']) ? ($language->slug == $lang->slug ? $term_id : 0) : $this->model->get_term($term_id, $language);
215
  // link to edit term (or a translation)
216
  if ($id && $term = get_term($id, $taxonomy)) {
217
+ $out .= sprintf('<a class="%1$s" title="%2$s" href="%3$s"></a>',
218
  $id == $term_id ? 'pll_icon_tick' : 'pll_icon_edit',
219
  esc_attr($term->name),
220
  esc_url(get_edit_term_link($id, $taxonomy, $post_type))
223
 
224
  // link to add a new translation
225
  else {
226
+ $out .= sprintf('<a class="pll_icon_add" title="%1$s" href="%2$s"></a>',
227
  __('Add new translation', 'polylang'),
228
  esc_url($this->links->get_new_term_translation_link($term_id, $taxonomy, $post_type, $language))
229
  );
230
  }
231
+
232
+ return $out;
233
  }
234
  }
admin/admin-filters-term.php CHANGED
@@ -458,6 +458,10 @@ class PLL_Admin_Filters_Term {
458
  if (!empty($args['pll_get_terms_not_translated']))
459
  return $clauses;
460
 
 
 
 
 
461
  // The only ajax response I want to deal with is when changing the language in post metabox
462
  if (isset($_POST['action']) && !in_array($_POST['action'], array('post_lang_choice', 'term_lang_choice', 'get-tagcloud')))
463
  return $clauses;
458
  if (!empty($args['pll_get_terms_not_translated']))
459
  return $clauses;
460
 
461
+ // admin language filter for ajax paginate_links in taxonomies metabox in nav menus panel
462
+ if (!empty($_POST['action']) && !empty($this->curlang) && 'menu-get-metabox' == $_POST['action'])
463
+ return $this->model->terms_clauses($clauses, $this->curlang);
464
+
465
  // The only ajax response I want to deal with is when changing the language in post metabox
466
  if (isset($_POST['action']) && !in_array($_POST['action'], array('post_lang_choice', 'term_lang_choice', 'get-tagcloud')))
467
  return $clauses;
frontend/frontend-links.php CHANGED
@@ -203,25 +203,6 @@ class PLL_Frontend_Links extends PLL_Links {
203
  return empty($ok) ? $url : (empty($path) ? rtrim($this->get_home_url($this->curlang), '/') : $this->get_home_url($this->curlang));
204
  }
205
 
206
- /*
207
- * checks if the current user can read the post
208
- *
209
- * @since 1.5
210
- *
211
- * @param int $post_id
212
- * @return bool
213
- */
214
- public function current_user_can_read($post_id) {
215
- $post = get_post($post_id);
216
- if (in_array($post->post_status, get_post_stati(array('public' => true))))
217
- return true;
218
-
219
- $post_type_object = get_post_type_object($post->post_type);
220
- $user = wp_get_current_user();
221
- return is_user_logged_in() && (current_user_can($post_type_object->cap->read_private_posts) || $user->ID == $post->post_author);
222
- }
223
-
224
-
225
  /*
226
  * returns the url of the translation (if exists) of the current page
227
  *
203
  return empty($ok) ? $url : (empty($path) ? rtrim($this->get_home_url($this->curlang), '/') : $this->get_home_url($this->curlang));
204
  }
205
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  /*
207
  * returns the url of the translation (if exists) of the current page
208
  *
include/links-domain.php CHANGED
@@ -36,7 +36,7 @@ class PLL_Links_Domain extends PLL_Links_Model {
36
  */
37
  public function remove_language_from_link($url) {
38
  if (!empty($this->options['domains']))
39
- $url = preg_replace('#^('.implode('|', $this->options['domains']).')#', $this->home , $url);
40
  return $url;
41
  }
42
 
36
  */
37
  public function remove_language_from_link($url) {
38
  if (!empty($this->options['domains']))
39
+ $url = str_replace((is_ssl() ? 'https://' : 'http://') . parse_url($url, PHP_URL_HOST), $this->home, $url);
40
  return $url;
41
  }
42
 
include/links.php CHANGED
@@ -153,5 +153,23 @@ class PLL_Links {
153
 
154
  return add_query_arg($args, admin_url('edit-tags.php'));
155
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
 
153
 
154
  return add_query_arg($args, admin_url('edit-tags.php'));
155
  }
156
+
157
+ /*
158
+ * checks if the current user can read the post
159
+ *
160
+ * @since 1.5
161
+ *
162
+ * @param int $post_id
163
+ * @return bool
164
+ */
165
+ public function current_user_can_read($post_id) {
166
+ $post = get_post($post_id);
167
+ if (in_array($post->post_status, get_post_stati(array('public' => true))))
168
+ return true;
169
+
170
+ $post_type_object = get_post_type_object($post->post_type);
171
+ $user = wp_get_current_user();
172
+ return is_user_logged_in() && (current_user_can($post_type_object->cap->read_private_posts) || $user->ID == $post->post_author);
173
+ }
174
  }
175
 
include/wpml-compat.php CHANGED
@@ -75,7 +75,7 @@ if (!function_exists('icl_get_home_url')) {
75
  if (!function_exists('icl_get_languages')) {
76
  function icl_get_languages($args = '') {
77
  global $polylang;
78
- if (empty($polylang) || empty($polylang->curlang))
79
  return array();
80
 
81
  $args = extract(wp_parse_args($args));
@@ -558,7 +558,9 @@ class PLL_WPML_Config {
558
  protected function register_string_recursive($context, $strings, $options) {
559
  foreach ($options as $name => $value) {
560
  if (isset($strings[$name])) {
561
- if (is_string($value) && $strings[$name] == 1)
 
 
562
  pll_register_string($name, $value, $context);
563
  elseif (is_array($value) && is_array($strings[$name]))
564
  $this->register_string_recursive($context, $strings[$name], $value);
@@ -665,7 +667,9 @@ class PLL_WPML_Config {
665
  protected function translate_strings_recursive($strings, $values) {
666
  foreach ($values as $name => $value) {
667
  if (isset($strings[$name])) {
668
- if (is_string($value) && $strings[$name] == 1)
 
 
669
  $values[$name] = pll__($value);
670
  elseif (is_array($value) && is_array($strings[$name]))
671
  $values[$name] = $this->translate_strings_recursive($strings[$name], $value);
75
  if (!function_exists('icl_get_languages')) {
76
  function icl_get_languages($args = '') {
77
  global $polylang;
78
+ if (empty($polylang) || !($polylang instanceof PLL_Frontend) || empty($polylang->curlang))
79
  return array();
80
 
81
  $args = extract(wp_parse_args($args));
558
  protected function register_string_recursive($context, $strings, $options) {
559
  foreach ($options as $name => $value) {
560
  if (isset($strings[$name])) {
561
+ // allow numeric values to be translated
562
+ // https://wordpress.org/support/topic/wpml-configxml-strings-skipped-when-numbers-ids
563
+ if ((is_numeric($value) || is_string($value)) && $strings[$name] == 1)
564
  pll_register_string($name, $value, $context);
565
  elseif (is_array($value) && is_array($strings[$name]))
566
  $this->register_string_recursive($context, $strings[$name], $value);
667
  protected function translate_strings_recursive($strings, $values) {
668
  foreach ($values as $name => $value) {
669
  if (isset($strings[$name])) {
670
+ // allow numeric values to be translated
671
+ // https://wordpress.org/support/topic/wpml-configxml-strings-skipped-when-numbers-ids
672
+ if ((is_numeric($value) || is_string($value)) && $strings[$name] == 1)
673
  $values[$name] = pll__($value);
674
  elseif (is_array($value) && is_array($strings[$name]))
675
  $values[$name] = $this->translate_strings_recursive($strings[$name], $value);
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
- Version: 1.5.5
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.5.5');
37
  define('PLL_MIN_WP_VERSION', '3.5');
38
 
39
  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.5.6
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.5.6');
37
  define('PLL_MIN_WP_VERSION', '3.5');
38
 
39
  define('POLYLANG_BASENAME', plugin_basename(__FILE__)); // plugin name as known by WP
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.0
7
- Stable tag: 1.5.5
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
@@ -63,11 +63,19 @@ See http://polylang.wordpress.com/documentation/contribute/
63
 
64
  == Upgrade Notice ==
65
 
66
- = 1.5.5 =
67
- 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.5.5
68
 
69
  == Changelog ==
70
 
 
 
 
 
 
 
 
 
71
  = 1.5.5 (2014-09-10) =
72
 
73
  * Fix: missing argument 4 in icl_translate
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 3.5
6
  Tested up to: 4.0
7
+ Stable tag: 1.5.6
8
  License: GPLv2 or later
9
 
10
  Polylang adds multilingual content management support to WordPress.
63
 
64
  == Upgrade Notice ==
65
 
66
+ = 1.5.6 =
67
+ 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.5.6
68
 
69
  == Changelog ==
70
 
71
+ = 1.5.6 (2014-10-11) =
72
+
73
+ * Fix: the admin language filter is not active for paginated taxonomy in nav menu admin panel
74
+ * Fix: wrong redirection if a domain is a substring of another domain (ex: mysite.com and mysite.co)
75
+ * Fix: impossible to translate numeric values in options defined in wpml-config.xml
76
+ * Fix: call to undefined method PLL_Links::get_translation_url() with Avada theme
77
+ * Fix: manage_{$this->screen->taxonomy}_custom_icolumn is a filter and not an action
78
+
79
  = 1.5.5 (2014-09-10) =
80
 
81
  * Fix: missing argument 4 in icl_translate