Polylang - Version 2.5.1

Version Description

(2018-01-16) =

  • Security: Fix categories and media duplication not protected from CSRF
  • Pro: Allow to update the plugin with WP CLI
  • Pro: Fix search in the button block not filtered in the correct language (needs WP 5.1)
  • Add Saraiki to the predefined languages list
  • Fix a conflict causing a blank page with Divi
Download this release

Release Info

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

Code changes from version 2.5 to 2.5.1

admin/admin-links.php CHANGED
@@ -47,7 +47,7 @@ class PLL_Admin_Links extends PLL_Links {
47
  'new_lang' => $language->slug,
48
  );
49
 
50
- $link = add_query_arg( $args, admin_url( 'post-new.php' ) );
51
  }
52
 
53
  /**
@@ -182,4 +182,3 @@ class PLL_Admin_Links extends PLL_Links {
182
  ) : '';
183
  }
184
  }
185
-
47
  'new_lang' => $language->slug,
48
  );
49
 
50
+ $link = wp_nonce_url( add_query_arg( $args, admin_url( 'post-new.php' ) ), 'new-post-translation' );
51
  }
52
 
53
  /**
182
  ) : '';
183
  }
184
  }
 
include/crud-posts.php CHANGED
@@ -242,6 +242,10 @@ class PLL_CRUD_Posts {
242
  * @return int id of the translated media
243
  */
244
  public function create_media_translation( $post_id, $lang ) {
 
 
 
 
245
  $post = get_post( $post_id );
246
 
247
  if ( empty( $post ) ) {
242
  * @return int id of the translated media
243
  */
244
  public function create_media_translation( $post_id, $lang ) {
245
+ if ( empty( $post_id ) ) {
246
+ return $post_id;
247
+ }
248
+
249
  $post = get_post( $post_id );
250
 
251
  if ( empty( $post ) ) {
include/license.php CHANGED
@@ -37,6 +37,7 @@ class PLL_License {
37
 
38
  // Updater
39
  add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
 
40
 
41
  // Register settings
42
  add_filter( 'pll_settings_licenses', array( $this, 'settings' ) );
37
 
38
  // Updater
39
  add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
40
+ add_action( 'cli_init', array( $this, 'auto_updater' ), 0 ); // For WP CLI.
41
 
42
  // Register settings
43
  add_filter( 'pll_settings_licenses', array( $this, 'settings' ) );
js/block-editor.js CHANGED
@@ -80,8 +80,12 @@ jQuery( document ).ready(function( $ ) {
80
  // If the post is well saved, we can reload the page
81
  unsubscribe();
82
  window.location.reload();
 
 
 
83
  } )
84
  .catch( function() {
 
85
  unsubscribe();
86
  } );
87
  } );
80
  // If the post is well saved, we can reload the page
81
  unsubscribe();
82
  window.location.reload();
83
+ }, function() {
84
+ // If the post save failed
85
+ unsubscribe();
86
  } )
87
  .catch( function() {
88
+ // If an exception is thrown
89
  unsubscribe();
90
  } );
91
  } );
