| @@ -8,10 +8,8 @@ | ||
| 8 | 8 | const languagesList = jQuery( '.post_lang_choice' ); |
| 9 | 9 | |
| 10 | 10 | // Dialog box for alerting the user about a risky changing. |
| 11 | 11 | const initializeConfirmationModal = () => { |
| 12 | - // We can't use underscore or lodash in this common code because it depends of the context classic or block editor. | |
| 13 | - // Classic editor underscore is loaded, Block editor lodash is loaded. | |
| 14 | 12 | const { __ } = wp.i18n; |
| 15 | 13 | |
| 16 | 14 | // Create dialog container. |
| 17 | 15 | const dialogContainer = jQuery( |
| @@ -23,14 +21,14 @@ | ||
| 23 | 21 | ).text( __( 'Are you sure you want to change the language of the current content?', 'polylang' ) ); |
| 24 | 22 | |
| 25 | 23 | // Put it after languages list dropdown. |
| 26 | 24 | // PHPCS ignore dialogContainer is a new safe HTML code generated above. |
| 27 | - languagesList.after( dialogContainer ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.after | |
| 25 | + languagesList.after( dialogContainer ); | |
| 28 | 26 | |
| 29 | 27 | const dialogResult = new Promise( |
| 30 | 28 | ( confirm, cancel ) => { |
| 31 | - const confirmDialog = ( what ) => { // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 32 | - switch ( what ) { // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 29 | + const confirmDialog = ( what ) => { | |
| 30 | + switch ( what ) { | |
| 33 | 31 | case 'yes': |
| 34 | 32 | // Confirm the new language. |
| 35 | 33 | languagesList.data( 'old-value', languagesList.children( ':selected' ).first().val() ); |
| 36 | 34 | confirm(); |
| @@ -40,10 +38,10 @@ | ||
| 40 | 38 | languagesList.val( languagesList.data( 'old-value' ) ); |
| 41 | 39 | cancel( 'Cancel' ); |
| 42 | 40 | break; |
| 43 | 41 | } |
| 44 | - dialogContainer.dialog( 'close' ); // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 45 | - } // phpcs:ignore PEAR.Functions.FunctionCallSignature.Indent | |
| 42 | + dialogContainer.dialog( 'close' ); | |
| 43 | + } | |
| 46 | 44 | |
| 47 | 45 | // Initialize dialog box in the case a language is selected but not added in the list. |
| 48 | 46 | const dialogOptions = { |
| 49 | 47 | autoOpen: false, |
| @@ -123,9 +121,9 @@ | ||
| 123 | 121 | '&_pll_nonce=' + jQuery('#_pll_nonce').val(), |
| 124 | 122 | select: function (event, ui) { |
| 125 | 123 | jQuery('#htr_lang_' + tr_lang).val(ui.item.id); |
| 126 | 124 | // ui.item.link is built and come from server side and is well escaped when necessary |
| 127 | - td.html(ui.item.link); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 125 | + td.html(ui.item.link); | |
| 128 | 126 | }, |
| 129 | 127 | } |
| 130 | 128 | ); |
| 131 | 129 | |
| @@ -135,9 +133,9 @@ | ||
| 135 | 133 | function () { |
| 136 | 134 | if ( ! jQuery(this).val() ) { |
| 137 | 135 | jQuery('#htr_lang_' + tr_lang).val(0); |
| 138 | 136 | // Value is retrieved from HTML already generated server side |
| 139 | - td.html(td.siblings('.hidden').children().clone()); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 137 | + td.html(td.siblings('.hidden').children().clone()); | |
| 140 | 138 | } |
| 141 | 139 | } |
| 142 | 140 | ); |
| 143 | 141 | } |
| @@ -190,9 +188,9 @@ | ||
| 190 | 188 | } |
| 191 | 189 | |
| 192 | 190 | // @see code from WordPress core https://github.com/WordPress/WordPress/blob/5.2.2/wp-admin/js/tags-box.js#L291 |
| 193 | 191 | // @see wp_generate_tag_cloud function which generate the escaped HTML https://github.com/WordPress/WordPress/blob/a02b5cc2a8eecb8e076fbb7cf4de7bd2ec8a8eb1/wp-includes/category-template.php#L966-L975 |
| 194 | - r = $( '<div />' ).addClass( 'the-tagcloud' ).attr( 'id', 'tagcloud-' + tax ).html( r ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 192 | + r = $( '<div />' ).addClass( 'the-tagcloud' ).attr( 'id', 'tagcloud-' + tax ).html( r ); | |
| 195 | 193 | $( 'a', r ).on( |
| 196 | 194 | 'click', |
| 197 | 195 | function () { |
| 198 | 196 | tagBox.flushTags( $( this ).closest( '.inside' ).children( '.tagsdiv' ), this ); |
| @@ -204,14 +202,14 @@ | ||
| 204 | 202 | // add an if else condition to allow modifying the tags outputted when switching the language |
| 205 | 203 | var v = tagCloud.css( 'display' ); |
| 206 | 204 | if ( v ) { |
| 207 | 205 | // See the comment above when r variable is created. |
| 208 | - $( '#tagcloud-' + tax ).replaceWith( r ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.replaceWith | |
| 206 | + $( '#tagcloud-' + tax ).replaceWith( r ); | |
| 209 | 207 | $( '#tagcloud-' + tax ).css( 'display', v ); |
| 210 | 208 | } |
| 211 | 209 | else { |
| 212 | 210 | // See the comment above when r variable is created. |
| 213 | - $( '#' + id ).after( r ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.after | |
| 211 | + $( '#' + id ).after( r ); | |
| 214 | 212 | } |
| 215 | 213 | } |
| 216 | 214 | ); |
| 217 | 215 | } |
| @@ -233,9 +231,9 @@ | ||
| 233 | 231 | |
| 234 | 232 | // add our hidden field in the new category form - for each hierarchical taxonomy |
| 235 | 233 | // to set the language when creating a new category |
| 236 | 234 | // html code inserted come from html code itself. |
| 237 | - $( '#' + taxonomy + '-add-submit' ).before( // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.before | |
| 235 | + $( '#' + taxonomy + '-add-submit' ).before( | |
| 238 | 236 | $( '<input />' ).attr( 'type', 'hidden' ) |
| 239 | 237 | .attr( 'id', taxonomy + '-lang' ) |
| 240 | 238 | .attr( 'name', 'term_lang_choice' ) |
| 241 | 239 | .attr( 'value', $( '.post_lang_choice' ).val() ) |
| @@ -285,9 +283,9 @@ | ||
| 285 | 283 | function () { |
| 286 | 284 | switch ( this.what ) { |
| 287 | 285 | case 'translations': // translations fields |
| 288 | 286 | // Data is built and come from server side and is well escaped when necessary |
| 289 | - $( '.translations' ).html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 287 | + $( '.translations' ).html( this.data ); | |
| 290 | 288 | initMetaboxAutoComplete(); |
| 291 | 289 | break; |
| 292 | 290 | case 'taxonomy': // categories metabox for posts |
| 293 | 291 | var tax = this.data; |
| @@ -292,30 +290,30 @@ | ||
| 292 | 290 | case 'taxonomy': // categories metabox for posts |
| 293 | 291 | var tax = this.data; |
| 294 | 292 | // @see wp_terms_checklist https://github.com/WordPress/WordPress/blob/5.2.2/wp-admin/includes/template.php#L175 |
| 295 | 293 | // @see https://github.com/WordPress/WordPress/blob/5.2.2/wp-admin/includes/class-walker-category-checklist.php#L89-L111 |
| 296 | - $( '#' + tax + 'checklist' ).html( this.supplemental.all ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 294 | + $( '#' + tax + 'checklist' ).html( this.supplemental.all ); | |
| 297 | 295 | // @see wp_popular_terms_checklist https://github.com/WordPress/WordPress/blob/5.2.2/wp-admin/includes/template.php#L236 |
| 298 | - $( '#' + tax + 'checklist-pop' ).html( this.supplemental.populars ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 296 | + $( '#' + tax + 'checklist-pop' ).html( this.supplemental.populars ); | |
| 299 | 297 | // @see wp_dropdown_categories https://github.com/WordPress/WordPress/blob/5.5.1/wp-includes/category-template.php#L336 |
| 300 | 298 | // which is called by PLL_Admin_Classic_Editor::post_lang_choice to generate supplemental.dropdown |
| 301 | - $( '#new' + tax + '_parent' ).replaceWith( this.supplemental.dropdown ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.replaceWith | |
| 299 | + $( '#new' + tax + '_parent' ).replaceWith( this.supplemental.dropdown ); | |
| 302 | 300 | $( '#' + tax + '-lang' ).val( $( '.post_lang_choice' ).val() ); // hidden field |
| 303 | 301 | break; |
| 304 | 302 | case 'pages': // parent dropdown list for pages |
| 305 | 303 | // @see wp_dropdown_pages https://github.com/WordPress/WordPress/blob/5.2.2/wp-includes/post-template.php#L1186-L1208 |
| 306 | 304 | // @see https://github.com/WordPress/WordPress/blob/5.2.2/wp-includes/class-walker-page-dropdown.php#L88 |
| 307 | - $( '#parent_id' ).html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 305 | + $( '#parent_id' ).html( this.data ); | |
| 308 | 306 | break; |
| 309 | 307 | case 'flag': // flag in front of the select dropdown |
| 310 | 308 | // Data is built and come from server side and is well escaped when necessary |
| 311 | - $( '.pll-select-flag' ).html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 309 | + $( '.pll-select-flag' ).html( this.data ); | |
| 312 | 310 | break; |
| 313 | 311 | case 'permalink': // Sample permalink |
| 314 | 312 | var div = $( '#edit-slug-box' ); |
| 315 | 313 | if ( '-1' != this.data && div.children().length ) { |
| 316 | 314 | // @see get_sample_permalink_html https://github.com/WordPress/WordPress/blob/5.2.2/wp-admin/includes/post.php#L1425-L1454 |
| 317 | - div.html( this.data ); // phpcs:ignore WordPressVIPMinimum.JS.HTMLExecutingFunctions.html | |
| 315 | + div.html( this.data ); | |
| 318 | 316 | } |
| 319 | 317 | break; |
| 320 | 318 | } |
| 321 | 319 | } |