Polylang - Version 2.1.5

Version Description

(2017-05-31) =

  • Add compatibility with new media widgets introduced in WP 4.8
  • Removing the language information in URL for the default language is now default
  • Update plugin updater class to 1.6.12
  • Pro: fix PHP notices when duplicating the content
  • Fix: test existence of twentyseventeen_panel_count instead of relying only on the active template
  • Fix: set current property to false when removing the current-menu-item class #134 props @mowar
  • Fix PHP notice when editing a term without language
  • Fix possible PHP notice when deleting a category
  • Fix fatal error with Gantry 5
Download this release

Release Info

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

Code changes from version 2.1.4 to 2.1.5

admin/admin-filters-term.php CHANGED
@@ -112,15 +112,18 @@ class PLL_Admin_Filters_Term {
112
  * @since 0.1
113
  */
114
  public function edit_term_form( $tag ) {
115
- $term_id = $tag->term_id;
116
- $lang = $this->model->term->get_language( $term_id );
117
- $taxonomy = $tag->taxonomy;
118
  $post_type = isset( $GLOBALS['post_type'] ) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
119
 
120
  if ( ! post_type_exists( $post_type ) ) {
121
  return;
122
  }
123
 
 
 
 
 
 
 
124
  $dropdown = new PLL_Walker_Dropdown();
125
 
126
  // Disable the language dropdown and the translations input fields for default categories to prevent removal
@@ -165,10 +168,13 @@ class PLL_Admin_Filters_Term {
165
  * @return string modified html
166
  */
167
  public function wp_dropdown_cats( $output ) {
168
- if ( isset( $_GET['taxonomy'], $_GET['from_tag'], $_GET['new_lang'] ) && taxonomy_exists( $_GET['taxonomy'] ) && $id = get_term( (int) $_GET['from_tag'], $_GET['taxonomy'] )->parent ) {
169
- $lang = $this->model->get_language( $_GET['new_lang'] );
170
- if ( $parent = $this->model->term->get_translation( $id, $lang ) ) {
171
- return str_replace( '"'.$parent.'"', '"'.$parent.'" selected="selected"', $output );
 
 
 
172
  }
173
  }
174
  return $output;
112
  * @since 0.1
113
  */
114
  public function edit_term_form( $tag ) {
 
 
 
115
  $post_type = isset( $GLOBALS['post_type'] ) ? $GLOBALS['post_type'] : $_REQUEST['post_type'];
116
 
117
  if ( ! post_type_exists( $post_type ) ) {
118
  return;
119
  }
120
 
121
+ $term_id = $tag->term_id;
122
+ $taxonomy = $tag->taxonomy;
123
+
124
+ $lang = $this->model->term->get_language( $term_id );
125
+ $lang = empty( $lang ) ? $this->pref_lang : $lang;
126
+
127
  $dropdown = new PLL_Walker_Dropdown();
128
 
129
  // Disable the language dropdown and the translations input fields for default categories to prevent removal
168
  * @return string modified html
169
  */
170
  public function wp_dropdown_cats( $output ) {
171
+ if ( isset( $_GET['taxonomy'], $_GET['from_tag'], $_GET['new_lang'] ) && taxonomy_exists( $_GET['taxonomy'] ) ) {
172
+ $term = get_term( (int) $_GET['from_tag'], $_GET['taxonomy'] );
173
+ if ( $term && $id = $term->parent ) {
174
+ $lang = $this->model->get_language( $_GET['new_lang'] );
175
+ if ( $parent = $this->model->term->get_translation( $id, $lang ) ) {
176
+ return str_replace( '"' . $parent . '"', '"' . $parent . '" selected="selected"', $output );
177
+ }
178
  }
179
  }
180
  return $output;
frontend/frontend-filters.php CHANGED
@@ -41,6 +41,12 @@ class PLL_Frontend_Filters extends PLL_Filters{
41
  add_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10, 2 );
42
  add_filter( 'sidebars_widgets', array( $this, 'sidebars_widgets' ) );
43
 
 
 
 
 
 
 
44
  // Strings translation ( must be applied before WordPress applies its default formatting filters )
45
  foreach ( array( 'widget_text', 'widget_title', 'option_blogname', 'option_blogdescription', 'option_date_format', 'option_time_format' ) as $filter ) {
46
  add_filter( $filter, 'pll__', 1 );
@@ -228,7 +234,7 @@ class PLL_Frontend_Filters extends PLL_Filters{
228
  foreach ( $widgets as $key => $widget ) {
229
  // Nothing can be done if the widget is created using pre WP2.8 API :(
230
  // There is no object, so we can't access it to get the widget options
231
- if ( ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' ) ) {
232
  continue;
233
  }
234
 
@@ -245,6 +251,34 @@ class PLL_Frontend_Filters extends PLL_Filters{
245
  return $sidebars_widgets;
246
  }
247
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  /**
249
  * Translates biography
250
  *
41
  add_filter( 'widget_display_callback', array( $this, 'widget_display_callback' ), 10, 2 );
42
  add_filter( 'sidebars_widgets', array( $this, 'sidebars_widgets' ) );
43
 
44
+ if ( $this->options['media_support'] ) {
45
+ foreach ( array( 'audio', 'image', 'video' ) as $media ) {
46
+ add_filter( "widget_media_{$media}_instance", array( $this, 'widget_media_instance' ), 1 ); // Since WP 4.8
47
+ }
48
+ }
49
+
50
  // Strings translation ( must be applied before WordPress applies its default formatting filters )
51
  foreach ( array( 'widget_text', 'widget_title', 'option_blogname', 'option_blogdescription', 'option_date_format', 'option_time_format' ) as $filter ) {
52
  add_filter( $filter, 'pll__', 1 );
234
  foreach ( $widgets as $key => $widget ) {
235
  // Nothing can be done if the widget is created using pre WP2.8 API :(
236
  // There is no object, so we can't access it to get the widget options
237
+ if ( ! isset( $wp_registered_widgets[ $widget ]['callback'] ) || ! is_array( $wp_registered_widgets[ $widget ]['callback'] ) || ! isset( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! is_object( $wp_registered_widgets[ $widget ]['callback'][0] ) || ! method_exists( $wp_registered_widgets[ $widget ]['callback'][0], 'get_settings' ) ) {
238
  continue;
239
  }
240
 
251
  return $sidebars_widgets;
252
  }
253
 
254
+ /**
255
+ * Translates media in media widgets
256
+ *
257
+ * @since 2.1.5
258
+ *
259
+ * @param array $instance Widget instance data
260
+ * @return array
261
+ */
262
+ public function widget_media_instance( $instance ) {
263
+ if ( empty( $instance['pll_lang'] ) && $instance['attachment_id'] && $tr_id = pll_get_post( $instance['attachment_id'] ) ) {
264
+ $instance['attachment_id'] = $tr_id;
265
+ $attachment = get_post( $tr_id );
266
+
267
+ if ( $instance['caption'] && ! empty( $attachment->post_excerpt ) ) {
268
+ $instance['caption'] = $attachment->post_excerpt;
269
+ }
270
+
271
+ if ( $instance['alt'] && $alt_text = get_post_meta( $tr_id, '_wp_attachment_image_alt', true ) ) {
272
+ $instance['alt'] = $alt_text;
273
+ }
274
+
275
+ if ( $instance['image_title'] && ! empty( $attachment->post_title ) ) {
276
+ $instance['image_title'] = $attachment->post_title;
277
+ }
278
+ }
279
+ return $instance;
280
+ }
281
+
282
  /**
283
  * Translates biography
284
  *
frontend/frontend-nav-menu.php CHANGED
@@ -138,6 +138,7 @@ class PLL_Frontend_Nav_Menu extends PLL_Nav_Menu {
138
  foreach ( $items as $item ) {
139
  if ( ! empty( $item->classes ) && is_array( $item->classes ) ) {
140
  if ( in_array( 'current-lang', $item->classes ) ) {
 
141
  $item->classes = array_diff( $item->classes, array( 'current-menu-item' ) );
142
  $r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); // Remove the classes for these ancestors
143
  } elseif ( in_array( 'current-menu-item', $item->classes ) ) {
138
  foreach ( $items as $item ) {
139
  if ( ! empty( $item->classes ) && is_array( $item->classes ) ) {
140
  if ( in_array( 'current-lang', $item->classes ) ) {
141
+ $item->current = false;
142
  $item->classes = array_diff( $item->classes, array( 'current-menu-item' ) );
143
  $r_ids = array_merge( $r_ids, $this->get_ancestors( $item ) ); // Remove the classes for these ancestors
144
  } elseif ( in_array( 'current-menu-item', $item->classes ) ) {
install/install.php CHANGED
@@ -40,14 +40,14 @@ class PLL_Install extends PLL_Install_Base {
40
  */
41
  static public function get_default_options() {
42
  return array(
43
- 'browser' => 1, // default language for the front page is set by browser preference
44
- 'rewrite' => 1, // remove /language/ in permalinks ( was the opposite before 0.7.2 )
45
- 'hide_default' => 0, // do not remove URL language information for default language
46
- 'force_lang' => 1, // add URL language information ( was 0 before 1.7 )
47
- 'redirect_lang' => 0, // do not redirect the language page to the homepage
48
- 'media_support' => 1, // support languages and translation for media by default
49
- 'uninstall' => 0, // do not remove data when uninstalling Polylang
50
- 'sync' => array(), // synchronisation is disabled by default ( was the opposite before 1.2 )
51
  'post_types' => array(),
52
  'taxonomies' => array(),
53
  'domains' => array(),
40
  */
41
  static public function get_default_options() {
42
  return array(
43
+ 'browser' => 1, // Default language for the front page is set by browser preference
44
+ 'rewrite' => 1, // Remove /language/ in permalinks ( was the opposite before 0.7.2 )
45
+ 'hide_default' => 1, // Remove URL language information for default language ( was the opposite before 2.1.5 )
46
+ 'force_lang' => 1, // Add URL language information ( was 0 before 1.7 )
47
+ 'redirect_lang' => 0, // Do not redirect the language page to the homepage
48
+ 'media_support' => 1, // Support languages and translation for media by default
49
+ 'uninstall' => 0, // Do not remove data when uninstalling Polylang
50
+ 'sync' => array(), // Synchronisation is disabled by default ( was the opposite before 1.2 )
51
  'post_types' => array(),
52
  'taxonomies' => array(),
53
  'domains' => array(),
install/plugin-updater.php CHANGED
@@ -10,7 +10,7 @@ if ( ! defined( 'ABSPATH' ) ) {
10
  * Modified version with 'polylang' text domain and comments for translators
11
  *
12
  * @author Easy Digital Downloads
13
- * @version 1.6.11
14
  */
15
  class PLL_Plugin_Updater {
16
 
@@ -284,8 +284,8 @@ class PLL_Plugin_Updater {
284
  // Convert sections into an associative array, since we're getting an object, but Core expects an array.
285
  if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
286
  $new_sections = array();
287
- foreach ( $_data->sections as $key => $key ) {
288
- $new_sections[ $key ] = $key;
289
  }
290
 
291
  $_data->sections = $new_sections;
@@ -294,8 +294,8 @@ class PLL_Plugin_Updater {
294
  // Convert banners into an associative array, since we're getting an object, but Core expects an array.
295
  if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
296
  $new_banners = array();
297
- foreach ( $_data->banners as $key => $key ) {
298
- $new_banners[ $key ] = $key;
299
  }
300
 
301
  $_data->banners = $new_banners;
10
  * Modified version with 'polylang' text domain and comments for translators
11
  *
12
  * @author Easy Digital Downloads
13
+ * @version 1.6.12
14
  */
15
  class PLL_Plugin_Updater {
16
 
284
  // Convert sections into an associative array, since we're getting an object, but Core expects an array.
285
  if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
286
  $new_sections = array();
287
+ foreach ( $_data->sections as $key => $value ) {
288
+ $new_sections[ $key ] = $value;
289
  }
290
 
291
  $_data->sections = $new_sections;
294
  // Convert banners into an associative array, since we're getting an object, but Core expects an array.
295
  if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
296
  $new_banners = array();
297
+ foreach ( $_data->banners as $key => $value ) {
298
+ $new_banners[ $key ] = $value;
299
  }
300
 
301
  $_data->banners = $new_banners;
modules/plugins/plugins-compat.php CHANGED
@@ -654,7 +654,7 @@ class PLL_Plugins_Compat {
654
  * @since 2.0.10
655
  */
656
  public function twenty_seventeen_init() {
657
- if ( 'twentyseventeen' === get_template() && did_action( 'pll_init' ) && PLL() instanceof PLL_Frontend ) {
658
  $num_sections = twentyseventeen_panel_count();
659
  for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
660
  add_filter( 'theme_mod_panel_' . $i, 'pll_get_post' );
654
  * @since 2.0.10
655
  */
656
  public function twenty_seventeen_init() {
657
+ if ( 'twentyseventeen' === get_template() && function_exists( 'twentyseventeen_panel_count' ) && did_action( 'pll_init' ) && PLL() instanceof PLL_Frontend ) {
658
  $num_sections = twentyseventeen_panel_count();
659
  for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
660
  add_filter( 'theme_mod_panel_' . $i, 'pll_get_post' );
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.1.4
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
@@ -35,7 +35,7 @@ if ( ! defined( 'ABSPATH' ) ) {
35
  exit; // don't access directly
36
  };
37
 
38
- define( 'POLYLANG_VERSION', '2.1.4' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.1.5
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
35
  exit; // don't access directly
36
  };
37
 
38
+ define( 'POLYLANG_VERSION', '2.1.5' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: Chouby
3
  Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
- Tested up to: 4.7
7
- Stable tag: 2.1.4
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,18 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  = 2.1.4 (2017-05-16) =
80
 
81
  * Pro: fix user not logged in on secondary domain when previewing changes
3
  Donate link: https://polylang.pro
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.4
6
+ Tested up to: 4.8
7
+ Stable tag: 2.1.5
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.1.5 (2017-05-31) =
80
+
81
+ * Add compatibility with new media widgets introduced in WP 4.8
82
+ * Removing the language information in URL for the default language is now default
83
+ * Update plugin updater class to 1.6.12
84
+ * Pro: fix PHP notices when duplicating the content
85
+ * Fix: test existence of `twentyseventeen_panel_count` instead of relying only on the active template
86
+ * Fix: set current property to false when removing the current-menu-item class #134 props @mowar
87
+ * Fix PHP notice when editing a term without language
88
+ * Fix possible PHP notice when deleting a category
89
+ * Fix fatal error with Gantry 5
90
+
91
  = 2.1.4 (2017-05-16) =
92
 
93
  * Pro: fix user not logged in on secondary domain when previewing changes