Polylang - Version 1.7.11

Version Description

(2015-10-15) =

  • fix: conflict with GET ajax requests sent by the jquery method load
  • fix: notice in frontend-nav-menu.php at line 211 (introduced in 1.7.10) props Jesse Graupmann
  • fix: the parent list in page attributes metabox is not in the correct language (introduced in 1.7.10)
  • fix: error 404 for attachments
  • fix: the language switcher is not displayed when combining "Forces link to front page" and "Hides languages with no translation"
Download this release

Release Info

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

Code changes from version 1.7.10 to 1.7.11

admin/admin-filters-post.php CHANGED
@@ -75,7 +75,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
75
  }
76
  }
77
  }
78
-
79
  // hierarchical post types
80
  if ('edit' == $screen->base && is_post_type_hierarchical($screen->post_type)) {
81
  $pages = get_pages();
@@ -241,7 +241,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
241
  'echo' => 0,
242
  );
243
  $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); // since WP 3.3
244
-
245
  $x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages( $dropdown_args )));
246
  }
247
 
@@ -261,10 +261,10 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
261
 
262
  if (!post_type_exists($_REQUEST['post_type']))
263
  die(0);
264
-
265
  $post_language = $this->model->get_language($_REQUEST['post_language']);
266
  $translation_language = $this->model->get_language($_REQUEST['translation_language']);
267
-
268
  // don't order by title: see https://wordpress.org/support/topic/find-translated-post-when-10-is-not-enough
269
  $args = array(
270
  's' => wp_unslash($_REQUEST['term']),
@@ -279,7 +279,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
279
  'terms' => $translation_language->term_taxonomy_id
280
  ))
281
  );
282
-
283
  // allow plugins to change args help fixing edge cases: see same topic as above
284
  $args = apply_filters('pll_ajax_posts_not_translated_args', $args);
285
  $posts = get_posts($args);
@@ -328,7 +328,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
328
  // bulk edit does not modify the language
329
  if (isset($_REQUEST['bulk_edit']) && $_REQUEST['inline_lang_choice'] == -1) {
330
  check_admin_referer('bulk-posts');
331
- $lang = $this->model->get_post_language($post_id); // get the post language for later use when saving terms
332
  }
333
  // a language is set in the language dropdown
334
  else {
@@ -354,11 +354,16 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
354
  }
355
  }
356
 
357
- // do not assign a language to 'auto-draft' posts as it would prevent set_default_language to correctly assign the first language
358
- elseif ( 'auto-draft' != $post->post_status ) {
359
- $this->set_default_language($post_id);
 
 
360
  }
361
 
 
 
 
362
  // make sure we get save terms in the right language (especially tags with same name in different languages)
363
  if (!empty($lang)) {
364
 
75
  }
76
  }
77
  }
78
+
79
  // hierarchical post types
80
  if ('edit' == $screen->base && is_post_type_hierarchical($screen->post_type)) {
81
  $pages = get_pages();
241
  'echo' => 0,
242
  );
243
  $dropdown_args = apply_filters( 'page_attributes_dropdown_pages_args', $dropdown_args, $post ); // since WP 3.3
244
+
245
  $x->Add(array('what' => 'pages', 'data' => wp_dropdown_pages( $dropdown_args )));
246
  }
247
 
261
 
262
  if (!post_type_exists($_REQUEST['post_type']))
263
  die(0);
264
+
265
  $post_language = $this->model->get_language($_REQUEST['post_language']);
266
  $translation_language = $this->model->get_language($_REQUEST['translation_language']);
267
+
268
  // don't order by title: see https://wordpress.org/support/topic/find-translated-post-when-10-is-not-enough
269
  $args = array(
270
  's' => wp_unslash($_REQUEST['term']),
279
  'terms' => $translation_language->term_taxonomy_id
280
  ))
281
  );
282
+
283
  // allow plugins to change args help fixing edge cases: see same topic as above
284
  $args = apply_filters('pll_ajax_posts_not_translated_args', $args);
