PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 4.7.0
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v4.7.0
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
← All changes | js/wposmush.js +31 -18 3.7.1 → 4.7.0 View file →
@@ -23,9 +23,8 @@
23 23 smush_images_select_none_btn = $('#wpo_smush_images_select_none'),
24 24 smush_images_stats_clear_btn = $('#wpo_smush_clear_stats_btn'),
25 25 smush_selected_images_btn = $('#wpo_smush_images_btn'),
26 26 smush_mark_as_compressed_btn = $('#wpo_smush_mark_as_compressed'),
27 - convert_to_webp_btn = $('.wpo_smush.column-wpo_smush .convert-to-webp');
28 27 smush_mark_all_as_uncompressed_btn = $('#wpo_smush_mark_all_as_uncompressed_btn'),
29 28 restore_all_compressed_images_btn = $('#wpo_smush_restore_all_compressed_images_btn'),
30 29 smush_view_logs_btn = $('.wpo_smush_get_logs'),
31 30 smush_delete_backup_images_btn = $('#wpo_smush_delete_backup_btn'),
@@ -102,10 +101,8 @@
102 101 smush_from_media_library = true;
103 102 smush_completed = false;
104 103 if (smush_timer_locked) return;
105 104 block_ui('', $.extend(block_ui_custom_options, {message: $('#wpo_smush_images_information_container')}), false, true);
106 - $('#wpo_smush_images_information_server').html(wposmush.smush_settings.compression_server);
107 -
108 105 clear_smush_stats();
109 106
110 107 smush_timer_handle = window.setInterval(smush_timer, 1000);
111 108 smush_manager_send_command('process_bulk_smush', data);
@@ -725,9 +722,9 @@
725 722 $('#enable_webp_conversion').prop("checked", false);
726 723 if ('update_failed_no_working_webp_converter' === resp.error_code) {
727 724 var html_msg = '<p>'
728 725 + wposmush.webp_conversion_tool_error
729 - + ' <a href="https://getwpo.com/faqs/#How-can-I-get-WebP-conversion-tools-to-work-" target="_blank">'
726 + + ' <a href="https://teamupdraft.com/documentation/wp-optimize/topics/image-compression/troubleshooting/the-webp-conversion-tool-is-not-working/" target="_blank">'
730 727 + wposmush.webp_conversion_tool_how_to
731 728 + '</a></p>';
732 729 $('#smush-information-modal .smush-information').html(html_msg);
733 730 } else {
@@ -738,9 +735,9 @@
738 735 $('#enable_webp_conversion').prop("disabled", false);
739 736 });
740 737 });
741 738
742 - convert_to_webp_btn.on('click', function(e){
739 + $('body').on('click', '.wpo_smush.column-wpo_smush .convert-to-webp', function(e){
743 740 e.preventDefault();
744 741 var $link = $(this);
745 742 data = {
746 743 'attachment_id': $(this).data('attachment-id'),
@@ -745,16 +742,17 @@
745 742 data = {
746 743 'attachment_id': $(this).data('attachment-id'),
747 744 skip_notice: true
748 745 };
749 - block_ui(wposmush.converting_to_webp);
746 + block_ui(wposmush.converting_to_webp, {}, 0, true);
750 747 smush_manager_send_command('convert_to_webp_format', data, function(response) {
751 - if (response.error) {
752 - block_ui(response.error, {}, 2000);
753 - } else {
748 + if (response.success) {
754 749 block_ui(response.success, {}, 2000);
755 750 $link.next().remove();
751 + if ($link.prev().is('.wpo-action-separator')) $link.prev().remove();
756 752 $link.remove();
753 + } else {
754 + block_ui(response.error || response.error_message || wposmush.server_error , {}, 2000);
757 755 }
758 756 });
759 757 });
760 758
@@ -928,9 +926,9 @@
928 926
929 927 /**
930 928 * Update images optimization tab view with data returned from images optimization.
931 929 *
932 - * @param {Object} data - meta data returned from task manager
930 + * @param {Object} data - metadata returned from task manager
933 931 *
934 932 * @return void
935 933 */
936 934 function update_view_show_uncompressed_images(data) {
@@ -990,10 +988,8 @@
990 988 function update_view_bulk_smush_start() {
991 989 if (smush_timer_locked) return;
992 990
993 991 block_ui('', $.extend(block_ui_custom_options, {message: $('#wpo_smush_images_information_container')}), false, true);
994 - service = $('.compression_server input[type="radio"]:checked + label small').text();
995 - $('#wpo_smush_images_information_server').html(service);
996 992
997 993 clear_smush_stats();
998 994
999 995 smush_timer_handle = window.setInterval(smush_timer, 1000);
@@ -1068,8 +1064,11 @@
1068 1064 };
1069 1065
1070 1066 (function(single_callback) {
1071 1067 heartbeat_agents.push(heartbeat.add_agent({
1068 + // We have to use a non-unique agent in the complete action because the info update subactions
1069 + // have the same names, and the agent may not be added. This ensures that the "smush_complete" action will run.
1070 + _unique: false,
1072 1071 _wait: false,
1073 1072 _keep: false,
1074 1073 command: 'updraft_smush_ajax',
1075 1074 command_data: {data: data, subaction: 'get_ui_update'},
@@ -1075,8 +1074,12 @@
1075 1074 command_data: {data: data, subaction: 'get_ui_update'},
1076 1075 callback: function(resp) {
1077 1076
1078 1077 summary = resp.session_stats;
1078 + // Prevent pops with undefined headers
1079 + if (!resp.session_stats) {
1080 + return;
1081 + }
1079 1082
1080 1083 if (0 != resp.completed_task_count) {
1081 1084 summary += '<hr>' + resp.summary;
1082 1085 }
@@ -1217,9 +1220,10 @@
1217 1220 if (0 == selected_image.length) return;
1218 1221
1219 1222 data = {
1220 1223 selected_image: selected_image,
1221 - smush_options: smush_options
1224 + smush_options: smush_options,
1225 + skip_notice: true
1222 1226 }
1223 1227
1224 1228 block_ui(wposmush.compress_single_image_dialog, {}, false, true);
1225 1229 smush_manager_send_command('compress_single_image', data, function(resp) {
@@ -1241,9 +1245,9 @@
1241 1245 // if no selected images then exit.
1242 1246 if (0 == selected_image.length) return;
1243 1247
1244 1248 block_ui(wposmush.please_wait);
1245 - var data = { 'blog_id': blog_id, 'selected_image': selected_image };
1249 + var data = { 'blog_id': blog_id, 'selected_image': selected_image, skip_notice: true };
1246 1250
1247 1251 smush_manager_send_command.apply({unique: false}, ['restore_single_image', data, function(resp) {
1248 1252 var done = function(resp_summary_alt) {
1249 1253 if ('undefined' != typeof(resp_summary_alt)) {
@@ -1305,9 +1309,11 @@
1305 1309 operation: resp.operation
1306 1310 }
1307 1311 }
1308 1312 } else {
1309 - block_ui(resp.error_message);
1313 + // Update the error message to be user-friendly
1314 + if (/exceeded_max_filesize/.test(resp.error_message)) resp.error_message = wposmush.exceeded_max_filesize
1315 + block_ui(resp.error_message, {}, 4000);
1310 1316 }
1311 1317 }
1312 1318
1313 1319 /**
@@ -1437,20 +1443,27 @@
1437 1443 * @param {string} action The action to send
1438 1444 * @param {[type]} data Data to send
1439 1445 * @param {Function} callback Will be called with the results
1440 1446 * @param {boolean} json_parse JSON parse the results
1447 + * @param {boolean} wait Wait for the response
1441 1448 *
1442 1449 * @return {JSON}
1443 1450 */
1444 - function smush_manager_send_command(action, data, callback, json_parse) {
1451 + function smush_manager_send_command(action, data, callback, json_parse, wait) {
1445 1452
1446 1453 json_parse = ('undefined' === typeof json_parse) ? true : json_parse;
1454 + var _wait = ('undefined' === typeof wait) ? false : wait;
1447 1455
1448 - data = (data.hasOwnProperty('skip_notice') && Object.keys(data).length === 1) || $.isEmptyObject(data) ? {'use_cache' : false} : data;
1456 + var skip_notice = data.hasOwnProperty('skip_notice');
1457 + var data_has_only_skip_notice = skip_notice && 1 === Object.keys(data).length;
1458 + var is_data_empty = $.isEmptyObject(data);
1449 1459
1460 + data = is_data_empty ? {'use_cache' : false} : data;
1461 + if (data_has_only_skip_notice) data.use_cache = false;
1462 +
1450 1463 (function(single_callback, _keep, _unique) {
1451 1464 heartbeat_agents.push(heartbeat.add_agent({
1452 - _wait: false,
1465 + _wait: _wait,
1453 1466 _keep: _keep,
1454 1467 _unique: _unique,
1455 1468 command: 'updraft_smush_ajax',
1456 1469 command_data: {data: data, subaction: action},