Polylang - Version 2.1.3

Version Description

(2017-04-11) =

  • Pro: Fix translated slug of 'page' if it is translated to an empty string
  • Update plugin udpater class to 1.6.11
  • Strings registered with a wpml-config.xml file or WPML functions are now multiline by default
  • Translate the site title in emails sent to the user
  • Fix sanitize_user for specific locales
  • Fix deprecation notice in Yoast SEO integration
  • Fix: Clean term cache after the language has been set in mass #119
Download this release

Release Info

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

Code changes from version 2.1.2 to 2.1.3

admin/admin-base.php CHANGED
@@ -31,7 +31,7 @@ class PLL_Admin_Base extends PLL_Base {
31
 
32
  // Lingotek
33
  if ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) {
34
- require_once( POLYLANG_DIR . '/lingotek/lingotek.php' );
35
  }
36
  }
37
 
31
 
32
  // Lingotek
33
  if ( ! defined( 'PLL_LINGOTEK_AD' ) || PLL_LINGOTEK_AD ) {
34
+ require_once POLYLANG_DIR . '/lingotek/lingotek.php';
35
  }
36
  }
37
 
admin/admin-filters-post.php CHANGED
@@ -230,7 +230,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
230
 
231
  echo '<div id="post-translations" class="translations">';
232
  if ( $lang ) {
233
- include( PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php' );
234
  }
235
  echo '</div>' . "\n";
236
  }
@@ -257,7 +257,7 @@ class PLL_Admin_Filters_Post extends PLL_Admin_Filters_Post_Base {
257
 
258
  ob_start();
259
  if ( $lang ) {
260
- include( PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php' );
261
  }
262
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
263
  ob_end_clean();
230
 
231
  echo '<div id="post-translations" class="translations">';
232
  if ( $lang ) {
233
+ include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php';
234
  }
235
  echo '</div>' . "\n";
236
  }
257
 
258
  ob_start();
259
  if ( $lang ) {
260
+ include PLL_ADMIN_INC . '/view-translations-' . ( 'attachment' == $post_type ? 'media' : 'post' ) . '.php';
261
  }
262
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
263
  ob_end_clean();
admin/admin-filters-term.php CHANGED
@@ -101,7 +101,7 @@ class PLL_Admin_Filters_Term {
101
  // Adds translation fields
102
  echo '<div id="term-translations" class="form-field">';
103
  if ( $lang ) {
104
- include( PLL_ADMIN_INC.'/view-translations-term.php' );
105
  }
106
  echo '</div>'."\n";
107
  }
@@ -151,7 +151,7 @@ class PLL_Admin_Filters_Term {
151
 
152
  echo '<tr id="term-translations" class="form-field">';
153
  if ( $lang ) {
154
- include( PLL_ADMIN_INC.'/view-translations-term.php' );
155
  }
156
  echo '</tr>'."\n";
157
  }
@@ -455,7 +455,7 @@ class PLL_Admin_Filters_Term {
455
 
456
  ob_start();
457
  if ( $lang ) {
458
- include( PLL_ADMIN_INC.'/view-translations-term.php' );
459
  }
460
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
461
  ob_end_clean();
101
  // Adds translation fields
102
  echo '<div id="term-translations" class="form-field">';
103
  if ( $lang ) {
104
+ include PLL_ADMIN_INC . '/view-translations-term.php';
105
  }
106
  echo '</div>'."\n";
107
  }
151
 
152
  echo '<tr id="term-translations" class="form-field">';
153
  if ( $lang ) {
154
+ include PLL_ADMIN_INC . '/view-translations-term.php';
155
  }
156
  echo '</tr>'."\n";
157
  }
455
 
456
  ob_start();
457
  if ( $lang ) {
458
+ include PLL_ADMIN_INC . '/view-translations-term.php';
459
  }
460
  $x = new WP_Ajax_Response( array( 'what' => 'translations', 'data' => ob_get_contents() ) );
461
  ob_end_clean();
