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

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-conte.../plugins/wp-smush.../_src/js/smush
File: smush.js
[500] Fix | Delete
/**
[501] Fix | Delete
* After the bulk optimization has been finished.
[502] Fix | Delete
*/
[503] Fix | Delete
bulkDone() {
[504] Fix | Delete
if ( ! this.is_bulk ) {
[505] Fix | Delete
return;
[506] Fix | Delete
}
[507] Fix | Delete
[508] Fix | Delete
// Enable the button.
[509] Fix | Delete
this.enableButton();
[510] Fix | Delete
[511] Fix | Delete
// Show notice.
[512] Fix | Delete
if ( 0 === this.ids.length ) {
[513] Fix | Delete
jQuery('.bulk-smush-wrapper .wp-smush-all-done').removeClass( 'sui-hidden' );
[514] Fix | Delete
jQuery( '.wp-smush-bulk-wrapper' ).addClass( 'sui-hidden' );
[515] Fix | Delete
// Hide the progress bar if scan is finished.
[516] Fix | Delete
jQuery( '.wp-smush-bulk-progress-bar-wrapper' ).addClass( 'sui-hidden' );
[517] Fix | Delete
[518] Fix | Delete
// Reset the progress when we finish so the next smushing starts from zero.
[519] Fix | Delete
this._updateProgress( 0, 0 );
[520] Fix | Delete
}
[521] Fix | Delete
[522] Fix | Delete
// Enable re-Smush and scan button.
[523] Fix | Delete
jQuery( '.wp-resmush.wp-smush-action' ).removeProp(
[524] Fix | Delete
'disabled'
[525] Fix | Delete
);
[526] Fix | Delete
}
[527] Fix | Delete
[528] Fix | Delete
showAnimatedUpsellNotice() {
[529] Fix | Delete
if ( ! this.errors.length ) {
[530] Fix | Delete
return;
[531] Fix | Delete
}
[532] Fix | Delete
// Only show animated upsell if exists an animated error in first 5 errors.
[533] Fix | Delete
// Note, this.errors will be reset each we resume so let detect animated error from elements.
[534] Fix | Delete
const bulkErrors = document.querySelector('.smush-bulk-errors');
[535] Fix | Delete
if ( ! bulkErrors ) {
[536] Fix | Delete
return;
[537] Fix | Delete
}
[538] Fix | Delete
const firstAnimatedError = bulkErrors.querySelector( '[data-error-code="animated"]' );
[539] Fix | Delete
if ( ! firstAnimatedError ) {
[540] Fix | Delete
return;
[541] Fix | Delete
}
[542] Fix | Delete
const first5Errors = Array.prototype.slice.call(bulkErrors.childNodes, 0, 5 );
[543] Fix | Delete
return first5Errors.includes( firstAnimatedError );
[544] Fix | Delete
}
[545] Fix | Delete
[546] Fix | Delete
maybeShowCDNActivationNotice() {
[547] Fix | Delete
// Only for pro users.
[548] Fix | Delete
if ( ! wp_smush_msgs.smush_cdn_activation_notice || ! this.showAnimatedUpsellNotice() ) {
[549] Fix | Delete
return;
[550] Fix | Delete
}
[551] Fix | Delete
WP_Smush.helpers.renderActivationCDNNotice( wp_smush_msgs.smush_cdn_activation_notice );
[552] Fix | Delete
}
[553] Fix | Delete
[554] Fix | Delete
maybeShowUnlimitedUpsellNotice() {
[555] Fix | Delete
const unlimitedUpsellNotice = document.querySelector('.wp-smush-global-upsell');
[556] Fix | Delete
if ( ! unlimitedUpsellNotice ) {
[557] Fix | Delete
return;
[558] Fix | Delete
}
[559] Fix | Delete
unlimitedUpsellNotice.classList.remove( 'sui-hidden' );
[560] Fix | Delete
}
[561] Fix | Delete
[562] Fix | Delete
maybeShowBulkErrorActions() {
[563] Fix | Delete
if ( ! this.errors.length ) {
[564] Fix | Delete
return;
[565] Fix | Delete
}
[566] Fix | Delete
const bulkErrorActionsElement = document.querySelector('.smush-bulk-errors-actions');
[567] Fix | Delete
if ( ! bulkErrorActionsElement ) {
[568] Fix | Delete
return;
[569] Fix | Delete
}
[570] Fix | Delete
[571] Fix | Delete
bulkErrorActionsElement.classList.remove('sui-hidden');
[572] Fix | Delete
}
[573] Fix | Delete
[574] Fix | Delete
/**
[575] Fix | Delete
* Free Smush limit exceeded.
[576] Fix | Delete
*/
[577] Fix | Delete
freeExceeded() {
[578] Fix | Delete
const progress = jQuery( '.wp-smush-bulk-progress-bar-wrapper' );
[579] Fix | Delete
progress.addClass( 'wp-smush-exceed-limit' ).removeClass('sui-hidden');
[580] Fix | Delete
progress
[581] Fix | Delete
.find( '.sui-progress-block .wp-smush-cancel-bulk' )
[582] Fix | Delete
.removeClass( 'sui-hidden' );
[583] Fix | Delete
progress
[584] Fix | Delete
.find( '.sui-progress-block .wp-smush-all' )
[585] Fix | Delete
.addClass( 'sui-hidden' );
[586] Fix | Delete
[587] Fix | Delete
progress
[588] Fix | Delete
.find( 'i.sui-icon-loader' )
[589] Fix | Delete
.addClass( 'sui-icon-info' )
[590] Fix | Delete
.removeClass( 'sui-icon-loader' )
[591] Fix | Delete
.removeClass( 'sui-loading' );
[592] Fix | Delete
[593] Fix | Delete
document
[594] Fix | Delete
.getElementById( 'bulk-smush-resume-button' )
[595] Fix | Delete
.classList.remove( 'sui-hidden' );
[596] Fix | Delete
[597] Fix | Delete
this.showBulkFreeLimitReachedNotice();
[598] Fix | Delete
}
[599] Fix | Delete
[600] Fix | Delete
showBulkFreeLimitReachedNotice() {
[601] Fix | Delete
const bulkFreeLimitReachedNotice = document.getElementById( 'smush-limit-reached-notice' );
[602] Fix | Delete
if ( bulkFreeLimitReachedNotice ) {
[603] Fix | Delete
bulkFreeLimitReachedNotice.classList.remove( 'sui-hidden' );
[604] Fix | Delete
}
[605] Fix | Delete
}
[606] Fix | Delete
[607] Fix | Delete
hideBulkFreeLimitReachedNotice() {
[608] Fix | Delete
const bulkFreeLimitReachedNotice = document.getElementById( 'smush-limit-reached-notice' );
[609] Fix | Delete
if ( bulkFreeLimitReachedNotice ) {
[610] Fix | Delete
bulkFreeLimitReachedNotice.classList.add( 'sui-hidden' );
[611] Fix | Delete
}
[612] Fix | Delete
}
[613] Fix | Delete
[614] Fix | Delete
/**
[615] Fix | Delete
* Adds the stats for the current image to existing stats.
[616] Fix | Delete
*
[617] Fix | Delete
* @param {Array} imageStats
[618] Fix | Delete
* @param {string} imageStats.count
[619] Fix | Delete
* @param {boolean} imageStats.is_lossy
[620] Fix | Delete
* @param {Array} imageStats.savings_resize
[621] Fix | Delete
* @param {Array} imageStats.savings_conversion
[622] Fix | Delete
* @param {string} imageStats.size_before
[623] Fix | Delete
* @param {string} imageStats.size_after
[624] Fix | Delete
* @param {string} type
[625] Fix | Delete
*/
[626] Fix | Delete
static updateLocalizedStats( imageStats, type ) {
[627] Fix | Delete
// Increase the Smush count.
[628] Fix | Delete
if ( 'undefined' === typeof window.wp_smushit_data ) {
[629] Fix | Delete
return;
[630] Fix | Delete
}
[631] Fix | Delete
[632] Fix | Delete
// No need to increase attachment count, resize, conversion savings for directory Smush.
[633] Fix | Delete
if ( 'media' === type ) {
[634] Fix | Delete
wp_smushit_data.count_smushed = parseInt( wp_smushit_data.count_smushed ) + 1;
[635] Fix | Delete
[636] Fix | Delete
// Increase Smushed image count.
[637] Fix | Delete
wp_smushit_data.count_images = parseInt( wp_smushit_data.count_images ) + parseInt( imageStats.count );
[638] Fix | Delete
[639] Fix | Delete
// Increase super Smush count, if applicable.
[640] Fix | Delete
if ( imageStats.is_lossy ) {
[641] Fix | Delete
wp_smushit_data.count_supersmushed = parseInt( wp_smushit_data.count_supersmushed ) + 1;
[642] Fix | Delete
}
[643] Fix | Delete
[644] Fix | Delete
// Add to resize savings.
[645] Fix | Delete
wp_smushit_data.savings_resize =
[646] Fix | Delete
'undefined' !== typeof imageStats.savings_resize.bytes
[647] Fix | Delete
? parseInt( wp_smushit_data.savings_resize ) + parseInt( imageStats.savings_resize.bytes )
[648] Fix | Delete
: parseInt( wp_smushit_data.savings_resize );
[649] Fix | Delete
[650] Fix | Delete
// Update resize count.
[651] Fix | Delete
wp_smushit_data.count_resize =
[652] Fix | Delete
'undefined' !== typeof imageStats.savings_resize.bytes
[653] Fix | Delete
? parseInt( wp_smushit_data.count_resize ) + 1
[654] Fix | Delete
: wp_smushit_data.count_resize;
[655] Fix | Delete
[656] Fix | Delete
// Add to conversion savings.
[657] Fix | Delete
wp_smushit_data.savings_conversion =
[658] Fix | Delete
'undefined' !== typeof imageStats.savings_conversion &&
[659] Fix | Delete
'undefined' !== typeof imageStats.savings_conversion.bytes
[660] Fix | Delete
? parseInt( wp_smushit_data.savings_conversion ) + parseInt( imageStats.savings_conversion.bytes )
[661] Fix | Delete
: parseInt( wp_smushit_data.savings_conversion );
[662] Fix | Delete
} else if ( 'directory_smush' === type ) {
[663] Fix | Delete
//Increase smushed image count
[664] Fix | Delete
wp_smushit_data.count_images = parseInt( wp_smushit_data.count_images ) + 1;
[665] Fix | Delete
} else if ( 'nextgen' === type ) {
[666] Fix | Delete
wp_smushit_data.count_smushed = parseInt( wp_smushit_data.count_smushed ) + 1;
[667] Fix | Delete
wp_smushit_data.count_supersmushed = parseInt( wp_smushit_data.count_supersmushed ) + 1;
[668] Fix | Delete
[669] Fix | Delete
// Increase Smushed image count.
[670] Fix | Delete
wp_smushit_data.count_images = parseInt( wp_smushit_data.count_images ) + parseInt( imageStats.count );
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
// If we have savings. Update savings.
[674] Fix | Delete
if ( imageStats.size_before > imageStats.size_after ) {
[675] Fix | Delete
wp_smushit_data.size_before =
[676] Fix | Delete
'undefined' !== typeof imageStats.size_before
[677] Fix | Delete
? parseInt( wp_smushit_data.size_before ) + parseInt( imageStats.size_before )
[678] Fix | Delete
: parseInt( wp_smushit_data.size_before );
[679] Fix | Delete
wp_smushit_data.size_after =
[680] Fix | Delete
'undefined' !== typeof imageStats.size_after
[681] Fix | Delete
? parseInt( wp_smushit_data.size_after ) + parseInt( imageStats.size_after )
[682] Fix | Delete
: parseInt( wp_smushit_data.size_after );
[683] Fix | Delete
}
[684] Fix | Delete
[685] Fix | Delete
// Add stats for resizing. Update savings.
[686] Fix | Delete
if ( 'undefined' !== typeof imageStats.savings_resize ) {
[687] Fix | Delete
wp_smushit_data.size_before =
[688] Fix | Delete
'undefined' !== typeof imageStats.savings_resize.size_before
[689] Fix | Delete
? parseInt( wp_smushit_data.size_before ) + parseInt( imageStats.savings_resize.size_before )
[690] Fix | Delete
: parseInt( wp_smushit_data.size_before );
[691] Fix | Delete
wp_smushit_data.size_after =
[692] Fix | Delete
'undefined' !== typeof imageStats.savings_resize.size_after
[693] Fix | Delete
? parseInt( wp_smushit_data.size_after ) + parseInt( imageStats.savings_resize.size_after )
[694] Fix | Delete
: parseInt( wp_smushit_data.size_after );
[695] Fix | Delete
}
[696] Fix | Delete
[697] Fix | Delete
// Add stats for conversion. Update savings.
[698] Fix | Delete
if ( 'undefined' !== typeof imageStats.savings_conversion ) {
[699] Fix | Delete
wp_smushit_data.size_before =
[700] Fix | Delete
'undefined' !== typeof imageStats.savings_conversion.size_before
[701] Fix | Delete
? parseInt( wp_smushit_data.size_before ) + parseInt( imageStats.savings_conversion.size_before )
[702] Fix | Delete
: parseInt( wp_smushit_data.size_before );
[703] Fix | Delete
wp_smushit_data.size_after =
[704] Fix | Delete
'undefined' !== typeof imageStats.savings_conversion.size_after
[705] Fix | Delete
? parseInt( wp_smushit_data.size_after ) + parseInt( imageStats.savings_conversion.size_after )
[706] Fix | Delete
: parseInt( wp_smushit_data.size_after );
[707] Fix | Delete
}
[708] Fix | Delete
}
[709] Fix | Delete
[710] Fix | Delete
/**
[711] Fix | Delete
* Update progress.
[712] Fix | Delete
*
[713] Fix | Delete
* @param {Object} _res
[714] Fix | Delete
*/
[715] Fix | Delete
updateProgress( _res ) {
[716] Fix | Delete
if ( ! this.is_bulk_resmush && ! this.is_bulk ) {
[717] Fix | Delete
return;
[718] Fix | Delete
}
[719] Fix | Delete
[720] Fix | Delete
let progress = 0;
[721] Fix | Delete
[722] Fix | Delete
// Update localized stats.
[723] Fix | Delete
if (
[724] Fix | Delete
_res &&
[725] Fix | Delete
'undefined' !== typeof _res.data &&
[726] Fix | Delete
'undefined' !== typeof _res.data.stats
[727] Fix | Delete
) {
[728] Fix | Delete
Smush.updateLocalizedStats( _res.data.stats, this.smush_type );
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
if ( ! this.is_bulk_resmush ) {
[732] Fix | Delete
// Handle progress for normal bulk smush.
[733] Fix | Delete
progress =
[734] Fix | Delete
( ( this.smushed + this.errors.length ) / this.total ) * 100;
[735] Fix | Delete
} else {
[736] Fix | Delete
// If the request was successful, update the progress bar.
[737] Fix | Delete
if ( _res.success ) {
[738] Fix | Delete
// Handle progress for super Smush progress bar.
[739] Fix | Delete
if ( wp_smushit_data.resmush.length > 0 ) {
[740] Fix | Delete
// Update the count.
[741] Fix | Delete
jQuery( '.wp-smush-images-remaining' ).html(
[742] Fix | Delete
wp_smushit_data.resmush.length
[743] Fix | Delete
);
[744] Fix | Delete
} else if (
[745] Fix | Delete
0 === wp_smushit_data.resmush.length &&
[746] Fix | Delete
0 === this.ids.length
[747] Fix | Delete
) {
[748] Fix | Delete
// If all images are re-Smushed, show the All Smushed message.
[749] Fix | Delete
jQuery('.bulk-resmush-wrapper .wp-smush-all-done').removeClass( 'sui-hidden' );
[750] Fix | Delete
[751] Fix | Delete
// Hide everything else.
[752] Fix | Delete
jQuery(
[753] Fix | Delete
'.wp-smush-resmush-wrap, .wp-smush-bulk-progress-bar-wrapper'
[754] Fix | Delete
).addClass( 'sui-hidden' );
[755] Fix | Delete
}
[756] Fix | Delete
}
[757] Fix | Delete
[758] Fix | Delete
// Handle progress for normal bulk Smush. Set progress bar width.
[759] Fix | Delete
if (
[760] Fix | Delete
'undefined' !== typeof this.ids &&
[761] Fix | Delete
'undefined' !== typeof this.total &&
[762] Fix | Delete
this.total > 0
[763] Fix | Delete
) {
[764] Fix | Delete
progress =
[765] Fix | Delete
( ( this.smushed + this.errors.length ) / this.total ) *
[766] Fix | Delete
100;
[767] Fix | Delete
}
[768] Fix | Delete
}
[769] Fix | Delete
[770] Fix | Delete
// Reset the lossless images count in case of pending images for resmush ( Nextgen only ).
[771] Fix | Delete
if (
[772] Fix | Delete
'nextgen' === this.smush_type &&
[773] Fix | Delete
wp_smushit_data.resmush.length > 0 &&
[774] Fix | Delete
(this.smushed + this.errors.length <= 1)
[775] Fix | Delete
) {
[776] Fix | Delete
wp_smushit_data.count_images -= (wp_smushit_data.resmush.length + 1);
[777] Fix | Delete
}
[778] Fix | Delete
[779] Fix | Delete
// No more images left. Show bulk wrapper and Smush notice.
[780] Fix | Delete
if ( 0 === this.ids.length ) {
[781] Fix | Delete
// TODO: Check it with BO and maybe move these into progress bar module for reusing.
[782] Fix | Delete
jQuery('.bulk-smush-wrapper .wp-smush-all-done').removeClass( 'sui-hidden' );
[783] Fix | Delete
jQuery( '.wp-smush-bulk-wrapper' ).addClass( 'sui-hidden' );
[784] Fix | Delete
}
[785] Fix | Delete
[786] Fix | Delete
// Increase the progress bar and counter.
[787] Fix | Delete
this._updateProgress(
[788] Fix | Delete
this.smushed + this.errors.length,
[789] Fix | Delete
WP_Smush.helpers.precise_round( progress, 1 )
[790] Fix | Delete
);
[791] Fix | Delete
[792] Fix | Delete
// Avoid updating the stats twice when the bulk smush ends on Smush's page.
[793] Fix | Delete
if (0 !== this.ids.length || 'nextgen' === this.smush_type) {
[794] Fix | Delete
// Update stats and counts.
[795] Fix | Delete
Smush.updateStats(this.smush_type);
[796] Fix | Delete
}
[797] Fix | Delete
}
[798] Fix | Delete
[799] Fix | Delete
/**
[800] Fix | Delete
* Update progress.
[801] Fix | Delete
*
[802] Fix | Delete
* @param {number} count Number of images optimized.
[803] Fix | Delete
* @param {string} width Percentage complete.
[804] Fix | Delete
* @private
[805] Fix | Delete
*/
[806] Fix | Delete
_updateProgress( count, width ) {
[807] Fix | Delete
if ( ! this.is_bulk && ! this.is_bulk_resmush ) {
[808] Fix | Delete
return;
[809] Fix | Delete
}
[810] Fix | Delete
[811] Fix | Delete
// Progress bar label.
[812] Fix | Delete
jQuery( 'span.wp-smush-images-percent' ).html( width + '%' );
[813] Fix | Delete
// Progress bar.
[814] Fix | Delete
jQuery( '.bulk-smush-wrapper .wp-smush-progress-inner' ).css(
[815] Fix | Delete
'width',
[816] Fix | Delete
width + '%'
[817] Fix | Delete
);
[818] Fix | Delete
[819] Fix | Delete
// Progress bar status.
[820] Fix | Delete
jQuery( '.bulk-smush-wrapper .sui-progress-state-text' )
[821] Fix | Delete
.find( 'span:first-child' )
[822] Fix | Delete
.html( count )
[823] Fix | Delete
.find( 'span:last-child' )
[824] Fix | Delete
.html( this.total );
[825] Fix | Delete
}
[826] Fix | Delete
[827] Fix | Delete
/**
[828] Fix | Delete
* Whether to send the ajax requests further or not.
[829] Fix | Delete
*
[830] Fix | Delete
* @return {*|boolean} Should continue or not.
[831] Fix | Delete
*/
[832] Fix | Delete
continue() {
[833] Fix | Delete
return this.continueSmush && this.ids.length > 0 && this.is_bulk;
[834] Fix | Delete
let continueSmush = this.button.attr( 'continue_smush' );
[835] Fix | Delete
[836] Fix | Delete
if ( 'undefined' === typeof continueSmush ) {
[837] Fix | Delete
continueSmush = true;
[838] Fix | Delete
}
[839] Fix | Delete
[840] Fix | Delete
if ( 'false' === continueSmush || ! continueSmush ) {
[841] Fix | Delete
continueSmush = false;
[842] Fix | Delete
}
[843] Fix | Delete
[844] Fix | Delete
return continueSmush && this.ids.length > 0 && this.is_bulk;
[845] Fix | Delete
}
[846] Fix | Delete
[847] Fix | Delete
onStart() {
[848] Fix | Delete
this.deferred = jQuery.Deferred();
[849] Fix | Delete
this.deferred.errors = [];
[850] Fix | Delete
this.continueSmush = true;
[851] Fix | Delete
// TODO: errors will reset after bulk smush limit is reached and user clicks continue.
[852] Fix | Delete
this.errors = [];
[853] Fix | Delete
// Smushed and total we take from the progress bar... I don't like this :-(
[854] Fix | Delete
const progressBar = jQuery(
[855] Fix | Delete
'.bulk-smush-wrapper .sui-progress-state-text'
[856] Fix | Delete
);
[857] Fix | Delete
this.smushed = parseInt(
[858] Fix | Delete
progressBar.find( 'span:first-child' ).html()
[859] Fix | Delete
);
[860] Fix | Delete
this.total = parseInt( progressBar.find( 'span:last-child' ).html() );
[861] Fix | Delete
[862] Fix | Delete
jQuery('.wp-smush-restore').prop('disabled', true);
[863] Fix | Delete
}
[864] Fix | Delete
[865] Fix | Delete
/**
[866] Fix | Delete
* Send ajax request for optimizing single and bulk, call update_progress on ajax response.
[867] Fix | Delete
*
[868] Fix | Delete
* @return {*} Ajax call response.
[869] Fix | Delete
*/
[870] Fix | Delete
callAjax(newBulkSmushStarted = false) {
[871] Fix | Delete
/**
[872] Fix | Delete
* This here little piece of code allows to track auto continue clicks and halts bulk Smush until the page
[873] Fix | Delete
* is reloaded.
[874] Fix | Delete
*
[875] Fix | Delete
* @since 3.5.0
[876] Fix | Delete
* @see https://wordpress.org/plugins/wp-nonstop-smushit/
[877] Fix | Delete
*/
[878] Fix | Delete
if (
[879] Fix | Delete
0 !== perf &&
[880] Fix | Delete
'undefined' !== typeof perf &&
[881] Fix | Delete
10 > performance.now() - perf
[882] Fix | Delete
) {
[883] Fix | Delete
this.freeExceeded();
[884] Fix | Delete
return this.deferred;
[885] Fix | Delete
}
[886] Fix | Delete
[887] Fix | Delete
let nonceValue = window.wp_smush_msgs.nonce;
[888] Fix | Delete
// Remove from array while processing so we can continue where left off.
[889] Fix | Delete
this.current_id = this.is_bulk
[890] Fix | Delete
? this.ids.shift()
[891] Fix | Delete
: this.button.data( 'id' );
[892] Fix | Delete
[893] Fix | Delete
// Remove the ID from respective variable as well.
[894] Fix | Delete
Smush.updateSmushIds( this.current_id );
[895] Fix | Delete
[896] Fix | Delete
const nonceField = this.button.parent().find( '#_wp_smush_nonce' );
[897] Fix | Delete
if ( nonceField.length > 0 ) {
[898] Fix | Delete
nonceValue = nonceField.val();
[899] Fix | Delete
}
[900] Fix | Delete
[901] Fix | Delete
const self = this;
[902] Fix | Delete
[903] Fix | Delete
this.request = Smush.ajax(
[904] Fix | Delete
this.is_bulk_resmush,
[905] Fix | Delete
this.current_id,
[906] Fix | Delete
this.url,
[907] Fix | Delete
nonceValue,
[908] Fix | Delete
newBulkSmushStarted
[909] Fix | Delete
)
[910] Fix | Delete
.done( function( res ) {
[911] Fix | Delete
// If no response or success is false, do not process further. Increase the error count except if bulk request limit exceeded.
[912] Fix | Delete
if (
[913] Fix | Delete
'undefined' === typeof res.success ||
[914] Fix | Delete
( 'undefined' !== typeof res.success &&
[915] Fix | Delete
false === res.success &&
[916] Fix | Delete
'undefined' !== typeof res.data &&
[917] Fix | Delete
'limit_exceeded' !== res.data.error )
[918] Fix | Delete
) {
[919] Fix | Delete
self.errors.push( self.current_id );
[920] Fix | Delete
const error = res.data.error;
[921] Fix | Delete
[922] Fix | Delete
/** @param {string} res.data.file_name */
[923] Fix | Delete
const errorMsg = WP_Smush.helpers.prepareBulkSmushErrorRow(
[924] Fix | Delete
error.error_message,
[925] Fix | Delete
error.file_name,
[926] Fix | Delete
error.thumbnail,
[927] Fix | Delete
self.current_id,
[928] Fix | Delete
self.smush_type,
[929] Fix | Delete
error.error_code
[930] Fix | Delete
);
[931] Fix | Delete
[932] Fix | Delete
self.log.removeClass('sui-hidden');
[933] Fix | Delete
[934] Fix | Delete
// Print the error on screen.
[935] Fix | Delete
self.log.find( '.smush-bulk-errors' ).append( errorMsg );
[936] Fix | Delete
if ( self.errors.length > 4 ) {
[937] Fix | Delete
self.log.find( '.smush-bulk-errors' ).addClass('overflow-box');
[938] Fix | Delete
jQuery( '.smush-bulk-errors-actions' ).removeClass( 'sui-hidden' );
[939] Fix | Delete
}
[940] Fix | Delete
} else if (
[941] Fix | Delete
'undefined' !== typeof res.success &&
[942] Fix | Delete
res.success
[943] Fix | Delete
) {
[944] Fix | Delete
// Increment the smushed count if image smushed without errors.
[945] Fix | Delete
self.smushed++;
[946] Fix | Delete
}
[947] Fix | Delete
[948] Fix | Delete
// Check whether to show the warning notice or not.
[949] Fix | Delete
Smush.membershipValidity( res.data );
[950] Fix | Delete
[951] Fix | Delete
/**
[952] Fix | Delete
* Bulk Smush limit exceeded: Stop ajax requests, remove progress bar, append the last image ID
[953] Fix | Delete
* back to Smush variable, and reset variables to allow the user to continue bulk Smush.
[954] Fix | Delete
*/
[955] Fix | Delete
if (
[956] Fix | Delete
'undefined' !== typeof res.data &&
[957] Fix | Delete
'limit_exceeded' === res.data.error &&
[958] Fix | Delete
'resolved' !== self.deferred.state()
[959] Fix | Delete
) {
[960] Fix | Delete
// Hide bulk running message.
[961] Fix | Delete
const bulkRunning = document.getElementById(
[962] Fix | Delete
'wp-smush-running-notice'
[963] Fix | Delete
);
[964] Fix | Delete
bulkRunning.classList.add( 'sui-hidden' );
[965] Fix | Delete
[966] Fix | Delete
// Add a data attribute to the Smush button, to stop sending ajax.
[967] Fix | Delete
// self.button.attr( 'continue_smush', false );
[968] Fix | Delete
self.continueSmush = false;
[969] Fix | Delete
[970] Fix | Delete
// Reinsert the current ID.
[971] Fix | Delete
wp_smushit_data.unsmushed.unshift( self.current_id );
[972] Fix | Delete
self.ids.unshift( self.current_id );
[973] Fix | Delete
[974] Fix | Delete
perf = performance.now();
[975] Fix | Delete
self.freeExceeded();
[976] Fix | Delete
} else if ( self.is_bulk ) {
[977] Fix | Delete
self.updateProgress( res );
[978] Fix | Delete
Smush.updateScoreProgress();
[979] Fix | Delete
}
[980] Fix | Delete
[981] Fix | Delete
if (0 === self.ids.length && self.is_bulk ) {
[982] Fix | Delete
self.onBulkSmushCompleted();
[983] Fix | Delete
}
[984] Fix | Delete
[985] Fix | Delete
self.singleDone();
[986] Fix | Delete
} )
[987] Fix | Delete
.always( function() {
[988] Fix | Delete
if ( ! self.continue() || ! self.is_bulk ) {
[989] Fix | Delete
// Calls deferred.done()
[990] Fix | Delete
self.deferred.resolve();
[991] Fix | Delete
} else {
[992] Fix | Delete
self.callAjax(false);
[993] Fix | Delete
}
[994] Fix | Delete
} );
[995] Fix | Delete
[996] Fix | Delete
this.deferred.errors = this.errors;
[997] Fix | Delete
[998] Fix | Delete
return this.deferred;
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function