PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | assets/js/mainwp-updates.js +302 -52 6.1.6 → 6.2.2 View file →
@@ -44,20 +44,36 @@
44 44 });
45 45 };
46 46
47 47 // Decode slug safely.
48 -globalThis.mainwp_decode_slug = function (value) { // NOSONAR
48 +globalThis.mainwp_decode_slug = function (value, escape ) { // NOSONAR
49 49 if (typeof value !== 'string' || !value.includes('%')) {
50 - return value;
50 + return (true === escape && typeof value === 'string') ? mainwp_escape_html(value) : value;
51 51 }
52 52
53 53 try {
54 - return decodeURIComponent(value);
54 + value = decodeURIComponent(value);
55 55 } catch {
56 - return value;
56 + // nothing.
57 57 }
58 +
59 + if(true === escape){
60 + return mainwp_escape_html(value);
61 + }
62 +
63 + return value;
58 64 };
59 65
66 +globalThis.mainwp_escape_html = function (value) { // NOSONAR
67 + const div = document.createElement('div');
68 + div.textContent = value ?? '';
69 +
70 + return div.innerHTML
71 + .replace(/"/g, '"')
72 + .replace(/'/g, ''');
73 +};
74 +
75 +
60 76 // Normalize slug list to array.
61 77 globalThis.mainwp_slug_list_to_array = function (value) { // NOSONAR.
62 78 if (Array.isArray(value)) {
63 79 return value.filter(function (v) { return v !== null && v !== undefined && String(v).trim() !== ''; });
@@ -1039,11 +1055,99 @@
1039 1055 while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) {
1040 1056 updatesoverview_plugins_upgrade_all_upgrade_next();
1041 1057 }
1042 1058 };
1043 -let updatesoverview_plugins_upgrade_all_update_site_status = function (siteId, newStatus) {
1044 - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').html(newStatus);
1059 +let updatesoverview_plugins_upgrade_all_update_site_status = function (siteId, newStatus, append) {
1060 + const $status = jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]');
1061 +
1062 + if (append) {
1063 + $status.append(newStatus);
1064 + } else {
1065 + $status.html(newStatus);
1066 + }
1045 1067 };
1068 +
1069 +/**
1070 + * Updates the status popup for a site upgrade item.
1071 + *
1072 + * @param {number|string} siteId The site ID.
1073 + * @param {number} itemnumber The upgrade item number.
1074 + * @param {Object} options Options for updating the popup status.
1075 + * @param {*} options.status The status content or value.
1076 + * @param {boolean} options.ispopup Whether to display the status in a popup.
1077 + * @param {*} options.icon The icon to display with the status.
1078 + * @param {boolean} options.append Whether to append the content instead of replacing it.
1079 + * @param {*} options.addition Additional content or data to include.
1080 + * @param {boolean} options.isHidden Whether to hide the status.
1081 + *
1082 + * @returns {void}
1083 + */
1084 +let upgradeall_update_site_popup_multi_status = function (siteId, itemnumber, options = {}) {
1085 + if (!siteId) {
1086 + return;
1087 + }
1088 + const {
1089 + status = false,
1090 + ispopup = false,
1091 + icon = false,
1092 + append = false,
1093 + addition = false,
1094 + isHidden = false,
1095 + } = options;
1096 +
1097 + const $sitestatus = jQuery(`.updatesoverview-upgrade-status-wp[siteid="${siteId}"]`);
1098 + const clsitem = Number.isInteger(itemnumber) ? `status-item-${itemnumber}` : 'status-item-1';
1099 + const clspop = true === ispopup ? 'mainwp-html-popup' : '';
1100 +
1101 + let $item = $sitestatus.find(`.${clspop ? clspop + '.' : ''}${clsitem}`);
1102 +
1103 + if ( ! $item.length ) {
1104 + const item = true === ispopup
1105 + ? `<span class="${clspop} ${clsitem}" data-position="left center" data-html=""></span>`
1106 + : `<span class="${clsitem}" data-position="left center" data-tooltip=""></span>`;
1107 + $sitestatus.append(item);
1108 + $item = $sitestatus.find(`.${clspop ? clspop + '.' : ''}${clsitem}`);
1109 + }
1110 +
1111 + if(true === isHidden){
1112 + $item.hide();
1113 + } else {
1114 + $item.show();
1115 + }
1116 +
1117 + if ( typeof icon === 'string' ) {
1118 + $item.html(icon);
1119 + }
1120 +
1121 + if ( typeof status === 'string' ) {
1122 + if(true === ispopup){
1123 + let content = status;
1124 + if (append) {
1125 + const existingContent = $item?.attr('data-html') || '';
1126 + content = existingContent
1127 + ? `${existingContent}<br>${status}`
1128 + : status;
1129 + }
1130 + $item.attr('data-html', content);
1131 + mainwp_init_html_popup($item, content);
1132 + } else {
1133 + let content = status;
1134 + if (append) {
1135 + const existingContent = $item?.attr('data-tooltip') || '';
1136 + content = existingContent
1137 + ? `${existingContent}; ${status}`
1138 + : status;
1139 + }
1140 + $item.attr('data-tooltip', content);
1141 + }
1142 + }
1143 +
1144 + if ( typeof addition === 'string' ) {
1145 + $sitestatus.append(addition);
1146 + }
1147 +};
1148 +
1149 +
1046 1150 let updatesoverview_plugins_upgrade_all_upgrade_next = function () {
1047 1151 mainwpVars.currentThreads++;
1048 1152 mainwpVars.websitesLeft--;
1049 1153
@@ -1064,13 +1168,18 @@
1064 1168 };
1065 1169
1066 1170 let updatesoverview_check_to_continue_updates = function () {
1067 1171 mainwpVars.bulkTaskRunning = false;
1068 - setTimeout(function () {
1069 - if (!mainwpVars?.errorCount && jQuery('.updates-regression-score-red-flag').length === 0) {
1070 - mainwpPopup('#mainwp-sync-sites-modal').close(true);
1071 - }
1072 - }, 3000);
1172 + if (!mainwpVars?.errorCount){
1173 + setTimeout(function () {
1174 + // wait for generated updates-regression-score-red-flag.
1175 + if (jQuery('.updates-regression-score-red-flag').length === 0) {
1176 + mainwpPopup('#mainwp-sync-sites-modal').close(true);
1177 + }
1178 + }, 3000);
1179 + } else {
1180 + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed'));
1181 + }
1073 1182 return false;
1074 1183 }
1075 1184
1076 1185 let updatesoverview_plugins_upgrade_all_update_done = function () {
@@ -1097,9 +1206,9 @@
1097 1206 );
1098 1207 };
1099 1208 }
1100 1209
1101 -let updatesoverview_plugins_upgrade_int_after_backup = function (pSlug, pWebsiteId, pBulkMode, pLastResult) { // NOSONAR - nest functions.
1210 +let updatesoverview_plugins_upgrade_int_after_backup = function (pSlug, pWebsiteId, pBulkMode, pLastResult, errorHappen) { // NOSONAR - nest functions.
1102 1211 return function () {
1103 1212 let slugList = globalThis.mainwp_slug_list_to_array(pSlug); // NOSONAR -- window is ok.
1104 1213
1105 1214 const yithSlugList = slugList.filter(slg => slg.startsWith('yith-'));
@@ -1133,8 +1242,12 @@
1133 1242 }
1134 1243 websiteHolder.find('td:last-child').html(waiting_icon);
1135 1244 }
1136 1245
1246 + if( errorHappen === undefined ){
1247 + errorHappen = false;
1248 + }
1249 +
1137 1250 let data = mainwp_secure_data({
1138 1251 action: 'mainwp_upgradeplugintheme',
1139 1252 websiteId: pWebsiteId,
1140 1253 type: 'plugin',
@@ -1154,8 +1267,9 @@
1154 1267 slugParts = [pSlug];
1155 1268 }
1156 1269 let done = false;
1157 1270 let bulk_errors = [];
1271 + let res_started;
1158 1272 let _icon = '<i class="red times icon"></i>';
1159 1273 for (let sid of slugParts) {
1160 1274 let websiteHolder = jQuery('.plugins-bulk-updates[plugin_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]');
1161 1275 if (!websiteHolder.exists()) {
@@ -1167,11 +1281,13 @@
1167 1281 if (!done && pBulkMode)
1168 1282 updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, extErr);
1169 1283 websiteHolder.find('td:last-child').html(extErr);
1170 1284 mainwpVars.errorCount++;
1285 + errorHappen = true;
1171 1286 } else {
1172 1287 let res = response.result;
1173 1288 let res_error = response.result_error;
1289 + res_started = response.result_started; // for backward compatibility.
1174 1290 if (mainwp_get_result_entry(res, sid)) {
1175 1291 lastResult = res;
1176 1292 let _success_icon = `<i class="green check icon"></i>`;
1177 1293 let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '">' + _success_icon + '</span>';
@@ -1176,21 +1292,30 @@
1176 1292 let _success_icon = `<i class="green check icon"></i>`;
1177 1293 let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '">' + _success_icon + '</span>';
1178 1294 websiteHolder.attr('updated', 1);
1179 1295 websiteHolder.find('td:last-child').html(success_icon + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId));
1180 - } else if (res_error[sid]) {
1181 - let _error = res_error[sid];
1296 + } else if (mainwp_get_result_entry(res_started, sid)) { // for backward compatibility.
1297 + let _success_icon = `<i class="green check icon"></i>`;
1298 + let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + _success_icon + '</span>';
1299 + websiteHolder.attr('updated', 1);
1300 + websiteHolder.find('td:last-child').html(success_icon + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId));
1301 + } else if (mainwp_get_result_entry(res_error, sid)) {
1302 + let _error = mainwp_get_result_entry(res_error, sid);
1182 1303 let roll_error = mainwp_updates_get_rollback_msg(_error);
1304 + let roll_icon = _icon;
1183 1305 if (roll_error) {
1184 1306 _error = roll_error;
1185 - _icon = mainwpParams.roll_ui_icon;
1307 + roll_icon = mainwpParams.roll_ui_icon;
1186 1308 }
1187 - bulk_errors.push(_error);
1188 - websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + _error + '">' + _icon + '</span>');
1309 + bulk_errors.push(mainwp_escape_html(_error));
1310 + websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + mainwp_escape_html(_error) + '">' + roll_icon + '</span>');
1189 1311 mainwpVars.errorCount++;
1312 + errorHappen = true;
1190 1313 } else {
1314 + bulk_errors.push(MainWP.I18n.t('Update failed. Please try again.'));
1191 1315 websiteHolder.find('td:last-child').html('<i class="red times icon"></i>');
1192 1316 mainwpVars.errorCount++;
1317 + errorHappen = true;
1193 1318 }
1194 1319 }
1195 1320 }
1196 1321
@@ -1199,9 +1324,9 @@
1199 1324 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', bulk_errors.join('<br />'));
1200 1325 }
1201 1326
1202 1327 if (remainingSlugs && remainingSlugs.length > 0) {
1203 - updatesoverview_plugins_upgrade_int_after_backup(remainingSlugs, pWebsiteId, pBulkMode, lastResult)();
1328 + updatesoverview_plugins_upgrade_int_after_backup(remainingSlugs, pWebsiteId, pBulkMode, lastResult, errorHappen)();
1204 1329 return;
1205 1330 }
1206 1331 if (
1207 1332 pBulkMode &&
@@ -1206,9 +1331,10 @@
1206 1331 if (
1207 1332 pBulkMode &&
1208 1333 !bulk_errors.length &&
1209 1334 !response.error &&
1210 - !response.notices
1335 + !response.notices &&
1336 + !errorHappen
1211 1337 ) {
1212 1338 if (
1213 1339 lastResult &&
1214 1340 typeof mainwp_html_regression !== "undefined" &&
@@ -1222,9 +1348,18 @@
1222 1348 pWebsiteId,
1223 1349 success_icon + ' ' + regression_icon_loading
1224 1350 );
1225 1351 } else if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
1226 - updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>');
1352 + let success_icon = `<i class="green check icon"></i>`;
1353 + // for backward compatibility.
1354 + if (
1355 + res_started !== null &&
1356 + typeof res_started === 'object' &&
1357 + Object.keys(res_started).length > 0
1358 + ) {
1359 + success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + success_icon + '</span>';
1360 + }
1361 + updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, success_icon);
1227 1362 }
1228 1363 }
1229 1364 if (pBulkMode) {
1230 1365 updatesoverview_plugins_upgrade_all_update_done();
@@ -1260,8 +1395,9 @@
1260 1395 }(pSlug, pWebsiteId, pBulkMode),
1261 1396 error: function (xhr) {
1262 1397 this.tryCount++;
1263 1398 if (this.tryCount >= this.retryLimit) {
1399 + mainwpVars.errorCount++;
1264 1400 this.endError();
1265 1401 return;
1266 1402 }
1267 1403 let pXhr = xhr;
@@ -1648,8 +1784,9 @@
1648 1784 let extErr = getErrorMessageInfo(response.error, 'ui')
1649 1785 if (!done && pBulkMode)
1650 1786 updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, extErr);
1651 1787 websiteHolder.find('td:last-child').html(extErr);
1788 + mainwpVars.errorCount++;
1652 1789 } else {
1653 1790 let res = response.result;
1654 1791 let res_error = response.result_error;
1655 1792 if (mainwp_get_result_entry(res, sid)) {
@@ -1669,14 +1806,14 @@
1669 1806 _error = roll_error;
1670 1807 _icon = mainwpParams.roll_ui_icon;
1671 1808 bulk_icon = mainwpParams.roll_ui_icon;
1672 1809 }
1673 - bulk_errors.push(_error);
1810 + bulk_errors.push(mainwp_escape_html(_error));
1674 1811 mainwpVars.errorCount++;
1675 1812 }
1676 1813 if (_error) {
1677 1814 websiteHolder.find('td:last-child').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
1678 - mainwp_init_html_popup(websiteHolder.find('td:last-child').find('.mainwp-html-popup'), _error);
1815 + mainwp_init_html_popup(websiteHolder.find('td:last-child').find('.mainwp-html-popup'), mainwp_escape_html(_error));
1679 1816 }
1680 1817 }
1681 1818 }
1682 1819
@@ -1745,8 +1882,9 @@
1745 1882 }(slug, websiteId, bulkMode),
1746 1883 error: function (xhr) {
1747 1884 this.tryCount++;
1748 1885 if (this.tryCount >= this.retryLimit) {
1886 + mainwpVars.errorCount++;
1749 1887 this.endError();
1750 1888 return;
1751 1889 }
1752 1890
@@ -2169,8 +2307,10 @@
2169 2307 setTimeout(function () {
2170 2308 // close and refresh page
2171 2309 mainwpPopup('#mainwp-sync-sites-modal').close(true);
2172 2310 }, 3000);
2311 + } else {
2312 + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed'));
2173 2313 }
2174 2314 return;
2175 2315 }
2176 2316
@@ -2242,8 +2382,9 @@
2242 2382 let isError = true;
2243 2383 if (response.error) {
2244 2384 result = getErrorMessage(response.error);
2245 2385 pErrorMessage = result;
2386 + mainwpVars.errorCount++;
2246 2387 } else {
2247 2388 let res = response.result;
2248 2389 if (mainwp_get_result_entry(res, sid)) {
2249 2390 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
@@ -2328,8 +2469,9 @@
2328 2469 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone),
2329 2470 error: function (xhr) {
2330 2471 this.tryCount++;
2331 2472 if (this.tryCount >= this.retryLimit) {
2473 + mainwpVars.errorCount++;
2332 2474 this.endError();
2333 2475 return;
2334 2476 }
2335 2477 let pXhr = xhr;
@@ -2402,8 +2544,9 @@
2402 2544 }
2403 2545 if (response.error) {
2404 2546 result = getErrorMessage(response.error);
2405 2547 pErrorMessage = result;
2548 + mainwpVars.errorCount++;
2406 2549 }
2407 2550 else {
2408 2551 let res = response.result; // result is an object
2409 2552 let res_error = response.result_error;
@@ -2481,8 +2624,9 @@
2481 2624 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone),
2482 2625 error: function (xhr) {
2483 2626 this.tryCount++;
2484 2627 if (this.tryCount >= this.retryLimit) {
2628 + mainwpVars.errorCount++;
2485 2629 this.endError();
2486 2630 return;
2487 2631 }
2488 2632 setTimeout(function (pRqst, pXhr) {
@@ -2659,8 +2803,9 @@
2659 2803 }
2660 2804 if (response.error) {
2661 2805 result = getErrorMessage(response.error);
2662 2806 pErrorMessage = result;
2807 + mainwpVars.errorCount++;
2663 2808 } else {
2664 2809 let res = response.result;
2665 2810 if (mainwp_get_result_entry(res, sid)) {
2666 2811 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
@@ -3896,41 +4041,87 @@
3896 4041 };
3897 4042 updatesoverview_update_popup_init(initData);
3898 4043
3899 4044 // Show icon waiting
4045 + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>');
4046 + // init sites status items.
4047 + const statuses = [
4048 + {
4049 + item: 1,
4050 + icon: waiting_icon,
4051 + },
4052 + {
4053 + item: 2,
4054 + ispopup: true,
4055 + icon: '<i class="green check icon"></i>',
4056 + isHidden: true,
4057 + },
4058 + {
4059 + item: 3,
4060 + ispopup: true,
4061 + icon: '<i class="red times icon"></i>',
4062 + isHidden: true,
4063 + },
4064 + {
4065 + item: 5,
4066 + ispopup: true,
4067 + icon: '', // Reserved for future use.
4068 + isHidden: true,
4069 + },
4070 + ];
4071 +
3900 4072 const regression_waiting_icon = render_html_regression_waiting_icon();
3901 - let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>');
3902 - if (regression_waiting_icon && "" !== regression_waiting_icon) {
3903 - waiting_icon += regression_waiting_icon;
4073 +
4074 + if (regression_waiting_icon) {
4075 + statuses.push({
4076 + item: 4,
4077 + icon: regression_waiting_icon,
4078 + isHidden: true,
4079 + });
3904 4080 }
3905 4081
3906 - updatesoverview_plugins_upgrade_all_update_site_status(pId, waiting_icon);
4082 + updatesoverview_plugins_upgrade_all_update_site_status(pId,''); // clear status first.
3907 4083
4084 + statuses.forEach((status) => {
4085 + const { item, ...options } = status;
4086 + upgradeall_update_site_popup_multi_status(pId, item, options);
4087 + });
4088 +
3908 4089 let queue = list.slice();
3909 - let lastResult = null;
4090 + let countError = 0;
4091 + let lastResult = '';
3910 4092
3911 - let processNext = function () {
4093 + let processLoop = function (response) {
3912 4094 if (queue.length === 0) {
3913 4095 mainwpPopup('#mainwp-sync-sites-modal').setProgressSite(1);
3914 - let success_icon = '<i class="green check icon"></i>';
3915 4096 if (
3916 4097 lastResult &&
3917 4098 typeof mainwp_html_regression !== "undefined" &&
3918 4099 mainwp_html_regression.use_after_updates === "1"
3919 4100 ) {
3920 - let regression_icon_loading = render_html_regression_icon(lastResult, function (regression_final_icon) {
3921 - const final_icon = `${success_icon} ${regression_final_icon}`;
3922 - updatesoverview_plugins_upgrade_all_update_site_status(pId, final_icon);
4101 + let regression_icon_callback = render_html_regression_icon(lastResult, function (regression_final_icon) {
4102 + upgradeall_update_site_popup_multi_status(pId, 4, {
4103 + icon: regression_final_icon,
4104 + });
3923 4105 });
3924 - updatesoverview_plugins_upgrade_all_update_site_status(pId, `${success_icon} ${regression_icon_loading}`);
3925 - } else {
3926 - updatesoverview_plugins_upgrade_all_update_site_status(pId, success_icon);
4106 + upgradeall_update_site_popup_multi_status(pId, 4, {
4107 + icon: regression_icon_callback,
4108 + });
3927 4109 }
3928 - if (jQuery('.updates-regression-score-red-flag').length === 0) {
4110 + upgradeall_update_site_popup_multi_status(pId, 1, {
4111 + isHidden: true // hide spinner.
4112 + });
4113 +
4114 + if ( countError === 0 ) {
3929 4115 setTimeout(function () {
3930 - mainwpPopup('#mainwp-sync-sites-modal').close();
3931 - globalThis.location.href = location.href; // NOSONAR - window is ok.
4116 + // wait for generated updates-regression-score-red-flag.
4117 + if( jQuery('.updates-regression-score-red-flag').length === 0 ) {
4118 + mainwpPopup('#mainwp-sync-sites-modal').close();
4119 + globalThis.location.href = location.href; // NOSONAR - window is ok.
4120 + }
3932 4121 }, 3000);
4122 + } else {
4123 + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed'));
3933 4124 }
3934 4125 return;
3935 4126 }
3936 4127
@@ -3940,37 +4131,96 @@
3940 4131 websiteId: pId,
3941 4132 type: what,
3942 4133 slug: item
3943 4134 });
3944 -
4135 + let decoded = mainwp_decode_slug(item, true);
3945 4136 jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex.
3946 4137 let res_error = response.result_error;
3947 - let _icon = '<i class="red times icon"></i>';
3948 4138 let hasError = false;
3949 -
3950 4139 if (response.error) {
3951 - let extErr = getErrorMessageInfo(response.error, 'ui');
3952 - updatesoverview_plugins_upgrade_all_update_site_status(pId, extErr);
4140 + let extErr = getErrorMessageInfo(response.error);
4141 + let new_status = decoded + ` - ${mainwp_escape_html(extErr)}`;
4142 + upgradeall_update_site_popup_multi_status(pId, 3, {
4143 + status:new_status,
4144 + append:true,
4145 + ispopup: true
4146 + });
3953 4147 hasError = true;
3954 4148 } else if (res_error && mainwp_get_result_entry(res_error, item)) {
4149 + let new_status = decoded;
3955 4150 let _error = mainwp_get_result_entry(res_error, item);
3956 4151 let roll_error = mainwp_updates_get_rollback_msg(_error);
3957 4152 if (roll_error) {
3958 - _error = roll_error;
3959 - _icon = mainwpParams.roll_ui_icon;
4153 + new_status += ` - ${mainwp_escape_html(roll_error)}`;
4154 + let _icon = mainwpParams.roll_ui_icon;
4155 + upgradeall_update_site_popup_multi_status(pId, 5, {
4156 + icon: _icon,
4157 + ispopup: true,
4158 + });
4159 + upgradeall_update_site_popup_multi_status(pId, 5, {
4160 + status: new_status,
4161 + ispopup: true,
4162 + append:true
4163 + });
4164 + } else {
4165 + new_status += ` - ${mainwp_escape_html(_error)}`;
4166 + upgradeall_update_site_popup_multi_status(pId, 3, {
4167 + status: new_status,
4168 + ispopup: true,
4169 + append:true
4170 + });
3960 4171 }
3961 - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"]').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
3962 - mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"] .mainwp-html-popup', _error);
3963 4172 hasError = true;
4173 + } else {
4174 + let new_status = decoded;
4175 + let statusItem = 2;
4176 + // for backward compatibility.
4177 + if (mainwp_get_result_entry(response.result_started, item)) {
4178 + new_status = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + new_status + '</span>';
4179 + hasError = true; // Prevent the popup from closing automatically.
4180 + } else if (!mainwp_get_result_entry(response.result, item)) {
4181 + new_status += ` - ${MainWP.I18n.t('Failed to update. Please try again.')}`;
4182 + hasError = true; // Prevent the popup from closing automatically.
4183 + statusItem = 3;
4184 + } else {
4185 + new_status += ` - ${MainWP.I18n.t('Updated successfully')}`;
4186 + }
4187 + upgradeall_update_site_popup_multi_status(pId, statusItem, {
4188 + status: new_status,
4189 + ispopup: true,
4190 + append:true
4191 + });
3964 4192 }
3965 4193
3966 - if (!hasError) {
3967 - lastResult = response.result;
4194 + if( !hasError ){
4195 + lastResult = response?.result;
4196 + } else {
4197 + ++countError;
3968 4198 }
3969 - processNext();
3970 - }, 'json');
4199 +
4200 + processLoop(response);
4201 + }, 'json').fail(function (jqXHR, textStatus, errorThrown) {
4202 + let errorMessage = errorThrown || textStatus || MainWP.I18n.t('Invalid response from the server');
4203 + let new_status = decoded + ` - ${MainWP.I18n.t('Failed to update')}: ${mainwp_escape_html(errorMessage)}`;
4204 +
4205 + upgradeall_update_site_popup_multi_status(pId, 3, {
4206 + status: new_status,
4207 + ispopup: true,
4208 + append: true
4209 + });
4210 +
4211 + ++countError; // Prevent the popup from closing automatically.
4212 +
4213 + processLoop({
4214 + error: errorMessage,
4215 + result: {},
4216 + result_error: {},
4217 + result_started: {}
4218 + });
4219 + });
3971 4220 };
3972 - processNext();
4221 +
4222 + processLoop();
3973 4223 }
3974 4224
3975 4225 // for semantic ui checkboxes
3976 4226 jQuery(function () {