js/block-editor.min.js CHANGED
@@ -1 +1 @@
1
- wp.apiFetch.use(function(options,next){if('undefined'===typeof options.url){if('undefined'===typeof options.data){options.path+=((options.path.indexOf('?')>=0)?'&lang=':'?lang=')+getCurrentLanguage()}else{options.data.lang=getCurrentLanguage()}}return next(options)});function getCurrentLanguage(){return document.querySelector('[name=post_lang_choice]').value}jQuery(document).ready(function($){$('.post_lang_choice').change(function(){const select=wp.data.select;const dispatch=wp.data.dispatch;const subscribe=wp.data.subscribe;let unsubscribe=null;const savePostIsDone=new Promise(function(resolve,reject){unsubscribe=subscribe(function(){const isSavePostSucceeded=select('core/editor').didPostSaveRequestSucceed();const isSavePostFailed=select('core/editor').didPostSaveRequestFail();if(isSavePostSucceeded||isSavePostFailed){if(isSavePostFailed){reject()}else{resolve()}}})});if(location.pathname.match(/post-new.php/gi)){const title=select('core/editor').getEditedPostAttribute('title');const content=select('core/editor').getEditedPostAttribute('content');const excerpt=select('core/editor').getEditedPostAttribute('excerpt');if(''===title&&''===content&&''===excerpt){if(-1!=location.search.indexOf('new_lang')){window.location.search=window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/,'new_lang='+this.value+'$1$2');}else{window.location.search=window.location.search+((-1!=window.location.search.indexOf('?'))?'&':'?')+'new_lang='+this.value}}}dispatch('core/editor').savePost();savePostIsDone.then(function(){unsubscribe();window.location.reload()}).catch(function(){unsubscribe()})})});
1
+ wp.apiFetch.use(function(options,next){if('undefined'===typeof options.url){if('undefined'===typeof options.data){options.path+=((options.path.indexOf('?')>=0)?'&lang=':'?lang=')+getCurrentLanguage()}else{options.data.lang=getCurrentLanguage()}}return next(options)});function getCurrentLanguage(){return document.querySelector('[name=post_lang_choice]').value}jQuery(document).ready(function($){$('.post_lang_choice').change(function(){const select=wp.data.select;const dispatch=wp.data.dispatch;const subscribe=wp.data.subscribe;let unsubscribe=null;const savePostIsDone=new Promise(function(resolve,reject){unsubscribe=subscribe(function(){const isSavePostSucceeded=select('core/editor').didPostSaveRequestSucceed();const isSavePostFailed=select('core/editor').didPostSaveRequestFail();if(isSavePostSucceeded||isSavePostFailed){if(isSavePostFailed){reject()}else{resolve()}}})});if(location.pathname.match(/post-new.php/gi)){const title=select('core/editor').getEditedPostAttribute('title');const content=select('core/editor').getEditedPostAttribute('content');const excerpt=select('core/editor').getEditedPostAttribute('excerpt');if(''===title&&''===content&&''===excerpt){if(-1!=location.search.indexOf('new_lang')){window.location.search=window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/,'new_lang='+this.value+'$1$2');}else{window.location.search=window.location.search+((-1!=window.location.search.indexOf('?'))?'&':'?')+'new_lang='+this.value}}}dispatch('core/editor').savePost();savePostIsDone.then(function(){unsubscribe();window.location.reload()},function(){unsubscribe()}).catch(function(){unsubscribe()})})});
modules/sync/admin-sync.php CHANGED
@@ -34,8 +34,14 @@ class PLL_Admin_Sync extends PLL_Sync {
34
  * @return int
35
  */
36
  public function wp_insert_post_parent( $post_parent, $post_id, $postarr ) {
37
- // Make sure not to impact media translations created at the same time
38
- return isset( $_GET['from_post'], $_GET['new_lang'], $_GET['post_type'] ) && $_GET['post_type'] === $postarr['post_type'] && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && ( $parent = $this->model->post->get_translation( $id, $_GET['new_lang'] ) ) ? $parent : $post_parent;
 
 
 
 
 
 
39
  }
40
 
41
  /**
@@ -48,6 +54,8 @@ class PLL_Admin_Sync extends PLL_Sync {
48
  */
49
  public function wp_insert_post_data( $data ) {
50
  if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $data['post_type'] ) ) {
 
 
51
  $from_post_id = (int) $_GET['from_post'];
52
  $from_post = get_post( $from_post_id );
53
 
@@ -56,7 +64,7 @@ class PLL_Admin_Sync extends PLL_Sync {
56
  }
57
 
58
  // Copy the date only if the synchronization is activated
59
- if ( in_array( 'post_date', PLL()->options['sync'] ) ) {
60
  $data['post_date'] = $from_post->post_date;
61
  $data['post_date_gmt'] = $from_post->post_date_gmt;
62
  }
@@ -75,9 +83,11 @@ class PLL_Admin_Sync extends PLL_Sync {
75
  static $done = array();
76
 
77
  if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $post->post_type ) ) {
 
 
78
  // Capability check already done in post-new.php
79
  $from_post_id = (int) $_GET['from_post'];
80
- $lang = $this->model->get_language( $_GET['new_lang'] );
81
 
82
  if ( ! $from_post_id || ! $lang || ! empty( $done[ $from_post_id ] ) ) {
83
  return;
@@ -109,6 +119,8 @@ class PLL_Admin_Sync extends PLL_Sync {
109
 
110
  // For new drafts, save the date now otherwise it is overriden by WP. Thanks to JoryHogeveen. See #32.
111
  if ( in_array( 'post_date', $this->options['sync'] ) && isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) {
 
 
112
  unset( $postarr['post_date'] );
113
  unset( $postarr['post_date_gmt'] );
114
 
@@ -126,7 +138,7 @@ class PLL_Admin_Sync extends PLL_Sync {
126
  if ( isset( $GLOBALS['post_type'] ) ) {
127
  $post_type = $GLOBALS['post_type'];
128
  } elseif ( isset( $_REQUEST['post_type'] ) ) {
129
- $post_type = $_REQUEST['post_type']; // 2nd case for quick edit
130
  }
131
 
132
  // Make sure not to impact media translations when creating them at the same time as post
34
  * @return int
35
  */
36
  public function wp_insert_post_parent( $post_parent, $post_id, $postarr ) {
37
+ if ( isset( $_GET['from_post'], $_GET['new_lang'], $_GET['post_type'] ) ) {
38
+ check_admin_referer( 'new-post-translation' );
39
+ // Make sure not to impact media translations created at the same time
40
+ if ( $_GET['post_type'] === $postarr['post_type'] && ( $id = wp_get_post_parent_id( (int) $_GET['from_post'] ) ) && $parent = $this->model->post->get_translation( $id, sanitize_key( $_GET['new_lang'] ) ) ) {
41
+ $post_parent = $parent;
42
+ }
43
+ }
44
+ return $post_parent;
45
  }
46
 
47
  /**
54
  */
55
  public function wp_insert_post_data( $data ) {
56
  if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $data['post_type'] ) ) {
57
+ check_admin_referer( 'new-post-translation' );
58
+
59
  $from_post_id = (int) $_GET['from_post'];
60
  $from_post = get_post( $from_post_id );
61
 
64
  }
65
 
66
  // Copy the date only if the synchronization is activated
67
+ if ( in_array( 'post_date', $this->options['sync'] ) ) {
68
  $data['post_date'] = $from_post->post_date;
69
  $data['post_date_gmt'] = $from_post->post_date_gmt;
70
  }
83
  static $done = array();
84
 
85
  if ( isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] && $this->model->is_translated_post_type( $post->post_type ) ) {
86
+ check_admin_referer( 'new-post-translation' );
87
+
88
  // Capability check already done in post-new.php
89
  $from_post_id = (int) $_GET['from_post'];
90
+ $lang = $this->model->get_language( sanitize_key( $_GET['new_lang'] ) );
91
 
92
  if ( ! $from_post_id || ! $lang || ! empty( $done[ $from_post_id ] ) ) {
93
  return;
119
 
120
  // For new drafts, save the date now otherwise it is overriden by WP. Thanks to JoryHogeveen. See #32.
121
  if ( in_array( 'post_date', $this->options['sync'] ) && isset( $GLOBALS['pagenow'], $_GET['from_post'], $_GET['new_lang'] ) && 'post-new.php' === $GLOBALS['pagenow'] ) {
122
+ check_admin_referer( 'new-post-translation' );
123
+
124
  unset( $postarr['post_date'] );
125
  unset( $postarr['post_date_gmt'] );
126
 
138
  if ( isset( $GLOBALS['post_type'] ) ) {
139
  $post_type = $GLOBALS['post_type'];
140
  } elseif ( isset( $_REQUEST['post_type'] ) ) {
141
+ $post_type = sanitize_key( $_REQUEST['post_type'] ); // 2nd case for quick edit
142
  }
143
 
144
  // Make sure not to impact media translations when creating them at the same time as post
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.5
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
@@ -12,7 +12,7 @@ Domain Path: /languages
12
  */
13
 
14
  /*
15
- * Copyright 2011-2018 Frédéric Demarle
16
  *
17
  * This program is free software; you can redistribute it and/or modify
18
  * it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_BASENAME' ) ) {
53
  }
54
  } else {
55
  // Go on loading the plugin
56
- define( 'POLYLANG_VERSION', '2.5' );
57
  define( 'PLL_MIN_WP_VERSION', '4.7' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /**
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.5.1
7
  Author: Frédéric Demarle
8
  Author uri: https://polylang.pro
9
  Description: Adds multilingual capability to WordPress
12
  */
13
 
14
  /*
15
+ * Copyright 2011-2019 Frédéric Demarle
16
  *
17
  * This program is free software; you can redistribute it and/or modify
18
  * it under the terms of the GNU General Public License as published by
53
  }
54
  } else {
55
  // Go on loading the plugin
56
+ define( 'POLYLANG_VERSION', '2.5.1' );
57
  define( 'PLL_MIN_WP_VERSION', '4.7' );
58
 
59
  define( 'POLYLANG_FILE', __FILE__ ); // this file
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.7
6
  Tested up to: 5.0
7
- Stable tag: 2.5
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -76,6 +76,14 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
76
 
77
  == Changelog ==
78
 
 
 
 
 
 
 
 
 
79
  = 2.5 (2018-12-06) =
80
 
81
  * Add compatibility with WP 5.0
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.7
6
  Tested up to: 5.0
7
+ Stable tag: 2.5.1
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
76
 
77
  == Changelog ==
78
 
79
+ = 2.5.1 (2018-01-16) =
80
+
81
+ * Security: Fix categories and media duplication not protected from CSRF
82
+ * Pro: Allow to update the plugin with WP CLI
83
+ * Pro: Fix search in the button block not filtered in the correct language (needs WP 5.1)
84
+ * Add Saraiki to the predefined languages list
85
+ * Fix a conflict causing a blank page with Divi
86
+
87
  = 2.5 (2018-12-06) =
88
 
89
  * Add compatibility with WP 5.0
settings/languages.php CHANGED
@@ -884,6 +884,13 @@ $languages = array(
884
  'flag' => 'sk',
885
  'facebook' => 'sk_SK',
886
  ),
 
 
 
 
 
 
 
887
  'sl_SI' => array(
888
  'code' => 'sl',
889
  'locale' => 'sl_SI',
884
  'flag' => 'sk',
885
  'facebook' => 'sk_SK',
886
  ),
887
+ 'skr' => array(
888
+ 'code' => 'skr',
889
+ 'locale' => 'skr',
890
+ 'name' => 'سرائیکی',
891
+ 'dir' => 'rtl',
892
+ 'flag' => 'pk',
893
+ ),
894
  'sl_SI' => array(
895
  'code' => 'sl',
896
  'locale' => 'sl_SI',