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.3 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 All 156 releases
← All changes | assets/js/mainwp-updates.js +573 -236 6.1 → 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() !== ''; });
@@ -89,14 +105,14 @@
89 105 // carefully remove this, or it will causing error with display or according sorting
90 106 jQuery(parent).find("[row-uid='" + uid + "']").next().remove(); // remove content according part
91 107 jQuery(parent).find("[row-uid='" + uid + "']").remove(); // remove title according part
92 108 } else {
93 - jQuery(parent).find("[total-uid='" + uid + "']").html(total + ' ' + (total == 1 ? __('Update') : __('Updates')));
109 + jQuery(parent).find("[total-uid='" + uid + "']").html(total + ' ' + (total == 1 ? MainWP.I18n.t('Update') : MainWP.I18n.t('Updates')));
94 110 jQuery(parent).find("[total-uid='" + uid + "']").attr('sort-value', total);
95 111 }
96 112
97 113 if (can_update) {
98 - jQuery(parent).find("[btn-all-uid='" + uid + "']").text(total == 1 ? __('Update') : __('Update All')).show();
114 + jQuery(parent).find("[btn-all-uid='" + uid + "']").text(total == 1 ? MainWP.I18n.t('Update') : MainWP.I18n.t('Update All')).show();
99 115 }
100 116 });
101 117 }
102 118
@@ -116,9 +132,9 @@
116 132 }
117 133
118 134 updatesoverviewContinueAfterBackup = function (pId, pUpgradeElement) {
119 135 return function () {
120 - jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + __('Updating. Please wait...') + waiting_icon);
136 + jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + MainWP.I18n.t('Updating. Please wait...') + waiting_icon);
121 137 pUpgradeElement.val(1);
122 138 let data = mainwp_secure_data({
123 139 action: 'mainwp_upgradewp',
124 140 id: pId
@@ -131,9 +147,9 @@
131 147 err_msg = response.error.extra + ' ';
132 148 }
133 149 let errIcon = '<i class="pause yellow icon"></i>';
134 150 if (response?.error?.errorCode == 'SUSPENDED_SITE') {
135 - errIcon = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '">' + errIcon + '</span>';
151 + errIcon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '">' + errIcon + '</span>';
136 152 }
137 153 jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + err_msg + '">' + errIcon + '</span>');
138 154 } else {
139 155
@@ -150,9 +166,9 @@
150 166 let siteNames = [];
151 167
152 168 siteNames[id] = jQuery('.mainwp-wordpress-update[site_id="' + id + '"]').attr('site_name');
153 169
154 - let msg = __('Are you sure you want to update the Wordpress core files on the selected site?');
170 + let msg = MainWP.I18n.t('Are you sure you want to update the Wordpress core files on the selected site?');
155 171 mainwp_confirm(msg, function () {
156 172 return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames);
157 173 }, false, 1);
158 174 };
@@ -165,15 +181,18 @@
165 181 let continueUpdatesAll = '', continueUpdatesSlug = '';
166 182 let continueUpdating = false;
167 183 let updatesoverview_update_popup_init = function (data) {
168 184 data = data || {};
169 - data.allowMultiple = true;
170 - data.callback = function () {
171 - mainwpVars.bulkTaskRunning = false;
172 - mainwp_forceReload();
173 - };
174 - data.statusText = __('updated');
175 - mainwpPopup('#mainwp-sync-sites-modal').init(data);
185 + let settings = {
186 + allowMultiple: true,
187 + statusText: MainWP.I18n.t('updated'),
188 + callback: function () {
189 + mainwpVars.bulkTaskRunning = false;
190 + mainwp_forceReload();
191 + }
192 + }
193 + jQuery.extend(settings, data);
194 + mainwpPopup('#mainwp-sync-sites-modal').init(settings);
176 195 }
177 196
178 197 let updatesmanage_link_to_site = function (name, siteid) {
179 198 return '<a href="admin.php?page=managesites&dashboard=' + siteid + '">' + name + '</a>';
@@ -219,9 +238,9 @@
219 238 }
220 239 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate) {
221 240 return function () {
222 241 let initData = {
223 - title: __('Updating All'),
242 + title: MainWP.I18n.t('Updating All'),
224 243 progressMax: pSitesCount,
225 244 };
226 245
227 246 updatesoverview_update_popup_init(initData);
@@ -243,9 +262,9 @@
243 262 if (value) { // to fix
244 263 sitesList.push(decodeURIComponent(value));
245 264 }
246 265 });
247 - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('WordPress Core'), sitesList.join('<br />'));
266 + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('WordPress Core'), sitesList.join('<br />'));
248 267 mainwp_confirm(confirmMsg, _callback, false, 2);
249 268 }
250 269 return;
251 270 }
@@ -434,9 +453,9 @@
434 453 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesTranslationSlugs) {
435 454 return function () {
436 455
437 456 let initData = {
438 - title: __('Updating all...'),
457 + title: MainWP.I18n.t('Updating all...'),
439 458 progressMax: pSitesCount
440 459 };
441 460 updatesoverview_update_popup_init(initData);
442 461
@@ -460,9 +479,9 @@
460 479 if (value) { // to fix
461 480 sitesList.push(decodeURIComponent(value));
462 481 }
463 482 });
464 - let confirmMsg = __('You are about to update %1 on the following site(s):\n%2?', 'translations', sitesList.join(', '));
483 + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s):\n%2?', 'translations', sitesList.join(', '));
465 484 mainwp_confirm(confirmMsg, _callback, false, 2);
466 485 }
467 486 return false;
468 487 }
@@ -531,9 +550,9 @@
531 550
532 551 // init and show popup
533 552
534 553 let initData = {
535 - title: __('Updating %1', decodeURIComponent(translationName)),
554 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(translationName)),
536 555 progressMax: pSitesCount
537 556 };
538 557 updatesoverview_update_popup_init(initData);
539 558 //Step 3: start updates
@@ -553,9 +572,9 @@
553 572 if (value) { // to fix
554 573 sitesList.push(decodeURIComponent(value));
555 574 }
556 575 });
557 - let confirmMsg = __('You are about to update the %1 translation on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', translationName, sitesList.join('<br />'));
576 + let confirmMsg = MainWP.I18n.t('You are about to update the %1 translation on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', translationName, sitesList.join('<br />'));
558 577 mainwp_confirm(confirmMsg, _callback, false, 2);
559 578 }
560 579 return;
561 580 }
@@ -642,9 +661,9 @@
642 661 }
643 662
644 663 // Show icon waiting
645 664 const regression_waiting_icon = render_html_regression_waiting_icon();
646 - let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...'));
665 + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Updating. Please wait...'));
647 666 if (regression_waiting_icon && "" !== regression_waiting_icon) {
648 667 waiting_icon += regression_waiting_icon;
649 668 }
650 669
@@ -712,9 +731,9 @@
712 731 websiteHolder.attr('updated', 1);
713 732 websiteHolder.find('td:last-child').html(success_icon);
714 733 } else {
715 734 mainwpVars.errorCount++;
716 - _error = __('Update failed. Please try again.');
735 + _error = MainWP.I18n.t('Update failed. Please try again.');
717 736 if (!done && pBulkMode) {
718 737 updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html=""><i class="red times icon"></i></span>');
719 738 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
720 739 }
@@ -755,11 +774,11 @@
755 774 if (!websiteHolder.exists()) {
756 775 websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]');
757 776 }
758 777
759 - result = __('FAILED');
778 + result = MainWP.I18n.t('FAILED');
760 779 if (!done && pBulkMode) {
761 - updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-red"><i class="exclamation icon"></i> ' + __('FAILED') + '</span>');
780 + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-red"><i class="exclamation icon"></i> ' + MainWP.I18n.t('FAILED') + '</span>');
762 781 updatesoverview_translations_upgrade_all_update_done();
763 782 done = true;
764 783 }
765 784
@@ -873,9 +892,9 @@
873 892 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) {
874 893 return function () {
875 894
876 895 let initData = {
877 - title: __('Updating all'),
896 + title: MainWP.I18n.t('Updating all'),
878 897 progressMax: pSitesCount
879 898 };
880 899 updatesoverview_update_popup_init(initData);
881 900
@@ -898,9 +917,9 @@
898 917 if (value) { // to fix
899 918 sitesList.push(decodeURIComponent(value));
900 919 }
901 920 });
902 - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('plugins'), sitesList.join('<br />'));
921 + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('plugins'), sitesList.join('<br />'));
903 922 mainwp_confirm(confirmMsg, _callback, false, 2);
904 923 }
905 924 return;
906 925 }
@@ -958,9 +977,9 @@
958 977
959 978 let _callback = function () {
960 979
961 980 for (let id of sitesToUpdate) {
962 - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<span data-inverted="" data-position="left center" data-tooltip="' + __('Pending', 'mainwp') + '"><i class="clock outline icon"></i></span> ' + '</span>');
981 + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Pending', 'mainwp') + '"><i class="clock outline icon"></i></span> ' + '</span>');
963 982 }
964 983
965 984 let sitesCount = sitesToUpdate.length;
966 985
@@ -967,9 +986,9 @@
967 986 updatesoverviewContinueAfterBackup = function (pSitesCount, pSlug, pSitesToUpdate) {
968 987 return function () {
969 988
970 989 let initData = {
971 - title: __('Updating %1', decodeURIComponent(pluginName)),
990 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(pluginName)),
972 991 progressMax: pSitesCount
973 992 };
974 993 updatesoverview_update_popup_init(initData);
975 994
@@ -991,9 +1010,9 @@
991 1010 if (value) { // to fix
992 1011 sitesList.push(decodeURIComponent(value));
993 1012 }
994 1013 });
995 - let confirmMsg = __('You are about to update the %1 plugin on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', pluginName, sitesList.join('<br />'));
1014 + let confirmMsg = MainWP.I18n.t('You are about to update the %1 plugin on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', pluginName, sitesList.join('<br />'));
996 1015 mainwp_confirm(confirmMsg, _callback, false, 2);
997 1016 }
998 1017 return;
999 1018 }
@@ -1036,11 +1055,99 @@
1036 1055 while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) {
1037 1056 updatesoverview_plugins_upgrade_all_upgrade_next();
1038 1057 }
1039 1058 };
1040 -let updatesoverview_plugins_upgrade_all_update_site_status = function (siteId, newStatus) {
1041 - 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 + }
1042 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 +
1043 1150 let updatesoverview_plugins_upgrade_all_upgrade_next = function () {
1044 1151 mainwpVars.currentThreads++;
1045 1152 mainwpVars.websitesLeft--;
1046 1153
@@ -1061,13 +1168,18 @@
1061 1168 };
1062 1169
1063 1170 let updatesoverview_check_to_continue_updates = function () {
1064 1171 mainwpVars.bulkTaskRunning = false;
1065 - setTimeout(function () {
1066 - if (!mainwpVars?.errorCount && jQuery('.updates-regression-score-red-flag').length === 0) {
1067 - mainwpPopup('#mainwp-sync-sites-modal').close(true);
1068 - }
1069 - }, 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 + }
1070 1182 return false;
1071 1183 }
1072 1184
1073 1185 let updatesoverview_plugins_upgrade_all_update_done = function () {
@@ -1094,9 +1206,9 @@
1094 1206 );
1095 1207 };
1096 1208 }
1097 1209
1098 -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.
1099 1211 return function () {
1100 1212 let slugList = globalThis.mainwp_slug_list_to_array(pSlug); // NOSONAR -- window is ok.
1101 1213
1102 1214 const yithSlugList = slugList.filter(slg => slg.startsWith('yith-'));
@@ -1117,9 +1229,9 @@
1117 1229 }
1118 1230
1119 1231 let lastResult = pLastResult || null;
1120 1232 const regression_waiting_icon = render_html_regression_waiting_icon();
1121 - let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ';
1233 + let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ';
1122 1234 if (regression_waiting_icon && "" !== regression_waiting_icon) {
1123 1235 waiting_icon += regression_waiting_icon;
1124 1236 }
1125 1237
@@ -1130,8 +1242,12 @@
1130 1242 }
1131 1243 websiteHolder.find('td:last-child').html(waiting_icon);
1132 1244 }
1133 1245
1246 + if( errorHappen === undefined ){
1247 + errorHappen = false;
1248 + }
1249 +
1134 1250 let data = mainwp_secure_data({
1135 1251 action: 'mainwp_upgradeplugintheme',
1136 1252 websiteId: pWebsiteId,
1137 1253 type: 'plugin',
@@ -1151,8 +1267,9 @@
1151 1267 slugParts = [pSlug];
1152 1268 }
1153 1269 let done = false;
1154 1270 let bulk_errors = [];
1271 + let res_started;
1155 1272 let _icon = '<i class="red times icon"></i>';
1156 1273 for (let sid of slugParts) {
1157 1274 let websiteHolder = jQuery('.plugins-bulk-updates[plugin_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]');
1158 1275 if (!websiteHolder.exists()) {
@@ -1164,30 +1281,41 @@
1164 1281 if (!done && pBulkMode)
1165 1282 updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, extErr);
1166 1283 websiteHolder.find('td:last-child').html(extErr);
1167 1284 mainwpVars.errorCount++;
1285 + errorHappen = true;
1168 1286 } else {
1169 1287 let res = response.result;
1170 1288 let res_error = response.result_error;
1289 + res_started = response.result_started; // for backward compatibility.
1171 1290 if (mainwp_get_result_entry(res, sid)) {
1172 1291 lastResult = res;
1173 1292 let _success_icon = `<i class="green check icon"></i>`;
1174 - let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '">' + _success_icon + '</span>';
1293 + let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '">' + _success_icon + '</span>';
1175 1294 websiteHolder.attr('updated', 1);
1176 1295 websiteHolder.find('td:last-child').html(success_icon + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId));
1177 - } else if (res_error[sid]) {
1178 - 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);
1179 1303 let roll_error = mainwp_updates_get_rollback_msg(_error);
1304 + let roll_icon = _icon;
1180 1305 if (roll_error) {
1181 1306 _error = roll_error;
1182 - _icon = mainwpParams.roll_ui_icon;
1307 + roll_icon = mainwpParams.roll_ui_icon;
1183 1308 }
1184 - bulk_errors.push(_error);
1185 - 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>');
1186 1311 mainwpVars.errorCount++;
1312 + errorHappen = true;
1187 1313 } else {
1314 + bulk_errors.push(MainWP.I18n.t('Update failed. Please try again.'));
1188 1315 websiteHolder.find('td:last-child').html('<i class="red times icon"></i>');
1189 1316 mainwpVars.errorCount++;
1317 + errorHappen = true;
1190 1318 }
1191 1319 }
1192 1320 }
1193 1321
@@ -1196,9 +1324,9 @@
1196 1324 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', bulk_errors.join('<br />'));
1197 1325 }
1198 1326
1199 1327 if (remainingSlugs && remainingSlugs.length > 0) {
1200 - updatesoverview_plugins_upgrade_int_after_backup(remainingSlugs, pWebsiteId, pBulkMode, lastResult)();
1328 + updatesoverview_plugins_upgrade_int_after_backup(remainingSlugs, pWebsiteId, pBulkMode, lastResult, errorHappen)();
1201 1329 return;
1202 1330 }
1203 1331 if (
1204 1332 pBulkMode &&
@@ -1203,9 +1331,10 @@
1203 1331 if (
1204 1332 pBulkMode &&
1205 1333 !bulk_errors.length &&
1206 1334 !response.error &&
1207 - !response.notices
1335 + !response.notices &&
1336 + !errorHappen
1208 1337 ) {
1209 1338 if (
1210 1339 lastResult &&
1211 1340 typeof mainwp_html_regression !== "undefined" &&
@@ -1219,9 +1348,18 @@
1219 1348 pWebsiteId,
1220 1349 success_icon + ' ' + regression_icon_loading
1221 1350 );
1222 1351 } else if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
1223 - 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);
1224 1362 }
1225 1363 }
1226 1364 if (pBulkMode) {
1227 1365 updatesoverview_plugins_upgrade_all_update_done();
@@ -1257,8 +1395,9 @@
1257 1395 }(pSlug, pWebsiteId, pBulkMode),
1258 1396 error: function (xhr) {
1259 1397 this.tryCount++;
1260 1398 if (this.tryCount >= this.retryLimit) {
1399 + mainwpVars.errorCount++;
1261 1400 this.endError();
1262 1401 return;
1263 1402 }
1264 1403 let pXhr = xhr;
@@ -1367,9 +1506,9 @@
1367 1506 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) {
1368 1507 return function () {
1369 1508
1370 1509 let initData = {
1371 - title: __('Updating all...'),
1510 + title: MainWP.I18n.t('Updating all...'),
1372 1511 progressMax: pSitesCount
1373 1512 };
1374 1513 updatesoverview_update_popup_init(initData);
1375 1514
@@ -1391,9 +1530,9 @@
1391 1530 if (value) { // to fix
1392 1531 sitesList.push(decodeURIComponent(value));
1393 1532 }
1394 1533 });
1395 - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('themes'), sitesList.join('<br />'));
1534 + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('themes'), sitesList.join('<br />'));
1396 1535 mainwp_confirm(confirmMsg, _callback, false, 2);
1397 1536 }
1398 1537 return;
1399 1538 }
@@ -1428,9 +1567,9 @@
1428 1567 return foundChildren;
1429 1568 }
1430 1569
1431 1570 let updates_please_select_items_notice = function () {
1432 - let msg = __('Please, select items to update.');
1571 + let msg = MainWP.I18n.t('Please, select items to update.');
1433 1572 jQuery('#mainwp-modal-confirm-select .content-massage').html(msg);
1434 1573 jQuery('#mainwp-modal-confirm-select').modal('show');
1435 1574 return false;
1436 1575 }
@@ -1473,9 +1612,9 @@
1473 1612 return function () {
1474 1613 //Step 2: show form
1475 1614
1476 1615 let initData = {
1477 - title: __('Updating %1', decodeURIComponent(themeName)),
1616 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(themeName)),
1478 1617 progressMax: pSitesCount
1479 1618 };
1480 1619 updatesoverview_update_popup_init(initData);
1481 1620
@@ -1497,9 +1636,9 @@
1497 1636 if (value) { // to fix
1498 1637 sitesList.push(decodeURIComponent(value));
1499 1638 }
1500 1639 });
1501 - let confirmMsg = __('You are about to update the %1 theme on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', themeName, sitesList.join('<br />'));
1640 + let confirmMsg = MainWP.I18n.t('You are about to update the %1 theme on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', themeName, sitesList.join('<br />'));
1502 1641 mainwp_confirm(confirmMsg, _callback, false, 2);
1503 1642 }
1504 1643 return;
1505 1644 }
@@ -1599,9 +1738,9 @@
1599 1738
1600 1739 let lastResultFinal = lastResult || null;
1601 1740 // Show icon waiting
1602 1741 const regression_waiting_icon = render_html_regression_waiting_icon();
1603 - let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...'));
1742 + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Updating. Please wait...'));
1604 1743 if (regression_waiting_icon && "" !== regression_waiting_icon) {
1605 1744 waiting_icon += regression_waiting_icon;
1606 1745 }
1607 1746
@@ -1645,8 +1784,9 @@
1645 1784 let extErr = getErrorMessageInfo(response.error, 'ui')
1646 1785 if (!done && pBulkMode)
1647 1786 updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, extErr);
1648 1787 websiteHolder.find('td:last-child').html(extErr);
1788 + mainwpVars.errorCount++;
1649 1789 } else {
1650 1790 let res = response.result;
1651 1791 let res_error = response.result_error;
1652 1792 if (mainwp_get_result_entry(res, sid)) {
@@ -1651,9 +1791,9 @@
1651 1791 let res_error = response.result_error;
1652 1792 if (mainwp_get_result_entry(res, sid)) {
1653 1793 lastResultFinal = res;
1654 1794 let _success_icon = `<i class="green check icon"></i>`;
1655 - const success_icon = `<span data-inverted="" data-position="left center" data-tooltip="${__('Update successful', 'mainwp')}">${_success_icon}</span>`;
1795 + const success_icon = `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Update successful', 'mainwp')}">${_success_icon}</span>`;
1656 1796 websiteHolder.attr('updated', 1);
1657 1797 websiteHolder.find('td:last-child').html(success_icon);
1658 1798 } else {
1659 1799 let _error = '';
@@ -1666,14 +1806,14 @@
1666 1806 _error = roll_error;
1667 1807 _icon = mainwpParams.roll_ui_icon;
1668 1808 bulk_icon = mainwpParams.roll_ui_icon;
1669 1809 }
1670 - bulk_errors.push(_error);
1810 + bulk_errors.push(mainwp_escape_html(_error));
1671 1811 mainwpVars.errorCount++;
1672 1812 }
1673 1813 if (_error) {
1674 1814 websiteHolder.find('td:last-child').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
1675 - 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));
1676 1816 }
1677 1817 }
1678 1818 }
1679 1819
@@ -1742,8 +1882,9 @@
1742 1882 }(slug, websiteId, bulkMode),
1743 1883 error: function (xhr) {
1744 1884 this.tryCount++;
1745 1885 if (this.tryCount >= this.retryLimit) {
1886 + mainwpVars.errorCount++;
1746 1887 this.endError();
1747 1888 return;
1748 1889 }
1749 1890
@@ -1764,14 +1905,70 @@
1764 1905
1765 1906 return false;
1766 1907 };
1767 1908
1909 +const updatesoverview_global_upgrade_all = function (which, current_siteid) { // NOSONAR - Complexity.
1910 + if (mainwpVars.bulkTaskRunning) {
1911 + return;
1912 + }
1913 + updatesoverview_global_prepare_upgrade_all(which, current_siteid);
1914 +}
1768 1915
1916 +const updatesoverview_global_prepare_upgrade_all = function (which, current_siteid) { // NOSONAR - Complexity.
1917 + if (mainwpVars.bulkTaskRunning) {
1918 + return;
1919 + }
1920 + const onPrepared = () => updatesoverview_global_run_upgrade_all(which);
1921 +
1922 + updatesoverview_global_prepare_data_upgrade_all(which, onPrepared, current_siteid);
1923 +}
1924 +
1925 +const updatesoverview_global_prepare_data_upgrade_all = function (which, onPrepared, current_siteid) {
1926 +
1927 + let initData = {
1928 + title: MainWP.I18n.t('Updating All'),
1929 + initVisibleContentMsg: true,
1930 + contentMsg: MainWP.I18n.t('Preparing update data, please wait...'),
1931 + };
1932 + mainwpPopup('#mainwp-prepare-data-modal').init(initData);
1933 +
1934 + let data = mainwp_secure_data({
1935 + action: 'mainwp_overview_prepare_upgradeall',
1936 + which: which,
1937 + site_id: current_siteid
1938 + });
1939 +
1940 + jQuery.ajax({
1941 + type: "POST",
1942 + url: ajaxurl,
1943 + data: data,
1944 + dataType: 'html',
1945 + success: function (response) {
1946 + if (response && typeof onPrepared === 'function') {
1947 + jQuery('#mainwp_prepare_global_update_all_container').html(response);
1948 + onPrepared();
1949 + } else {
1950 + setTimeout(function () {
1951 + mainwp_forceReload();
1952 + }, 2000);
1953 + }
1954 + },
1955 + error: function (xhr, status, error) {
1956 + console.error('Failed to prepare update data:', error);
1957 + setTimeout(function () {
1958 + mainwp_forceReload();
1959 + }, 2000);
1960 + }
1961 + });
1962 +}
1963 +
1964 +
1769 1965 /* eslint-disable complexity */
1770 -let updatesoverview_global_upgrade_all = function (which) { // NOSONAR - Complexity.
1966 +const updatesoverview_global_run_upgrade_all = function (which) { // NOSONAR - Complexity.
1771 1967
1772 - if (mainwpVars.bulkTaskRunning)
1968 + if (mainwpVars.bulkTaskRunning) {
1773 1969 return;
1970 + }
1774 1971
1775 1972 //Step 1: build form
1776 1973 let sitesToUpdate = [];
1777 1974 let sitesToUpgrade = [];
@@ -1778,11 +1975,10 @@
1778 1975 let sitesPluginSlugs = {};
1779 1976 let sitesThemeSlugs = {};
1780 1977 let sitesTranslationSlugs = {};
1781 1978 let siteNames = {};
1979 + let suspendedWebsites = [];
1782 1980
1783 - mainwpPopup('#mainwp-sync-sites-modal').clearList();
1784 -
1785 1981 let sitesCount = 0;
1786 1982 let foundChildren;
1787 1983
1788 1984 if (which == 'all' || which == 'wp') {
@@ -1800,8 +1996,12 @@
1800 1996 }
1801 1997
1802 1998 if (!sitesToUpgrade.includes(siteId))
1803 1999 sitesToUpgrade.push(siteId);
2000 +
2001 + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') {
2002 + suspendedWebsites.push(siteId);
2003 + }
1804 2004 }
1805 2005 }
1806 2006 }
1807 2007
@@ -1825,8 +2025,11 @@
1825 2025 sitesPluginSlugs[siteId] = pluginSlug;
1826 2026 } else {
1827 2027 sitesPluginSlugs[siteId] += ',' + pluginSlug;
1828 2028 }
2029 + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') {
2030 + suspendedWebsites.push(siteId);
2031 + }
1829 2032 }
1830 2033 }
1831 2034 }
1832 2035
@@ -1850,8 +2053,11 @@
1850 2053 sitesThemeSlugs[siteId] = themeSlug;
1851 2054 } else {
1852 2055 sitesThemeSlugs[siteId] += ',' + themeSlug;
1853 2056 }
2057 + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') {
2058 + suspendedWebsites.push(siteId);
2059 + }
1854 2060 }
1855 2061 }
1856 2062 }
1857 2063
@@ -1875,13 +2081,17 @@
1875 2081 sitesTranslationSlugs[siteId] = transSlug;
1876 2082 } else {
1877 2083 sitesTranslationSlugs[siteId] += ',' + transSlug;
1878 2084 }
2085 + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') {
2086 + suspendedWebsites.push(siteId);
2087 + }
1879 2088 }
1880 2089 }
1881 2090 }
1882 2091
1883 2092 let _callback = function () { // NOSONAR - Complexity.
2093 + mainwpPopup('#mainwp-sync-sites-modal').clearList();
1884 2094 //Build form
1885 2095 for (let siteId of sitesToUpdate) {
1886 2096 let whatToUpgrade = '';
1887 2097 if (sitesToUpgrade.includes(siteId))
@@ -1926,18 +2136,22 @@
1926 2136 }
1927 2137 mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', siteId) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[siteId]), siteId) + ' (' + whatToUpgrade + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + siteId + '">' + '<i class="clock outline icon"></i> ' + '</span>');
1928 2138 }
1929 2139
1930 - updatesoverviewContinueAfterBackup = updatesoverview_global_upgrade_all_after_backup(sitesCount, sitesToUpdate, sitesToUpgrade, sitesPluginSlugs, sitesThemeSlugs, sitesTranslationSlugs);
2140 + updatesoverviewContinueAfterBackup = updatesoverview_global_upgrade_all_after_backup(sitesCount, sitesToUpdate, sitesToUpgrade, sitesPluginSlugs, sitesThemeSlugs, sitesTranslationSlugs, suspendedWebsites);
1931 2141 return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames);
1932 2142 } // end _callback()
1933 -
1934 - updatesoverview_global_upgrade_all_start(which, siteNames, _callback);
2143 + if (Object.keys(siteNames).length === 0) {
2144 + mainwpVars.bulkTaskRunning = false;
2145 + mainwpPopup('#mainwp-prepare-data-modal').getContentMsgEl().html('<div class="ui yellow message">' + MainWP.I18n.t('There are no updates available to process. Please try again.') + '</div>');
2146 + } else {
2147 + updatesoverview_global_upgrade_all_start(which, siteNames, _callback);
2148 + }
1935 2149 };
1936 2150
1937 2151 let updatesoverview_global_upgrade_all_start = function (which, siteNames, _callback) {
1938 2152 // new confirm message
1939 - if (jQuery(siteNames).length > 0) {
2153 + if (Object.keys(siteNames).length) {
1940 2154 let sitesList = [];
1941 2155 jQuery.each(siteNames, function (index, value) {
1942 2156 if (value) { // to fix
1943 2157 sitesList.push(decodeURIComponent(value));
@@ -1943,37 +2157,37 @@
1943 2157 sitesList.push(decodeURIComponent(value));
1944 2158 }
1945 2159 });
1946 2160
1947 - let whichUpdates = __('WordPress core files, plugins, themes and translations');
2161 + let whichUpdates = MainWP.I18n.t('WordPress core files, plugins, themes and translations');
1948 2162 if (which == 'wp') {
1949 - whichUpdates = __('WordPress core files');
2163 + whichUpdates = MainWP.I18n.t('WordPress core files');
1950 2164 } else if (which == 'plugin') {
1951 - whichUpdates = __('plugins');
2165 + whichUpdates = MainWP.I18n.t('plugins');
1952 2166 } else if (which == 'theme') {
1953 - whichUpdates = __('themes');
2167 + whichUpdates = MainWP.I18n.t('themes');
1954 2168 } else if (which == 'translation') {
1955 - whichUpdates = __('translations');
2169 + whichUpdates = MainWP.I18n.t('translations');
1956 2170 }
1957 2171
1958 - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', whichUpdates, sitesList.join('<br />'));
2172 + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', whichUpdates, sitesList.join('<br />'));
1959 2173
1960 2174 mainwp_confirm(confirmMsg, _callback, false, 2);
1961 2175 }
1962 2176 }
1963 2177
1964 -let updatesoverview_global_upgrade_all_after_backup = function (pSitesCount, pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs) {
2178 +let updatesoverview_global_upgrade_all_after_backup = function (pSitesCount, pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended) {
1965 2179 return function () {
1966 2180 //Step 2: show form
1967 2181
1968 2182 let initData = {
1969 - title: __('Updating All'),
1970 - progressMax: pSitesCount
2183 + title: MainWP.I18n.t('Updating All'),
2184 + progressMax: pSitesCount,
1971 2185 };
1972 2186 updatesoverview_update_popup_init(initData);
1973 2187
1974 2188 //Step 3: start updates
1975 - updatesoverview_upgrade_all_int(pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs);
2189 + updatesoverview_upgrade_all_int(pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended);
1976 2190
1977 2191 updatesoverviewContinueAfterBackup = undefined;
1978 2192 };
1979 2193 }
@@ -1980,10 +2194,11 @@
1980 2194
1981 2195 /* eslint-enable complexity */
1982 2196 let websitesTransSlugsToUpgrade;
1983 2197
1984 -let updatesoverview_upgrade_all_int = function (pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs) {
2198 +let updatesoverview_upgrade_all_int = function (pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended) {
1985 2199 mainwpVars.websitesToUpdate = pSitesToUpdate;
2200 + mainwpVars.websitesSuspended = pSitesSuspended;
1986 2201
1987 2202 mainwpVars.websitesToUpgrade = pSitesToUpgrade;
1988 2203
1989 2204 websitesPluginSlugsToUpgrade = pSitesPluginSlugs;
@@ -2000,8 +2215,10 @@
2000 2215 mainwpVars.websitesTotal = mainwpVars.websitesLeft = mainwpVars.websitesToUpdate.length;
2001 2216
2002 2217 mainwpVars.bulkTaskRunning = true;
2003 2218
2219 + console.log('Suspended sites: ' + mainwpVars.websitesSuspended.join(', '));
2220 +
2004 2221 updatesoverview_upgrade_all_loop_next();
2005 2222 };
2006 2223
2007 2224 let updatesoverview_upgrade_all_loop_next = function () {
@@ -2032,8 +2249,19 @@
2032 2249
2033 2250 let websiteId = mainwpVars.websitesToUpdate[mainwpVars.currentWebsite++];
2034 2251 updatesoverview_upgrade_all_update_site_status(websiteId, waiting_icon);
2035 2252
2253 + console.log('Starting upgrade process for site ' + websiteId);
2254 +
2255 + // process suspended site here to avoid starting the upgrade process and then showing the error after few seconds, also to avoid retrying the upgrade process for suspended sites in case of retry mechanism is triggered for some reason.
2256 + if (mainwpVars.websitesSuspended.includes(websiteId)) {
2257 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2258 + updatesoverview_upgrade_all_update_site_bold(websiteId, false, msgUI);
2259 + mainwpVars.errorCount++;
2260 + updatesoverview_upgrade_all_update_done();
2261 + return;
2262 + }
2263 +
2036 2264 let params = {
2037 2265 'websiteId': websiteId,
2038 2266 'pThemeSlugToUpgrade': websitesThemeSlugsToUpgrade[websiteId],
2039 2267 'pPluginSlugToUpgrade': websitesPluginSlugsToUpgrade[websiteId],
@@ -2079,8 +2307,10 @@
2079 2307 setTimeout(function () {
2080 2308 // close and refresh page
2081 2309 mainwpPopup('#mainwp-sync-sites-modal').close(true);
2082 2310 }, 3000);
2311 + } else {
2312 + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed'));
2083 2313 }
2084 2314 return;
2085 2315 }
2086 2316
@@ -2132,13 +2362,14 @@
2132 2362 success: function (pWebsiteId, pSlug, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2133 2363 return function (response) { // NOSONAR - complex ok.
2134 2364 let slugParts = pSlug.split(',');
2135 2365 if (response?.error?.errorCode == 'SUSPENDED_SITE') {
2136 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause circular yellow inverted icon"></i></span>';
2366 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2137 2367 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2138 2368 pPluginDone = true;
2139 2369 pUpgradeDone = true;
2140 2370 pTransDone = true;
2371 + pThemeDone = true;
2141 2372 mainwpVars.errorCount++;
2142 2373 } else {
2143 2374 for (let sid of slugParts) {
2144 2375 let result;
@@ -2151,8 +2382,9 @@
2151 2382 let isError = true;
2152 2383 if (response.error) {
2153 2384 result = getErrorMessage(response.error);
2154 2385 pErrorMessage = result;
2386 + mainwpVars.errorCount++;
2155 2387 } else {
2156 2388 let res = response.result;
2157 2389 if (mainwp_get_result_entry(res, sid)) {
2158 2390 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
@@ -2158,9 +2390,9 @@
2158 2390 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
2159 2391 websiteHolder.attr('updated', 1);
2160 2392 isError = false;
2161 2393 } else {
2162 - result = __('Update failed!');
2394 + result = MainWP.I18n.t('Update failed!');
2163 2395 pErrorMessage = result;
2164 2396 }
2165 2397 }
2166 2398
@@ -2174,32 +2406,32 @@
2174 2406 }
2175 2407
2176 2408 }
2177 2409 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'theme');
2410 + }
2178 2411
2179 - //If all done: continue, else delay 400ms to not stress the server
2180 - let fnc = function () {
2181 - let params = {
2182 - 'pWebsiteId': pWebsiteId,
2183 - 'pThemeSlugToUpgrade': remainingThemeSlugs,
2184 - 'pPluginSlugToUpgrade': pPluginSlugToUpgrade,
2185 - 'pWordpressUpgrade': pWordpressUpgrade,
2186 - 'pThemeDone': remainingThemeSlugs === '',
2187 - 'pPluginDone': pPluginDone,
2188 - 'pUpgradeDone': pUpgradeDone,
2189 - 'pErrorMessage': pErrorMessage,
2190 - 'pTransSlugToUpgrade': pTransSlugToUpgrade,
2191 - 'pTransDone': pTransDone,
2192 - 'bulkErrorCode': bulkErrorCode
2193 - };
2194 - updatesoverview_upgrade_int_loop_flow(params);
2412 + //If all done: continue, else delay 400ms to not stress the server
2413 + let fnc = function () {
2414 + let params = {
2415 + 'pWebsiteId': pWebsiteId,
2416 + 'pThemeSlugToUpgrade': remainingThemeSlugs,
2417 + 'pPluginSlugToUpgrade': pPluginSlugToUpgrade,
2418 + 'pWordpressUpgrade': pWordpressUpgrade,
2419 + 'pThemeDone': pThemeDone ? true : remainingThemeSlugs === '',
2420 + 'pPluginDone': pPluginDone,
2421 + 'pUpgradeDone': pUpgradeDone,
2422 + 'pErrorMessage': pErrorMessage,
2423 + 'pTransSlugToUpgrade': pTransSlugToUpgrade,
2424 + 'pTransDone': pTransDone,
2425 + 'bulkErrorCode': bulkErrorCode
2195 2426 };
2427 + updatesoverview_upgrade_int_loop_flow(params);
2428 + };
2196 2429
2197 - if (pPluginDone && pUpgradeDone && pTransDone)
2198 - fnc();
2199 - else
2200 - setTimeout(fnc, 400);
2201 - }
2430 + if (pPluginDone && pUpgradeDone && pTransDone)
2431 + fnc();
2432 + else
2433 + setTimeout(fnc, 400);
2202 2434 }
2203 2435 }(pWebsiteId, currentThemeSlug, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone),
2204 2436 tryCount: 0,
2205 2437 retryLimit: 3,
@@ -2237,8 +2469,9 @@
2237 2469 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone),
2238 2470 error: function (xhr) {
2239 2471 this.tryCount++;
2240 2472 if (this.tryCount >= this.retryLimit) {
2473 + mainwpVars.errorCount++;
2241 2474 this.endError();
2242 2475 return;
2243 2476 }
2244 2477 let pXhr = xhr;
@@ -2285,14 +2518,15 @@
2285 2518 success: function (pWebsiteId, pThemeSlugToUpgrade, pSlug, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2286 2519 return function (response) { // NOSONAR - complex ok.
2287 2520 bulkErrorCode = response?.error?.errorCode ?? '';
2288 2521 if (bulkErrorCode == 'SUSPENDED_SITE') {
2289 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2522 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2290 2523 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2291 2524
2292 2525 pThemeDone = true;
2293 2526 pUpgradeDone = true;
2294 2527 pTransDone = true;
2528 + pPluginDone = true;
2295 2529
2296 2530 mainwpVars.errorCount++;
2297 2531
2298 2532 } else {
@@ -2310,8 +2544,9 @@
2310 2544 }
2311 2545 if (response.error) {
2312 2546 result = getErrorMessage(response.error);
2313 2547 pErrorMessage = result;
2548 + mainwpVars.errorCount++;
2314 2549 }
2315 2550 else {
2316 2551 let res = response.result; // result is an object
2317 2552 let res_error = response.result_error;
@@ -2322,38 +2557,38 @@
2322 2557 pErrorMessage = mainwp_get_result_entry(res_error, sid);
2323 2558 let roll_error = mainwp_updates_get_rollback_msg(pErrorMessage);
2324 2559 mainwp_put_actions_errors_msg('updateall', pWebsiteId, roll_error ? 'roll' : 'default', roll_error || pErrorMessage);// save errors to show later.
2325 2560 } else {
2326 - result = __('Update failed!');
2561 + result = MainWP.I18n.t('Update failed!');
2327 2562 pErrorMessage = result;
2328 2563 }
2329 2564 }
2330 2565 }
2331 2566 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'plugin');
2567 + }
2332 2568
2333 - //If all done: continue, else delay 400ms to not stress the server
2334 - let fnc = function () {
2335 - let params = {
2336 - 'pWebsiteId': pWebsiteId,
2337 - 'pThemeSlugToUpgrade': pThemeSlugToUpgrade,
2338 - 'pPluginSlugToUpgrade': remainingPluginSlugs,
2339 - 'pWordpressUpgrade': pWordpressUpgrade,
2340 - 'pThemeDone': pThemeDone,
2341 - 'pPluginDone': remainingPluginSlugs === '',
2342 - 'pUpgradeDone': pUpgradeDone,
2343 - 'pErrorMessage': pErrorMessage,
2344 - 'pTransSlugToUpgrade': pTransSlugToUpgrade,
2345 - 'pTransDone': pTransDone,
2346 - 'bulkErrorCode': bulkErrorCode
2347 - };
2348 - updatesoverview_upgrade_int_loop_flow(params);
2569 + //If all done: continue, else delay 400ms to not stress the server
2570 + let fnc = function () {
2571 + let params = {
2572 + 'pWebsiteId': pWebsiteId,
2573 + 'pThemeSlugToUpgrade': pThemeSlugToUpgrade,
2574 + 'pPluginSlugToUpgrade': remainingPluginSlugs,
2575 + 'pWordpressUpgrade': pWordpressUpgrade,
2576 + 'pThemeDone': pThemeDone,
2577 + 'pPluginDone': pPluginDone ? true : remainingPluginSlugs === '',
2578 + 'pUpgradeDone': pUpgradeDone,
2579 + 'pErrorMessage': pErrorMessage,
2580 + 'pTransSlugToUpgrade': pTransSlugToUpgrade,
2581 + 'pTransDone': pTransDone,
2582 + 'bulkErrorCode': bulkErrorCode
2349 2583 };
2584 + updatesoverview_upgrade_int_loop_flow(params);
2585 + };
2350 2586
2351 - if (pThemeDone && pUpgradeDone && pTransDone)
2352 - fnc();
2353 - else
2354 - setTimeout(fnc, 400);
2355 - }
2587 + if (pThemeDone && pUpgradeDone && pTransDone)
2588 + fnc();
2589 + else
2590 + setTimeout(fnc, 400);
2356 2591 }
2357 2592 }(pWebsiteId, pThemeSlugToUpgrade, currentPluginSlug, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone),
2358 2593 tryCount: 0,
2359 2594 retryLimit: 3,
@@ -2389,8 +2624,9 @@
2389 2624 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone),
2390 2625 error: function (xhr) {
2391 2626 this.tryCount++;
2392 2627 if (this.tryCount >= this.retryLimit) {
2628 + mainwpVars.errorCount++;
2393 2629 this.endError();
2394 2630 return;
2395 2631 }
2396 2632 setTimeout(function (pRqst, pXhr) {
@@ -2421,9 +2657,9 @@
2421 2657 success: function (WebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2422 2658 return function (response) {
2423 2659 let bulkErrorCode = response?.error?.errorCode ?? '';
2424 2660 if (bulkErrorCode == 'SUSPENDED_SITE') {
2425 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2661 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2426 2662 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2427 2663
2428 2664 pThemeDone = true;
2429 2665 pPluginDone = true;
@@ -2466,9 +2702,8 @@
2466 2702 if (pThemeDone && pPluginDone && pTransDone)
2467 2703 fnc();
2468 2704 else
2469 2705 setTimeout(fnc, 400);
2470 -
2471 2706 }
2472 2707 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pErrorMessage, pTransSlugToUpgrade, pTransDone),
2473 2708 tryCount: 0,
2474 2709 retryLimit: 3,
@@ -2542,14 +2777,15 @@
2542 2777 success: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pSlug) { // NOSONAR - compatible.
2543 2778 return function (response) { // NOSONAR -complex.
2544 2779 let bulkErrorCode = response?.error?.errorCode ?? '';
2545 2780 if (bulkErrorCode == 'SUSPENDED_SITE') {
2546 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2781 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2547 2782 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2548 2783
2549 2784 pThemeDone = true;
2550 2785 pPluginDone = true;
2551 2786 pUpgradeDone = true;
2787 + pTransDone = true;
2552 2788
2553 2789 mainwpVars.errorCount++;
2554 2790
2555 2791 } else {
@@ -2567,8 +2803,9 @@
2567 2803 }
2568 2804 if (response.error) {
2569 2805 result = getErrorMessage(response.error);
2570 2806 pErrorMessage = result;
2807 + mainwpVars.errorCount++;
2571 2808 } else {
2572 2809 let res = response.result;
2573 2810 if (mainwp_get_result_entry(res, sid)) {
2574 2811 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
@@ -2573,9 +2810,9 @@
2573 2810 if (mainwp_get_result_entry(res, sid)) {
2574 2811 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
2575 2812 websiteHolder.attr('updated', 1);
2576 2813 } else {
2577 - result = __('Update failed!');
2814 + result = MainWP.I18n.t('Update failed!');
2578 2815 pErrorMessage = result;
2579 2816 }
2580 2817 }
2581 2818 }
@@ -2580,32 +2817,31 @@
2580 2817 }
2581 2818 }
2582 2819
2583 2820 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'translation');
2584 -
2585 - //If all done: continue, else delay 400ms to not stress the server
2586 - let fnc = function () {
2587 - let params = {
2588 - 'pWebsiteId': pWebsiteId,
2589 - 'pThemeSlugToUpgrade': pThemeSlugToUpgrade,
2590 - 'pPluginSlugToUpgrade': pPluginSlugToUpgrade,
2591 - 'pWordpressUpgrade': pWordpressUpgrade,
2592 - 'pThemeDone': pThemeDone,
2593 - 'pPluginDone': pPluginDone,
2594 - 'pUpgradeDone': pUpgradeDone,
2595 - 'pErrorMessage': pErrorMessage,
2596 - 'pTransSlugToUpgrade': remainingTransSlugs,
2597 - 'pTransDone': remainingTransSlugs === '',
2598 - 'bulkErrorCode': bulkErrorCode
2599 - };
2600 - updatesoverview_upgrade_int_loop_flow(params);
2821 + }
2822 + //If all done: continue, else delay 400ms to not stress the server
2823 + let fnc = function () {
2824 + let params = {
2825 + 'pWebsiteId': pWebsiteId,
2826 + 'pThemeSlugToUpgrade': pThemeSlugToUpgrade,
2827 + 'pPluginSlugToUpgrade': pPluginSlugToUpgrade,
2828 + 'pWordpressUpgrade': pWordpressUpgrade,
2829 + 'pThemeDone': pThemeDone,
2830 + 'pPluginDone': pPluginDone,
2831 + 'pUpgradeDone': pUpgradeDone,
2832 + 'pErrorMessage': pErrorMessage,
2833 + 'pTransSlugToUpgrade': remainingTransSlugs,
2834 + 'pTransDone': pTransDone ? true : remainingTransSlugs === '',
2835 + 'bulkErrorCode': bulkErrorCode
2601 2836 };
2837 + updatesoverview_upgrade_int_loop_flow(params);
2838 + };
2602 2839
2603 - if (pThemeDone && pUpgradeDone && pPluginDone)
2604 - fnc();
2605 - else
2606 - setTimeout(fnc, 400);
2607 - }
2840 + if (pThemeDone && pUpgradeDone && pPluginDone)
2841 + fnc();
2842 + else
2843 + setTimeout(fnc, 400);
2608 2844 }
2609 2845 }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, currentTransSlug),
2610 2846 tryCount: 0,
2611 2847 retryLimit: 3,
@@ -2663,9 +2899,9 @@
2663 2899 });
2664 2900 } else {
2665 2901 if (bulkErrorCode === 'SUSPENDED_SITE') {
2666 2902 let _icon = '<i class="pause yellow icon"></i>';
2667 - let _error = __('Suspended site.');
2903 + let _error = MainWP.I18n.t('Suspended site.');
2668 2904 updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
2669 2905 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
2670 2906 } else if ((pErrorMessage != undefined) && (pErrorMessage != '')) {
2671 2907 mainwpVars.errorCount++;
@@ -2682,9 +2918,9 @@
2682 2918 _error = otherErrors
2683 2919 }
2684 2920
2685 2921 if (_error == '') {
2686 - _error = __('Update failed. Please try again.');
2922 + _error = MainWP.I18n.t('Update failed. Please try again.');
2687 2923 }
2688 2924
2689 2925 updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
2690 2926 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
@@ -2746,9 +2982,9 @@
2746 2982 parent.find('td:last-child').html('<span data-tooltip="Please wait..." data-position="left center" data-inverted=""><i class="notched circle loading icon"></i></span>');
2747 2983 jQuery.post(ajaxurl, data, function (response) {
2748 2984 if (response.result) {
2749 2985 parent.attr('dismissed', '-1');
2750 - parent.find('td:last-child').html(__('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'));
2986 + parent.find('td:last-child').html(MainWP.I18n.t('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'));
2751 2987
2752 2988 } else {
2753 2989 parent.find('td:last-child').html(getErrorMessage(response.error));
2754 2990 }
@@ -2795,9 +3031,9 @@
2795 3031 siteElement.remove();
2796 3032
2797 3033 if (parent.children('tr').length == 0) {
2798 3034 jQuery('#mainwp-unignore-detail-all').addClass('disabled');
2799 - parent.append('<tr><td colspan="999">' + __('No ignored abandoned %1s', pWhat) + '</td></tr>');
3035 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned %1s', pWhat) + '</td></tr>');
2800 3036 }
2801 3037 }
2802 3038 }
2803 3039 }(what, slug, id), 'json');
@@ -2817,9 +3053,9 @@
2817 3053 return function (response) {
2818 3054 if (response.result) {
2819 3055 let tableElement = jQuery('#ignored-abandoned-' + pWhat + 's-list');
2820 3056 tableElement.find('tr').remove();
2821 - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned %1s', pWhat) + '</td></tr>');
3057 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned %1s', pWhat) + '</td></tr>');
2822 3058 jQuery('#mainwp-unignore-detail-all').addClass('disabled');
2823 3059 }
2824 3060 }
2825 3061 }(what), 'json');
@@ -2860,9 +3096,9 @@
2860 3096 if (response.result) {
2861 3097 let tableElement = jQuery('#ignored-globally-abandoned-plugins-list');
2862 3098 tableElement.find('tr').remove();
2863 3099 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
2864 - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned plugins.') + '</td></tr>');
3100 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned plugins.') + '</td></tr>');
2865 3101 }
2866 3102 }, 'json');
2867 3103
2868 3104 return false;
@@ -2884,9 +3120,9 @@
2884 3120 let parent = ignoreElement.parent();
2885 3121 ignoreElement.remove();
2886 3122 if (parent.children('tr').length == 0) {
2887 3123 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
2888 - parent.append('<tr><td colspan="999">' + __('No ignored abandoned plugins.') + '</td></tr>');
3124 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned plugins.') + '</td></tr>');
2889 3125 }
2890 3126 }
2891 3127 }, 'json');
2892 3128 return false;
@@ -2925,9 +3161,9 @@
2925 3161 if (response.result) {
2926 3162 let tableElement = jQuery('#globally-ignored-themes-list');
2927 3163 tableElement.find('tr').remove();
2928 3164 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
2929 - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned themes.') + '</td></tr>');
3165 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned themes.') + '</td></tr>');
2930 3166 }
2931 3167 }, 'json');
2932 3168
2933 3169 return false;
@@ -2947,9 +3183,9 @@
2947 3183 let parent = ignoreElement.parent();
2948 3184 ignoreElement.remove();
2949 3185 if (parent.children('tr').length == 0) {
2950 3186 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
2951 - parent.append('<tr><td colspan="999">' + __('No ignored abandoned themes.') + '</td></tr>');
3187 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned themes.') + '</td></tr>');
2952 3188 }
2953 3189 }
2954 3190 }, 'json');
2955 3191
@@ -2987,9 +3223,9 @@
2987 3223 } else {
2988 3224 jQuery('#wp_http_response_code_' + id).removeClass('http-response-ok');
2989 3225 }
2990 3226 } else {
2991 - jQuery('#wp_http_response_code_' + id + ' .http-code').html(__('Undefined error!'));
3227 + jQuery('#wp_http_response_code_' + id + ' .http-code').html(MainWP.I18n.t('Undefined error!'));
2992 3228 }
2993 3229 }, 'json');
2994 3230 return false;
2995 3231 };
@@ -3072,9 +3308,9 @@
3072 3308 let parent = siteElement.parent();
3073 3309 mainwp_responsive_fix_remove_child_row(siteElement);
3074 3310 siteElement.remove();
3075 3311 if (parent.children('tr').length == 0) {
3076 - parent.append('<tr><td colspan="999">' + __('No ignored %1s', pWhat) + '</td></tr>');
3312 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored %1s', pWhat) + '</td></tr>');
3077 3313 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3078 3314 }
3079 3315 }
3080 3316 }
@@ -3095,9 +3331,9 @@
3095 3331 return function (response) {
3096 3332 if (response.result) {
3097 3333 let tableElement = jQuery('#ignored-' + pWhat + 's-list');
3098 3334 tableElement.find('tr').remove();
3099 - tableElement.append('<tr><td colspan="999">' + __('No ignored %1s', pWhat) + '</td></tr>');
3335 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored %1s', pWhat) + '</td></tr>');
3100 3336 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3101 3337 }
3102 3338 }
3103 3339 }(what), 'json');
@@ -3107,9 +3343,9 @@
3107 3343 /**Plugins part**/
3108 3344 let updatesoverview_plugins_ignore_detail = function (slug, name, id, obj, ignore_ver) {
3109 3345 const row = jQuery(obj).closest("tr");
3110 3346 const site_name = jQuery(row).attr("site_name");
3111 - let msg = __(
3347 + let msg = MainWP.I18n.t(
3112 3348 "Are you sure you want to ignore %1 plugin updates on %2? The updates will no longer be visible in your MainWP Dashboard.",
3113 3349 decodeURIComponent(name),
3114 3350 site_name ?? ''
3115 3351 );
@@ -3128,9 +3364,9 @@
3128 3364 let updatesoverview_plugins_unignore_detail_all = function () {
3129 3365 return updatesoverview_unignore_plugintheme_by_site_all('plugin');
3130 3366 };
3131 3367 let updatesoverview_themes_ignore_detail = function (slug, name, id, obj, ignore_ver) {
3132 - let msg = __("Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.", name);
3368 + let msg = MainWP.I18n.t("Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.", name);
3133 3369 mainwp_confirm(msg, function () {
3134 3370 return updatesoverview_ignore_plugintheme_by_site('theme', slug, name, id, obj, ignore_ver);
3135 3371 }, false);
3136 3372 return false;
@@ -3145,14 +3381,14 @@
3145 3381 const row = jQuery(obj).closest("tr");
3146 3382 const site_name = jQuery(row).attr("site_name");
3147 3383 let msg = '';
3148 3384 if (site_name === undefined) {
3149 - msg = __(
3385 + msg = MainWP.I18n.t(
3150 3386 "Are you sure you want to ignore the %1 plugin updates? The updates will no longer be visible in your MainWP Dashboard.",
3151 3387 decodeURIComponent(name)
3152 3388 );
3153 3389 } else {
3154 - msg = __(
3390 + msg = MainWP.I18n.t(
3155 3391 "Are you sure you want to ignore %1 plugin updates on %2 site? The updates will no longer be visible in your MainWP Dashboard.",
3156 3392 decodeURIComponent(name),
3157 3393 site_name
3158 3394 );
@@ -3196,9 +3432,9 @@
3196 3432 if (response.result) {
3197 3433 let tableElement = jQuery('#globally-ignored-plugins-list');
3198 3434 tableElement.find('tr').remove();
3199 3435 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3200 - tableElement.append('<tr><td colspan="999">' + __('No ignored plugins.') + '</td></tr>');
3436 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored plugins.') + '</td></tr>');
3201 3437 }
3202 3438 }, 'json');
3203 3439 return false;
3204 3440 };
@@ -3217,9 +3453,9 @@
3217 3453 let parent = ignoreElement.parent();
3218 3454 ignoreElement.remove();
3219 3455 if (parent.children('tr').length == 0) {
3220 3456 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3221 - parent.append('<tr><td colspan="999">' + __('No ignored plugins.') + '</td></tr>');
3457 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored plugins.') + '</td></tr>');
3222 3458 }
3223 3459 }
3224 3460 }, 'json');
3225 3461 return false;
@@ -3225,9 +3461,9 @@
3225 3461 return false;
3226 3462 };
3227 3463
3228 3464 let updatesoverview_themes_ignore_all = function (slug, name, obj, ver) {
3229 - let msg = __('Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.', name);
3465 + let msg = MainWP.I18n.t('Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.', name);
3230 3466 mainwp_confirm(msg, function () {
3231 3467
3232 3468 let data = mainwp_secure_data({
3233 3469 action: 'mainwp_ignorepluginsthemes', // ignore global or this version global.
@@ -3267,9 +3503,9 @@
3267 3503 if (response.result) {
3268 3504 let tableElement = jQuery('#globally-ignored-themes-list');
3269 3505 tableElement.find('tr').remove();
3270 3506 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3271 - tableElement.append('<tr><td colspan="999">' + __('No ignored themes.') + '</td></tr>');
3507 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored themes.') + '</td></tr>');
3272 3508 }
3273 3509 }, 'json');
3274 3510
3275 3511 return false;
@@ -3289,9 +3525,9 @@
3289 3525 let parent = ignoreElement.parent();
3290 3526 ignoreElement.remove();
3291 3527 if (parent.children('tr').length == 0) {
3292 3528 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3293 - parent.append('<tr><td colspan="999">' + __('No ignored themes.') + '</td></tr>');
3529 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored themes.') + '</td></tr>');
3294 3530 }
3295 3531 }
3296 3532 }, 'json');
3297 3533 return false;
@@ -3371,9 +3607,9 @@
3371 3607 let parent = siteElement.parent();
3372 3608 mainwp_responsive_fix_remove_child_row(siteElement);
3373 3609 siteElement.remove();
3374 3610 if (parent.children('tr').length == 0) {
3375 - parent.append('<tr><td colspan="999">' + __('No ignored WordPress') + '</td></tr>');
3611 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress') + '</td></tr>');
3376 3612 jQuery('#mainwp-unignore-cores-detail-all').addClass('disabled');
3377 3613 }
3378 3614 }
3379 3615 }
@@ -3392,9 +3628,9 @@
3392 3628 return function (response) {
3393 3629 if (response.result && 'success' == response.result) {
3394 3630 let parent = jQuery('#ignored-cores-list');
3395 3631 parent.find('tr').remove();
3396 - parent.append('<tr><td colspan="999">' + __('No ignored WordPress') + '</td></tr>');
3632 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress') + '</td></tr>');
3397 3633 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3398 3634 }
3399 3635 }
3400 3636 }, 'json');
@@ -3413,9 +3649,9 @@
3413 3649 let parent = ignoreElement.parent();
3414 3650 ignoreElement.remove();
3415 3651 if (parent.children('tr').length == 0) {
3416 3652 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3417 - parent.append('<tr><td colspan="999">' + __('No ignored WordPress.') + '</td></tr>');
3653 + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress.') + '</td></tr>');
3418 3654 }
3419 3655 }
3420 3656 }, 'json');
3421 3657 return false;
@@ -3433,9 +3669,9 @@
3433 3669 if (response.result) {
3434 3670 let tableElement = jQuery('#globally-ignored-cores-list');
3435 3671 tableElement.find('tr').remove();
3436 3672 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3437 - tableElement.append('<tr><td colspan="999">' + __('No ignored WordPress.') + '</td></tr>');
3673 + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress.') + '</td></tr>');
3438 3674 }
3439 3675 }, 'json');
3440 3676 return false;
3441 3677 };
@@ -3440,9 +3676,9 @@
3440 3676 return false;
3441 3677 };
3442 3678
3443 3679 let updatesoverview_upgrade_translation = function (id, slug) {
3444 - let msg = __('Are you sure you want to update the translation on the selected site?');
3680 + let msg = MainWP.I18n.t('Are you sure you want to update the translation on the selected site?');
3445 3681 mainwp_confirm(msg, function () {
3446 3682 return updatesoverview_translations_upgrade_int(slug, id);
3447 3683 }, false, 1);
3448 3684 };
@@ -3447,9 +3683,9 @@
3447 3683 }, false, 1);
3448 3684 };
3449 3685
3450 3686 let updatesoverview_translations_upgrade = function (slug, websiteid) {
3451 - let msg = __('Are you sure you want to update the translation on the selected site?');
3687 + let msg = MainWP.I18n.t('Are you sure you want to update the translation on the selected site?');
3452 3688 mainwp_confirm(msg, function () {
3453 3689 return updatesoverview_translations_upgrade_int(slug, websiteid);
3454 3690 }, false, 1);
3455 3691 };
@@ -3454,9 +3690,9 @@
3454 3690 }, false, 1);
3455 3691 };
3456 3692
3457 3693 let updatesoverview_plugins_upgrade = function (slug, websiteid) {
3458 - let msg = __('Are you sure you want to update the plugin on the selected site?');
3694 + let msg = MainWP.I18n.t('Are you sure you want to update the plugin on the selected site?');
3459 3695 mainwp_confirm(msg, function () {
3460 3696 return updatesoverview_plugins_upgrade_int(slug, websiteid);
3461 3697 }, false, 1);
3462 3698 };
@@ -3461,9 +3697,9 @@
3461 3697 }, false, 1);
3462 3698 };
3463 3699
3464 3700 let updatesoverview_themes_upgrade = function (slug, websiteid) {
3465 - let msg = __('Are you sure you want to update the theme on the selected site?');
3701 + let msg = MainWP.I18n.t('Are you sure you want to update the theme on the selected site?');
3466 3702 mainwp_confirm(msg, function () {
3467 3703 return updatesoverview_themes_upgrade_int(slug, websiteid);
3468 3704 }, false, 1);
3469 3705 };
@@ -3482,11 +3718,11 @@
3482 3718 return updatesoverview_upgrade_plugintheme('translation', id, slug, groupId);
3483 3719 };
3484 3720
3485 3721 let updatesoverview_upgrade_translation_all = function (id, updatesSelected) {
3486 - let msg = __('Are you sure you want to update all translations?');
3722 + let msg = MainWP.I18n.t('Are you sure you want to update all translations?');
3487 3723 if (updatesSelected !== undefined && updatesSelected) {
3488 - msg = __('Are you sure you want to update selected translations?');
3724 + msg = MainWP.I18n.t('Are you sure you want to update selected translations?');
3489 3725 }
3490 3726 mainwp_confirm(msg, function () {
3491 3727 return updatesoverview_upgrade_plugintheme_all('translation', id, false, updatesSelected);
3492 3728 }, false, 2);
@@ -3493,11 +3729,11 @@
3493 3729 return false;
3494 3730 };
3495 3731
3496 3732 let updatesoverview_group_upgrade_translation_all = function (id, groupId, updatesSelected) {
3497 - let msg = __('Are you sure you want to update all translations?');
3733 + let msg = MainWP.I18n.t('Are you sure you want to update all translations?');
3498 3734 if (updatesSelected !== undefined && updatesSelected) {
3499 - msg = __('Are you sure you want to update selected translations?');
3735 + msg = MainWP.I18n.t('Are you sure you want to update selected translations?');
3500 3736 }
3501 3737 mainwp_confirm(msg, function () {
3502 3738 return updatesoverview_group_upgrade_plugintheme_all('translation', id, false, groupId, updatesSelected);
3503 3739 }, false, 2);
@@ -3504,9 +3740,9 @@
3504 3740 return false;
3505 3741 };
3506 3742
3507 3743 let updatesoverview_upgrade_plugin = function (id, slug) {
3508 - let msg = __('Are you sure you want to update the plugin on the selected site?');
3744 + let msg = MainWP.I18n.t('Are you sure you want to update the plugin on the selected site?');
3509 3745 mainwp_confirm(msg, function () {
3510 3746 return updatesoverview_upgrade_plugintheme('plugin', id, slug);
3511 3747 }, false, 1);
3512 3748 };
@@ -3511,11 +3747,11 @@
3511 3747 }, false, 1);
3512 3748 };
3513 3749
3514 3750 let updatesoverview_upgrade_plugin_all = function (id, updatesSelected) {
3515 - let msg = __('Are you sure you want to update all plugins?');
3751 + let msg = MainWP.I18n.t('Are you sure you want to update all plugins?');
3516 3752 if (updatesSelected !== undefined && updatesSelected) {
3517 - msg = __('Are you sure you want to update selected plugins?');
3753 + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?');
3518 3754 }
3519 3755 mainwp_confirm(msg, function () {
3520 3756 return updatesoverview_upgrade_plugintheme_all('plugin', id, false, updatesSelected);
3521 3757 }, false, 2);
@@ -3522,11 +3758,11 @@
3522 3758 return false;
3523 3759 };
3524 3760
3525 3761 let updatesoverview_group_upgrade_plugin_all = function (id, groupId, updatesSelected) {
3526 - let msg = __('Are you sure you want to update all plugins?');
3762 + let msg = MainWP.I18n.t('Are you sure you want to update all plugins?');
3527 3763 if (updatesSelected !== undefined && updatesSelected) {
3528 - msg = __('Are you sure you want to update selected plugins?');
3764 + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?');
3529 3765 }
3530 3766 mainwp_confirm(msg, function () {
3531 3767 return updatesoverview_group_upgrade_plugintheme_all('plugin', id, false, groupId, updatesSelected);
3532 3768 }, false, 2);
@@ -3533,17 +3769,17 @@
3533 3769 return false;
3534 3770 };
3535 3771
3536 3772 let updatesoverview_upgrade_theme = function (id, slug) {
3537 - let msg = __('Are you sure you want to update the theme on the selected site?');
3773 + let msg = MainWP.I18n.t('Are you sure you want to update the theme on the selected site?');
3538 3774 mainwp_confirm(msg, function () {
3539 3775 return updatesoverview_upgrade_plugintheme('theme', id, slug);
3540 3776 }, false, 1);
3541 3777 };
3542 3778 let updatesoverview_upgrade_theme_all = function (id, updatesSelected) {
3543 - let msg = __('Are you sure you want to update all themes?');
3779 + let msg = MainWP.I18n.t('Are you sure you want to update all themes?');
3544 3780 if (updatesSelected !== undefined && updatesSelected) {
3545 - msg = __('Are you sure you want to update selected themes?');
3781 + msg = MainWP.I18n.t('Are you sure you want to update selected themes?');
3546 3782 }
3547 3783 mainwp_confirm(msg, function () {
3548 3784 return updatesoverview_upgrade_plugintheme_all('theme', id, false, updatesSelected);
3549 3785 }, false, 2);
@@ -3550,11 +3786,11 @@
3550 3786 return false;
3551 3787 };
3552 3788
3553 3789 let updatesoverview_group_upgrade_theme_all = function (id, groupId, updatesSelected) {
3554 - let msg = __('Are you sure you want to update all themes?');
3790 + let msg = MainWP.I18n.t('Are you sure you want to update all themes?');
3555 3791 if (updatesSelected !== undefined && updatesSelected) {
3556 - msg = __('Are you sure you want to update selected themes?');
3792 + msg = MainWP.I18n.t('Are you sure you want to update selected themes?');
3557 3793 }
3558 3794 mainwp_confirm(msg, function () {
3559 3795 return updatesoverview_group_upgrade_plugintheme_all('theme', id, false, groupId, updatesSelected);
3560 3796 }, false, 2);
@@ -3668,9 +3904,9 @@
3668 3904 }
3669 3905
3670 3906 const icon_success =
3671 3907 '<span data-inverted="" data-position="left center" data-tooltip="' +
3672 - __('Update successful.', 'mainwp') +
3908 + MainWP.I18n.t('Update successful.', 'mainwp') +
3673 3909 '"><i class="green check icon"></i></span>';
3674 3910
3675 3911 const handleFinalIcon = function (regression_icon_final) {
3676 3912 const html_final = icon_success + regression_icon_final;
@@ -3694,9 +3930,9 @@
3694 3930 let newList = [];
3695 3931
3696 3932 // Show icon waiting
3697 3933 const regression_waiting_icon = render_html_regression_waiting_icon();
3698 - let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + __('Updating. Please wait...');
3934 + let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + MainWP.I18n.t('Updating. Please wait...');
3699 3935 if (regression_waiting_icon && "" !== regression_waiting_icon) {
3700 3936 waiting_icon += regression_waiting_icon;
3701 3937 }
3702 3938
@@ -3748,9 +3984,9 @@
3748 3984 parent.find('td:last-child').html(extErr);
3749 3985 } else {
3750 3986 let res = response.result;
3751 3987 let res_error = response.result_error;
3752 - const icon_success = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful.', 'mainwp') + '"><i class="green check icon"></i></span>';
3988 + const icon_success = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful.', 'mainwp') + '"><i class="green check icon"></i></span>';
3753 3989 if (mainwp_get_result_entry(res, item)) {
3754 3990 parent.find('td:last-child').html(icon_success);
3755 3991 lastResult = res;
3756 3992 lastSuccessParent = parent;
@@ -3792,54 +4028,100 @@
3792 4028 let updateCount = list.length;
3793 4029 if (updateCount == 0)
3794 4030 return;
3795 4031
3796 - let updateWhat = what == 'theme' ? __('themes') : __('translations');
3797 - updateWhat = (what == 'plugin') ? __('plugins') : updateWhat;
4032 + let updateWhat = what == 'theme' ? MainWP.I18n.t('themes') : MainWP.I18n.t('translations');
4033 + updateWhat = (what == 'plugin') ? MainWP.I18n.t('plugins') : updateWhat;
3798 4034
3799 4035 mainwpPopup('#mainwp-sync-sites-modal').clearList();
3800 4036 mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', pId) + ' ' + updatesmanage_link_to_site(decodeURIComponent(pSiteName), pId) + ' (' + updateCount + ' ' + updateWhat + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + pId + '">' + '<i class="clock outline icon"></i> ' + '</span>');
3801 4037
3802 4038 let initData = {
3803 - title: __('Updating all'),
4039 + title: MainWP.I18n.t('Updating all'),
3804 4040 progressMax: 1
3805 4041 };
3806 4042 updatesoverview_update_popup_init(initData);
3807 4043
3808 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 +
3809 4072 const regression_waiting_icon = render_html_regression_waiting_icon();
3810 - let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>');
3811 - if (regression_waiting_icon && "" !== regression_waiting_icon) {
3812 - 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 + });
3813 4080 }
3814 4081
3815 - updatesoverview_plugins_upgrade_all_update_site_status(pId, waiting_icon);
4082 + updatesoverview_plugins_upgrade_all_update_site_status(pId,''); // clear status first.
3816 4083
4084 + statuses.forEach((status) => {
4085 + const { item, ...options } = status;
4086 + upgradeall_update_site_popup_multi_status(pId, item, options);
4087 + });
4088 +
3817 4089 let queue = list.slice();
3818 - let lastResult = null;
4090 + let countError = 0;
4091 + let lastResult = '';
3819 4092
3820 - let processNext = function () {
4093 + let processLoop = function (response) {
3821 4094 if (queue.length === 0) {
3822 4095 mainwpPopup('#mainwp-sync-sites-modal').setProgressSite(1);
3823 - let success_icon = '<i class="green check icon"></i>';
3824 4096 if (
3825 4097 lastResult &&
3826 4098 typeof mainwp_html_regression !== "undefined" &&
3827 4099 mainwp_html_regression.use_after_updates === "1"
3828 4100 ) {
3829 - let regression_icon_loading = render_html_regression_icon(lastResult, function (regression_final_icon) {
3830 - const final_icon = `${success_icon} ${regression_final_icon}`;
3831 - 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 + });
3832 4105 });
3833 - updatesoverview_plugins_upgrade_all_update_site_status(pId, `${success_icon} ${regression_icon_loading}`);
3834 - } else {
3835 - 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 + });
3836 4109 }
3837 - 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 ) {
3838 4115 setTimeout(function () {
3839 - mainwpPopup('#mainwp-sync-sites-modal').close();
3840 - 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 + }
3841 4121 }, 3000);
4122 + } else {
4123 + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed'));
3842 4124 }
3843 4125 return;
3844 4126 }
3845 4127
@@ -3849,37 +4131,96 @@
3849 4131 websiteId: pId,
3850 4132 type: what,
3851 4133 slug: item
3852 4134 });
3853 -
4135 + let decoded = mainwp_decode_slug(item, true);
3854 4136 jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex.
3855 4137 let res_error = response.result_error;
3856 - let _icon = '<i class="red times icon"></i>';
3857 4138 let hasError = false;
3858 -
3859 4139 if (response.error) {
3860 - let extErr = getErrorMessageInfo(response.error, 'ui');
3861 - 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 + });
3862 4147 hasError = true;
3863 4148 } else if (res_error && mainwp_get_result_entry(res_error, item)) {
4149 + let new_status = decoded;
3864 4150 let _error = mainwp_get_result_entry(res_error, item);
3865 4151 let roll_error = mainwp_updates_get_rollback_msg(_error);
3866 4152 if (roll_error) {
3867 - _error = roll_error;
3868 - _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 + });
3869 4171 }
3870 - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"]').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
3871 - mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"] .mainwp-html-popup', _error);
3872 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 + });
3873 4192 }
3874 4193
3875 - if (!hasError) {
3876 - lastResult = response.result;
4194 + if( !hasError ){
4195 + lastResult = response?.result;
4196 + } else {
4197 + ++countError;
3877 4198 }
3878 - processNext();
3879 - }, '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 + });
3880 4220 };
3881 - processNext();
4221 +
4222 + processLoop();
3882 4223 }
3883 4224
3884 4225 // for semantic ui checkboxes
3885 4226 jQuery(function () {
@@ -4036,13 +4377,9 @@
4036 4377 icon_html = '<i class="fire alternate red icon updates-regression-score-red-flag"></i>'; // Major differences.
4037 4378 }
4038 4379
4039 4380 if (icon_html !== "" && Number.isInteger(website_id)) {
4040 - let msg = 'Change score changed. Click to review changes.';
4041 - // eslint-disable-next-line no-constant-condition
4042 - if (typeof mainwpTranslations) {
4043 - msg = mainwpTranslations?.Change_score_changed_Click_to_review_changes || msg;
4044 - }
4381 + const msg = MainWP.I18n.t('Change score changed. Click to review changes.');
4045 4382 icon_html = `<a href="admin.php?page=ManageSitesHTMLRegression&id=${website_id}" target="_blank" data-tooltip="${msg}" data-inverted="" data-position="left center">${icon_html}</a>`;
4046 4383 }
4047 4384
4048 4385 return icon_html;
@@ -4052,9 +4389,9 @@
4052 4389 const render_html_regression_icon = function (result, onDone) {
4053 4390 if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
4054 4391 return '';
4055 4392 }
4056 - const loading_icon = `<span data-inverted="" data-position="left center" data-tooltip="${__('Regression scan in progress...', 'mainwp')}"><i class="notched circle loading icon"></i></span>`;
4393 + const loading_icon = `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Regression scan in progress...', 'mainwp')}"><i class="notched circle loading icon"></i></span>`;
4057 4394 setTimeout(() => {
4058 4395 let _icon = '';
4059 4396 if (
4060 4397 result?.html_regression_max_scope &&
@@ -4083,11 +4420,11 @@
4083 4420 if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
4084 4421 return '';
4085 4422 }
4086 4423
4087 - return `<span data-inverted="" data-position="left center" data-tooltip="${__('Regression Testing scan will begin after the update is completed.', 'mainwp')}"><i class="hourglass half icon"></i></span>`;
4424 + return `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Regression Testing scan will begin after the update is completed.', 'mainwp')}"><i class="hourglass half icon"></i></span>`;
4088 4425 }
4089 4426
4090 4427 // Render Tooltip Loading Icon.
4091 4428 const render_tooltip_loading_icon = function (icon_html) {
4092 - return `<span data-inverted="" data-position="left center" data-tooltip="${__('Update in progress…', 'mainwp')}">${icon_html}</span>`
4429 + return `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Update in progress…', 'mainwp')}">${icon_html}</span>`
4093 4430 }