Version Description
(2021-03-23) =
- Fix a warning when a language is corrupted in database (term_language missing)
- Fix confirmation modal with WooCommerce and WordPress < 5.6
- Fix an ajax conflict with WooCommerce Tree Table Rate Shipping and HubSpot All-In-One Marketing
Download this release
Release Info
Developer | Chouby |
Plugin | Polylang |
Version | 3.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.3
- admin/admin-base.php +18 -5
- admin/admin-model.php +6 -1
- css/build/dialog.css +3 -0
- css/build/dialog.min.css +1 -1
- css/dialog.css +3 -0
- include/language.php +4 -6
- js/build/block-editor.js +35 -31
- js/build/block-editor.min.js +1 -1
- js/build/classic-editor.js +35 -31
- js/build/classic-editor.min.js +1 -1
- js/lib/confirmation-modal.js +35 -31
- polylang.php +2 -2
- readme.txt +7 -1
admin/admin-base.php
CHANGED
@@ -273,11 +273,21 @@ abstract class PLL_Admin_Base extends PLL_Base {
|
|
273 |
$.ajaxPrefilter( function ( options, originalOptions, jqXHR ) {
|
274 |
if ( -1 != options.url.indexOf( ajaxurl ) || -1 != ajaxurl.indexOf( options.url ) ) {
|
275 |
|
276 |
-
function
|
277 |
-
if ( 'undefined' === typeof options.data || '' === options.data ) {
|
|
|
278 |
options.data = '<?php echo $str; // phpcs:ignore WordPress.Security.EscapeOutput ?>';
|
279 |
} else {
|
280 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
}
|
282 |
}
|
283 |
|
@@ -285,16 +295,19 @@ abstract class PLL_Admin_Base extends PLL_Base {
|
|
285 |
* options.processData set to true is the default jQuery process where the data is converted in a query string by using jQuery.param().
|
286 |
* This step is done before applying filters. Thus here the options.data is already a string in this case.
|
287 |
* @See https://github.com/jquery/jquery/blob/3.5.1/src/ajax.js#L563-L569 jQuery ajax function.
|
|
|
|
|
|
|
288 |
*/
|
289 |
if ( options.processData ) {
|
290 |
-
|
291 |
} else {
|
292 |
/*
|
293 |
* If options.processData is set to false data could be undefined or pass as a string.
|
294 |
* So data as to be processed as if options.processData is set to true.
|
295 |
*/
|
296 |
if ( 'undefined' === typeof options.data || 'string' === typeof options.data ) {
|
297 |
-
|
298 |
} else {
|
299 |
// Otherwise options.data is probably an object.
|
300 |
options.data = Object.assign( options.data, <?php echo $arr; // phpcs:ignore WordPress.Security.EscapeOutput ?> );
|
273 |
$.ajaxPrefilter( function ( options, originalOptions, jqXHR ) {
|
274 |
if ( -1 != options.url.indexOf( ajaxurl ) || -1 != ajaxurl.indexOf( options.url ) ) {
|
275 |
|
276 |
+
function addPolylangParametersAsString() {
|
277 |
+
if ( 'undefined' === typeof options.data || '' === options.data.trim() ) {
|
278 |
+
// Only Polylang data need to be send. So it could be as a simple query string.
|
279 |
options.data = '<?php echo $str; // phpcs:ignore WordPress.Security.EscapeOutput ?>';
|
280 |
} else {
|
281 |
+
/*
|
282 |
+
* In some cases data could be a JSON string like in third party plugins.
|
283 |
+
* So we need not to break their process by adding polylang parameters as valid JSON datas.
|
284 |
+
*/
|
285 |
+
try {
|
286 |
+
options.data = JSON.stringify( Object.assign( JSON.parse( options.data ), <?php echo $arr; // phpcs:ignore WordPress.Security.EscapeOutput ?> ) );
|
287 |
+
} catch( exception ) {
|
288 |
+
// Add Polylang data to the existing query string.
|
289 |
+
options.data = options.data + '&<?php echo $str; // phpcs:ignore WordPress.Security.EscapeOutput ?>';
|
290 |
+
}
|
291 |
}
|
292 |
}
|
293 |
|
295 |
* options.processData set to true is the default jQuery process where the data is converted in a query string by using jQuery.param().
|
296 |
* This step is done before applying filters. Thus here the options.data is already a string in this case.
|
297 |
* @See https://github.com/jquery/jquery/blob/3.5.1/src/ajax.js#L563-L569 jQuery ajax function.
|
298 |
+
* It is the most case WordPress send ajax request this way however third party plugins or themes could be send JSON string.
|
299 |
+
* Use JSON format is recommended in jQuery.param() documentation to be able to send complex data structures.
|
300 |
+
* @See https://api.jquery.com/jquery.param/ jQuery param function.
|
301 |
*/
|
302 |
if ( options.processData ) {
|
303 |
+
addPolylangParametersAsString();
|
304 |
} else {
|
305 |
/*
|
306 |
* If options.processData is set to false data could be undefined or pass as a string.
|
307 |
* So data as to be processed as if options.processData is set to true.
|
308 |
*/
|
309 |
if ( 'undefined' === typeof options.data || 'string' === typeof options.data ) {
|
310 |
+
addPolylangParametersAsString();
|
311 |
} else {
|
312 |
// Otherwise options.data is probably an object.
|
313 |
options.data = Object.assign( options.data, <?php echo $arr; // phpcs:ignore WordPress.Security.EscapeOutput ?> );
|
admin/admin-model.php
CHANGED
@@ -235,7 +235,12 @@ class PLL_Admin_Model extends PLL_Model {
|
|
235 |
// And finally update the language itself
|
236 |
$description = maybe_serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
237 |
wp_update_term( (int) $lang->term_id, 'language', array( 'slug' => $slug, 'name' => $args['name'], 'description' => $description, 'term_group' => (int) $args['term_group'] ) );
|
238 |
-
|
|
|
|
|
|
|
|
|
|
|
239 |
|
240 |
/**
|
241 |
* Fires when a language is updated.
|
235 |
// And finally update the language itself
|
236 |
$description = maybe_serialize( array( 'locale' => $args['locale'], 'rtl' => (int) $args['rtl'], 'flag_code' => empty( $args['flag'] ) ? '' : $args['flag'] ) );
|
237 |
wp_update_term( (int) $lang->term_id, 'language', array( 'slug' => $slug, 'name' => $args['name'], 'description' => $description, 'term_group' => (int) $args['term_group'] ) );
|
238 |
+
if ( empty( $lang->tl_term_id ) ) {
|
239 |
+
// Attempt to repair the term_language if it has been deleted by a database cleaning tool.
|
240 |
+
wp_insert_term( $args['name'], 'term_language', array( 'slug' => 'pll_' . $slug ) );
|
241 |
+
} else {
|
242 |
+
wp_update_term( (int) $lang->tl_term_id, 'term_language', array( 'slug' => 'pll_' . $slug, 'name' => $args['name'] ) );
|
243 |
+
}
|
244 |
|
245 |
/**
|
246 |
* Fires when a language is updated.
|
css/build/dialog.css
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
background: #fff;
|
15 |
border: 0;
|
16 |
color: #444;
|
|
|
17 |
}
|
18 |
.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar {
|
19 |
background: #fcfcfc;
|
@@ -44,6 +45,8 @@
|
|
44 |
right: 0;
|
45 |
width: 36px;
|
46 |
height: 36px;
|
|
|
|
|
47 |
}
|
48 |
.ui-dialog.pll-confirmation-modal .ui-dialog-content {
|
49 |
border: 0;
|
14 |
background: #fff;
|
15 |
border: 0;
|
16 |
color: #444;
|
17 |
+
border-radius: 0; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
18 |
}
|
19 |
.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar {
|
20 |
background: #fcfcfc;
|
45 |
right: 0;
|
46 |
width: 36px;
|
47 |
height: 36px;
|
48 |
+
border: 0; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
49 |
+
background: none; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
50 |
}
|
51 |
.ui-dialog.pll-confirmation-modal .ui-dialog-content {
|
52 |
border: 0;
|
css/build/dialog.min.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
.pll-confirmation-modal.ui-widget,.pll-confirmation-modal .ui-widget,.pll-confirmation-modal.ui-widget .ui-widget{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px}.pll-confirmation-modal.ui-dialog{padding:0;z-index:100102;background:#fff;border:0;color:#444}.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar{background:#fcfcfc;border-radius:0;border:0;border-bottom:1px solid #dfdfdf;height:36px;font-size:18px;font-weight:600;line-height:2;padding:0 36px 0 16px;color:#444;position:static}.ui-dialog.pll-confirmation-modal .ui-dialog-title{float:none;width:auto;margin:0}.pll-confirmation-modal .ui-widget-header .ui-icon{background:none;position:static}.pll-confirmation-modal .ui-button.ui-dialog-titlebar-close{padding:0;margin:0;top:0;right:0;width:36px;height:36px}.ui-dialog.pll-confirmation-modal .ui-dialog-content{border:0;padding:16px;color:#444;position:static;box-sizing:border-box}.ui-dialog.pll-confirmation-modal .ui-dialog-buttonpane{margin:0;padding:16px;border:0;background:#fcfcfc;border-top:1px solid #dfdfdf}.ui-dialog.pll-confirmation-modal .ui-dialog-buttonpane .ui-button{margin:0 0 0 16px;padding:0 10px 1px;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;position:static;line-height:2;vertical-align:top}.ui-dialog.pll-confirmation-modal .ui-button:focus,.ui-dialog.pll-confirmation-modal .ui-button:hover{background:#fafafa;border-color:#999;color:#23282d}.pll-confirmation-modal+.ui-widget-overlay{background:#000;opacity:.7;z-index:100101}
|
1 |
+
.pll-confirmation-modal.ui-widget,.pll-confirmation-modal .ui-widget,.pll-confirmation-modal.ui-widget .ui-widget{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;font-size:13px}.pll-confirmation-modal.ui-dialog{padding:0;z-index:100102;background:#fff;border:0;color:#444;border-radius:0}.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar{background:#fcfcfc;border-radius:0;border:0;border-bottom:1px solid #dfdfdf;height:36px;font-size:18px;font-weight:600;line-height:2;padding:0 36px 0 16px;color:#444;position:static}.ui-dialog.pll-confirmation-modal .ui-dialog-title{float:none;width:auto;margin:0}.pll-confirmation-modal .ui-widget-header .ui-icon{background:none;position:static}.pll-confirmation-modal .ui-button.ui-dialog-titlebar-close{padding:0;margin:0;top:0;right:0;width:36px;height:36px;border:0;background:none}.ui-dialog.pll-confirmation-modal .ui-dialog-content{border:0;padding:16px;color:#444;position:static;box-sizing:border-box}.ui-dialog.pll-confirmation-modal .ui-dialog-buttonpane{margin:0;padding:16px;border:0;background:#fcfcfc;border-top:1px solid #dfdfdf}.ui-dialog.pll-confirmation-modal .ui-dialog-buttonpane .ui-button{margin:0 0 0 16px;padding:0 10px 1px;background:#f7f7f7;border:1px solid #ccc;border-radius:3px;position:static;line-height:2;vertical-align:top}.ui-dialog.pll-confirmation-modal .ui-button:focus,.ui-dialog.pll-confirmation-modal .ui-button:hover{background:#fafafa;border-color:#999;color:#23282d}.pll-confirmation-modal+.ui-widget-overlay{background:#000;opacity:.7;z-index:100101}
|
css/dialog.css
CHANGED
@@ -14,6 +14,7 @@
|
|
14 |
background: #fff;
|
15 |
border: 0;
|
16 |
color: #444;
|
|
|
17 |
}
|
18 |
.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar {
|
19 |
background: #fcfcfc;
|
@@ -44,6 +45,8 @@
|
|
44 |
right: 0;
|
45 |
width: 36px;
|
46 |
height: 36px;
|
|
|
|
|
47 |
}
|
48 |
.ui-dialog.pll-confirmation-modal .ui-dialog-content {
|
49 |
border: 0;
|
14 |
background: #fff;
|
15 |
border: 0;
|
16 |
color: #444;
|
17 |
+
border-radius: 0; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
18 |
}
|
19 |
.ui-dialog.pll-confirmation-modal .ui-dialog-titlebar {
|
20 |
background: #fcfcfc;
|
45 |
right: 0;
|
46 |
width: 36px;
|
47 |
height: 36px;
|
48 |
+
border: 0; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
49 |
+
background: none; /* Override WooCommerce dialog styles - jQuery UI 1.11.4 - WP < 5.6 */
|
50 |
}
|
51 |
.ui-dialog.pll-confirmation-modal .ui-dialog-content {
|
52 |
border: 0;
|
include/language.php
CHANGED
@@ -187,15 +187,13 @@ class PLL_Language {
|
|
187 |
* @param WP_Term $term_language Corresponding 'term_language' term.
|
188 |
*/
|
189 |
public function __construct( $language, $term_language = null ) {
|
190 |
-
|
191 |
-
|
192 |
foreach ( $language as $prop => $value ) {
|
193 |
$this->$prop = $value;
|
194 |
}
|
195 |
-
}
|
196 |
-
|
197 |
-
// Build the object from taxonomy terms.
|
198 |
-
elseif ( ! empty( $term_language ) ) {
|
199 |
$this->term_id = (int) $language->term_id;
|
200 |
$this->name = $language->name;
|
201 |
$this->slug = $language->slug;
|
187 |
* @param WP_Term $term_language Corresponding 'term_language' term.
|
188 |
*/
|
189 |
public function __construct( $language, $term_language = null ) {
|
190 |
+
if ( empty( $term_language ) ) {
|
191 |
+
// Build the object from all properties stored as an array.
|
192 |
foreach ( $language as $prop => $value ) {
|
193 |
$this->$prop = $value;
|
194 |
}
|
195 |
+
} else {
|
196 |
+
// Build the object from taxonomy terms.
|
|
|
|
|
197 |
$this->term_id = (int) $language->term_id;
|
198 |
$this->name = $language->name;
|
199 |
$this->slug = $language->slug;
|
js/build/block-editor.js
CHANGED
@@ -45,34 +45,30 @@ const initializeConfimationModal = () => {
|
|
45 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
46 |
|
47 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
73 |
-
confirmDialog( 'no' );
|
74 |
-
},
|
75 |
-
buttons: [
|
76 |
{
|
77 |
text: __( 'OK', 'polylang' ),
|
78 |
click: function( event ) {
|
@@ -84,9 +80,17 @@ const initializeConfimationModal = () => {
|
|
84 |
click: function( event ) {
|
85 |
confirmDialog( 'no' );
|
86 |
}
|
87 |
-
}
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
);
|
92 |
return { dialogContainer, dialogResult };
|
45 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
46 |
|
47 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
48 |
+
const dialogOptions = {
|
49 |
+
autoOpen: false,
|
50 |
+
modal: true,
|
51 |
+
draggable: false,
|
52 |
+
resizable: false,
|
53 |
+
title: __( 'Change language', 'polylang' ),
|
54 |
+
minWidth: 600,
|
55 |
+
maxWidth: '100%',
|
56 |
+
open: function( event, ui ) {
|
57 |
+
// Change dialog box position for rtl language
|
58 |
+
if ( jQuery( 'body' ).hasClass( 'rtl' ) ) {
|
59 |
+
jQuery( this ).parent().css(
|
60 |
+
{
|
61 |
+
right: jQuery( this ).parent().css( 'left' ),
|
62 |
+
left: 'auto'
|
63 |
+
}
|
64 |
+
);
|
65 |
+
}
|
66 |
+
},
|
67 |
+
close: function( event, ui ) {
|
68 |
+
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
69 |
+
confirmDialog( 'no' );
|
70 |
+
},
|
71 |
+
buttons: [
|
|
|
|
|
|
|
|
|
72 |
{
|
73 |
text: __( 'OK', 'polylang' ),
|
74 |
click: function( event ) {
|
80 |
click: function( event ) {
|
81 |
confirmDialog( 'no' );
|
82 |
}
|
83 |
+
}
|
84 |
+
]
|
85 |
+
};
|
86 |
+
|
87 |
+
if ( jQuery.ui.version >= '1.12.0' ) {
|
88 |
+
Object.assign( dialogOptions, { classes: { 'ui-dialog': 'pll-confirmation-modal' } } );
|
89 |
+
} else {
|
90 |
+
Object.assign( dialogOptions, { dialogClass: 'pll-confirmation-modal' } ); // jQuery UI 1.11.4 - WP < 5.6
|
91 |
+
}
|
92 |
+
|
93 |
+
dialogContainer.dialog( dialogOptions );
|
94 |
}
|
95 |
);
|
96 |
return { dialogContainer, dialogResult };
|
js/build/block-editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
"use strict";const languagesList=jQuery(".post_lang_choice"),initializeConfimationModal=()=>{const{__:t}=wp.i18n,a=jQuery("<div/>",{id:"pll-dialog",style:"display:none;"}).text(t("Are you sure you want to change the language of the current content?","polylang"));languagesList.after(a);const e=new Promise(((e,n)=>{const l=t=>{switch(t){case"yes":languagesList.data("old-value",languagesList.children(":selected")[0].value),e();break;case"no":languagesList.val(languagesList.data("old-value")),n("Cancel")}a.dialog("close")}
|
1 |
+
"use strict";const languagesList=jQuery(".post_lang_choice"),initializeConfimationModal=()=>{const{__:t}=wp.i18n,a=jQuery("<div/>",{id:"pll-dialog",style:"display:none;"}).text(t("Are you sure you want to change the language of the current content?","polylang"));languagesList.after(a);const e=new Promise(((e,n)=>{const l=t=>{switch(t){case"yes":languagesList.data("old-value",languagesList.children(":selected")[0].value),e();break;case"no":languagesList.val(languagesList.data("old-value")),n("Cancel")}a.dialog("close")},i={autoOpen:!1,modal:!0,draggable:!1,resizable:!1,title:t("Change language","polylang"),minWidth:600,maxWidth:"100%",open:function(t,a){jQuery("body").hasClass("rtl")&&jQuery(this).parent().css({right:jQuery(this).parent().css("left"),left:"auto"})},close:function(t,a){l("no")},buttons:[{text:t("OK","polylang"),click:function(t){l("yes")}},{text:t("Cancel","polylang"),click:function(t){l("no")}}]};jQuery.ui.version>="1.12.0"?Object.assign(i,{classes:{"ui-dialog":"pll-confirmation-modal"}}):Object.assign(i,{dialogClass:"pll-confirmation-modal"}),a.dialog(i)}));return{dialogContainer:a,dialogResult:e}},initializeLanguageOldValue=()=>{languagesList.attr("data-old-value",languagesList.children(":selected")[0].value)};function getCurrentLanguage(){return document.querySelector("[name=post_lang_choice]").value}wp.apiFetch.use((function(t,a){return void 0===t.url&&(void 0===t.data||null===t.data?t.path+=(t.path.indexOf("?")>=0?"&lang=":"?lang=")+getCurrentLanguage():t.data.lang=getCurrentLanguage()),a(t)})),jQuery((function(t){function a(){t(".tr_lang").each((function(){var a=t(this).attr("id").substring(8),e=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+a+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(n,l){t("#htr_lang_"+a).val(l.item.id),e.html(l.item.link)}}),t(this).on("blur",(function(){t(this).val()||(t("#htr_lang_"+a).val(0),e.html(e.siblings(".hidden").children().clone()))}))}))}initializeLanguageOldValue(),t(".post_lang_choice").on("change",(function(e){const n=wp.data.select,l=wp.data.dispatch,i=wp.data.subscribe,o=function(){const t=wp.data.select("core/editor"),a=t.getEditedPostAttribute("title").trim(),e=t.getEditedPostAttribute("content").trim(),n=t.getEditedPostAttribute("excerpt").trim();return!a&&!e&&!n}(),s=initializeConfimationModal(),{dialogContainer:c}=s;let{dialogResult:r}=s;const u=e.target;var g;location.pathname.match(/post-new.php/gi)&&o&&(g=u.value,-1!=location.search.indexOf("new_lang")?window.location.search=window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/,"new_lang="+g+"$1$2"):window.location.search=window.location.search+(-1!=window.location.search.indexOf("?")?"&":"?")+"new_lang="+g),t(this).data("old-value")===u.value||o?(initializeLanguageOldValue(),r=Promise.resolve()):c.dialog("open"),r.then((()=>{var e={action:"post_lang_choice",lang:u.value,post_type:t("#post_type").val(),post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,e,(function(e){var o=wpAjax.parseAjaxResponse(e,"ajax-response");t.each(o.responses,(function(){switch(this.what){case"translations":t(".translations").html(this.data),a();break;case"flag":t(".pll-select-flag").html(this.data)}})),function(){let t=null;const a=new Promise((function(a,e){t=i((function(){const t=n("core/editor").didPostSaveRequestSucceed(),l=n("core/editor").didPostSaveRequestFail();(t||l)&&(l?e():a())}))}));l("core/editor").savePost(),a.then((function(){window.location.reload()}),(function(){t()})).catch((function(){t()}))}()}))}),(()=>{}))})),a()}));
|
js/build/classic-editor.js
CHANGED
@@ -45,34 +45,30 @@ const initializeConfimationModal = () => {
|
|
45 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
46 |
|
47 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
73 |
-
confirmDialog( 'no' );
|
74 |
-
},
|
75 |
-
buttons: [
|
76 |
{
|
77 |
text: __( 'OK', 'polylang' ),
|
78 |
click: function( event ) {
|
@@ -84,9 +80,17 @@ const initializeConfimationModal = () => {
|
|
84 |
click: function( event ) {
|
85 |
confirmDialog( 'no' );
|
86 |
}
|
87 |
-
}
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
}
|
91 |
);
|
92 |
return { dialogContainer, dialogResult };
|
45 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
46 |
|
47 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
48 |
+
const dialogOptions = {
|
49 |
+
autoOpen: false,
|
50 |
+
modal: true,
|
51 |
+
draggable: false,
|
52 |
+
resizable: false,
|
53 |
+
title: __( 'Change language', 'polylang' ),
|
54 |
+
minWidth: 600,
|
55 |
+
maxWidth: '100%',
|
56 |
+
open: function( event, ui ) {
|
57 |
+
// Change dialog box position for rtl language
|
58 |
+
if ( jQuery( 'body' ).hasClass( 'rtl' ) ) {
|
59 |
+
jQuery( this ).parent().css(
|
60 |
+
{
|
61 |
+
right: jQuery( this ).parent().css( 'left' ),
|
62 |
+
left: 'auto'
|
63 |
+
}
|
64 |
+
);
|
65 |
+
}
|
66 |
+
},
|
67 |
+
close: function( event, ui ) {
|
68 |
+
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
69 |
+
confirmDialog( 'no' );
|
70 |
+
},
|
71 |
+
buttons: [
|
|
|
|
|
|
|
|
|
72 |
{
|
73 |
text: __( 'OK', 'polylang' ),
|
74 |
click: function( event ) {
|
80 |
click: function( event ) {
|
81 |
confirmDialog( 'no' );
|
82 |
}
|
83 |
+
}
|
84 |
+
]
|
85 |
+
};
|
86 |
+
|
87 |
+
if ( jQuery.ui.version >= '1.12.0' ) {
|
88 |
+
Object.assign( dialogOptions, { classes: { 'ui-dialog': 'pll-confirmation-modal' } } );
|
89 |
+
} else {
|
90 |
+
Object.assign( dialogOptions, { dialogClass: 'pll-confirmation-modal' } ); // jQuery UI 1.11.4 - WP < 5.6
|
91 |
+
}
|
92 |
+
|
93 |
+
dialogContainer.dialog( dialogOptions );
|
94 |
}
|
95 |
);
|
96 |
return { dialogContainer, dialogResult };
|
js/build/classic-editor.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
"use strict";const languagesList=jQuery(".post_lang_choice"),initializeConfimationModal=()=>{const{__:t}=wp.i18n,a=jQuery("<div/>",{id:"pll-dialog",style:"display:none;"}).text(t("Are you sure you want to change the language of the current content?","polylang"));languagesList.after(a);const e=new Promise(((e,l)=>{const n=t=>{switch(t){case"yes":languagesList.data("old-value",languagesList.children(":selected")[0].value),e();break;case"no":languagesList.val(languagesList.data("old-value")),l("Cancel")}a.dialog("close")}
|
1 |
+
"use strict";const languagesList=jQuery(".post_lang_choice"),initializeConfimationModal=()=>{const{__:t}=wp.i18n,a=jQuery("<div/>",{id:"pll-dialog",style:"display:none;"}).text(t("Are you sure you want to change the language of the current content?","polylang"));languagesList.after(a);const e=new Promise(((e,l)=>{const n=t=>{switch(t){case"yes":languagesList.data("old-value",languagesList.children(":selected")[0].value),e();break;case"no":languagesList.val(languagesList.data("old-value")),l("Cancel")}a.dialog("close")},i={autoOpen:!1,modal:!0,draggable:!1,resizable:!1,title:t("Change language","polylang"),minWidth:600,maxWidth:"100%",open:function(t,a){jQuery("body").hasClass("rtl")&&jQuery(this).parent().css({right:jQuery(this).parent().css("left"),left:"auto"})},close:function(t,a){n("no")},buttons:[{text:t("OK","polylang"),click:function(t){n("yes")}},{text:t("Cancel","polylang"),click:function(t){n("no")}}]};jQuery.ui.version>="1.12.0"?Object.assign(i,{classes:{"ui-dialog":"pll-confirmation-modal"}}):Object.assign(i,{dialogClass:"pll-confirmation-modal"}),a.dialog(i)}));return{dialogContainer:a,dialogResult:e}},initializeLanguageOldValue=()=>{languagesList.attr("data-old-value",languagesList.children(":selected")[0].value)};jQuery((function(t){t.ajaxPrefilter((function(a,e,l){var n=t(".post_lang_choice").val();"string"==typeof a.data&&-1!==a.url.indexOf("action=ajax-tag-search")&&n&&(a.data="lang="+n+"&"+a.data)}))})),jQuery((function(t){tagBox.get=function(a){var e=a.substr(a.indexOf("-")+1),l={action:"get-tagcloud",lang:t(".post_lang_choice").val(),tax:e};t.post(ajaxurl,l,(function(l,n){0!=l&&"success"==n||(l=wpAjax.broken),l=t("<div />").addClass("the-tagcloud").attr("id","tagcloud-"+e).html(l),t("a",l).on("click",(function(){return tagBox.flushTags(t(this).closest(".inside").children(".tagsdiv"),this),!1}));var i=t("#tagcloud-"+e).css("display");i?(t("#tagcloud-"+e).replaceWith(l),t("#tagcloud-"+e).css("display",i)):t("#"+a).after(l)}))}})),jQuery((function(t){var a=new Array;function e(){t(".tr_lang").each((function(){var a=t(this).attr("id").substring(8),e=t(this).parent().parent().siblings(".pll-edit-column");t(this).autocomplete({minLength:0,source:ajaxurl+"?action=pll_posts_not_translated&post_language="+t(".post_lang_choice").val()+"&translation_language="+a+"&post_type="+t("#post_type").val()+"&_pll_nonce="+t("#_pll_nonce").val(),select:function(l,n){t("#htr_lang_"+a).val(n.item.id),e.html(n.item.link)}}),t(this).on("blur",(function(){t(this).val()||(t("#htr_lang_"+a).val(0),e.html(e.siblings(".hidden").children().clone()))}))}))}t(".categorydiv").each((function(){var e,l;(e=t(this).attr("id").split("-")).shift(),l=e.join("-"),a.push(l),t("#"+l+"-add-submit").before(t("<input />").attr("type","hidden").attr("id",l+"-lang").attr("name","term_lang_choice").attr("value",t(".post_lang_choice").val()))})),initializeLanguageOldValue(),t(".post_lang_choice").on("change",(function(l){const n=initializeConfimationModal(),{dialogContainer:i}=n;let{dialogResult:s}=n;const o=l.target;t(this).data("old-value")===o.value||function(){const a=t("input#title").val(),e=t("textarea#content").val(),l=t("textarea#excerpt").val();return!a&&!e&&!l}()?s=Promise.resolve():i.dialog("open"),s.then((()=>{var l=o.options[o.options.selectedIndex].lang,n=t('.pll-translation-column > span[lang="'+l+'"]').attr("dir"),i={action:"post_lang_choice",lang:o.value,post_type:t("#post_type").val(),taxonomies:a,post_id:t("#post_ID").val(),_pll_nonce:t("#_pll_nonce").val()};t.post(ajaxurl,i,(function(a){var i=wpAjax.parseAjaxResponse(a,"ajax-response");t.each(i.responses,(function(){switch(this.what){case"translations":t(".translations").html(this.data),e();break;case"taxonomy":var a=this.data;t("#"+a+"checklist").html(this.supplemental.all),t("#"+a+"checklist-pop").html(this.supplemental.populars),t("#new"+a+"_parent").replaceWith(this.supplemental.dropdown),t("#"+a+"-lang").val(t(".post_lang_choice").val());break;case"pages":t("#parent_id").html(this.data);break;case"flag":t(".pll-select-flag").html(this.data);break;case"permalink":var l=t("#edit-slug-box");"-1"!=this.data&&l.children().length&&l.html(this.data)}})),initializeLanguageOldValue(),t(".tagcloud-link").each((function(){var a=t(this).attr("id");tagBox.get(a)})),t("body").removeClass("pll-dir-rtl").removeClass("pll-dir-ltr").addClass("pll-dir-"+n),t("#content_ifr").contents().find("html").attr("lang",l).attr("dir",n),t("#content_ifr").contents().find("body").attr("dir",n),pll.media.resetAllAttachmentsCollections()}))}),(()=>{}))})),e()}));var pll=window.pll||{};_.extend(pll,{media:{}});var media=_.extend(pll.media,{attachmentsCollections:[],query:function(t){var a=pll.media.query.delegate(t);return pll.media.attachmentsCollections.push(a),a},resetAllAttachmentsCollections:function(){this.attachmentsCollections.forEach((function(t){t.reset(),t.mirroring&&(t.mirroring._hasMore=!0,t.mirroring.reset())}))}});"undefined"!=typeof wp&&void 0!==wp.media&&(media.query=_.extend(media.query,{delegate:wp.media.query}),wp.media.query=media.query);
|
js/lib/confirmation-modal.js
CHANGED
@@ -42,34 +42,30 @@ export const initializeConfimationModal = () => {
|
|
42 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
43 |
|
44 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
70 |
-
confirmDialog( 'no' );
|
71 |
-
},
|
72 |
-
buttons: [
|
73 |
{
|
74 |
text: __( 'OK', 'polylang' ),
|
75 |
click: function( event ) {
|
@@ -81,9 +77,17 @@ export const initializeConfimationModal = () => {
|
|
81 |
click: function( event ) {
|
82 |
confirmDialog( 'no' );
|
83 |
}
|
84 |
-
}
|
85 |
-
|
86 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
88 |
);
|
89 |
return { dialogContainer, dialogResult };
|
42 |
} // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent
|
43 |
|
44 |
// Initialize dialog box in the case a language is selected but not added in the list.
|
45 |
+
const dialogOptions = {
|
46 |
+
autoOpen: false,
|
47 |
+
modal: true,
|
48 |
+
draggable: false,
|
49 |
+
resizable: false,
|
50 |
+
title: __( 'Change language', 'polylang' ),
|
51 |
+
minWidth: 600,
|
52 |
+
maxWidth: '100%',
|
53 |
+
open: function( event, ui ) {
|
54 |
+
// Change dialog box position for rtl language
|
55 |
+
if ( jQuery( 'body' ).hasClass( 'rtl' ) ) {
|
56 |
+
jQuery( this ).parent().css(
|
57 |
+
{
|
58 |
+
right: jQuery( this ).parent().css( 'left' ),
|
59 |
+
left: 'auto'
|
60 |
+
}
|
61 |
+
);
|
62 |
+
}
|
63 |
+
},
|
64 |
+
close: function( event, ui ) {
|
65 |
+
// When we're closing the dialog box we need to cancel the language change as we click on Cancel button.
|
66 |
+
confirmDialog( 'no' );
|
67 |
+
},
|
68 |
+
buttons: [
|
|
|
|
|
|
|
|
|
69 |
{
|
70 |
text: __( 'OK', 'polylang' ),
|
71 |
click: function( event ) {
|
77 |
click: function( event ) {
|
78 |
confirmDialog( 'no' );
|
79 |
}
|
80 |
+
}
|
81 |
+
]
|
82 |
+
};
|
83 |
+
|
84 |
+
if ( jQuery.ui.version >= '1.12.0' ) {
|
85 |
+
Object.assign( dialogOptions, { classes: { 'ui-dialog': 'pll-confirmation-modal' } } );
|
86 |
+
} else {
|
87 |
+
Object.assign( dialogOptions, { dialogClass: 'pll-confirmation-modal' } ); // jQuery UI 1.11.4 - WP < 5.6
|
88 |
+
}
|
89 |
+
|
90 |
+
dialogContainer.dialog( dialogOptions );
|
91 |
}
|
92 |
);
|
93 |
return { dialogContainer, dialogResult };
|
polylang.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
* Plugin Name: Polylang
|
11 |
* Plugin URI: https://polylang.pro
|
12 |
* Description: Adds multilingual capability to WordPress
|
13 |
-
* Version: 3.0.
|
14 |
* Requires at least: 5.1
|
15 |
* Requires PHP: 5.6
|
16 |
* Author: WP SYNTEX
|
@@ -53,7 +53,7 @@ if ( defined( 'POLYLANG_VERSION' ) ) {
|
|
53 |
}
|
54 |
} else {
|
55 |
// Go on loading the plugin
|
56 |
-
define( 'POLYLANG_VERSION', '3.0.
|
57 |
define( 'PLL_MIN_WP_VERSION', '5.1' );
|
58 |
define( 'PLL_MIN_PHP_VERSION', '5.6' );
|
59 |
|
10 |
* Plugin Name: Polylang
|
11 |
* Plugin URI: https://polylang.pro
|
12 |
* Description: Adds multilingual capability to WordPress
|
13 |
+
* Version: 3.0.3
|
14 |
* Requires at least: 5.1
|
15 |
* Requires PHP: 5.6
|
16 |
* Author: WP SYNTEX
|
53 |
}
|
54 |
} else {
|
55 |
// Go on loading the plugin
|
56 |
+
define( 'POLYLANG_VERSION', '3.0.3' );
|
57 |
define( 'PLL_MIN_WP_VERSION', '5.1' );
|
58 |
define( 'PLL_MIN_PHP_VERSION', '5.6' );
|
59 |
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ Tags: multilingual, bilingual, translate, translation, language, multilanguage,
|
|
5 |
Requires at least: 5.1
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 5.6
|
8 |
-
Stable tag: 3.0.
|
9 |
License: GPLv3 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
@@ -78,6 +78,12 @@ Don't hesitate to [give your feedback](http://wordpress.org/support/view/plugin-
|
|
78 |
|
79 |
== Changelog ==
|
80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
= 3.0.2 (2021-03-16) =
|
82 |
|
83 |
* Move hreflang attributes higher in the head section #771
|
5 |
Requires at least: 5.1
|
6 |
Tested up to: 5.7
|
7 |
Requires PHP: 5.6
|
8 |
+
Stable tag: 3.0.3
|
9 |
License: GPLv3 or later
|
10 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
11 |
|
78 |
|
79 |
== Changelog ==
|
80 |
|
81 |
+
= 3.0.3 (2021-03-23) =
|
82 |
+
|
83 |
+
* Fix a warning when a language is corrupted in database (term_language missing)
|
84 |
+
* Fix confirmation modal with WooCommerce and WordPress < 5.6
|
85 |
+
* Fix an ajax conflict with WooCommerce Tree Table Rate Shipping and HubSpot All-In-One Marketing
|
86 |
+
|
87 |
= 3.0.2 (2021-03-16) =
|
88 |
|
89 |
* Move hreflang attributes higher in the head section #771
|