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/wp-conte.../plugins/wp-smush.../_src/js/modules
File: background-process.js
/* global WP_Smush */
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* Bulk Smush Background Optimization.
[3] Fix | Delete
*
[4] Fix | Delete
* @since 3.12.0
[5] Fix | Delete
*/
[6] Fix | Delete
import Fetcher from '../utils/fetcher';
[7] Fix | Delete
import tracker from '../utils/tracker';
[8] Fix | Delete
import SmushProgress from '../common/progressbar';
[9] Fix | Delete
import {GlobalStats, UpsellManger} from "../common/globalStats";
[10] Fix | Delete
import loopbackTester from '../loopback-tester';
[11] Fix | Delete
[12] Fix | Delete
(function () {
[13] Fix | Delete
'use strict';
[14] Fix | Delete
if (!window.wp_smush_msgs) {
[15] Fix | Delete
return;
[16] Fix | Delete
}
[17] Fix | Delete
const $ = document.querySelector.bind(document);
[18] Fix | Delete
const NO_FREE_LIMITED = 50;
[19] Fix | Delete
[20] Fix | Delete
/**
[21] Fix | Delete
* Handle Background Process.
[22] Fix | Delete
* @returns
[23] Fix | Delete
*/
[24] Fix | Delete
const BackgroundProcess = () => {
[25] Fix | Delete
return {
[26] Fix | Delete
handle(action) {
[27] Fix | Delete
return Fetcher.background[action]();
[28] Fix | Delete
},
[29] Fix | Delete
initState() {
[30] Fix | Delete
return Fetcher.background.initState();
[31] Fix | Delete
},
[32] Fix | Delete
}
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
/**
[36] Fix | Delete
* Background Optimization.
[37] Fix | Delete
*/
[38] Fix | Delete
const BackgroundSmush = (() => {
[39] Fix | Delete
[40] Fix | Delete
const startBtn = window.wp_smushit_data && window.wp_smushit_data.bo_stats && $('.wp-smush-bo-start');
[41] Fix | Delete
if (!startBtn) {
[42] Fix | Delete
return;
[43] Fix | Delete
}
[44] Fix | Delete
[45] Fix | Delete
const BO = new BackgroundProcess();
[46] Fix | Delete
const bulkWrapper = $('.bulk-smush-wrapper');
[47] Fix | Delete
const reScanImagesButton = $('.wp-smush-scan');
[48] Fix | Delete
let intervalHandle = 0;
[49] Fix | Delete
let cancellationInProgress = false;
[50] Fix | Delete
return {
[51] Fix | Delete
hookStatusChecks() {
[52] Fix | Delete
if (intervalHandle) {
[53] Fix | Delete
// Already done
[54] Fix | Delete
return;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
let count = 0;
[58] Fix | Delete
let statusSyncInProgress = false;
[59] Fix | Delete
let statSyncInProgress = false;
[60] Fix | Delete
intervalHandle = setInterval(() => {
[61] Fix | Delete
if (statusSyncInProgress) {
[62] Fix | Delete
return;
[63] Fix | Delete
}
[64] Fix | Delete
statusSyncInProgress = true;
[65] Fix | Delete
[66] Fix | Delete
count++;
[67] Fix | Delete
const statusSynced = this.syncBackgroundStatus();
[68] Fix | Delete
if (count % 3 === 0) {
[69] Fix | Delete
// Do a full update every nth time
[70] Fix | Delete
statusSynced.then(() => {
[71] Fix | Delete
if (!statSyncInProgress) {
[72] Fix | Delete
this.syncStats().then(() => {
[73] Fix | Delete
statSyncInProgress = false;
[74] Fix | Delete
});
[75] Fix | Delete
statSyncInProgress = true;
[76] Fix | Delete
}
[77] Fix | Delete
});
[78] Fix | Delete
}
[79] Fix | Delete
[80] Fix | Delete
statusSynced.finally(() => {
[81] Fix | Delete
statusSyncInProgress = false;
[82] Fix | Delete
});
[83] Fix | Delete
}, 3 * 1000);
[84] Fix | Delete
},
[85] Fix | Delete
resetBOStatsOnStart() {
[86] Fix | Delete
GlobalStats.setBoStats( {
[87] Fix | Delete
is_cancelled: false,
[88] Fix | Delete
is_completed: false,
[89] Fix | Delete
processed_items: 0,
[90] Fix | Delete
failed_items: 0,
[91] Fix | Delete
} );
[92] Fix | Delete
},
[93] Fix | Delete
start() {
[94] Fix | Delete
// Reset boStats.
[95] Fix | Delete
this.resetBOStatsOnStart();
[96] Fix | Delete
[97] Fix | Delete
// Disable UI.
[98] Fix | Delete
this.onStart();
[99] Fix | Delete
[100] Fix | Delete
loopbackTester.performTest().then( ( res ) => {
[101] Fix | Delete
const isLoopbackHealthy = res?.loopback;
[102] Fix | Delete
if ( isLoopbackHealthy ) {
[103] Fix | Delete
// Start BO.
[104] Fix | Delete
this.startBulkSmush();
[105] Fix | Delete
} else {
[106] Fix | Delete
this.showLoopbackErrorModal();
[107] Fix | Delete
this.onStartFailure();
[108] Fix | Delete
}
[109] Fix | Delete
} ).catch( ( error ) => {
[110] Fix | Delete
console.error( 'Error:', error );
[111] Fix | Delete
this.showLoopbackErrorModal();
[112] Fix | Delete
this.onStartFailure();
[113] Fix | Delete
} );
[114] Fix | Delete
},
[115] Fix | Delete
startBulkSmush() {
[116] Fix | Delete
BO.handle('start').then((res) => {
[117] Fix | Delete
if (res.success) {
[118] Fix | Delete
// Update stats.
[119] Fix | Delete
const updatedStats = this.updateStats(res.data, false);
[120] Fix | Delete
// Show progress bar.
[121] Fix | Delete
this.showProgressBar();
[122] Fix | Delete
this.hookStatusChecks();
[123] Fix | Delete
if ( updatedStats ) {
[124] Fix | Delete
// Render stats.
[125] Fix | Delete
GlobalStats.renderStats();
[126] Fix | Delete
}
[127] Fix | Delete
} else {
[128] Fix | Delete
this.showFailureNotice( res );
[129] Fix | Delete
this.onStartFailure( res );
[130] Fix | Delete
}
[131] Fix | Delete
});
[132] Fix | Delete
},
[133] Fix | Delete
showFailureNotice( res ) {
[134] Fix | Delete
WP_Smush.helpers.showNotice( res, {
[135] Fix | Delete
'showdismiss': true,
[136] Fix | Delete
'autoclose' : false,
[137] Fix | Delete
} );
[138] Fix | Delete
},
[139] Fix | Delete
onStartFailure( res ) {
[140] Fix | Delete
this.cancelBulk();
[141] Fix | Delete
},
[142] Fix | Delete
showLoopbackErrorModal() {
[143] Fix | Delete
const loopbackErrorModal = document.getElementById( 'smush-loopback-error-dialog' );
[144] Fix | Delete
if ( ! loopbackErrorModal || ! window.SUI ) {
[145] Fix | Delete
return;
[146] Fix | Delete
}
[147] Fix | Delete
[148] Fix | Delete
// Cache current process type.
[149] Fix | Delete
loopbackErrorModal.dataset.processType = 'smush';
[150] Fix | Delete
[151] Fix | Delete
WP_Smush.helpers.showModal( loopbackErrorModal.id );
[152] Fix | Delete
},
[153] Fix | Delete
/**
[154] Fix | Delete
* Initial state when load the Bulk Smush page while BO is running.
[155] Fix | Delete
*/
[156] Fix | Delete
initState() {
[157] Fix | Delete
if (!GlobalStats.getBoStats().in_processing) {
[158] Fix | Delete
return;
[159] Fix | Delete
}
[160] Fix | Delete
// Disable UI.
[161] Fix | Delete
this.onStart();
[162] Fix | Delete
// Start BO.
[163] Fix | Delete
BO.initState().then((res) => {
[164] Fix | Delete
if (res.success) {
[165] Fix | Delete
// Update stats.
[166] Fix | Delete
this.updateStats(res.data, false);
[167] Fix | Delete
// Show progress bar.
[168] Fix | Delete
this.showProgressBar();
[169] Fix | Delete
this.hookStatusChecks();
[170] Fix | Delete
// Maybe update errors.
[171] Fix | Delete
if ( res.data.errors && ! Object.keys( GlobalStats.getErrors() ).length ) {
[172] Fix | Delete
GlobalStats.setErrors( res.data.errors );
[173] Fix | Delete
}
[174] Fix | Delete
// Render stats.
[175] Fix | Delete
GlobalStats.renderStats();
[176] Fix | Delete
} else {
[177] Fix | Delete
WP_Smush.helpers.showNotice( res );
[178] Fix | Delete
}
[179] Fix | Delete
});
[180] Fix | Delete
},
[181] Fix | Delete
/**
[182] Fix | Delete
* Cancel.
[183] Fix | Delete
*/
[184] Fix | Delete
cancel() {
[185] Fix | Delete
cancellationInProgress = true;
[186] Fix | Delete
this.setCancelButtonStateToStarted();
[187] Fix | Delete
BO.handle('cancel').then((res) => {
[188] Fix | Delete
if (res.success) {
[189] Fix | Delete
this.cancelBulk();
[190] Fix | Delete
} else {
[191] Fix | Delete
WP_Smush.helpers.showNotice( res );
[192] Fix | Delete
}
[193] Fix | Delete
});
[194] Fix | Delete
},
[195] Fix | Delete
hideProgressBar() {
[196] Fix | Delete
// Hide progress bar.
[197] Fix | Delete
SmushProgress.close().update(0, GlobalStats.getBoStats().total_items);
[198] Fix | Delete
},
[199] Fix | Delete
showProgressBar() {
[200] Fix | Delete
// Reset progress bar.
[201] Fix | Delete
SmushProgress.update(GlobalStats.getBoStats().processed_items, GlobalStats.getBoStats().total_items);
[202] Fix | Delete
// Show progress bar.
[203] Fix | Delete
SmushProgress.show();
[204] Fix | Delete
},
[205] Fix | Delete
/**
[206] Fix | Delete
* Update stats.
[207] Fix | Delete
* @param {Object} newStats Included increment stats and new BO stats.
[208] Fix | Delete
* @param updateGlobal
[209] Fix | Delete
*/
[210] Fix | Delete
updateStats(newStats, updateGlobal) {
[211] Fix | Delete
// Make sure we have processed_stats/errors property (not added by default when start).
[212] Fix | Delete
newStats.global_stats = newStats.global_stats || {};
[213] Fix | Delete
newStats.errors = newStats.errors || {};
[214] Fix | Delete
const {
[215] Fix | Delete
global_stats,
[216] Fix | Delete
errors,
[217] Fix | Delete
...newBoStats
[218] Fix | Delete
} = newStats;
[219] Fix | Delete
if ( ! GlobalStats.isChangedStats( newBoStats ) ) {
[220] Fix | Delete
return false;
[221] Fix | Delete
}
[222] Fix | Delete
// Update BO stats.
[223] Fix | Delete
GlobalStats.setBoStats(newBoStats);
[224] Fix | Delete
if (updateGlobal) {
[225] Fix | Delete
// Update global stats.
[226] Fix | Delete
GlobalStats.setGlobalStats(global_stats);
[227] Fix | Delete
}
[228] Fix | Delete
// Update Errors.
[229] Fix | Delete
GlobalStats.setErrors( errors );
[230] Fix | Delete
return true;
[231] Fix | Delete
},
[232] Fix | Delete
cancelBulk() {
[233] Fix | Delete
// Sync Stats.
[234] Fix | Delete
this.syncStats(() => {
[235] Fix | Delete
if (100 === GlobalStats.getGlobalStats().percent_optimized) {
[236] Fix | Delete
// If the last item was getting processed when the user cancelled then the process might have completed
[237] Fix | Delete
GlobalStats.setBoStats( {
[238] Fix | Delete
is_completed: true
[239] Fix | Delete
} );
[240] Fix | Delete
this.onCompletedBulk();
[241] Fix | Delete
} else {
[242] Fix | Delete
// Update status of boStats.
[243] Fix | Delete
GlobalStats.setBoStats( {
[244] Fix | Delete
is_cancelled: true
[245] Fix | Delete
} );
[246] Fix | Delete
// Reset and hide progress bar.
[247] Fix | Delete
this.onFinish();
[248] Fix | Delete
// Bulk is cancelled, show bulk desc.
[249] Fix | Delete
SmushProgress.showBulkSmushDescription();
[250] Fix | Delete
}
[251] Fix | Delete
[252] Fix | Delete
cancellationInProgress = false;
[253] Fix | Delete
});
[254] Fix | Delete
},
[255] Fix | Delete
showCompletedMessage() {
[256] Fix | Delete
// Render completed message.
[257] Fix | Delete
// Show completed message.
[258] Fix | Delete
const processedWrapper = bulkWrapper.querySelector('.wp-smush-all-done');
[259] Fix | Delete
if ( GlobalStats.getBoStats().failed_items ) {
[260] Fix | Delete
let completeMessage = wp_smush_msgs.all_failed;
[261] Fix | Delete
if ( ! this.isFailedAllItems() ) {
[262] Fix | Delete
completeMessage = wp_smush_msgs.error_in_bulk.replace( '{{smushed}}', GlobalStats.getBoStats().total_items - GlobalStats.getBoStats().failed_items )
[263] Fix | Delete
.replace('{{total}}', GlobalStats.getBoStats().total_items )
[264] Fix | Delete
.replace('{{errors}}', GlobalStats.getBoStats().failed_items );
[265] Fix | Delete
}
[266] Fix | Delete
processedWrapper.querySelector('p').innerHTML = completeMessage;
[267] Fix | Delete
processedWrapper.classList.remove('sui-notice-success', 'sui-notice-warning');
[268] Fix | Delete
const noticeType = this.getNoticeType();
[269] Fix | Delete
const noticeIcon = 'warning' === noticeType ? 'info' : 'check-tick';
[270] Fix | Delete
const iconElement = processedWrapper.querySelector('.sui-notice-icon');
[271] Fix | Delete
processedWrapper.classList.add( 'sui-notice-' + noticeType );
[272] Fix | Delete
iconElement.classList.remove('sui-icon-check-tick', 'sui-icon-info');
[273] Fix | Delete
iconElement.classList.add( 'sui-icon-' + noticeIcon );
[274] Fix | Delete
} else {
[275] Fix | Delete
processedWrapper.querySelector('p').innerHTML = wp_smush_msgs.all_smushed;
[276] Fix | Delete
}
[277] Fix | Delete
processedWrapper.classList.remove('sui-hidden');
[278] Fix | Delete
},
[279] Fix | Delete
isFailedAllItems() {
[280] Fix | Delete
return GlobalStats.getBoStats().failed_items === GlobalStats.getBoStats().total_items;
[281] Fix | Delete
},
[282] Fix | Delete
getNoticeType() {
[283] Fix | Delete
return this.isFailedAllItems() ? 'warning' : 'success';
[284] Fix | Delete
},
[285] Fix | Delete
onCompletedBulk() {
[286] Fix | Delete
// Reset and hide progress bar.
[287] Fix | Delete
this.onFinish();
[288] Fix | Delete
// Bulk is completed, hide bulk desc.
[289] Fix | Delete
SmushProgress.hideBulkSmushDescription();
[290] Fix | Delete
// Show completed message.
[291] Fix | Delete
this.showCompletedMessage();
[292] Fix | Delete
[293] Fix | Delete
// Reset the progress when we finish so the next smushing starts from zero.
[294] Fix | Delete
SmushProgress.update(0, GlobalStats.getBoStats().total_items);
[295] Fix | Delete
},
[296] Fix | Delete
completeBulk() {
[297] Fix | Delete
// Sync Stats.
[298] Fix | Delete
this.syncStats(() => this.onCompletedBulk());
[299] Fix | Delete
},
[300] Fix | Delete
syncStats(onComplete = () => false) {
[301] Fix | Delete
return BO.handle('getStats').then((res) => {
[302] Fix | Delete
if ( res.success ) {
[303] Fix | Delete
const responseErrors = res.data.errors || {};
[304] Fix | Delete
this.updateStats( { global_stats: res.data, errors: responseErrors }, true );
[305] Fix | Delete
GlobalStats.renderStats();
[306] Fix | Delete
if ( res.data.content ) {
[307] Fix | Delete
$('#wp-smush-bulk-content').innerHTML = res.data.content;
[308] Fix | Delete
}
[309] Fix | Delete
onComplete();
[310] Fix | Delete
} else {
[311] Fix | Delete
WP_Smush.helpers.showNotice( res );
[312] Fix | Delete
}
[313] Fix | Delete
}).catch( (error) => console.log('error', error));
[314] Fix | Delete
},
[315] Fix | Delete
syncBackgroundStatus() {
[316] Fix | Delete
return BO.handle('getStatus').then((res) => {
[317] Fix | Delete
if ((res.data || {}).in_process_notice) {
[318] Fix | Delete
SmushProgress.setNotice( res.data.in_process_notice );
[319] Fix | Delete
}
[320] Fix | Delete
[321] Fix | Delete
if (res.success) {
[322] Fix | Delete
// Update stats.
[323] Fix | Delete
if ( this.updateStats(res.data, false) ) {
[324] Fix | Delete
// Update progress bar.
[325] Fix | Delete
SmushProgress.update(GlobalStats.getBoStats().processed_items, GlobalStats.getBoStats().total_items);
[326] Fix | Delete
[327] Fix | Delete
if (! GlobalStats.getBoStats().is_cancelled && ! GlobalStats.getBoStats().is_completed) {
[328] Fix | Delete
// Render stats.
[329] Fix | Delete
GlobalStats.renderStats();
[330] Fix | Delete
}
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
if (GlobalStats.getBoStats().is_cancelled && !cancellationInProgress) {
[334] Fix | Delete
// Cancelled on server side
[335] Fix | Delete
this.cancelBulk();
[336] Fix | Delete
} else if (GlobalStats.getBoStats().is_completed) {
[337] Fix | Delete
this.completeBulk();
[338] Fix | Delete
} else if ( GlobalStats.getBoStats().is_dead ) {
[339] Fix | Delete
this.onDead();
[340] Fix | Delete
}
[341] Fix | Delete
} else {
[342] Fix | Delete
WP_Smush.helpers.showNotice( res );
[343] Fix | Delete
}
[344] Fix | Delete
});
[345] Fix | Delete
},
[346] Fix | Delete
onStart() {
[347] Fix | Delete
// Disable btn.
[348] Fix | Delete
startBtn.setAttribute('disabled', '');
[349] Fix | Delete
// Disable re-check images.
[350] Fix | Delete
reScanImagesButton && reScanImagesButton.setAttribute('disabled', '');
[351] Fix | Delete
$('.wp-smush-restore').setAttribute('disabled', '');
[352] Fix | Delete
// Show upsell cdn.
[353] Fix | Delete
UpsellManger.maybeShowCDNUpsellForPreSiteOnStart();
[354] Fix | Delete
[355] Fix | Delete
this.hideBulkSmushFailedNotice();
[356] Fix | Delete
[357] Fix | Delete
this.setCancelButtonStateToInitial();
[358] Fix | Delete
},
[359] Fix | Delete
hideBulkSmushFailedNotice() {
[360] Fix | Delete
const bulkSmushFailedNotice = document.querySelector( '.wp-smush-inline-retry-bulk-smush-notice' );
[361] Fix | Delete
if ( bulkSmushFailedNotice ) {
[362] Fix | Delete
bulkSmushFailedNotice.parentElement.classList.add( 'sui-hidden' );
[363] Fix | Delete
}
[364] Fix | Delete
},
[365] Fix | Delete
onFinish() {
[366] Fix | Delete
// Clear interval.
[367] Fix | Delete
if (intervalHandle) {
[368] Fix | Delete
clearInterval(intervalHandle);
[369] Fix | Delete
intervalHandle = 0;
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
// Disable btn.
[373] Fix | Delete
startBtn.removeAttribute('disabled');
[374] Fix | Delete
// Reset and hide Progress Bar.
[375] Fix | Delete
this.hideProgressBar();
[376] Fix | Delete
// Disable re-check images.
[377] Fix | Delete
reScanImagesButton && reScanImagesButton.removeAttribute('disabled', '');
[378] Fix | Delete
$('.wp-smush-restore').removeAttribute('disabled', '');
[379] Fix | Delete
[380] Fix | Delete
// Show upsell cdn.
[381] Fix | Delete
UpsellManger.maybeShowCDNUpsellForPreSiteOnCompleted();
[382] Fix | Delete
},
[383] Fix | Delete
onDead() {
[384] Fix | Delete
this.onFinish();
[385] Fix | Delete
SmushProgress.showBulkSmushDescription();
[386] Fix | Delete
this.showRetryBulkSmushModal();
[387] Fix | Delete
},
[388] Fix | Delete
showRetryBulkSmushModal() {
[389] Fix | Delete
const retryModalElement = document.getElementById( 'smush-retry-bulk-smush-notice' );
[390] Fix | Delete
if ( ! window.SUI || ! retryModalElement ) {
[391] Fix | Delete
return;
[392] Fix | Delete
}
[393] Fix | Delete
[394] Fix | Delete
retryModalElement.querySelector('.smush-retry-bulk-smush-notice-button').onclick = (e) => {
[395] Fix | Delete
e.preventDefault();
[396] Fix | Delete
window.SUI.closeModal( 'smush-retry-bulk-smush-notice' );
[397] Fix | Delete
this.start();
[398] Fix | Delete
}
[399] Fix | Delete
[400] Fix | Delete
window.SUI.openModal(
[401] Fix | Delete
'smush-retry-bulk-smush-notice',
[402] Fix | Delete
'wpbody-content',
[403] Fix | Delete
undefined,
[404] Fix | Delete
false
[405] Fix | Delete
);
[406] Fix | Delete
},
[407] Fix | Delete
init() {
[408] Fix | Delete
if (!startBtn) {
[409] Fix | Delete
return;
[410] Fix | Delete
}
[411] Fix | Delete
[412] Fix | Delete
// Start BO.
[413] Fix | Delete
startBtn.onclick = () => {
[414] Fix | Delete
const requiredScanMedia = startBtn.classList.contains('wp-smush-scan-and-bulk-smush');
[415] Fix | Delete
if ( requiredScanMedia ) {
[416] Fix | Delete
return;
[417] Fix | Delete
}
[418] Fix | Delete
this.start();
[419] Fix | Delete
}
[420] Fix | Delete
[421] Fix | Delete
const triggerBulkSmushButton = document.querySelector( '.wp-smush-inline-retry-bulk-smush-notice .wp-smush-trigger-bulk-smush' );
[422] Fix | Delete
if ( triggerBulkSmushButton ) {
[423] Fix | Delete
triggerBulkSmushButton.addEventListener( 'click', ( e ) => {
[424] Fix | Delete
e.preventDefault();
[425] Fix | Delete
[426] Fix | Delete
startBtn.click();
[427] Fix | Delete
} );
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
// If BO is running, initial new state.
[431] Fix | Delete
this.initState();
[432] Fix | Delete
},
[433] Fix | Delete
setCancelButtonStateToInitial() {
[434] Fix | Delete
SmushProgress.setCancelButtonLabel( wp_smush_msgs.cancel );
[435] Fix | Delete
SmushProgress.setOnCancelCallback( this.cancel.bind(this) );
[436] Fix | Delete
},
[437] Fix | Delete
setCancelButtonStateToStarted() {
[438] Fix | Delete
SmushProgress.setCancelButtonLabel( wp_smush_msgs.cancelling );
[439] Fix | Delete
SmushProgress.setOnCancelCallback( () => false );
[440] Fix | Delete
},
[441] Fix | Delete
}
[442] Fix | Delete
})();
[443] Fix | Delete
// Run.
[444] Fix | Delete
BackgroundSmush && BackgroundSmush.init();
[445] Fix | Delete
/**
[446] Fix | Delete
* For globalStats, we will need to update it on reload and after re-checking images,
[447] Fix | Delete
* and on finish the BO.
[448] Fix | Delete
* 1. On finish, we handled via BackgroundSmush.syncStats -> BackgroundSmush.updateStats
[449] Fix | Delete
* 2. On reload or after re-checking images, we need to update globalStats from global variable:
[450] Fix | Delete
* window.wp_smushit_data
[451] Fix | Delete
*/
[452] Fix | Delete
// Update global stats after re-checking images.
[453] Fix | Delete
document.addEventListener('wpSmushAfterRecheckImages', function(){
[454] Fix | Delete
GlobalStats.updateGlobalStatsFromSmushScriptData();
[455] Fix | Delete
});
[456] Fix | Delete
[457] Fix | Delete
document.addEventListener('backgroundBulkSmushOnScanCompleted', function(){
[458] Fix | Delete
if ( ! BackgroundSmush ) {
[459] Fix | Delete
return;
[460] Fix | Delete
}
[461] Fix | Delete
GlobalStats.setBoStats({
[462] Fix | Delete
in_processing: true,
[463] Fix | Delete
});
[464] Fix | Delete
BackgroundSmush.initState();
[465] Fix | Delete
});
[466] Fix | Delete
})();
[467] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function