| @@ -72,10 +72,8 @@ | ||
| 72 | 72 | const languagesList = jQuery('.post_lang_choice'); |
| 73 | 73 | |
| 74 | 74 | // Dialog box for alerting the user about a risky changing. |
| 75 | 75 | const initializeConfirmationModal = () => { |
| 76 | - // We can't use underscore or lodash in this common code because it depends of the context classic or block editor. | |
| 77 | - // Classic editor underscore is loaded, Block editor lodash is loaded. | |
| 78 | 76 | const { |
| 79 | 77 | __ |
| 80 | 78 | } = wp.i18n; |
| 81 | 79 | |
| @@ -86,15 +84,12 @@ | ||
| 86 | 84 | }).text(__('Are you sure you want to change the language of the current content?', 'polylang')); |
| 87 | 85 | |
| 88 | 86 | // Put it after languages list dropdown. |
| 89 | 87 | // PHPCS ignore dialogContainer is a new safe HTML code generated above. |
| 90 | - languagesList.after(dialogContainer); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.after | |
| 91 | - | |
| 88 | + languagesList.after(dialogContainer); | |
| 92 | 89 | const dialogResult = new Promise((confirm, cancel) => { |
| 93 | 90 | const confirmDialog = what => { |
| 94 | - // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 95 | 91 | switch (what) { |
| 96 | - // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 97 | 92 | case 'yes': |
| 98 | 93 | // Confirm the new language. |
| 99 | 94 | languagesList.data('old-value', languagesList.children(':selected').first().val()); |
| 100 | 95 | confirm(); |
| @@ -104,10 +99,10 @@ | ||
| 104 | 99 | languagesList.val(languagesList.data('old-value')); |
| 105 | 100 | cancel('Cancel'); |
| 106 | 101 | break; |
| 107 | 102 | } |
| 108 | - dialogContainer.dialog('close'); // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 109 | - }; // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 103 | + dialogContainer.dialog('close'); | |
| 104 | + }; | |
| 110 | 105 | |
| 111 | 106 | // Initialize dialog box in the case a language is selected but not added in the list. |
| 112 | 107 | const dialogOptions = { |
| 113 | 108 | autoOpen: false, |
| @@ -179,9 +174,9 @@ | ||
| 179 | 174 | source: ajaxurl + '?action=pll_posts_not_translated' + '&post_language=' + jQuery('.post_lang_choice').val() + '&translation_language=' + tr_lang + '&post_type=' + jQuery('#post_type').val() + '&_pll_nonce=' + jQuery('#_pll_nonce').val(), |
| 180 | 175 | select: function (event, ui) { |
| 181 | 176 | jQuery('#htr_lang_' + tr_lang).val(ui.item.id); |
| 182 | 177 | // ui.item.link is built and come from server side and is well escaped when necessary |
| 183 | - td.html(ui.item.link); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 178 | + td.html(ui.item.link); | |
| 184 | 179 | } |
| 185 | 180 | }); |
| 186 | 181 | |
| 187 | 182 | // when the input box is emptied |
| @@ -188,9 +183,9 @@ | ||
| 188 | 183 | jQuery(this).on('blur', function () { |
| 189 | 184 | if (!jQuery(this).val()) { |
| 190 | 185 | jQuery('#htr_lang_' + tr_lang).val(0); |
| 191 | 186 | // Value is retrieved from HTML already generated server side |
| 192 | - td.html(td.siblings('.hidden').children().clone()); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 187 | + td.html(td.siblings('.hidden').children().clone()); | |
| 193 | 188 | } |
| 194 | 189 | }); |
| 195 | 190 | }); |
| 196 | 191 | } |
| @@ -354,9 +349,8 @@ | ||
| 354 | 349 | dialogResult = Promise.resolve(); |
| 355 | 350 | } |
| 356 | 351 | dialogResult.then(() => { |
| 357 | 352 | let data = { |
| 358 | - // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 359 | 353 | action: 'post_lang_choice', |
| 360 | 354 | lang: selectedOption.value, |
| 361 | 355 | post_type: $('#post_type').val(), |
| 362 | 356 | post_id: $('#post_ID').val(), |
| @@ -386,11 +380,11 @@ | ||
| 386 | 380 | // new_lang input is controlled server side in PHP. The value come from the dropdown list of language returned and escaped server side. |
| 387 | 381 | // Notice that window.location changing triggers automatically page reloading. |
| 388 | 382 | if (-1 != location.search.indexOf('new_lang')) { |
| 389 | 383 | // use regexp non capturing group to replace new_lang parameter no matter where it is and capture other parameters which can be behind it |
| 390 | - window.location.search = window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/, 'new_lang=' + lang + '$1$2'); // phpcs:ignore WordPressVIPMinimum.JS.Window.location, WordPressVIPMinimum.JS.Window.VarAssignment | |
| 384 | + window.location.search = window.location.search.replace(/(?:new_lang=[^&]*)(&)?(.*)/, 'new_lang=' + lang + '$1$2'); | |
| 391 | 385 | } else { |
| 392 | - window.location.search = window.location.search + (-1 != window.location.search.indexOf('?') ? '&' : '?') + 'new_lang=' + lang; // phpcs:ignore WordPressVIPMinimum.JS.Window.location, WordPressVIPMinimum.JS.Window.VarAssignment | |
| 386 | + window.location.search = window.location.search + (-1 != window.location.search.indexOf('?') ? '&' : '?') + 'new_lang=' + lang; | |
| 393 | 387 | } |
| 394 | 388 | } |
| 395 | 389 | ; |
| 396 | 390 | |