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: admin.js
/* global ajaxurl */
[0] Fix | Delete
[1] Fix | Delete
import Smush from '../smush/smush';
[2] Fix | Delete
import {GlobalStats} from "../common/globalStats";
[3] Fix | Delete
import SmushProgress from "../common/progressbar";
[4] Fix | Delete
[5] Fix | Delete
const remove_element = function (el, timeout) {
[6] Fix | Delete
if (typeof timeout === 'undefined') {
[7] Fix | Delete
timeout = 100;
[8] Fix | Delete
}
[9] Fix | Delete
el.fadeTo(timeout, 0, function () {
[10] Fix | Delete
el.slideUp(timeout, function () {
[11] Fix | Delete
el.remove();
[12] Fix | Delete
});
[13] Fix | Delete
});
[14] Fix | Delete
};
[15] Fix | Delete
[16] Fix | Delete
jQuery(function ($) {
[17] Fix | Delete
'use strict';
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Disable the action links *
[21] Fix | Delete
*
[22] Fix | Delete
* @param c_element
[23] Fix | Delete
*/
[24] Fix | Delete
const disable_links = function (c_element) {
[25] Fix | Delete
const parent = c_element.parent();
[26] Fix | Delete
//reduce parent opacity
[27] Fix | Delete
parent.css({ opacity: '0.5' });
[28] Fix | Delete
//Disable Links
[29] Fix | Delete
parent.find('a').prop('disabled', true);
[30] Fix | Delete
};
[31] Fix | Delete
[32] Fix | Delete
/**
[33] Fix | Delete
* Enable the Action Links *
[34] Fix | Delete
*
[35] Fix | Delete
* @param c_element
[36] Fix | Delete
*/
[37] Fix | Delete
const enable_links = function (c_element) {
[38] Fix | Delete
const parent = c_element.parent();
[39] Fix | Delete
[40] Fix | Delete
//reduce parent opacity
[41] Fix | Delete
parent.css({ opacity: '1' });
[42] Fix | Delete
//Disable Links
[43] Fix | Delete
parent.find('a').prop('disabled', false);
[44] Fix | Delete
};
[45] Fix | Delete
[46] Fix | Delete
/**
[47] Fix | Delete
* Restore image request with a specified action for Media Library / NextGen Gallery
[48] Fix | Delete
*
[49] Fix | Delete
* @param {Object} e
[50] Fix | Delete
* @param {string} currentButton
[51] Fix | Delete
* @param {string} smushAction
[52] Fix | Delete
* @param {string} action
[53] Fix | Delete
*/
[54] Fix | Delete
const process_smush_action = function (
[55] Fix | Delete
e,
[56] Fix | Delete
currentButton,
[57] Fix | Delete
smushAction,
[58] Fix | Delete
action
[59] Fix | Delete
) {
[60] Fix | Delete
e.preventDefault();
[61] Fix | Delete
[62] Fix | Delete
// If disabled.
[63] Fix | Delete
if ( currentButton.attr( 'disabled' ) ) {
[64] Fix | Delete
return;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
// Remove Error.
[68] Fix | Delete
$('.wp-smush-error').remove();
[69] Fix | Delete
[70] Fix | Delete
// Hide stats.
[71] Fix | Delete
$('.smush-stats-wrapper').hide();
[72] Fix | Delete
[73] Fix | Delete
let mode = 'grid';
[74] Fix | Delete
if ('smush_restore_image' === smushAction) {
[75] Fix | Delete
if ($(document).find('div.media-modal.wp-core-ui').length > 0) {
[76] Fix | Delete
mode = 'grid';
[77] Fix | Delete
} else {
[78] Fix | Delete
mode =
[79] Fix | Delete
window.location.search.indexOf('item') > -1
[80] Fix | Delete
? 'grid'
[81] Fix | Delete
: 'list';
[82] Fix | Delete
}
[83] Fix | Delete
}
[84] Fix | Delete
[85] Fix | Delete
// Get the image ID and nonce.
[86] Fix | Delete
const params = {
[87] Fix | Delete
action: smushAction,
[88] Fix | Delete
attachment_id: currentButton.data('id'),
[89] Fix | Delete
mode,
[90] Fix | Delete
_nonce: currentButton.data('nonce'),
[91] Fix | Delete
};
[92] Fix | Delete
[93] Fix | Delete
// Reduce the opacity of stats and disable the click.
[94] Fix | Delete
disable_links(currentButton);
[95] Fix | Delete
[96] Fix | Delete
const oldLabel = currentButton.html();
[97] Fix | Delete
[98] Fix | Delete
currentButton.html(
[99] Fix | Delete
'<span class="spinner wp-smush-progress">' +
[100] Fix | Delete
wp_smush_msgs[action] +
[101] Fix | Delete
'</span>'
[102] Fix | Delete
);
[103] Fix | Delete
[104] Fix | Delete
// Restore the image.
[105] Fix | Delete
$.post(ajaxurl, params, function (r) {
[106] Fix | Delete
// Reset all functionality.
[107] Fix | Delete
enable_links(currentButton);
[108] Fix | Delete
[109] Fix | Delete
if (r.success && 'undefined' !== typeof r.data) {
[110] Fix | Delete
// Replace in immediate parent for NextGEN.
[111] Fix | Delete
if (
[112] Fix | Delete
'undefined' !== typeof this.data &&
[113] Fix | Delete
this.data.indexOf('nextgen') > -1
[114] Fix | Delete
) {
[115] Fix | Delete
// Show the smush button, and remove stats and restore option.
[116] Fix | Delete
currentButton.parents().eq(1).html(r.data.stats);
[117] Fix | Delete
} else if ('restore' === action) {
[118] Fix | Delete
// Show the smush button, and remove stats and restore option.
[119] Fix | Delete
currentButton.parents().eq(1).html(r.data.stats);
[120] Fix | Delete
} else {
[121] Fix | Delete
const wrapper = currentButton.parents().eq(1);
[122] Fix | Delete
if ( wp_smush_msgs.failed_item_smushed && wrapper.hasClass('smush-failed-processing') ) {
[123] Fix | Delete
wrapper.html( '<p class="smush-status smush-success">' + wp_smush_msgs.failed_item_smushed + '</p>' );
[124] Fix | Delete
setTimeout(function(){
[125] Fix | Delete
wrapper.html( r.data );
[126] Fix | Delete
}, 2000);
[127] Fix | Delete
} else {
[128] Fix | Delete
wrapper.html(r.data);
[129] Fix | Delete
}
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
if ('undefined' !== typeof r.data && 'restore' === action) {
[133] Fix | Delete
Smush.updateImageStats(r.data.new_size);
[134] Fix | Delete
}
[135] Fix | Delete
} else if (r.data && r.data.error_msg) {
[136] Fix | Delete
if (
[137] Fix | Delete
-1 === this.data.indexOf('nextgen')
[138] Fix | Delete
) {
[139] Fix | Delete
currentButton.closest( '.smushit' ).find('.smush-status').addClass('smush-warning').html(r.data.error_msg);
[140] Fix | Delete
} else {
[141] Fix | Delete
// Show error.
[142] Fix | Delete
currentButton.parent().append(r.data.error_msg);
[143] Fix | Delete
}
[144] Fix | Delete
[145] Fix | Delete
// Reset label and disable button on error.
[146] Fix | Delete
currentButton.attr('disabled', true);
[147] Fix | Delete
currentButton.html( oldLabel );
[148] Fix | Delete
}
[149] Fix | Delete
});
[150] Fix | Delete
};
[151] Fix | Delete
[152] Fix | Delete
/**
[153] Fix | Delete
* Validates the Resize Width and Height against the Largest Thumbnail Width and Height
[154] Fix | Delete
*
[155] Fix | Delete
* @param wrapper_div jQuery object for the whole setting row wrapper div
[156] Fix | Delete
* @param width_only Whether to validate only width
[157] Fix | Delete
* @param height_only Validate only Height
[158] Fix | Delete
* @return {boolean} All Good or not
[159] Fix | Delete
*/
[160] Fix | Delete
const validate_resize_settings = function (
[161] Fix | Delete
wrapper_div,
[162] Fix | Delete
width_only,
[163] Fix | Delete
height_only
[164] Fix | Delete
) {
[165] Fix | Delete
const resize_checkbox = wrapper_div.find('#resize');
[166] Fix | Delete
[167] Fix | Delete
if (!height_only) {
[168] Fix | Delete
var width_input = wrapper_div.find('#wp-smush-resize_width');
[169] Fix | Delete
var width_error_note = wrapper_div.find(
[170] Fix | Delete
'.sui-notice-info.wp-smush-update-width'
[171] Fix | Delete
);
[172] Fix | Delete
}
[173] Fix | Delete
if (!width_only) {
[174] Fix | Delete
var height_input = wrapper_div.find('#wp-smush-resize_height');
[175] Fix | Delete
var height_error_note = wrapper_div.find(
[176] Fix | Delete
'.sui-notice-info.wp-smush-update-height'
[177] Fix | Delete
);
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
let width_error = false;
[181] Fix | Delete
let height_error = false;
[182] Fix | Delete
[183] Fix | Delete
//If resize settings is not enabled, return true
[184] Fix | Delete
if (!resize_checkbox.is(':checked')) {
[185] Fix | Delete
return true;
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
//Check if we have localised width and height
[189] Fix | Delete
if (
[190] Fix | Delete
'undefined' === typeof wp_smushit_data.resize_sizes ||
[191] Fix | Delete
'undefined' === typeof wp_smushit_data.resize_sizes.width
[192] Fix | Delete
) {
[193] Fix | Delete
//Rely on server validation
[194] Fix | Delete
return true;
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
//Check for width
[198] Fix | Delete
if (
[199] Fix | Delete
!height_only &&
[200] Fix | Delete
'undefined' !== typeof width_input &&
[201] Fix | Delete
parseInt(wp_smushit_data.resize_sizes.width) >
[202] Fix | Delete
parseInt(width_input.val())
[203] Fix | Delete
) {
[204] Fix | Delete
width_input.parent().addClass('sui-form-field-error');
[205] Fix | Delete
width_error_note.show('slow');
[206] Fix | Delete
width_error = true;
[207] Fix | Delete
} else {
[208] Fix | Delete
//Remove error class
[209] Fix | Delete
width_input.parent().removeClass('sui-form-field-error');
[210] Fix | Delete
width_error_note.hide();
[211] Fix | Delete
if (height_input.hasClass('error')) {
[212] Fix | Delete
height_error_note.show('slow');
[213] Fix | Delete
}
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
//Check for height
[217] Fix | Delete
if (
[218] Fix | Delete
!width_only &&
[219] Fix | Delete
'undefined' !== typeof height_input &&
[220] Fix | Delete
parseInt(wp_smushit_data.resize_sizes.height) >
[221] Fix | Delete
parseInt(height_input.val())
[222] Fix | Delete
) {
[223] Fix | Delete
height_input.parent().addClass('sui-form-field-error');
[224] Fix | Delete
//If we are not showing the width error already
[225] Fix | Delete
if (!width_error) {
[226] Fix | Delete
height_error_note.show('slow');
[227] Fix | Delete
}
[228] Fix | Delete
height_error = true;
[229] Fix | Delete
} else {
[230] Fix | Delete
//Remove error class
[231] Fix | Delete
height_input.parent().removeClass('sui-form-field-error');
[232] Fix | Delete
height_error_note.hide();
[233] Fix | Delete
if (width_input.hasClass('error')) {
[234] Fix | Delete
width_error_note.show('slow');
[235] Fix | Delete
}
[236] Fix | Delete
}
[237] Fix | Delete
[238] Fix | Delete
if (width_error || height_error) {
[239] Fix | Delete
return false;
[240] Fix | Delete
}
[241] Fix | Delete
return true;
[242] Fix | Delete
};
[243] Fix | Delete
[244] Fix | Delete
/**
[245] Fix | Delete
* Update the progress bar width if we have images that needs to be resmushed
[246] Fix | Delete
*
[247] Fix | Delete
* @param unsmushed_count
[248] Fix | Delete
* @return {boolean}
[249] Fix | Delete
*/
[250] Fix | Delete
const update_progress_bar_resmush = function (unsmushed_count) {
[251] Fix | Delete
if ('undefined' === typeof unsmushed_count) {
[252] Fix | Delete
return false;
[253] Fix | Delete
}
[254] Fix | Delete
[255] Fix | Delete
const smushed_count = wp_smushit_data.count_total - unsmushed_count;
[256] Fix | Delete
[257] Fix | Delete
//Update the Progress Bar Width
[258] Fix | Delete
// get the progress bar
[259] Fix | Delete
const $progress_bar = jQuery(
[260] Fix | Delete
'.bulk-smush-wrapper .wp-smush-progress-inner'
[261] Fix | Delete
);
[262] Fix | Delete
if ($progress_bar.length < 1) {
[263] Fix | Delete
return;
[264] Fix | Delete
}
[265] Fix | Delete
[266] Fix | Delete
const width = (smushed_count / wp_smushit_data.count_total) * 100;
[267] Fix | Delete
[268] Fix | Delete
// increase progress
[269] Fix | Delete
$progress_bar.css('width', width + '%');
[270] Fix | Delete
};
[271] Fix | Delete
[272] Fix | Delete
const runRecheck = function (process_settings) {
[273] Fix | Delete
const button = $('.wp-smush-scan');
[274] Fix | Delete
[275] Fix | Delete
// Add a "loading" state to the button.
[276] Fix | Delete
button.addClass('sui-button-onload');
[277] Fix | Delete
[278] Fix | Delete
// Check if type is set in data attributes.
[279] Fix | Delete
let scan_type = button.data('type');
[280] Fix | Delete
scan_type = 'undefined' === typeof scan_type ? 'media' : scan_type;
[281] Fix | Delete
[282] Fix | Delete
// Remove the Skip resmush attribute from button.
[283] Fix | Delete
$('.wp-smush-all').removeAttr('data-smush');
[284] Fix | Delete
[285] Fix | Delete
// Disable Bulk smush button and itself.
[286] Fix | Delete
$('.wp-smush-all').prop('disabled', true);
[287] Fix | Delete
[288] Fix | Delete
// Hide Settings changed Notice.
[289] Fix | Delete
$('.wp-smush-settings-changed').hide();
[290] Fix | Delete
[291] Fix | Delete
// Ajax params.
[292] Fix | Delete
const params = {
[293] Fix | Delete
action: 'scan_for_resmush',
[294] Fix | Delete
type: scan_type,
[295] Fix | Delete
get_ui: true,
[296] Fix | Delete
process_settings,
[297] Fix | Delete
wp_smush_options_nonce: jQuery('#wp_smush_options_nonce').val(),
[298] Fix | Delete
};
[299] Fix | Delete
[300] Fix | Delete
// Send ajax request and get ids if any.
[301] Fix | Delete
$.get(ajaxurl, params, function (response) {
[302] Fix | Delete
if ( ! response?.success ) {
[303] Fix | Delete
WP_Smush.helpers.showNotice( response, {
[304] Fix | Delete
showdismiss: true,
[305] Fix | Delete
autoclose: false,
[306] Fix | Delete
} );
[307] Fix | Delete
return;
[308] Fix | Delete
}
[309] Fix | Delete
const stats = response.data;
[310] Fix | Delete
showRecheckImagesNotice( stats );
[311] Fix | Delete
GlobalStats.updateGlobalStatsFromSmushScriptData( stats );
[312] Fix | Delete
GlobalStats.renderStats();
[313] Fix | Delete
updateBulkSmushContentAfterReCheck( stats );
[314] Fix | Delete
}).always(function () {
[315] Fix | Delete
// Hide the progress bar.
[316] Fix | Delete
jQuery(
[317] Fix | Delete
'.bulk-smush-wrapper .wp-smush-bulk-progress-bar-wrapper'
[318] Fix | Delete
).addClass('sui-hidden');
[319] Fix | Delete
[320] Fix | Delete
// Add check complete status to button.
[321] Fix | Delete
button
[322] Fix | Delete
.removeClass('sui-button-onload')
[323] Fix | Delete
.addClass('smush-button-check-success');
[324] Fix | Delete
[325] Fix | Delete
const $defaultText = button.find('.wp-smush-default-text'),
[326] Fix | Delete
$completedText = button.find('.wp-smush-completed-text');
[327] Fix | Delete
[328] Fix | Delete
$defaultText.addClass('sui-hidden-important');
[329] Fix | Delete
$completedText.removeClass('sui-hidden');
[330] Fix | Delete
[331] Fix | Delete
// Remove success message from button.
[332] Fix | Delete
setTimeout(function () {
[333] Fix | Delete
button.removeClass('smush-button-check-success');
[334] Fix | Delete
[335] Fix | Delete
$defaultText.removeClass('sui-hidden-important');
[336] Fix | Delete
$completedText.addClass('sui-hidden');
[337] Fix | Delete
}, 2000);
[338] Fix | Delete
[339] Fix | Delete
$('.wp-smush-all').prop('disabled', false);
[340] Fix | Delete
});
[341] Fix | Delete
};
[342] Fix | Delete
[343] Fix | Delete
const showRecheckImagesNotice = ( stats ) => {
[344] Fix | Delete
if ( ! stats.notice ) {
[345] Fix | Delete
return;
[346] Fix | Delete
}
[347] Fix | Delete
let type = 'success';
[348] Fix | Delete
if ( 'undefined' !== typeof stats.noticeType ) {
[349] Fix | Delete
type = stats.noticeType;
[350] Fix | Delete
}
[351] Fix | Delete
window.SUI.openNotice(
[352] Fix | Delete
'wp-smush-ajax-notice',
[353] Fix | Delete
'<p>' + stats.notice + '</p>',
[354] Fix | Delete
{ type, icon: 'check-tick' }
[355] Fix | Delete
);
[356] Fix | Delete
};
[357] Fix | Delete
[358] Fix | Delete
const updateBulkSmushContentAfterReCheck = ( stats ) => {
[359] Fix | Delete
if ( SmushProgress.isEmptyObject ) {
[360] Fix | Delete
return;
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
SmushProgress.update( 0, stats.remaining_count );
[364] Fix | Delete
if ( stats.remaining_count < 1 ) {
[365] Fix | Delete
SmushProgress.hideBulkSmushDescription();
[366] Fix | Delete
SmushProgress.showBulkSmushAllDone();
[367] Fix | Delete
} else {
[368] Fix | Delete
SmushProgress.showBulkSmushDescription();
[369] Fix | Delete
SmushProgress.hideBulkSmushAllDone();
[370] Fix | Delete
}
[371] Fix | Delete
}
[372] Fix | Delete
[373] Fix | Delete
const updateDisplayedContentAfterReCheck = function (count) {
[374] Fix | Delete
const $pendingImagesWrappers = jQuery(
[375] Fix | Delete
'.bulk-smush-wrapper .wp-smush-bulk-wrapper'
[376] Fix | Delete
);
[377] Fix | Delete
const $allDoneWrappers = jQuery(
[378] Fix | Delete
'.bulk-smush-wrapper .wp-smush-all-done'
[379] Fix | Delete
);
[380] Fix | Delete
[381] Fix | Delete
if ($pendingImagesWrappers.length && $allDoneWrappers.length) {
[382] Fix | Delete
if (count === 0) {
[383] Fix | Delete
$pendingImagesWrappers.addClass('sui-hidden');
[384] Fix | Delete
$allDoneWrappers.find('p').html( wp_smush_msgs.all_smushed );
[385] Fix | Delete
$allDoneWrappers.find('.sui-notice-icon').removeClass('sui-icon-info').addClass('sui-icon-check-tick');
[386] Fix | Delete
$allDoneWrappers.removeClass('sui-notice-warning').addClass('sui-notice-success');
[387] Fix | Delete
$allDoneWrappers.removeClass('sui-hidden');
[388] Fix | Delete
} else {
[389] Fix | Delete
$pendingImagesWrappers.removeClass('sui-hidden');
[390] Fix | Delete
$allDoneWrappers.addClass('sui-hidden');
[391] Fix | Delete
[392] Fix | Delete
// Update texts mentioning the amount of unsmushed imagesin the summary icon tooltip.
[393] Fix | Delete
const $unsmushedTooltip = jQuery(
[394] Fix | Delete
'.sui-summary-smush .sui-summary-details .sui-tooltip'
[395] Fix | Delete
);
[396] Fix | Delete
[397] Fix | Delete
// The tooltip doesn't exist in the NextGen page.
[398] Fix | Delete
if ($unsmushedTooltip.length) {
[399] Fix | Delete
const textForm = 1 === count ? 'singular' : 'plural',
[400] Fix | Delete
tooltipText = $unsmushedTooltip
[401] Fix | Delete
.data(textForm)
[402] Fix | Delete
.replace('{count}', count);
[403] Fix | Delete
$unsmushedTooltip.attr('data-tooltip', tooltipText);
[404] Fix | Delete
}
[405] Fix | Delete
}
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
// Total count in the progress bar.
[409] Fix | Delete
jQuery('.wp-smush-total-count').text(count);
[410] Fix | Delete
};
[411] Fix | Delete
[412] Fix | Delete
// Scroll the element to top of the page.
[413] Fix | Delete
const goToByScroll = function (selector) {
[414] Fix | Delete
// Scroll if element found.
[415] Fix | Delete
if ($(selector).length > 0) {
[416] Fix | Delete
$('html, body').animate(
[417] Fix | Delete
{
[418] Fix | Delete
scrollTop: $(selector).offset().top - 100,
[419] Fix | Delete
},
[420] Fix | Delete
'slow'
[421] Fix | Delete
);
[422] Fix | Delete
}
[423] Fix | Delete
};
[424] Fix | Delete
[425] Fix | Delete
const update_cummulative_stats = function (stats) {
[426] Fix | Delete
//Update Directory Smush Stats
[427] Fix | Delete
if ('undefined' !== typeof stats.dir_smush) {
[428] Fix | Delete
const stats_human = $(
[429] Fix | Delete
'li.smush-dir-savings span.wp-smush-stats span.wp-smush-stats-human'
[430] Fix | Delete
);
[431] Fix | Delete
const stats_percent = $(
[432] Fix | Delete
'li.smush-dir-savings span.wp-smush-stats span.wp-smush-stats-percent'
[433] Fix | Delete
);
[434] Fix | Delete
[435] Fix | Delete
// Do not replace if 0 savings.
[436] Fix | Delete
if (stats.dir_smush.bytes > 0) {
[437] Fix | Delete
$('.wp-smush-dir-link').addClass('sui-hidden');
[438] Fix | Delete
[439] Fix | Delete
// Hide selector.
[440] Fix | Delete
$('li.smush-dir-savings .wp-smush-stats-label-message').hide();
[441] Fix | Delete
//Update Savings in bytes
[442] Fix | Delete
if (stats_human.length > 0) {
[443] Fix | Delete
stats_human.html(stats.dir_smush.human);
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
//Percentage section
[447] Fix | Delete
if (stats.dir_smush.percent > 0) {
[448] Fix | Delete
// Show size and percentage separator.
[449] Fix | Delete
$(
[450] Fix | Delete
'li.smush-dir-savings span.wp-smush-stats span.wp-smush-stats-sep'
[451] Fix | Delete
).removeClass('sui-hidden');
[452] Fix | Delete
//Update Optimisation percentage
[453] Fix | Delete
if (stats_percent.length > 0) {
[454] Fix | Delete
stats_percent.html(stats.dir_smush.percent + '%');
[455] Fix | Delete
}
[456] Fix | Delete
}
[457] Fix | Delete
} else {
[458] Fix | Delete
$('.wp-smush-dir-link').removeClass('sui-hidden');
[459] Fix | Delete
}
[460] Fix | Delete
}
[461] Fix | Delete
[462] Fix | Delete
//Update Combined stats
[463] Fix | Delete
if (
[464] Fix | Delete
'undefined' !== typeof stats.combined_stats &&
[465] Fix | Delete
stats.combined_stats.length > 0
[466] Fix | Delete
) {
[467] Fix | Delete
const c_stats = stats.combined_stats;
[468] Fix | Delete
[469] Fix | Delete
let smush_percent = (c_stats.smushed / c_stats.total_count) * 100;
[470] Fix | Delete
smush_percent = WP_Smush.helpers.precise_round(smush_percent, 1);
[471] Fix | Delete
[472] Fix | Delete
//Smushed Percent
[473] Fix | Delete
if (smush_percent) {
[474] Fix | Delete
$('div.wp-smush-count-total span.wp-smush-images-percent').html(
[475] Fix | Delete
smush_percent
[476] Fix | Delete
);
[477] Fix | Delete
}
[478] Fix | Delete
//Update Total Attachment Count
[479] Fix | Delete
if (c_stats.total_count) {
[480] Fix | Delete
$(
[481] Fix | Delete
'span.wp-smush-count-total span.wp-smush-total-optimised'
[482] Fix | Delete
).html(c_stats.total_count);
[483] Fix | Delete
}
[484] Fix | Delete
//Update Savings and Percent
[485] Fix | Delete
if (c_stats.savings) {
[486] Fix | Delete
$('span.wp-smush-savings span.wp-smush-stats-human').html(
[487] Fix | Delete
c_stats.savings
[488] Fix | Delete
);
[489] Fix | Delete
}
[490] Fix | Delete
if (c_stats.percent) {
[491] Fix | Delete
$('span.wp-smush-savings span.wp-smush-stats-percent').html(
[492] Fix | Delete
c_stats.percent
[493] Fix | Delete
);
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
};
[497] Fix | Delete
[498] Fix | Delete
/**
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function