285
  $posts = get_posts($args);
328
  // bulk edit does not modify the language
329
  if (isset($_REQUEST['bulk_edit']) && $_REQUEST['inline_lang_choice'] == -1) {
330
  check_admin_referer('bulk-posts');
331
+ $lang = $this->model->get_post_language($post_id); // get the post language for later use when saving terms
332
  }
333
  // a language is set in the language dropdown
334
  else {
354
  }
355
  }
356
 
357
+ // quick press
358
+ // 'post-quickpress-save', 'post-quickpress-publish' = backward compatibility WP < 3.8
359
+ elseif (isset($_REQUEST['action']) && in_array($_REQUEST['action'], array('post-quickpress-save', 'post-quickpress-publish', 'post-quickdraft-save'))) {
360
+ check_admin_referer('add-' . $post->post_type);
361
+ $this->model->set_post_language($post_id, $lang = $this->pref_lang); // default language for Quick draft
362
  }
363
 
364
+ else
365
+ $this->set_default_language($post_id);
366
+
367
  // make sure we get save terms in the right language (especially tags with same name in different languages)
368
  if (!empty($lang)) {
369
 
admin/admin.php CHANGED
@@ -132,8 +132,15 @@ class PLL_Admin extends PLL_Base {
132
 
133
  /*
134
  * sets pll_ajax_backend on all backend ajax request
135
- * takes care to situations where the ajax request has no options.data thanks to ScreenfeedFr
 
 
 
136
  * see: https://wordpress.org/support/topic/ajaxprefilter-may-not-work-as-expected
 
 
 
 
137
  *
138
  * @since 1.4
139
  */
@@ -145,7 +152,7 @@ class PLL_Admin extends PLL_Base {
145
 
146
  $str = $arr = '';
147
  foreach ($params as $k => $v) {
148
- $str .= $k . '=' . $v . '&';
149
  $arr .= (empty($arr) ? '' : ', ') . $k . ': ' . $v;
150
  }
151
  ?>
@@ -155,17 +162,22 @@ class PLL_Admin extends PLL_Base {
155
  $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
156
  if (options.url.indexOf(ajaxurl) != -1) {
157
  if ( typeof options.data === 'undefined' ) {
158
- options.data = options.type === "get" ? '<?php echo $str;?>' : {<?php echo $arr;?>};
159
  }
160
  else {
161
  if (typeof options.data === "string") {
162
- try {
163
- o = $.parseJSON(options.data);
164
- o = $.extend(o, {<?php echo $arr;?>});
165
- options.data = JSON.stringify(o);
166
  }
167
- catch(e) {
168
- options.data = '<?php echo $str;?>'+options.data;
 
 
 
 
 
 
 
169
  }
170
  }
171
  else {
132
 
133
  /*
134
  * sets pll_ajax_backend on all backend ajax request
135
+ * the final goal is to detect if an ajax request is made on admin or frontend
136
+ *
137
+ * takes care to various situations:
138
+ * when the ajax request has no options.data thanks to ScreenfeedFr
139
  * see: https://wordpress.org/support/topic/ajaxprefilter-may-not-work-as-expected
140
+ * when options.data is a json string
141
+ * see: https://wordpress.org/support/topic/polylang-breaking-third-party-ajax-requests-on-admin-panels
142
+ * when options.data is an empty string (GET request with the method 'load')
143
+ * see: https://wordpress.org/support/topic/invalid-url-during-wordpress-new-dashboard-widget-operation
144
  *
145
  * @since 1.4
146
  */
152
 
153
  $str = $arr = '';
154
  foreach ($params as $k => $v) {
155
+ $str .= ( empty( $str ) ? '' : '&' ) . $k . '=' . $v;
156
  $arr .= (empty($arr) ? '' : ', ') . $k . ': ' . $v;
157
  }
158
  ?>
162
  $.ajaxPrefilter(function (options, originalOptions, jqXHR) {
163
  if (options.url.indexOf(ajaxurl) != -1) {
164
  if ( typeof options.data === 'undefined' ) {
165
+ options.data = options.type.toLowerCase() === "get" ? '<?php echo $str;?>' : {<?php echo $arr;?>};
166
  }
167
  else {
168
  if (typeof options.data === "string") {
169
+ if ( '' === options.data && "get" === options.type.toLowerCase() ) {
170
+ options.url = options.url+'<?php echo '&' . $str;?>';
 
 
171
  }
172
+ else {
173
+ try {
174
+ o = $.parseJSON(options.data);
175
+ o = $.extend(o, {<?php echo $arr;?>});
176
+ options.data = JSON.stringify(o);
177
+ }
178
+ catch(e) {
179
+ options.data = '<?php echo $str . '&';?>'+options.data;
180
+ }
181
  }
182
  }
183
  else {
frontend/frontend-nav-menu.php CHANGED
@@ -202,12 +202,16 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
202
  public function wp_nav_menu_args( $args ) {
203
  $theme = get_option('stylesheet');
204
 
 
 
 
 
205
  // Get the nav menu based on the requested menu
206
  $menu = wp_get_nav_menu_object( $args['menu'] );
207
 
208
  // attempt to find a translation of this menu
209
  // this obviously does not work if the nav menu has no associated theme location
210
- if ( $menu && ! empty( $this->curlang ) ) {
211
  foreach ( $this->options['nav_menus'][ $theme ] as $menus ) {
212
  if ( in_array( $menu->term_id, $menus ) && ! empty( $menus[ $this->curlang->slug ] ) ) {
213
  $args['menu'] = $menus[ $this->curlang->slug ];
@@ -217,7 +221,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
217
  }
218
 
219
  // get the first menu that has items and and is in the current language if we still can't find a menu
220
- if ( ! $menu && ! $args['theme_location'] && ! empty( $this->curlang ) ) {
221
  $menus = wp_get_nav_menus();
222
  foreach ( $menus as $menu_maybe ) {
223
  if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
202
  public function wp_nav_menu_args( $args ) {
203
  $theme = get_option('stylesheet');
204
 
205
+ if ( empty( $this->curlang ) || empty( $this->options['nav_menus'][ $theme ] ) ) {
206
+ return $args;
207
+ }
208
+
209
  // Get the nav menu based on the requested menu
210
  $menu = wp_get_nav_menu_object( $args['menu'] );
211
 
212
  // attempt to find a translation of this menu
213
  // this obviously does not work if the nav menu has no associated theme location
214
+ if ( $menu ) {
215
  foreach ( $this->options['nav_menus'][ $theme ] as $menus ) {
216
  if ( in_array( $menu->term_id, $menus ) && ! empty( $menus[ $this->curlang->slug ] ) ) {
217
  $args['menu'] = $menus[ $this->curlang->slug ];
221
  }
222
 
223
  // get the first menu that has items and and is in the current language if we still can't find a menu
224
+ if ( ! $menu && ! $args['theme_location'] ) {
225
  $menus = wp_get_nav_menus();
226
  foreach ( $menus as $menu_maybe ) {
227
  if ( $menu_items = wp_get_nav_menu_items( $menu_maybe->term_id, array( 'update_post_term_cache' => false ) ) ) {
frontend/frontend.php CHANGED
@@ -101,9 +101,10 @@ class PLL_Frontend extends PLL_Base {
101
  }
102
 
103
  // remove pages query when the language is set unless we do a search
104
- // take care not to break the single page and taxonomies queries!
105
- if (empty($qv['post_type']) && !$query->is_search && !$query->is_page && empty($taxonomies))
106
- $query->set('post_type', 'post');
 
107
 
108
  // unset the is_archive flag for language pages to prevent loading the archive template
109
  // keep archive flag for comment feed otherwise the language filter does not work
101
  }
102
 
103
  // remove pages query when the language is set unless we do a search
104
+ // take care not to break the single page, attachment and taxonomies queries!
105
+ if ( empty( $qv['post_type']) && ! $query->is_search && ! $query->is_page && ! $query->is_attachment && empty( $taxonomies ) ) {
106
+ $query->set( 'post_type', 'post' );
107
+ }
108
 
109
  // unset the is_archive flag for language pages to prevent loading the archive template
110
  // keep archive flag for comment feed otherwise the language filter does not work
include/switcher.php CHANGED
@@ -57,8 +57,12 @@ class PLL_Switcher {
57
  $classes[] = 'current-lang';
58
  }
59
 
60
- $url = $args['post_id'] !== null && ($tr_id = $links->model->get_post($args['post_id'], $language)) && $links->current_user_can_read($tr_id) ? get_permalink($tr_id) :
61
- ($args['post_id'] === null && !$args['force_home'] ? $links->get_translation_url($language) : null);
 
 
 
 
62
 
63
  if ($no_translation = empty($url))
64
  $classes[] = 'no-translation';
@@ -69,7 +73,7 @@ class PLL_Switcher {
69
  if (empty($url) && $args['hide_if_no_translation'])
70
  continue;
71
 
72
- $url = empty($url) ? $links->get_home_url($language) : $url ; // if the page is not translated, link to the home page
73
 
74
  $name = $args['show_names'] || !$args['show_flags'] || $args['raw'] ? ($args['display_names_as'] == 'slug' ? $slug : $language->name) : '';
75
  $flag = $args['raw'] && !$args['show_flags'] ? $language->flag_url : ($args['show_flags'] ? $language->flag : '');
57
  $classes[] = 'current-lang';
58
  }
59
 
60
+ if ( $args['post_id'] !== null && ( $tr_id = $links->model->post->get( $args['post_id'], $language ) ) && $links->current_user_can_read( $tr_id ) ) {
61
+ $url = get_permalink( $tr_id );
62
+ }
63
+ elseif ( $args['post_id'] === null ) {
64
+ $url = $links->get_translation_url( $language );
65
+ }
66
 
67
  if ($no_translation = empty($url))
68
  $classes[] = 'no-translation';
73
  if (empty($url) && $args['hide_if_no_translation'])
74
  continue;
75
 
76
+ $url = empty( $url ) || $args['force_home'] ? $links->get_home_url( $language ) : $url ; // if the page is not translated, link to the home page
77
 
78
  $name = $args['show_names'] || !$args['show_flags'] || $args['raw'] ? ($args['display_names_as'] == 'slug' ? $slug : $language->name) : '';
79
  $flag = $args['raw'] && !$args['show_flags'] ? $language->flag_url : ($args['show_flags'] ? $language->flag : '');
polylang.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: Polylang
4
  Plugin URI: http://polylang.wordpress.com/
5
- Version: 1.7.10
6
  Author: Frédéric Demarle
7
  Author uri: http://polylang.wordpress.com
8
  Description: Adds multilingual capability to WordPress
@@ -34,7 +34,7 @@ Domain Path: /languages
34
  if (!function_exists('add_action'))
35
  exit();
36
 
37
- define('POLYLANG_VERSION', '1.7.10');
38
  define('PLL_MIN_WP_VERSION', '3.9');
39
 
40
  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.7.11
6
  Author: Frédéric Demarle
7
  Author uri: http://polylang.wordpress.com
8
  Description: Adds multilingual capability to WordPress
34
  if (!function_exists('add_action'))
35
  exit();
36
 
37
+ define('POLYLANG_VERSION', '1.7.11');
38
  define('PLL_MIN_WP_VERSION', '3.9');
39
 
40
  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.9
6
  Tested up to: 4.3
7
- Stable tag: 1.7.10
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -24,6 +24,12 @@ Polylang allows you to create a bilingual or multilingual WordPress site. You wr
24
  * A customizable language switcher is provided as a widget or in the nav menu
25
  * The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile
26
 
 
 
 
 
 
 
27
  = Translators =
28
 
29
  The plugin admin interface is currently available in 41 languages:
@@ -66,14 +72,10 @@ The plugin admin interface is currently available in 41 languages:
66
  * Brazilian Portuguese by [Henrique Vianna](http://henriquevianna.com/)
67
  * Georgian by [Tours in Georgia](http://www.georgia-tours.eu/)
68
  * Galician by [Toño Calo](http://fedellar.wordpress.com/)
69
- * Romanian by uskro
70
  * Japanese by [Eiko Toda](http://www.eikotoda.com)
71
  * Occitan by [Cédric Valmary](http://www.totenoc.eu/)
72
 
73
- = Credits =
74
-
75
- Most of the flags included with Polylang are coming from [famfamfam](http://famfamfam.com/) and are public domain. Wherever third party code has been used, credit has been given in the code’s comments.
76
-
77
  = Do you like Polylang? =
78
 
79
  Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-reviews/polylang#postform). It will help making the plugin better. Other [contributions](http://polylang.wordpress.com/documentation/contribute/) (such as new translations or helping other users on the support forum) are welcome !
@@ -112,6 +114,19 @@ See http://polylang.wordpress.com/documentation/contribute/
112
 
113
  == Changelog ==
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  = 1.7.10 (2015-09-28) =
116
 
117
  * Add Occitan translation contributed by [Cédric Valmary](http://www.totenoc.eu/)
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 3.9
6
  Tested up to: 4.3
7
+ Stable tag: 1.7.11
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
24
  * A customizable language switcher is provided as a widget or in the nav menu
25
  * The admin interface is of course multilingual too and each user can set the WordPress admin language in its profile
26
 
27
+ = Credits =
28
+
29
+ Thanks a lot to [Alex Lopez](http://www.alexlopez.rocks/) for the design of the banner and the logo.
30
+ Most of the flags included with Polylang are coming from [famfamfam](http://famfamfam.com/) and are public domain.
31
+ Wherever third party code has been used, credit has been given in the code’s comments.
32
+
33
  = Translators =
34
 
35
  The plugin admin interface is currently available in 41 languages:
72
  * Brazilian Portuguese by [Henrique Vianna](http://henriquevianna.com/)
73
  * Georgian by [Tours in Georgia](http://www.georgia-tours.eu/)
74
  * Galician by [Toño Calo](http://fedellar.wordpress.com/)
75
+ * Romanian by [Philippe C. Focsaneanu](http://www.pandemicdesign.no/)
76
  * Japanese by [Eiko Toda](http://www.eikotoda.com)
77
  * Occitan by [Cédric Valmary](http://www.totenoc.eu/)
78
 
 
 
 
 
79
  = Do you like Polylang? =
80
 
81
  Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-reviews/polylang#postform). It will help making the plugin better. Other [contributions](http://polylang.wordpress.com/documentation/contribute/) (such as new translations or helping other users on the support forum) are welcome !
114
 
115
  == Changelog ==
116
 
117
+ = 1.7.12
118
+
119
+ * The language taxonomy is now public for compatibility with WP 4.4
120
+ * fix: fatal error when using the argument 'post_id' in 'pll_the_languages()' (introduced in 1.7.11) [props EKesty](https://wordpress.org/support/topic/bug-on)
121
+
122
+ = 1.7.11 (2015-10-15) =
123
+
124
+ * fix: conflict with GET ajax requests sent by the jquery method load
125
+ * fix: notice in frontend-nav-menu.php at line 211 (introduced in 1.7.10) [props Jesse Graupmann](https://wordpress.org/support/topic/warning-and-notice-on-upgrade)
126
+ * fix: the parent list in page attributes metabox is not in the correct language (introduced in 1.7.10)
127
+ * fix: error 404 for attachments
128
+ * fix: the language switcher is not displayed when combining "Forces link to front page" and "Hides languages with no translation"
129
+
130
  = 1.7.10 (2015-09-28) =
131
 
132
  * Add Occitan translation contributed by [Cédric Valmary](http://www.totenoc.eu/)