admin/admin-filters.php CHANGED
@@ -35,7 +35,7 @@ class PLL_Admin_Filters extends PLL_Filters {
35
  add_filter( 'plugins_update_check_locales', array( $this, 'update_check_locales' ) );
36
 
37
  // We need specific filters for German and Danish
38
- $specific_locales = array( 'da_DK', 'de_DE', 'de_DE_formal', 'de_CH', 'de_CH_informal' );
39
  if ( array_intersect( $this->model->get_languages_list( array( 'fields' => 'locale' ) ), $specific_locales ) ) {
40
  add_filter( 'sanitize_title', array( $this, 'sanitize_title' ), 10, 3 );
41
  add_filter( 'sanitize_user', array( $this, 'sanitize_user' ), 10, 3 );
@@ -247,7 +247,7 @@ class PLL_Admin_Filters extends PLL_Filters {
247
  if ( ! $once && ! empty( $this->curlang ) ) {
248
  $once = true;
249
  add_filter( 'locale', array( $this, 'get_locale' ), 20 ); // After the filter for the admin interface
250
- $title = sanitize_title( $raw_username, '', $strict );
251
  remove_filter( 'locale', array( $this, 'get_locale' ), 20 );
252
  $once = false;
253
  }
35
  add_filter( 'plugins_update_check_locales', array( $this, 'update_check_locales' ) );
36
 
37
  // We need specific filters for German and Danish
38
+ $specific_locales = array( 'da_DK', 'de_DE', 'de_DE_formal', 'de_CH', 'de_CH_informal', 'ca', 'sr_RS', 'bs_BA' );
39
  if ( array_intersect( $this->model->get_languages_list( array( 'fields' => 'locale' ) ), $specific_locales ) ) {
40
  add_filter( 'sanitize_title', array( $this, 'sanitize_title' ), 10, 3 );
41
  add_filter( 'sanitize_user', array( $this, 'sanitize_user' ), 10, 3 );
247
  if ( ! $once && ! empty( $this->curlang ) ) {
248
  $once = true;
249
  add_filter( 'locale', array( $this, 'get_locale' ), 20 ); // After the filter for the admin interface
250
+ $username = sanitize_user( $raw_username, '', $strict );
251
  remove_filter( 'locale', array( $this, 'get_locale' ), 20 );
252
  $once = false;
253
  }
admin/admin-model.php CHANGED
@@ -308,7 +308,7 @@ class PLL_Admin_Model extends PLL_Model {
308
 
309
  $ids = array_map( 'intval', $ids );
310
  $lang = $this->get_language( $lang );
311
- $tt_id = 'term' == $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id;
312
 
313
  foreach ( $ids as $id ) {
314
  $values[] = $wpdb->prepare( '( %d, %d )', $id, $tt_id );
@@ -320,7 +320,9 @@ class PLL_Admin_Model extends PLL_Model {
320
  $lang->update_count(); // Updating term count is mandatory ( thanks to AndyDeGroo )
321
  }
322
 
323
- if ( 'term' == $type ) {
 
 
324
  foreach ( $ids as $id ) {
325
  $translations[] = array( $lang->slug => $id );
326
  }
@@ -328,6 +330,8 @@ class PLL_Admin_Model extends PLL_Model {
328
  if ( ! empty( $translations ) ) {
329
  $this->set_translation_in_mass( 'term', $translations );
330
  }
 
 
331
  }
332
  }
333
 
@@ -342,6 +346,8 @@ class PLL_Admin_Model extends PLL_Model {
342
  public function set_translation_in_mass( $type, $translations ) {
343
  global $wpdb;
344
 
 
 
345
  foreach ( $translations as $t ) {
346
  $term = uniqid( 'pll_' ); // the term name
347
  $terms[] = $wpdb->prepare( '( "%1$s", "%1$s" )', $term );
@@ -361,7 +367,8 @@ class PLL_Admin_Model extends PLL_Model {
361
 
362
  // Prepare terms taxonomy relationship
363
  foreach ( $terms as $term ) {
364
- $tts[] = $wpdb->prepare( '( %d, "%s", "%s", %d )', $term->term_id, $type . '_translations', $description[ $term->slug ], $count[ $term->slug ] );
 
365
  }
366
 
367
  // Insert term_taxonomy
@@ -371,7 +378,7 @@ class PLL_Admin_Model extends PLL_Model {
371
  }
372
 
373
  // Get all terms with term_taxonomy_id
374
- $terms = get_terms( $type . '_translations', array( 'hide_empty' => false ) );
375
 
376
  // Prepare objects relationships
377
  foreach ( $terms as $term ) {
@@ -390,6 +397,8 @@ class PLL_Admin_Model extends PLL_Model {
390
  $wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
391
  $trs = array_unique( $trs );
392
  }
 
 
393
  }
394
 
395
  /**
@@ -443,6 +452,7 @@ class PLL_Admin_Model extends PLL_Model {
443
  $terms = get_terms( array( 'post_translations', 'term_translations' ) );
444
 
445
  foreach ( $terms as $term ) {
 
446
  $tr = unserialize( $term->description );
447
  if ( ! empty( $tr[ $old_slug ] ) ) {
448
  if ( $new_slug ) {
@@ -487,8 +497,10 @@ class PLL_Admin_Model extends PLL_Model {
487
  " );
488
  }
489
 
490
- foreach ( $terms as $term ) {
491
- clean_term_cache( $term->term_id, $term->taxonomy );
 
 
492
  }
493
  }
494
 
308
 
309
  $ids = array_map( 'intval', $ids );
310
  $lang = $this->get_language( $lang );
311
+ $tt_id = 'term' === $type ? $lang->tl_term_taxonomy_id : $lang->term_taxonomy_id;
312
 
313
  foreach ( $ids as $id ) {
314
  $values[] = $wpdb->prepare( '( %d, %d )', $id, $tt_id );
320
  $lang->update_count(); // Updating term count is mandatory ( thanks to AndyDeGroo )
321
  }
322
 
323
+ if ( 'term' === $type ) {
324
+ clean_term_cache( $ids, 'term_language' );
325
+
326
  foreach ( $ids as $id ) {
327
  $translations[] = array( $lang->slug => $id );
328
  }
330
  if ( ! empty( $translations ) ) {
331
  $this->set_translation_in_mass( 'term', $translations );
332
  }
333
+ } else {
334
+ clean_term_cache( $ids, 'language' );
335
  }
336
  }
337
 
346
  public function set_translation_in_mass( $type, $translations ) {
347
  global $wpdb;
348
 
349
+ $taxonomy = $type . '_translations';
350
+
351
  foreach ( $translations as $t ) {
352
  $term = uniqid( 'pll_' ); // the term name
353
  $terms[] = $wpdb->prepare( '( "%1$s", "%1$s" )', $term );
367
 
368
  // Prepare terms taxonomy relationship
369
  foreach ( $terms as $term ) {
370
+ $term_ids[] = $term->term_id;
371
+ $tts[] = $wpdb->prepare( '( %d, "%s", "%s", %d )', $term->term_id, $taxonomy, $description[ $term->slug ], $count[ $term->slug ] );
372
  }
373
 
374
  // Insert term_taxonomy
378
  }
379
 
380
  // Get all terms with term_taxonomy_id
381
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => false ) );
382
 
383
  // Prepare objects relationships
384
  foreach ( $terms as $term ) {
397
  $wpdb->query( "INSERT INTO $wpdb->term_relationships ( object_id, term_taxonomy_id ) VALUES " . implode( ',', $trs ) );
398
  $trs = array_unique( $trs );
399
  }
400
+
401
+ clean_term_cache( $term_ids, $taxonomy );
402
  }
403
 
404
  /**
452
  $terms = get_terms( array( 'post_translations', 'term_translations' ) );
453
 
454
  foreach ( $terms as $term ) {
455
+ $term_ids[ $term->taxonomy ][] = $term->term_id;
456
  $tr = unserialize( $term->description );
457
  if ( ! empty( $tr[ $old_slug ] ) ) {
458
  if ( $new_slug ) {
497
  " );
498
  }
499
 
500
+ if ( ! empty( $term_ids ) ) {
501
+ foreach ( $term_ids as $taxonomy => $ids ) {
502
+ clean_term_cache( $ids, $taxonomy );
503
+ }
504
  }
505
  }
506
 
include/base.php CHANGED
@@ -26,6 +26,7 @@ abstract class PLL_Base {
26
 
27
  // User defined strings translations
28
  add_action( 'pll_language_defined', array( $this, 'load_strings_translations' ), 5 );
 
29
 
30
  // Switch_to_blog
31
  add_action( 'switch_blog', array( $this, 'switch_blog' ), 10, 2 );
@@ -50,11 +51,24 @@ abstract class PLL_Base {
50
  * Loads user defined strings translations
51
  *
52
  * @since 1.2
 
 
 
53
  */
54
- public function load_strings_translations() {
55
- $mo = new PLL_MO();
56
- $mo->import_from_db( $this->model->get_language( get_locale() ) );
57
- $GLOBALS['l10n']['pll_string'] = &$mo;
 
 
 
 
 
 
 
 
 
 
58
  }
59
 
60
  /**
26
 
27
  // User defined strings translations
28
  add_action( 'pll_language_defined', array( $this, 'load_strings_translations' ), 5 );
29
+ add_action( 'change_locale', array( $this, 'load_strings_translations' ) ); // Since WP 4.7
30
 
31
  // Switch_to_blog
32
  add_action( 'switch_blog', array( $this, 'switch_blog' ), 10, 2 );
51
  * Loads user defined strings translations
52
  *
53
  * @since 1.2
54
+ * @since 2.1.3 $locale parameter added.
55
+ *
56
+ * @param string $locale Locale. Defaults to current locale.
57
  */
58
+ public function load_strings_translations( $locale = '' ) {
59
+ if ( empty( $locale ) ) {
60
+ $locale = get_locale();
61
+ }
62
+
63
+ $language = $this->model->get_language( $locale );
64
+
65
+ if ( ! empty( $language ) ) {
66
+ $mo = new PLL_MO();
67
+ $mo->import_from_db( $language );
68
+ $GLOBALS['l10n']['pll_string'] = &$mo;
69
+ } else {
70
+ unset( $GLOBALS['l10n']['pll_string'] );
71
+ }
72
  }
73
 
74
  /**
include/class-polylang.php CHANGED
@@ -11,7 +11,7 @@ if ( ! defined( 'PLL_LOCAL_DIR' ) ) {
11
 
12
  // includes local config file if exists
13
  if ( file_exists( PLL_LOCAL_DIR . '/pll-config.php' ) ) {
14
- include_once( PLL_LOCAL_DIR . '/pll-config.php' );
15
  }
16
 
17
  /**
@@ -27,7 +27,7 @@ class Polylang {
27
  * @since 0.1
28
  */
29
  public function __construct() {
30
- require_once( PLL_INC . '/functions-wpcom-vip.php' ); // VIP functions
31
  spl_autoload_register( array( $this, 'autoload' ) ); // autoload classes
32
 
33
  $install = new PLL_Install( POLYLANG_BASENAME );
@@ -84,7 +84,7 @@ class Polylang {
84
 
85
  foreach ( $dirs as $dir ) {
86
  if ( file_exists( $file = "$dir/$class.php" ) ) {
87
- require_once( $file );
88
  return;
89
  }
90
  }
@@ -187,7 +187,7 @@ class Polylang {
187
  */
188
  do_action_ref_array( 'pll_pre_init', array( &$polylang ) );
189
 
190
- require_once( PLL_INC.'/api.php' ); // loads the API
191
 
192
  if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
193
  PLL_WPML_Compat::instance(); // WPML API
11
 
12
  // includes local config file if exists
13
  if ( file_exists( PLL_LOCAL_DIR . '/pll-config.php' ) ) {
14
+ include_once PLL_LOCAL_DIR . '/pll-config.php';
15
  }
16
 
17
  /**
27
  * @since 0.1
28
  */
29
  public function __construct() {
30
+ require_once PLL_INC . '/functions-wpcom-vip.php'; // VIP functions
31
  spl_autoload_register( array( $this, 'autoload' ) ); // autoload classes
32
 
33
  $install = new PLL_Install( POLYLANG_BASENAME );
84
 
85
  foreach ( $dirs as $dir ) {
86
  if ( file_exists( $file = "$dir/$class.php" ) ) {
87
+ require_once $file;
88
  return;
89
  }
90
  }
187
  */
188
  do_action_ref_array( 'pll_pre_init', array( &$polylang ) );
189
 
190
+ require_once PLL_INC.'/api.php'; // loads the API
191
 
192
  if ( ! defined( 'PLL_WPML_COMPAT' ) || PLL_WPML_COMPAT ) {
193
  PLL_WPML_Compat::instance(); // WPML API
include/filters.php CHANGED
@@ -33,6 +33,10 @@ class PLL_Filters {
33
 
34
  // Prevents deleting all the translations of the default category
35
  add_filter( 'map_meta_cap', array( $this, 'fix_delete_default_category' ), 10, 4 );
 
 
 
 
36
  }
37
 
38
  /**
@@ -202,4 +206,20 @@ class PLL_Filters {
202
 
203
  return $caps;
204
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
33
 
34
  // Prevents deleting all the translations of the default category
35
  add_filter( 'map_meta_cap', array( $this, 'fix_delete_default_category' ), 10, 4 );
36
+
37
+ // Translate the site title in emails sent to users
38
+ add_filter( 'password_change_email', array( $this, 'translate_user_email' ) );
39
+ add_filter( 'email_change_email', array( $this, 'translate_user_email' ) );
40
  }
41
 
42
  /**
206
 
207
  return $caps;
208
  }
209
+
210
+ /**
211
+ * Translates the site title in emails sent to the user (change email, reset password)
212
+ * It is necessary to filter the email because WP evaluates the site title before calling switch_to_locale()
213
+ *
214
+ * @since 2.1.3
215
+ *
216
+ * @param array $email
217
+ * @return array
218
+ */
219
+ function translate_user_email( $email ) {
220
+ $blog_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
221
+ $email['subject'] = sprintf( $email['subject'], $blog_name );
222
+ $email['message'] = str_replace( '###SITENAME###', $blog_name, $email['message'] );
223
+ return $email;
224
+ }
225
  }
include/widget-calendar.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
4
- require_once( ABSPATH . '/wp-includes/default-widgets.php' );
5
  }
6
 
7
  /**
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_Widget_Calendar' ) ) {
4
+ require_once ABSPATH . '/wp-includes/default-widgets.php';
5
  }
6
 
7
  /**
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.10
14
  */
15
  class PLL_Plugin_Updater {
16
 
@@ -372,7 +372,7 @@ class PLL_Plugin_Updater {
372
  $request->banners = maybe_unserialize( $request->banners );
373
  }
374
 
375
- if( ! empty( $request ) ) {
376
  foreach( $request->sections as $key => $section ) {
377
  $request->$key = (array) $section;
378
  }
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
 
372
  $request->banners = maybe_unserialize( $request->banners );
373
  }
374
 
375
+ if( ! empty( $request->sections ) ) {
376
  foreach( $request->sections as $key => $section ) {
377
  $request->$key = (array) $section;
378
  }
install/upgrade.php CHANGED
@@ -500,7 +500,7 @@ class PLL_Upgrade {
500
  return;
501
  }
502
 
503
- require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
504
  $translations = wp_get_available_translations();
505
  if ( ! $translations ) {
506
  return;
@@ -514,7 +514,7 @@ class PLL_Upgrade {
514
  }
515
 
516
  if ( ! empty( $translations_to_load ) ) {
517
- require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
518
  $upgrader = new Language_Pack_Upgrader( new Automatic_Upgrader_Skin );
519
  $upgrader->bulk_upgrade( $translations_to_load, array( 'clear_update_cache' => false ) );
520
  }
@@ -537,7 +537,7 @@ class PLL_Upgrade {
537
  */
538
  protected function upgrade_1_8() {
539
  // Adds the flag code in languages stored in DB
540
- include( PLL_SETTINGS_INC . '/languages.php' );
541
 
542
  $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
543
 
500
  return;
501
  }
502
 
503
+ require_once ABSPATH . 'wp-admin/includes/translation-install.php';
504
  $translations = wp_get_available_translations();
505
  if ( ! $translations ) {
506
  return;
514
  }
515
 
516
  if ( ! empty( $translations_to_load ) ) {
517
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
518
  $upgrader = new Language_Pack_Upgrader( new Automatic_Upgrader_Skin );
519
  $upgrader->bulk_upgrade( $translations_to_load, array( 'clear_update_cache' => false ) );
520
  }
537
  */
538
  protected function upgrade_1_8() {
539
  // Adds the flag code in languages stored in DB
540
+ include PLL_SETTINGS_INC . '/languages.php';
541
 
542
  $terms = get_terms( 'language', array( 'hide_empty' => 0 ) );
543
 
lingotek/lingotek.php CHANGED
@@ -274,7 +274,7 @@ class PLL_Lingotek {
274
  * @return string
275
  */
276
  protected function get_activate_link() {
277
- require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
278
 
279
  if ( ! array_key_exists( self::LINGOTEK, get_plugins() ) ) {
280
  if ( current_user_can( 'install_plugins' ) ) {
274
  * @return string
275
  */
276
  protected function get_activate_link() {
277
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
278
 
279
  if ( ! array_key_exists( self::LINGOTEK, get_plugins() ) ) {
280
  if ( current_user_can( 'install_plugins' ) ) {
modules/plugins/plugins-compat.php CHANGED
@@ -113,7 +113,7 @@ class PLL_Plugins_Compat {
113
  * @return array
114
  */
115
  function wp_import_terms( $terms ) {
116
- include( PLL_SETTINGS_INC . '/languages.php' );
117
 
118
  foreach ( $terms as $key => $term ) {
119
  if ( 'language' === $term['term_taxonomy'] ) {
@@ -362,12 +362,13 @@ class PLL_Plugins_Compat {
362
  */
363
  public function add_language_home_urls( $str ) {
364
  global $wpseo_sitemaps;
 
365
 
366
  $languages = wp_list_pluck( wp_list_filter( PLL()->model->get_languages_list() , array( 'active' => false ), 'NOT' ), 'slug' );
367
 
368
  foreach ( $languages as $lang ) {
369
  if ( empty( PLL()->options['hide_default'] ) || pll_default_language() !== $lang ) {
370
- $str .= $wpseo_sitemaps->sitemap_url( array(
371
  'loc' => pll_home_url( $lang ),
372
  'pri' => 1,
373
  'chf' => apply_filters( 'wpseo_sitemap_homepage_change_freq', 'daily', pll_home_url( $lang ) ),
113
  * @return array
114
  */
115
  function wp_import_terms( $terms ) {
116
+ include PLL_SETTINGS_INC . '/languages.php';
117
 
118
  foreach ( $terms as $key => $term ) {
119
  if ( 'language' === $term['term_taxonomy'] ) {
362
  */
363
  public function add_language_home_urls( $str ) {
364
  global $wpseo_sitemaps;
365
+ $renderer = version_compare( WPSEO_VERSION, '3.2', '<' ) ? $wpseo_sitemaps : $wpseo_sitemaps->renderer;
366
 
367
  $languages = wp_list_pluck( wp_list_filter( PLL()->model->get_languages_list() , array( 'active' => false ), 'NOT' ), 'slug' );
368
 
369
  foreach ( $languages as $lang ) {
370
  if ( empty( PLL()->options['hide_default'] ) || pll_default_language() !== $lang ) {
371
+ $str .= $renderer->sitemap_url( array(
372
  'loc' => pll_home_url( $lang ),
373
  'pri' => 1,
374
  'chf' => apply_filters( 'wpseo_sitemap_homepage_change_freq', 'daily', pll_home_url( $lang ) ),
modules/wpml/wpml-compat.php CHANGED
@@ -19,7 +19,7 @@ class PLL_WPML_Compat {
19
  */
20
  protected function __construct() {
21
  // Load the WPML API
22
- require_once( PLL_MODULES_INC . '/wpml/wpml-legacy-api.php' );
23
  $this->api = new PLL_WPML_API();
24
 
25
  self::$strings = get_option( 'polylang_wpml_strings', array() );
@@ -81,8 +81,8 @@ class PLL_WPML_Compat {
81
  * @param string $string the string to register
82
  */
83
  public function register_string( $context, $name, $string ) {
84
- // Registers the string if it does not exist yet
85
- $to_register = array( 'context' => $context, 'name' => $name, 'string' => $string, 'multiline' => false, 'icl' => true );
86
  if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
87
  self::$strings[] = $to_register;
88
  update_option( 'polylang_wpml_strings', self::$strings );
19
  */
20
  protected function __construct() {
21
  // Load the WPML API
22
+ require_once PLL_MODULES_INC . '/wpml/wpml-legacy-api.php';
23
  $this->api = new PLL_WPML_API();
24
 
25
  self::$strings = get_option( 'polylang_wpml_strings', array() );
81
  * @param string $string the string to register
82
  */
83
  public function register_string( $context, $name, $string ) {
84
+ // Registers the string if it does not exist yet (multiline as in WPML)
85
+ $to_register = array( 'context' => $context, 'name' => $name, 'string' => $string, 'multiline' => true, 'icl' => true );
86
  if ( ! in_array( $to_register, self::$strings ) && $to_register['string'] ) {
87
  self::$strings[] = $to_register;
88
  update_option( 'polylang_wpml_strings', self::$strings );
modules/wpml/wpml-config.php CHANGED
@@ -193,7 +193,7 @@ class PLL_WPML_Config {
193
  }
194
  } else {
195
  $attributes = $key->attributes();
196
- pll_register_string( (string) $attributes['name'], $options, $context );
197
  }
198
  }
199
 
193
  }
194
  } else {
195
  $attributes = $key->attributes();
196
+ pll_register_string( (string) $attributes['name'], $options, $context, true ); // Multiline as in WPML
197
  }
198
  }
199
 
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.1.2
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.2' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
@@ -49,4 +49,4 @@ define( 'PLL_INSTALL_INC', POLYLANG_DIR . '/install' );
49
  define( 'PLL_MODULES_INC', POLYLANG_DIR . '/modules' );
50
  define( 'PLL_SETTINGS_INC', POLYLANG_DIR . '/settings' );
51
 
52
- require_once( PLL_INC . '/class-polylang.php' );
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.1.3
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.3' );
39
  define( 'PLL_MIN_WP_VERSION', '4.4' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
49
  define( 'PLL_MODULES_INC', POLYLANG_DIR . '/modules' );
50
  define( 'PLL_SETTINGS_INC', POLYLANG_DIR . '/settings' );
51
 
52
+ require_once PLL_INC . '/class-polylang.php';
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.2
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,16 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
 
 
79
  = 2.1.2 (2017-03-09) =
80
 
81
  * Pro: Add filter 'pll_xdata_nonce_life'
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.3
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.1.3 (2017-04-11) =
80
+
81
+ * Pro: Fix translated slug of 'page' if it is translated to an empty string
82
+ * Update plugin udpater class to 1.6.11
83
+ * Strings registered with a wpml-config.xml file or WPML functions are now multiline by default
84
+ * Translate the site title in emails sent to the user
85
+ * Fix sanitize_user for specific locales
86
+ * Fix deprecation notice in Yoast SEO integration
87
+ * Fix: Clean term cache after the language has been set in mass #119
88
+
89
  = 2.1.2 (2017-03-09) =
90
 
91
  * Pro: Add filter 'pll_xdata_nonce_life'
settings/settings.php CHANGED
@@ -91,7 +91,7 @@ class PLL_Settings extends PLL_Admin_Base {
91
  * @since 0.8
92
  */
93
  public function metabox_about() {
94
- include( PLL_SETTINGS_INC.'/view-about.php' );
95
  }
96
 
97
  /**
@@ -161,7 +161,7 @@ class PLL_Settings extends PLL_Admin_Base {
161
 
162
  if ( $this->model->add_language( $_POST ) && 'en_US' !== $_POST['locale'] ) {
163
  // attempts to install the language pack
164
- require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
165
  if ( ! wp_download_language_pack( $_POST['locale'] ) ) {
166
  add_settings_error( 'general', 'pll_download_mo', __( 'The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang' ) );
167
  }
@@ -266,7 +266,7 @@ class PLL_Settings extends PLL_Admin_Base {
266
  }
267
 
268
  // displays the page
269
- include( PLL_SETTINGS_INC . '/view-languages.php' );
270
  }
271
 
272
  /**
91
  * @since 0.8
92
  */
93
  public function metabox_about() {
94
+ include PLL_SETTINGS_INC . '/view-about.php';
95
  }
96
 
97
  /**
161
 
162
  if ( $this->model->add_language( $_POST ) && 'en_US' !== $_POST['locale'] ) {
163
  // attempts to install the language pack
164
+ require_once ABSPATH . 'wp-admin/includes/translation-install.php';
165
  if ( ! wp_download_language_pack( $_POST['locale'] ) ) {
166
  add_settings_error( 'general', 'pll_download_mo', __( 'The language was created, but the WordPress language file was not downloaded. Please install it manually.', 'polylang' ) );
167
  }
266
  }
267
 
268
  // displays the page
269
+ include PLL_SETTINGS_INC . '/view-languages.php';
270
  }
271
 
272
  /**
settings/table-languages.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
5
  }
6
 
7
  /**
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
5
  }
6
 
7
  /**
settings/table-settings.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
5
  }
6
 
7
  /**
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
5
  }
6
 
7
  /**
settings/table-string.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
- require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' ); // since WP 3.1
5
  }
6
 
7
  /**
1
  <?php
2
 
3
  if ( ! class_exists( 'WP_List_Table' ) ) {
4
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; // since WP 3.1
5
  }
6
 
7
  /**
settings/view-languages.php CHANGED
@@ -8,7 +8,7 @@ if ( ! defined( 'ABSPATH' ) ) {
8
  exit; // Don't access directly
9
  };
10
 
11
- require(ABSPATH . 'wp-admin/options-head.php'); // Displays the errors messages as when we were a child of options-general.php
12
  ?>
13
  <div class="wrap">
14
  <h1><?php echo esc_html( $GLOBALS['title'] ); ?></h1><?php
@@ -17,7 +17,7 @@ require(ABSPATH . 'wp-admin/options-head.php'); // Displays the errors messages
17
  case 'lang': // Languages tab
18
  case 'strings': // String translations tab
19
  case 'settings': // Settings tab
20
- include( PLL_SETTINGS_INC . '/view-tab-' . $this->active_tab . '.php' );
21
  break;
22
 
23
  default:
8
  exit; // Don't access directly
9
  };
10
 
11
+ require ABSPATH . 'wp-admin/options-head.php'; // Displays the errors messages as when we were a child of options-general.php
12
  ?>
13
  <div class="wrap">
14
  <h1><?php echo esc_html( $GLOBALS['title'] ); ?></h1><?php
17
  case 'lang': // Languages tab
18
  case 'strings': // String translations tab
19
  case 'settings': // Settings tab
20
+ include PLL_SETTINGS_INC . '/view-tab-' . $this->active_tab . '.php';
21
  break;
22
 
23
  default:
settings/view-tab-lang.php CHANGED
@@ -42,7 +42,7 @@ if ( ! defined( 'ABSPATH' ) ) {
42
  <label for="lang_list"><?php esc_html_e( 'Choose a language', 'polylang' );?></label>
43
  <select name="lang_list" id="lang_list">
44
  <option value=""></option><?php
45
- include( PLL_SETTINGS_INC.'/languages.php' );
46
  foreach ( $languages as $lg ) {
47
  printf(
48
  '<option value="%1$s:%2$s:%3$s:%4$s">%5$s - %2$s</option>'."\n",
@@ -103,7 +103,7 @@ if ( ! defined( 'ABSPATH' ) ) {
103
  <label for="flag_list"><?php esc_html_e( 'Flag', 'polylang' );?></label>
104
  <select name="flag" id="flag_list">
105
  <option value=""></option><?php
106
- include( PLL_SETTINGS_INC.'/flags.php' );
107
  foreach ( $flags as $code => $label ) {
108
  printf(
109
  '<option value="%1$s"%2$s>%3$s</option>'."\n",
42
  <label for="lang_list"><?php esc_html_e( 'Choose a language', 'polylang' );?></label>
43
  <select name="lang_list" id="lang_list">
44
  <option value=""></option><?php
45
+ include PLL_SETTINGS_INC . '/languages.php';
46
  foreach ( $languages as $lg ) {
47
  printf(
48
  '<option value="%1$s:%2$s:%3$s:%4$s">%5$s - %2$s</option>'."\n",
103
  <label for="flag_list"><?php esc_html_e( 'Flag', 'polylang' );?></label>
104
  <select name="flag" id="flag_list">
105
  <option value=""></option><?php
106
+ include PLL_SETTINGS_INC . '/flags.php';
107
  foreach ( $flags as $code => $label ) {
108
  printf(
109
  '<option value="%1$s"%2$s>%3$s</option>'."\n",