Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wp-smush.../_src/js/smush
File: smush.js
/* global WP_Smush */
[0] Fix | Delete
/* global ajaxurl */
[1] Fix | Delete
/* global wp_smushit_data */
[2] Fix | Delete
[3] Fix | Delete
import {GlobalStats} from "../common/globalStats";
[4] Fix | Delete
import SmushProgress from "../common/progressbar";
[5] Fix | Delete
[6] Fix | Delete
let perf = 0;
[7] Fix | Delete
[8] Fix | Delete
import tracker from '../utils/tracker';
[9] Fix | Delete
[10] Fix | Delete
/**
[11] Fix | Delete
* Smush class.
[12] Fix | Delete
*
[13] Fix | Delete
* @since 2.9.0 Moved from admin.js into a dedicated ES6 class.
[14] Fix | Delete
*/
[15] Fix | Delete
class Smush {
[16] Fix | Delete
/**
[17] Fix | Delete
* Class constructor.
[18] Fix | Delete
*
[19] Fix | Delete
* @param {Object} button Button object that made the call.
[20] Fix | Delete
* @param {boolean} bulk Bulk smush or not.
[21] Fix | Delete
* @param {string} type Accepts: 'nextgen', 'media'.
[22] Fix | Delete
*/
[23] Fix | Delete
constructor( button, bulk, type = 'media' ) {
[24] Fix | Delete
this.onStart();
[25] Fix | Delete
[26] Fix | Delete
//If smush attribute is not defined, Need not skip re-Smush IDs.
[27] Fix | Delete
this.skip_resmush = ! (
[28] Fix | Delete
'undefined' === typeof button.data( 'smush' ) ||
[29] Fix | Delete
! button.data( 'smush' )
[30] Fix | Delete
);
[31] Fix | Delete
this.button = jQuery( button[ 0 ] );
[32] Fix | Delete
this.is_bulk = typeof bulk ? bulk : false;
[33] Fix | Delete
this.url = ajaxurl;
[34] Fix | Delete
this.log = jQuery( '.smush-final-log' );
[35] Fix | Delete
[36] Fix | Delete
this.setIds();
[37] Fix | Delete
[38] Fix | Delete
this.is_bulk_resmush =
[39] Fix | Delete
0 < wp_smushit_data.resmush.length && ! this.skip_resmush;
[40] Fix | Delete
this.status = this.button.parent().prev( '.smush-status' );
[41] Fix | Delete
[42] Fix | Delete
// Added for NextGen support.
[43] Fix | Delete
this.smush_type = type;
[44] Fix | Delete
this.single_ajax_suffix =
[45] Fix | Delete
'nextgen' === this.smush_type
[46] Fix | Delete
? 'smush_manual_nextgen'
[47] Fix | Delete
: 'wp_smushit_manual';
[48] Fix | Delete
this.bulk_ajax_suffix =
[49] Fix | Delete
'nextgen' === this.smush_type
[50] Fix | Delete
? 'wp_smushit_nextgen_bulk'
[51] Fix | Delete
: 'wp_smushit_bulk';
[52] Fix | Delete
this.get_stats_action = 'nextgen' === this.smush_type ? 'nextgen_get_stats' : 'get_stats';
[53] Fix | Delete
this.url = this.is_bulk
[54] Fix | Delete
? Smush.smushAddParams( this.url, {
[55] Fix | Delete
action: this.bulk_ajax_suffix,
[56] Fix | Delete
} )
[57] Fix | Delete
: Smush.smushAddParams( this.url, {
[58] Fix | Delete
action: this.single_ajax_suffix,
[59] Fix | Delete
} );
[60] Fix | Delete
[61] Fix | Delete
this.start();
[62] Fix | Delete
( ! this.is_bulk ) && this.run();
[63] Fix | Delete
this.bindDeferredEvents();
[64] Fix | Delete
[65] Fix | Delete
// Handle cancel ajax.
[66] Fix | Delete
// this.cancelAjax();
[67] Fix | Delete
[68] Fix | Delete
return this;
[69] Fix | Delete
}
[70] Fix | Delete
[71] Fix | Delete
/**
[72] Fix | Delete
* Add params to the URL.
[73] Fix | Delete
*
[74] Fix | Delete
* @param {string} url URL to add the params to.
[75] Fix | Delete
* @param {Object} data Object with params.
[76] Fix | Delete
* @return {string} URL with params.
[77] Fix | Delete
*/
[78] Fix | Delete
static smushAddParams( url, data ) {
[79] Fix | Delete
if ( ! jQuery.isEmptyObject( data ) ) {
[80] Fix | Delete
url +=
[81] Fix | Delete
( url.indexOf( '?' ) >= 0 ? '&' : '?' ) + jQuery.param( data );
[82] Fix | Delete
}
[83] Fix | Delete
[84] Fix | Delete
return url;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
/**
[88] Fix | Delete
* Check membership validity.
[89] Fix | Delete
*
[90] Fix | Delete
* @param {Object} data
[91] Fix | Delete
* @param {number} data.show_warning
[92] Fix | Delete
*/
[93] Fix | Delete
static membershipValidity( data ) {
[94] Fix | Delete
const memberValidityNotice = jQuery( '#wp-smush-invalid-member' );
[95] Fix | Delete
[96] Fix | Delete
// Check for membership warning.
[97] Fix | Delete
if (
[98] Fix | Delete
'undefined' !== typeof data &&
[99] Fix | Delete
'undefined' !== typeof data.show_warning &&
[100] Fix | Delete
memberValidityNotice.length > 0
[101] Fix | Delete
) {
[102] Fix | Delete
if ( data.show_warning ) {
[103] Fix | Delete
memberValidityNotice.show();
[104] Fix | Delete
} else {
[105] Fix | Delete
memberValidityNotice.hide();
[106] Fix | Delete
}
[107] Fix | Delete
}
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Send Ajax request for compressing the image.
[112] Fix | Delete
*
[113] Fix | Delete
* @param {boolean} isBulkResmush
[114] Fix | Delete
* @param {number} id
[115] Fix | Delete
* @param {string} sendUrl
[116] Fix | Delete
* @param {string} nonce
[117] Fix | Delete
* @param {boolean} newBulkSmushStarted
[118] Fix | Delete
* @return {*|jQuery.promise|void} Compression results.
[119] Fix | Delete
*/
[120] Fix | Delete
static ajax( isBulkResmush, id, sendUrl, nonce, newBulkSmushStarted= false ) {
[121] Fix | Delete
const param = jQuery.param( {
[122] Fix | Delete
is_bulk_resmush: isBulkResmush,
[123] Fix | Delete
attachment_id: id,
[124] Fix | Delete
_nonce: nonce,
[125] Fix | Delete
new_bulk_smush_started: newBulkSmushStarted
[126] Fix | Delete
} );
[127] Fix | Delete
[128] Fix | Delete
return jQuery.ajax( {
[129] Fix | Delete
type: 'GET',
[130] Fix | Delete
data: param,
[131] Fix | Delete
url: sendUrl,
[132] Fix | Delete
/** @param {Array} wp_smushit_data */
[133] Fix | Delete
timeout: wp_smushit_data.timeout,
[134] Fix | Delete
dataType: 'json',
[135] Fix | Delete
} );
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
/**
[139] Fix | Delete
* Sets this.ids.
[140] Fix | Delete
*/
[141] Fix | Delete
setIds() {
[142] Fix | Delete
let ids = [];
[143] Fix | Delete
if ( 0 < wp_smushit_data.resmush.length && ! this.skip_resmush ) {
[144] Fix | Delete
if ( 0 < wp_smushit_data.unsmushed.length ) {
[145] Fix | Delete
ids = wp_smushit_data.resmush.concat( wp_smushit_data.unsmushed );
[146] Fix | Delete
} else {
[147] Fix | Delete
ids = wp_smushit_data.resmush;
[148] Fix | Delete
}
[149] Fix | Delete
} else {
[150] Fix | Delete
ids = wp_smushit_data.unsmushed;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
if ( 'object' === typeof ids ) {
[154] Fix | Delete
// If button has re-Smush class, and we do have ids that needs to re-Smushed, put them in the list.
[155] Fix | Delete
this.ids = ids.filter( function( itm, i, a ) {
[156] Fix | Delete
return i === a.indexOf( itm );
[157] Fix | Delete
} );
[158] Fix | Delete
} else {
[159] Fix | Delete
this.ids = ids;
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
/**
[164] Fix | Delete
* Show loader in button for single and bulk Smush.
[165] Fix | Delete
*/
[166] Fix | Delete
start() {
[167] Fix | Delete
this.button.prop( 'disabled', true );
[168] Fix | Delete
this.button.addClass( 'wp-smush-started' );
[169] Fix | Delete
[170] Fix | Delete
this.bulkStart();
[171] Fix | Delete
this.singleStart();
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
/**
[175] Fix | Delete
* Start bulk Smush.
[176] Fix | Delete
*/
[177] Fix | Delete
bulkStart() {
[178] Fix | Delete
if ( ! this.is_bulk ) {
[179] Fix | Delete
return;
[180] Fix | Delete
}
[181] Fix | Delete
[182] Fix | Delete
// Hide the bulk div.
[183] Fix | Delete
jQuery( '.wp-smush-bulk-wrapper' ).addClass( 'sui-hidden' );
[184] Fix | Delete
[185] Fix | Delete
// Hide the bulk limit message.
[186] Fix | Delete
jQuery(
[187] Fix | Delete
'.wp-smush-bulk-progress-bar-wrapper .sui-notice-warning:first-of-type'
[188] Fix | Delete
).hide();
[189] Fix | Delete
[190] Fix | Delete
// Hide parent wrapper, if there are no other messages.
[191] Fix | Delete
if (
[192] Fix | Delete
0 >= jQuery( 'div.smush-final-log .smush-bulk-error-row' ).length
[193] Fix | Delete
) {
[194] Fix | Delete
jQuery( 'div.smush-final-log' ).addClass('sui-hidden');
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
// Show the progress bar.
[198] Fix | Delete
jQuery(
[199] Fix | Delete
'.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper, #wp-smush-running-notice'
[200] Fix | Delete
).removeClass( 'sui-hidden' );
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
/**
[204] Fix | Delete
* Start single image Smush.
[205] Fix | Delete
*/
[206] Fix | Delete
singleStart() {
[207] Fix | Delete
if ( this.is_bulk ) {
[208] Fix | Delete
return;
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
this.button.html(
[212] Fix | Delete
'<span class="spinner wp-smush-progress">' +
[213] Fix | Delete
window.wp_smush_msgs.smushing +
[214] Fix | Delete
'</span>'
[215] Fix | Delete
);
[216] Fix | Delete
this.status.removeClass( 'error' );
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
/**
[220] Fix | Delete
* Enable button.
[221] Fix | Delete
*/
[222] Fix | Delete
enableButton() {
[223] Fix | Delete
this.button.prop( 'disabled', false );
[224] Fix | Delete
jQuery('.wp-smush-all').prop('disabled', false);
[225] Fix | Delete
jQuery('.wp-smush-restore').prop('disabled', false);
[226] Fix | Delete
// For bulk process, enable other buttons.
[227] Fix | Delete
jQuery(
[228] Fix | Delete
'a.wp-smush-lossy-enable, button.wp-smush-resize-enable, button#save-settings-button'
[229] Fix | Delete
).prop('disabled', false);
[230] Fix | Delete
}
[231] Fix | Delete
[232] Fix | Delete
/**
[233] Fix | Delete
* Finish single image Smush.
[234] Fix | Delete
*/
[235] Fix | Delete
singleDone() {
[236] Fix | Delete
if ( this.is_bulk ) {
[237] Fix | Delete
return;
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
const self = this;
[241] Fix | Delete
[242] Fix | Delete
this.request
[243] Fix | Delete
.done( function( response ) {
[244] Fix | Delete
if ( 'undefined' !== typeof response.data ) {
[245] Fix | Delete
// Check if stats div exists.
[246] Fix | Delete
const parent = self.status.parent();
[247] Fix | Delete
[248] Fix | Delete
// Check whether to show membership validity notice or not.
[249] Fix | Delete
Smush.membershipValidity( response.data );
[250] Fix | Delete
[251] Fix | Delete
if ( ! response.success ) {
[252] Fix | Delete
if ( response.data.html_stats ) {
[253] Fix | Delete
parent.html( response.data.html_stats );
[254] Fix | Delete
} else {
[255] Fix | Delete
self.status.addClass( 'smush-warning' );
[256] Fix | Delete
/** @param {string} response.data.error_msg */
[257] Fix | Delete
self.status.html( response.data.error_msg );
[258] Fix | Delete
self.button.html(
[259] Fix | Delete
window.smush_vars.strings.stats_label
[260] Fix | Delete
);
[261] Fix | Delete
}
[262] Fix | Delete
} else {
[263] Fix | Delete
// If we've updated status, replace the content.
[264] Fix | Delete
parent.html( response.data );
[265] Fix | Delete
self.button.html( window.wp_smush_msgs.all_done );
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
/**
[269] Fix | Delete
* Update image size in attachment info panel.
[270] Fix | Delete
*
[271] Fix | Delete
* @param {string|number} response.data.new_size
[272] Fix | Delete
*/
[273] Fix | Delete
Smush.updateImageStats( response.data.new_size );
[274] Fix | Delete
}
[275] Fix | Delete
} )
[276] Fix | Delete
.fail( function( response ) {
[277] Fix | Delete
self.status.html( response.data );
[278] Fix | Delete
self.status.addClass( 'smush-warning' );
[279] Fix | Delete
self.enableButton();
[280] Fix | Delete
} );
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
/**
[284] Fix | Delete
* Get total images left to optimize.
[285] Fix | Delete
*
[286] Fix | Delete
* @see get_total_images_to_smush() in Abstract_Summary_Page class.
[287] Fix | Delete
*
[288] Fix | Delete
* @since 3.10.0
[289] Fix | Delete
*/
[290] Fix | Delete
static getTotalImagesToSmush() {
[291] Fix | Delete
const imagesToResmush = wp_smushit_data.resmush.length;
[292] Fix | Delete
[293] Fix | Delete
const unsmushedCount = wp_smushit_data.count_total - wp_smushit_data.count_smushed;
[294] Fix | Delete
[295] Fix | Delete
if ( unsmushedCount > 0 ) {
[296] Fix | Delete
return imagesToResmush + unsmushedCount;
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
return imagesToResmush;
[300] Fix | Delete
}
[301] Fix | Delete
[302] Fix | Delete
/**
[303] Fix | Delete
* Update the "optimized images" score on the summary meta box.
[304] Fix | Delete
*
[305] Fix | Delete
* @see get_grade_data() in Abstract_Summary_Page class.
[306] Fix | Delete
*
[307] Fix | Delete
* @since 3.10.0
[308] Fix | Delete
*/
[309] Fix | Delete
static updateScoreProgress() {
[310] Fix | Delete
let grade = 'sui-grade-dismissed';
[311] Fix | Delete
let percentOptimized = 0;
[312] Fix | Delete
let percentMetric = 0;
[313] Fix | Delete
[314] Fix | Delete
const totalImagesToSmush = Smush.getTotalImagesToSmush();
[315] Fix | Delete
const totalImages = parseInt( wp_smushit_data.count_total );
[316] Fix | Delete
[317] Fix | Delete
if ( totalImages === totalImagesToSmush ) {
[318] Fix | Delete
if ( totalImages > 0 ) {
[319] Fix | Delete
grade = 'sui-grade-f';
[320] Fix | Delete
}
[321] Fix | Delete
percentMetric = 100;
[322] Fix | Delete
} else if ( 0 < totalImages ) {
[323] Fix | Delete
percentOptimized = Math.floor( ( totalImages - totalImagesToSmush ) * 100 / totalImages );
[324] Fix | Delete
percentMetric = percentOptimized;
[325] Fix | Delete
grade = 'sui-grade-f';
[326] Fix | Delete
[327] Fix | Delete
if ( percentOptimized >= 60 && percentOptimized < 90 ) {
[328] Fix | Delete
grade = 'sui-grade-c';
[329] Fix | Delete
} else if ( percentOptimized >= 90 ) {
[330] Fix | Delete
grade = 'sui-grade-a';
[331] Fix | Delete
}
[332] Fix | Delete
}
[333] Fix | Delete
[334] Fix | Delete
const imageScore = jQuery( '#smush-image-score' );
[335] Fix | Delete
[336] Fix | Delete
imageScore
[337] Fix | Delete
.removeClass(
[338] Fix | Delete
function( index, className ) {
[339] Fix | Delete
const matchedClasses = className.match( /(^|\s)sui-grade-\S+/g );
[340] Fix | Delete
return ( matchedClasses || [] ).join( ' ' );
[341] Fix | Delete
}
[342] Fix | Delete
)
[343] Fix | Delete
.addClass( grade )
[344] Fix | Delete
.attr( 'data-score', percentOptimized )
[345] Fix | Delete
.find( '.sui-circle-score-label' ).html( percentOptimized );
[346] Fix | Delete
[347] Fix | Delete
imageScore
[348] Fix | Delete
.find( 'circle:last-child' )
[349] Fix | Delete
.attr( 'style', '--metric-array:' + ( 2.63893782902 * percentMetric ) + ' ' + ( 263.893782902 - percentMetric ) );
[350] Fix | Delete
}
[351] Fix | Delete
[352] Fix | Delete
/**
[353] Fix | Delete
* Update all stats sections based on the response.
[354] Fix | Delete
*
[355] Fix | Delete
* @param {string} scanType Current scan type.
[356] Fix | Delete
*/
[357] Fix | Delete
static updateStats( scanType ) {
[358] Fix | Delete
const isNextgen = 'undefined' !== typeof scanType && 'nextgen' === scanType;
[359] Fix | Delete
[360] Fix | Delete
// Calculate updated savings in bytes.
[361] Fix | Delete
wp_smushit_data.savings_bytes = parseInt( wp_smushit_data.size_before ) - parseInt( wp_smushit_data.size_after );
[362] Fix | Delete
[363] Fix | Delete
const formattedSize = WP_Smush.helpers.formatBytes( wp_smushit_data.savings_bytes, 0 );
[364] Fix | Delete
const statsHuman = jQuery( '.wp-smush-savings .wp-smush-stats-human' );
[365] Fix | Delete
[366] Fix | Delete
if ( isNextgen ) {
[367] Fix | Delete
statsHuman.html( formattedSize );
[368] Fix | Delete
} else {
[369] Fix | Delete
statsHuman.html( WP_Smush.helpers.getFormatFromString( formattedSize ) );
[370] Fix | Delete
jQuery( '.sui-summary-large.wp-smush-stats-human' )
[371] Fix | Delete
.html( WP_Smush.helpers.getSizeFromString( formattedSize ) );
[372] Fix | Delete
}
[373] Fix | Delete
[374] Fix | Delete
// Update the savings percent.
[375] Fix | Delete
wp_smushit_data.savings_percent = WP_Smush.helpers.precise_round(
[376] Fix | Delete
( parseInt( wp_smushit_data.savings_bytes ) /
[377] Fix | Delete
parseInt( wp_smushit_data.size_before ) ) *
[378] Fix | Delete
100,
[379] Fix | Delete
1
[380] Fix | Delete
);
[381] Fix | Delete
if ( ! isNaN( wp_smushit_data.savings_percent ) ) {
[382] Fix | Delete
jQuery( '.wp-smush-savings .wp-smush-stats-percent' )
[383] Fix | Delete
.html( wp_smushit_data.savings_percent );
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
// Update image count.
[387] Fix | Delete
if ( isNextgen ) {
[388] Fix | Delete
jQuery( '.sui-summary-details span.wp-smush-total-optimised' )
[389] Fix | Delete
.html( wp_smushit_data.count_images );
[390] Fix | Delete
} else {
[391] Fix | Delete
jQuery( 'span.smushed-items-count span.wp-smush-count-total span.wp-smush-total-optimised' )
[392] Fix | Delete
.html( wp_smushit_data.count_images );
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
// Update resize image count.
[396] Fix | Delete
if ( wp_smushit_data.count_resize > 0 ) {
[397] Fix | Delete
jQuery( 'span.smushed-items-count span.wp-smush-count-resize-total' ).removeClass( 'sui-hidden' );
[398] Fix | Delete
jQuery( 'span.smushed-items-count span.wp-smush-count-resize-total span.wp-smush-total-optimised' )
[399] Fix | Delete
.html( wp_smushit_data.count_resize );
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
// Update super-Smushed image count.
[403] Fix | Delete
const smushedCountDiv = jQuery( 'li.super-smush-attachments .smushed-count' );
[404] Fix | Delete
if ( smushedCountDiv.length && 'undefined' !== typeof wp_smushit_data.count_supersmushed ) {
[405] Fix | Delete
smushedCountDiv.html( wp_smushit_data.count_supersmushed );
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
// Update conversion savings.
[409] Fix | Delete
const smushConversionSavings = jQuery( '.smush-conversion-savings' );
[410] Fix | Delete
if (
[411] Fix | Delete
smushConversionSavings.length > 0 &&
[412] Fix | Delete
'undefined' !== typeof wp_smushit_data.savings_conversion &&
[413] Fix | Delete
wp_smushit_data.savings_conversion !== ''
[414] Fix | Delete
) {
[415] Fix | Delete
const conversionSavings = smushConversionSavings.find( '.wp-smush-stats' );
[416] Fix | Delete
if ( conversionSavings.length > 0 ) {
[417] Fix | Delete
conversionSavings.html(
[418] Fix | Delete
WP_Smush.helpers.formatBytes( wp_smushit_data.savings_conversion, 1 )
[419] Fix | Delete
);
[420] Fix | Delete
}
[421] Fix | Delete
}
[422] Fix | Delete
}
[423] Fix | Delete
[424] Fix | Delete
/**
[425] Fix | Delete
* Update image size in attachment info panel.
[426] Fix | Delete
*
[427] Fix | Delete
* @since 2.8
[428] Fix | Delete
*
[429] Fix | Delete
* @param {number} newSize
[430] Fix | Delete
*/
[431] Fix | Delete
static updateImageStats( newSize ) {
[432] Fix | Delete
if ( 0 === newSize ) {
[433] Fix | Delete
return;
[434] Fix | Delete
}
[435] Fix | Delete
[436] Fix | Delete
const attachmentSize = jQuery( '.attachment-info .file-size' );
[437] Fix | Delete
const currentSize = attachmentSize
[438] Fix | Delete
.contents()
[439] Fix | Delete
.filter( function() {
[440] Fix | Delete
return this.nodeType === 3;
[441] Fix | Delete
} )
[442] Fix | Delete
.text();
[443] Fix | Delete
[444] Fix | Delete
// There is a space before the size.
[445] Fix | Delete
if ( currentSize !== ' ' + newSize ) {
[446] Fix | Delete
const sizeStrongEl = attachmentSize
[447] Fix | Delete
.contents()
[448] Fix | Delete
.filter( function() {
[449] Fix | Delete
return this.nodeType === 1;
[450] Fix | Delete
} )
[451] Fix | Delete
.text();
[452] Fix | Delete
attachmentSize.html(
[453] Fix | Delete
'<strong>' + sizeStrongEl + '</strong> ' + newSize
[454] Fix | Delete
);
[455] Fix | Delete
}
[456] Fix | Delete
}
[457] Fix | Delete
[458] Fix | Delete
/**
[459] Fix | Delete
* Sync stats.
[460] Fix | Delete
*/
[461] Fix | Delete
syncStats() {
[462] Fix | Delete
const messageHolder = jQuery(
[463] Fix | Delete
'div.wp-smush-bulk-progress-bar-wrapper div.wp-smush-count.tc'
[464] Fix | Delete
);
[465] Fix | Delete
// Store the existing content in a variable.
[466] Fix | Delete
const progressMessage = messageHolder.html();
[467] Fix | Delete
/** @param {string} wp_smush_msgs.sync_stats */
[468] Fix | Delete
messageHolder.html( window.wp_smush_msgs.sync_stats );
[469] Fix | Delete
[470] Fix | Delete
const self = this;
[471] Fix | Delete
[472] Fix | Delete
// Send ajax.
[473] Fix | Delete
return jQuery
[474] Fix | Delete
.ajax( {
[475] Fix | Delete
type: 'GET',
[476] Fix | Delete
url: ajaxurl,
[477] Fix | Delete
data: {
[478] Fix | Delete
action: this.get_stats_action,
[479] Fix | Delete
_ajax_nonce: window.wp_smush_msgs.nonce,
[480] Fix | Delete
},
[481] Fix | Delete
success( response ) {
[482] Fix | Delete
if ( ! response?.success ) {
[483] Fix | Delete
WP_Smush.helpers.showNotice( response, {
[484] Fix | Delete
showdismiss: true,
[485] Fix | Delete
autoclose: false,
[486] Fix | Delete
} );
[487] Fix | Delete
return;
[488] Fix | Delete
}
[489] Fix | Delete
GlobalStats.updateGlobalStatsFromSmushScriptData( response.data );
[490] Fix | Delete
GlobalStats.renderStats();
[491] Fix | Delete
SmushProgress.update( 0, response.data.remaining_count );
[492] Fix | Delete
[493] Fix | Delete
jQuery('.wp-smush-scan').prop('disabled', false);
[494] Fix | Delete
self.hideBulkFreeLimitReachedNotice();
[495] Fix | Delete
},
[496] Fix | Delete
} )
[497] Fix | Delete
.always( () => messageHolder.html( progressMessage ) );
[498] Fix | Delete
}
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function