Polylang - Version 2.0.10

Version Description

(2016-12-05) =

  • Add support for front page panels of Twenty Seventeen
  • Remove draft posts from the language switcher even when the user is logged in
  • Fix: Make argument 2 of icl_object_id optional
  • Fix a conflict with the Divi theme (#67)
Download this release

Release Info

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

Code changes from version 2.0.9 to 2.0.10

include/links.php CHANGED
@@ -53,8 +53,13 @@ class PLL_Links {
53
  return true;
54
  }
55
 
56
- $post_type_object = get_post_type_object( $post->post_type );
57
- $user = wp_get_current_user();
58
- return is_user_logged_in() && ( current_user_can( $post_type_object->cap->read_private_posts ) || $user->ID == $post->post_author ); // Comparison must not be strict!
 
 
 
 
 
59
  }
60
  }
53
  return true;
54
  }
55
 
56
+ // Follow WP practices, which shows links to private posts ( when readable ), but not for draft posts ( ex: get_adjacent_post_link() )
57
+ if ( in_array( $post->post_status, get_post_stati( array( 'private' => true ) ) ) ) {
58
+ $post_type_object = get_post_type_object( $post->post_type );
59
+ $user = wp_get_current_user();
60
+ return is_user_logged_in() && ( current_user_can( $post_type_object->cap->read_private_posts ) || $user->ID == $post->post_author ); // Comparison must not be strict!
61
+ }
62
+
63
+ return false;
64
  }
65
  }
js/post.js CHANGED
@@ -2,7 +2,7 @@
2
  // valid for both tag metabox and quick edit
3
  (function( $ ){
4
  $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
5
- if ( 'undefined' !== typeof options.data && ( -1 !== options.url.indexOf( 'action=ajax-tag-search' ) || -1 !== options.data.indexOf( 'action=ajax-tag-search' ) ) && ( ( lang = $( '.post_lang_choice' ).val() ) || ( lang = $( ':input[name="inline_lang_choice"]' ).val() ) ) ) {
6
  options.data = 'lang=' + lang + '&' + options.data;
7
  }
8
  });
2
  // valid for both tag metabox and quick edit
3
  (function( $ ){
4
  $.ajaxPrefilter(function( options, originalOptions, jqXHR ) {
5
+ if ( 'string' === typeof options.data && ( -1 !== options.url.indexOf( 'action=ajax-tag-search' ) || -1 !== options.data.indexOf( 'action=ajax-tag-search' ) ) && ( ( lang = $( '.post_lang_choice' ).val() ) || ( lang = $( ':input[name="inline_lang_choice"]' ).val() ) ) ) {
6
  options.data = 'lang=' + lang + '&' + options.data;
7
  }
8
  });
js/post.min.js CHANGED
@@ -1 +1 @@
1
- !function(a){a.ajaxPrefilter(function(t){"undefined"==typeof t.data||-1===t.url.indexOf("action=ajax-tag-search")&&-1===t.data.indexOf("action=ajax-tag-search")||!(lang=a(".post_lang_choice").val())&&!(lang=a(':input[name="inline_lang_choice"]').val())||(t.data="lang="+lang+"&"+t.data)})}(jQuery),function(a){tagBox.get=function(t){var n=t.substr(t.indexOf("-")+1),e={action:"get-tagcloud",lang:a(".post_lang_choice").val(),tax:n};a.post(ajaxurl,e,function(e,i){0!=e&&"success"==i||(e=wpAjax.broken),e=a('<p id="tagcloud-'+n+'" class="the-tagcloud">'+e+"</p>"),a("a",e).click(function(){return tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this),!1}),(v=a(".the-tagcloud").css("display"))?(a(".the-tagcloud").replaceWith(e),a(".the-tagcloud").css("display",v)):a("#"+t).after(e)})}}(jQuery),function(a){a(document).bind("DOMNodeInserted",function(t){function n(t){"undefined"!=typeof pll_term_languages&&a.each(pll_term_languages,function(n,e){a.each(e,function(e,i){a.each(i,function(i){id="#"+e+"-"+pll_term_languages[n][e][i],t==n?a(id).show():a(id).hide()})})})}function e(t){"undefined"!=typeof pll_page_languages&&a.each(pll_page_languages,function(n,e){a.each(e,function(e){v=a('#post_parent option[value="'+pll_page_languages[n][e]+'"]'),t==n?v.show():v.hide()})})}var i=a(t.target);if("inline-edit"==i.attr("id")){var l=i.prev().attr("id").replace("post-","");if(l>0){var s=i.find(':input[name="inline_lang_choice"]'),o=a("#lang_"+l).html();s.val(o),n(o),e(o),s.change(function(){n(a(this).val()),e(a(this).val())})}}})}(jQuery),function(a){a(document).ajaxSuccess(function(t,n,e){function i(t){var n=new Array;a(".translation_"+t).each(function(){n.push(a(this).parent().parent().attr("id").substring(5))});var e={action:"pll_update_post_rows",post_id:t,translations:n.join(","),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("input[name='_inline_edit']").val()};a.post(ajaxurl,e,function(t){if(t){var n=wpAjax.parseAjaxResponse(t,"ajax-response");a.each(n.responses,function(){"row"==this.what&&a("#post-"+this.supplemental.post_id).replaceWith(this.data)})}})}var l=wpAjax.unserialize(e.data);"undefined"!=typeof l.action&&"inline-save"==l.action&&i(l.post_ID)})}(jQuery),jQuery(document).ready(function(a){function t(){a(".tr_lang").each(function(){var t=a(this).attr("id").substring(8),n=a(this).parent().siblings(".pll-edit-column");a(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+a(".post_lang_choice").val()+"&translation_language="+t+"&post_type="+a("#post_type").val()+"&_pll_nonce="+a("#_pll_nonce").val(),select:function(e,i){a("#htr_lang_"+t).val(i.item.id),n.html(i.item.link)}}),a(this).blur(function(){a(this).val()||(a("#htr_lang_"+t).val(0),n.html(n.siblings(".hidden").children().clone()))})})}var n=new Array;a(".categorydiv").each(function(){var t,e,i=a(this).attr("id");t=i.split("-"),t.shift(),e=t.join("-"),n.push(e),a("#"+e+"-add-submit").before(a("<input />").attr("type","hidden").attr("id",e+"-lang").attr("name","term_lang_choice").attr("value",a(".post_lang_choice").val()))}),a(".post_lang_choice").change(function(){var e={action:"post_lang_choice",lang:a(this).val(),post_type:a("#post_type").val(),taxonomies:n,post_id:a("#post_ID").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,e,function(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");a.each(e.responses,function(){switch(this.what){case"translations":a(".translations").html(this.data),t();break;case"taxonomy":var n=this.data;a("#"+n+"checklist").html(this.supplemental.all),a("#"+n+"checklist-pop").html(this.supplemental.populars),a("#new"+n+"_parent").replaceWith(this.supplemental.dropdown),a("#"+n+"-lang").val(a(".post_lang_choice").val());break;case"pages":a("#parent_id").html(this.data);break;case"flag":a(".pll-select-flag").html(this.data);break;case"permalink":var e=a("#edit-slug-box");"-1"!=this.data&&e.children().length&&e.html(this.data)}}),a(".tagcloud-link").each(function(){var t=a(this).attr("id");tagBox.get(t)})})}),t()});
1
+ !function(a){a.ajaxPrefilter(function(t){"string"!=typeof t.data||-1===t.url.indexOf("action=ajax-tag-search")&&-1===t.data.indexOf("action=ajax-tag-search")||!(lang=a(".post_lang_choice").val())&&!(lang=a(':input[name="inline_lang_choice"]').val())||(t.data="lang="+lang+"&"+t.data)})}(jQuery),function(a){tagBox.get=function(t){var n=t.substr(t.indexOf("-")+1),e={action:"get-tagcloud",lang:a(".post_lang_choice").val(),tax:n};a.post(ajaxurl,e,function(e,i){0!=e&&"success"==i||(e=wpAjax.broken),e=a('<p id="tagcloud-'+n+'" class="the-tagcloud">'+e+"</p>"),a("a",e).click(function(){return tagBox.flushTags(a(this).closest(".inside").children(".tagsdiv"),this),!1}),(v=a(".the-tagcloud").css("display"))?(a(".the-tagcloud").replaceWith(e),a(".the-tagcloud").css("display",v)):a("#"+t).after(e)})}}(jQuery),function(a){a(document).bind("DOMNodeInserted",function(t){function n(t){"undefined"!=typeof pll_term_languages&&a.each(pll_term_languages,function(n,e){a.each(e,function(e,i){a.each(i,function(i){id="#"+e+"-"+pll_term_languages[n][e][i],t==n?a(id).show():a(id).hide()})})})}function e(t){"undefined"!=typeof pll_page_languages&&a.each(pll_page_languages,function(n,e){a.each(e,function(e){v=a('#post_parent option[value="'+pll_page_languages[n][e]+'"]'),t==n?v.show():v.hide()})})}var i=a(t.target);if("inline-edit"==i.attr("id")){var l=i.prev().attr("id").replace("post-","");if(l>0){var s=i.find(':input[name="inline_lang_choice"]'),o=a("#lang_"+l).html();s.val(o),n(o),e(o),s.change(function(){n(a(this).val()),e(a(this).val())})}}})}(jQuery),function(a){a(document).ajaxSuccess(function(t,n,e){function i(t){var n=new Array;a(".translation_"+t).each(function(){n.push(a(this).parent().parent().attr("id").substring(5))});var e={action:"pll_update_post_rows",post_id:t,translations:n.join(","),post_type:a("input[name='post_type']").val(),screen:a("input[name='screen']").val(),_pll_nonce:a("input[name='_inline_edit']").val()};a.post(ajaxurl,e,function(t){if(t){var n=wpAjax.parseAjaxResponse(t,"ajax-response");a.each(n.responses,function(){"row"==this.what&&a("#post-"+this.supplemental.post_id).replaceWith(this.data)})}})}var l=wpAjax.unserialize(e.data);"undefined"!=typeof l.action&&"inline-save"==l.action&&i(l.post_ID)})}(jQuery),jQuery(document).ready(function(a){function t(){a(".tr_lang").each(function(){var t=a(this).attr("id").substring(8),n=a(this).parent().siblings(".pll-edit-column");a(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+a(".post_lang_choice").val()+"&translation_language="+t+"&post_type="+a("#post_type").val()+"&_pll_nonce="+a("#_pll_nonce").val(),select:function(e,i){a("#htr_lang_"+t).val(i.item.id),n.html(i.item.link)}}),a(this).blur(function(){a(this).val()||(a("#htr_lang_"+t).val(0),n.html(n.siblings(".hidden").children().clone()))})})}var n=new Array;a(".categorydiv").each(function(){var t,e,i=a(this).attr("id");t=i.split("-"),t.shift(),e=t.join("-"),n.push(e),a("#"+e+"-add-submit").before(a("<input />").attr("type","hidden").attr("id",e+"-lang").attr("name","term_lang_choice").attr("value",a(".post_lang_choice").val()))}),a(".post_lang_choice").change(function(){var e={action:"post_lang_choice",lang:a(this).val(),post_type:a("#post_type").val(),taxonomies:n,post_id:a("#post_ID").val(),_pll_nonce:a("#_pll_nonce").val()};a.post(ajaxurl,e,function(n){var e=wpAjax.parseAjaxResponse(n,"ajax-response");a.each(e.responses,function(){switch(this.what){case"translations":a(".translations").html(this.data),t();break;case"taxonomy":var n=this.data;a("#"+n+"checklist").html(this.supplemental.all),a("#"+n+"checklist-pop").html(this.supplemental.populars),a("#new"+n+"_parent").replaceWith(this.supplemental.dropdown),a("#"+n+"-lang").val(a(".post_lang_choice").val());break;case"pages":a("#parent_id").html(this.data);break;case"flag":a(".pll-select-flag").html(this.data);break;case"permalink":var e=a("#edit-slug-box");"-1"!=this.data&&e.children().length&&e.html(this.data)}}),a(".tagcloud-link").each(function(){var t=a(this).attr("id");tagBox.get(t)})})}),t()});
modules/plugins/plugins-compat.php CHANGED
@@ -53,6 +53,11 @@ class PLL_Plugins_Compat {
53
 
54
  // WP Sweep
55
  add_filter( 'wp_sweep_excluded_taxonomies', array( $this, 'wp_sweep_excluded_taxonomies' ) );
 
 
 
 
 
56
  }
57
 
58
  /**
@@ -607,6 +612,21 @@ class PLL_Plugins_Compat {
607
  return array_merge( $excluded_taxonomies, array( 'term_language', 'term_translations' ) );
608
  }
609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
610
  /**
611
  * Correspondance between WordPress locales and Facebook locales
612
  * @see https://translate.wordpress.org/
53
 
54
  // WP Sweep
55
  add_filter( 'wp_sweep_excluded_taxonomies', array( $this, 'wp_sweep_excluded_taxonomies' ) );
56
+
57
+ // Twenty Seventeen
58
+ if ( 'twentyseventeen' == get_template() ) {
59
+ add_action( 'init', array( $this, 'twenty_seventeen_init' ) );
60
+ }
61
  }
62
 
63
  /**
612
  return array_merge( $excluded_taxonomies, array( 'term_language', 'term_translations' ) );
613
  }
614
 
615
+ /**
616
+ * Twenty Seventeen
617
+ * Translates the front page panels
618
+ *
619
+ * @since 2.0.10
620
+ */
621
+ public function twenty_seventeen_init() {
622
+ if ( did_action( 'pll_init' ) && PLL() instanceof PLL_Frontend ) {
623
+ $num_sections = twentyseventeen_panel_count();
624
+ for ( $i = 1; $i < ( 1 + $num_sections ); $i++ ) {
625
+ add_filter( 'theme_mod_panel_' . $i, 'pll_get_post' );
626
+ }
627
+ }
628
+ }
629
+
630
  /**
631
  * Correspondance between WordPress locales and Facebook locales
632
  * @see https://translate.wordpress.org/
modules/wpml/wpml-legacy-api.php CHANGED
@@ -150,13 +150,13 @@ if ( ! function_exists( 'icl_link_to_element' ) ) {
150
  * @since 0.9.5
151
  *
152
  * @param int $id object id
153
- * @param string $type post type or taxonomy name of the object, defaults to 'post'
154
  * @param bool $return_original_if_missing optional, true if Polylang should return the original id if the translation is missing, defaults to false
155
  * @param string $lang optional, language code, defaults to current language
156
  * @return int|null the object id of the translation, null if the translation is missing and $return_original_if_missing set to false
157
  */
158
  if ( ! function_exists( 'icl_object_id' ) ) {
159
- function icl_object_id( $id, $type, $return_original_if_missing = false, $lang = false ) {
160
  $pll_type = ( 'post' === $type || pll_is_translated_post_type( $type ) ) ? 'post' : ( 'term' === $type || pll_is_translated_taxonomy( $type ) ? 'term' : false );
161
  return $pll_type && ( $lang = $lang ? $lang : pll_current_language() ) && ( $tr_id = PLL()->model->$pll_type->get_translation( $id, $lang ) ) ? $tr_id :
162
  ( $return_original_if_missing ? $id : null );
150
  * @since 0.9.5
151
  *
152
  * @param int $id object id
153
+ * @param string $type optional, post type or taxonomy name of the object, defaults to 'post'
154
  * @param bool $return_original_if_missing optional, true if Polylang should return the original id if the translation is missing, defaults to false
155
  * @param string $lang optional, language code, defaults to current language
156
  * @return int|null the object id of the translation, null if the translation is missing and $return_original_if_missing set to false
157
  */
158
  if ( ! function_exists( 'icl_object_id' ) ) {
159
+ function icl_object_id( $id, $type = 'post', $return_original_if_missing = false, $lang = false ) {
160
  $pll_type = ( 'post' === $type || pll_is_translated_post_type( $type ) ) ? 'post' : ( 'term' === $type || pll_is_translated_taxonomy( $type ) ? 'term' : false );
161
  return $pll_type && ( $lang = $lang ? $lang : pll_current_language() ) && ( $tr_id = PLL()->model->$pll_type->get_translation( $id, $lang ) ) ? $tr_id :
162
  ( $return_original_if_missing ? $id : null );
polylang.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
- Version: 2.0.9
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.0.9' );
39
  define( 'PLL_MIN_WP_VERSION', '4.0' );
40
 
41
  define( 'POLYLANG_FILE', __FILE__ ); // this file
3
  /*
4
  Plugin Name: Polylang
5
  Plugin URI: https://polylang.pro
6
+ Version: 2.0.10
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.0.10' );
39
  define( 'PLL_MIN_WP_VERSION', '4.0' );
40
 
41
  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.0
6
  Tested up to: 4.7
7
- Stable tag: 2.0.9
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
@@ -77,9 +77,16 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
77
 
78
  == Changelog ==
79
 
 
 
 
 
 
 
 
80
  = 2.0.9 (2016-11-15) =
81
 
82
- * fix javascript error in some ajax requests
83
 
84
  = 2.0.8 (2016-11-14) =
85
 
4
  Tags: multilingual, bilingual, translate, translation, language, multilanguage, international, localization
5
  Requires at least: 4.0
6
  Tested up to: 4.7
7
+ Stable tag: 2.0.10
8
  License: GPLv2 or later
9
 
10
  Making WordPress multilingual
77
 
78
  == Changelog ==
79
 
80
+ = 2.0.10 (2016-12-05) =
81
+
82
+ * Add support for front page panels of Twenty Seventeen
83
+ * Remove draft posts from the language switcher even when the user is logged in
84
+ * Fix: Make argument 2 of icl_object_id optional
85
+ * Fix a conflict with the Divi theme (#67)
86
+
87
  = 2.0.9 (2016-11-15) =
88
 
89
+ * Fix javascript error in some ajax requests
90
 
91
  = 2.0.8 (2016-11-14) =
92