PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.1
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 +403 -157 6.1.5 → 6.2.1 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 };
@@ -167,9 +183,9 @@
167 183 let updatesoverview_update_popup_init = function (data) {
168 184 data = data || {};
169 185 let settings = {
170 186 allowMultiple: true,
171 - statusText: __('updated'),
187 + statusText: MainWP.I18n.t('updated'),
172 188 callback: function () {
173 189 mainwpVars.bulkTaskRunning = false;
174 190 mainwp_forceReload();
175 191 }
@@ -222,9 +238,9 @@
222 238 }
223 239 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate) {
224 240 return function () {
225 241 let initData = {
226 - title: __('Updating All'),
242 + title: MainWP.I18n.t('Updating All'),
227 243 progressMax: pSitesCount,
228 244 };
229 245
230 246 updatesoverview_update_popup_init(initData);
@@ -246,9 +262,9 @@
246 262 if (value) { // to fix
247 263 sitesList.push(decodeURIComponent(value));
248 264 }
249 265 });
250 - 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 />'));
251 267 mainwp_confirm(confirmMsg, _callback, false, 2);
252 268 }
253 269 return;
254 270 }
@@ -437,9 +453,9 @@
437 453 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesTranslationSlugs) {
438 454 return function () {
439 455
440 456 let initData = {
441 - title: __('Updating all...'),
457 + title: MainWP.I18n.t('Updating all...'),
442 458 progressMax: pSitesCount
443 459 };
444 460 updatesoverview_update_popup_init(initData);
445 461
@@ -463,9 +479,9 @@
463 479 if (value) { // to fix
464 480 sitesList.push(decodeURIComponent(value));
465 481 }
466 482 });
467 - 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(', '));
468 484 mainwp_confirm(confirmMsg, _callback, false, 2);
469 485 }
470 486 return false;
471 487 }
@@ -534,9 +550,9 @@
534 550
535 551 // init and show popup
536 552
537 553 let initData = {
538 - title: __('Updating %1', decodeURIComponent(translationName)),
554 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(translationName)),
539 555 progressMax: pSitesCount
540 556 };
541 557 updatesoverview_update_popup_init(initData);
542 558 //Step 3: start updates
@@ -556,9 +572,9 @@
556 572 if (value) { // to fix
557 573 sitesList.push(decodeURIComponent(value));
558 574 }
559 575 });
560 - 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 />'));
561 577 mainwp_confirm(confirmMsg, _callback, false, 2);
562 578 }
563 579 return;
564 580 }
@@ -645,9 +661,9 @@
645 661 }
646 662
647 663 // Show icon waiting
648 664 const regression_waiting_icon = render_html_regression_waiting_icon();
649 - 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...'));
650 666 if (regression_waiting_icon && "" !== regression_waiting_icon) {
651 667 waiting_icon += regression_waiting_icon;
652 668 }
653 669
@@ -715,9 +731,9 @@
715 731 websiteHolder.attr('updated', 1);
716 732 websiteHolder.find('td:last-child').html(success_icon);
717 733 } else {
718 734 mainwpVars.errorCount++;
719 - _error = __('Update failed. Please try again.');
735 + _error = MainWP.I18n.t('Update failed. Please try again.');
720 736 if (!done && pBulkMode) {
721 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>');
722 738 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
723 739 }
@@ -758,11 +774,11 @@
758 774 if (!websiteHolder.exists()) {
759 775 websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]');
760 776 }
761 777
762 - result = __('FAILED');
778 + result = MainWP.I18n.t('FAILED');
763 779 if (!done && pBulkMode) {
764 - 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>');
765 781 updatesoverview_translations_upgrade_all_update_done();
766 782 done = true;
767 783 }
768 784
@@ -876,9 +892,9 @@
876 892 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) {
877 893 return function () {
878 894
879 895 let initData = {
880 - title: __('Updating all'),
896 + title: MainWP.I18n.t('Updating all'),
881 897 progressMax: pSitesCount
882 898 };
883 899 updatesoverview_update_popup_init(initData);
884 900
@@ -901,9 +917,9 @@
901 917 if (value) { // to fix
902 918 sitesList.push(decodeURIComponent(value));
903 919 }
904 920 });
905 - 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 />'));
906 922 mainwp_confirm(confirmMsg, _callback, false, 2);
907 923 }
908 924 return;
909 925 }
@@ -961,9 +977,9 @@
961 977
962 978 let _callback = function () {
963 979
964 980 for (let id of sitesToUpdate) {
965 - 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>');
966 982 }
967 983
968 984 let sitesCount = sitesToUpdate.length;
969 985
@@ -970,9 +986,9 @@
970 986 updatesoverviewContinueAfterBackup = function (pSitesCount, pSlug, pSitesToUpdate) {
971 987 return function () {
972 988
973 989 let initData = {
974 - title: __('Updating %1', decodeURIComponent(pluginName)),
990 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(pluginName)),
975 991 progressMax: pSitesCount
976 992 };
977 993 updatesoverview_update_popup_init(initData);
978 994
@@ -994,9 +1010,9 @@
994 1010 if (value) { // to fix
995 1011 sitesList.push(decodeURIComponent(value));
996 1012 }
997 1013 });
998 - 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 />'));
999 1015 mainwp_confirm(confirmMsg, _callback, false, 2);
1000 1016 }
1001 1017 return;
1002 1018 }
@@ -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-'));
@@ -1120,9 +1229,9 @@
1120 1229 }
1121 1230
1122 1231 let lastResult = pLastResult || null;
1123 1232 const regression_waiting_icon = render_html_regression_waiting_icon();
1124 - 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> ';
1125 1234 if (regression_waiting_icon && "" !== regression_waiting_icon) {
1126 1235 waiting_icon += regression_waiting_icon;
1127 1236 }
1128 1237
@@ -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,30 +1281,41 @@
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 - 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>';
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;
@@ -1370,9 +1506,9 @@
1370 1506 updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) {
1371 1507 return function () {
1372 1508
1373 1509 let initData = {
1374 - title: __('Updating all...'),
1510 + title: MainWP.I18n.t('Updating all...'),
1375 1511 progressMax: pSitesCount
1376 1512 };
1377 1513 updatesoverview_update_popup_init(initData);
1378 1514
@@ -1394,9 +1530,9 @@
1394 1530 if (value) { // to fix
1395 1531 sitesList.push(decodeURIComponent(value));
1396 1532 }
1397 1533 });
1398 - 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 />'));
1399 1535 mainwp_confirm(confirmMsg, _callback, false, 2);
1400 1536 }
1401 1537 return;
1402 1538 }
@@ -1431,9 +1567,9 @@
1431 1567 return foundChildren;
1432 1568 }
1433 1569
1434 1570 let updates_please_select_items_notice = function () {
1435 - let msg = __('Please, select items to update.');
1571 + let msg = MainWP.I18n.t('Please, select items to update.');
1436 1572 jQuery('#mainwp-modal-confirm-select .content-massage').html(msg);
1437 1573 jQuery('#mainwp-modal-confirm-select').modal('show');
1438 1574 return false;
1439 1575 }
@@ -1476,9 +1612,9 @@
1476 1612 return function () {
1477 1613 //Step 2: show form
1478 1614
1479 1615 let initData = {
1480 - title: __('Updating %1', decodeURIComponent(themeName)),
1616 + title: MainWP.I18n.t('Updating %1', decodeURIComponent(themeName)),
1481 1617 progressMax: pSitesCount
1482 1618 };
1483 1619 updatesoverview_update_popup_init(initData);
1484 1620
@@ -1500,9 +1636,9 @@
1500 1636 if (value) { // to fix
1501 1637 sitesList.push(decodeURIComponent(value));
1502 1638 }
1503 1639 });
1504 - 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 />'));
1505 1641 mainwp_confirm(confirmMsg, _callback, false, 2);
1506 1642 }
1507 1643 return;
1508 1644 }
@@ -1602,9 +1738,9 @@
1602 1738
1603 1739 let lastResultFinal = lastResult || null;
1604 1740 // Show icon waiting
1605 1741 const regression_waiting_icon = render_html_regression_waiting_icon();
1606 - 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...'));
1607 1743 if (regression_waiting_icon && "" !== regression_waiting_icon) {
1608 1744 waiting_icon += regression_waiting_icon;
1609 1745 }
1610 1746
@@ -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)) {
@@ -1654,9 +1791,9 @@
1654 1791 let res_error = response.result_error;
1655 1792 if (mainwp_get_result_entry(res, sid)) {
1656 1793 lastResultFinal = res;
1657 1794 let _success_icon = `<i class="green check icon"></i>`;
1658 - 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>`;
1659 1796 websiteHolder.attr('updated', 1);
1660 1797 websiteHolder.find('td:last-child').html(success_icon);
1661 1798 } else {
1662 1799 let _error = '';
@@ -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
@@ -1786,11 +1924,11 @@
1786 1924
1787 1925 const updatesoverview_global_prepare_data_upgrade_all = function (which, onPrepared, current_siteid) {
1788 1926
1789 1927 let initData = {
1790 - title: __('Updating All'),
1928 + title: MainWP.I18n.t('Updating All'),
1791 1929 initVisibleContentMsg: true,
1792 - contentMsg: __('Preparing update data, please wait...'),
1930 + contentMsg: MainWP.I18n.t('Preparing update data, please wait...'),
1793 1931 };
1794 1932 mainwpPopup('#mainwp-prepare-data-modal').init(initData);
1795 1933
1796 1934 let data = mainwp_secure_data({
@@ -2003,9 +2141,9 @@
2003 2141 return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames);
2004 2142 } // end _callback()
2005 2143 if (Object.keys(siteNames).length === 0) {
2006 2144 mainwpVars.bulkTaskRunning = false;
2007 - mainwpPopup('#mainwp-prepare-data-modal').getContentMsgEl().html('<div class="ui yellow message">' + __('There are no updates available to process. Please try again.') + '</div>');
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>');
2008 2146 } else {
2009 2147 updatesoverview_global_upgrade_all_start(which, siteNames, _callback);
2010 2148 }
2011 2149 };
@@ -2019,20 +2157,20 @@
2019 2157 sitesList.push(decodeURIComponent(value));
2020 2158 }
2021 2159 });
2022 2160
2023 - let whichUpdates = __('WordPress core files, plugins, themes and translations');
2161 + let whichUpdates = MainWP.I18n.t('WordPress core files, plugins, themes and translations');
2024 2162 if (which == 'wp') {
2025 - whichUpdates = __('WordPress core files');
2163 + whichUpdates = MainWP.I18n.t('WordPress core files');
2026 2164 } else if (which == 'plugin') {
2027 - whichUpdates = __('plugins');
2165 + whichUpdates = MainWP.I18n.t('plugins');
2028 2166 } else if (which == 'theme') {
2029 - whichUpdates = __('themes');
2167 + whichUpdates = MainWP.I18n.t('themes');
2030 2168 } else if (which == 'translation') {
2031 - whichUpdates = __('translations');
2169 + whichUpdates = MainWP.I18n.t('translations');
2032 2170 }
2033 2171
2034 - 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 />'));
2035 2173
2036 2174 mainwp_confirm(confirmMsg, _callback, false, 2);
2037 2175 }
2038 2176 }
@@ -2041,9 +2179,9 @@
2041 2179 return function () {
2042 2180 //Step 2: show form
2043 2181
2044 2182 let initData = {
2045 - title: __('Updating All'),
2183 + title: MainWP.I18n.t('Updating All'),
2046 2184 progressMax: pSitesCount,
2047 2185 };
2048 2186 updatesoverview_update_popup_init(initData);
2049 2187
@@ -2115,9 +2253,9 @@
2115 2253 console.log('Starting upgrade process for site ' + websiteId);
2116 2254
2117 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.
2118 2256 if (mainwpVars.websitesSuspended.includes(websiteId)) {
2119 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2257 + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
2120 2258 updatesoverview_upgrade_all_update_site_bold(websiteId, false, msgUI);
2121 2259 mainwpVars.errorCount++;
2122 2260 updatesoverview_upgrade_all_update_done();
2123 2261 return;
@@ -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
@@ -2222,9 +2362,9 @@
2222 2362 success: function (pWebsiteId, pSlug, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2223 2363 return function (response) { // NOSONAR - complex ok.
2224 2364 let slugParts = pSlug.split(',');
2225 2365 if (response?.error?.errorCode == 'SUSPENDED_SITE') {
2226 - let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow 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>';
2227 2367 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2228 2368 pPluginDone = true;
2229 2369 pUpgradeDone = true;
2230 2370 pTransDone = true;
@@ -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;
@@ -2249,9 +2390,9 @@
2249 2390 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
2250 2391 websiteHolder.attr('updated', 1);
2251 2392 isError = false;
2252 2393 } else {
2253 - result = __('Update failed!');
2394 + result = MainWP.I18n.t('Update failed!');
2254 2395 pErrorMessage = result;
2255 2396 }
2256 2397 }
2257 2398
@@ -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;
@@ -2376,9 +2518,9 @@
2376 2518 success: function (pWebsiteId, pThemeSlugToUpgrade, pSlug, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2377 2519 return function (response) { // NOSONAR - complex ok.
2378 2520 bulkErrorCode = response?.error?.errorCode ?? '';
2379 2521 if (bulkErrorCode == 'SUSPENDED_SITE') {
2380 - 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>';
2381 2523 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2382 2524
2383 2525 pThemeDone = true;
2384 2526 pUpgradeDone = true;
@@ -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;
@@ -2414,9 +2557,9 @@
2414 2557 pErrorMessage = mainwp_get_result_entry(res_error, sid);
2415 2558 let roll_error = mainwp_updates_get_rollback_msg(pErrorMessage);
2416 2559 mainwp_put_actions_errors_msg('updateall', pWebsiteId, roll_error ? 'roll' : 'default', roll_error || pErrorMessage);// save errors to show later.
2417 2560 } else {
2418 - result = __('Update failed!');
2561 + result = MainWP.I18n.t('Update failed!');
2419 2562 pErrorMessage = result;
2420 2563 }
2421 2564 }
2422 2565 }
@@ -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) {
@@ -2513,9 +2657,9 @@
2513 2657 success: function (WebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible.
2514 2658 return function (response) {
2515 2659 let bulkErrorCode = response?.error?.errorCode ?? '';
2516 2660 if (bulkErrorCode == 'SUSPENDED_SITE') {
2517 - 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>';
2518 2662 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2519 2663
2520 2664 pThemeDone = true;
2521 2665 pPluginDone = true;
@@ -2633,9 +2777,9 @@
2633 2777 success: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pSlug) { // NOSONAR - compatible.
2634 2778 return function (response) { // NOSONAR -complex.
2635 2779 let bulkErrorCode = response?.error?.errorCode ?? '';
2636 2780 if (bulkErrorCode == 'SUSPENDED_SITE') {
2637 - 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>';
2638 2782 updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI);
2639 2783
2640 2784 pThemeDone = true;
2641 2785 pPluginDone = true;
@@ -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;
@@ -2665,9 +2810,9 @@
2665 2810 if (mainwp_get_result_entry(res, sid)) {
2666 2811 mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result;
2667 2812 websiteHolder.attr('updated', 1);
2668 2813 } else {
2669 - result = __('Update failed!');
2814 + result = MainWP.I18n.t('Update failed!');
2670 2815 pErrorMessage = result;
2671 2816 }
2672 2817 }
2673 2818 }
@@ -2754,9 +2899,9 @@
2754 2899 });
2755 2900 } else {
2756 2901 if (bulkErrorCode === 'SUSPENDED_SITE') {
2757 2902 let _icon = '<i class="pause yellow icon"></i>';
2758 - let _error = __('Suspended site.');
2903 + let _error = MainWP.I18n.t('Suspended site.');
2759 2904 updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
2760 2905 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
2761 2906 } else if ((pErrorMessage != undefined) && (pErrorMessage != '')) {
2762 2907 mainwpVars.errorCount++;
@@ -2773,9 +2918,9 @@
2773 2918 _error = otherErrors
2774 2919 }
2775 2920
2776 2921 if (_error == '') {
2777 - _error = __('Update failed. Please try again.');
2922 + _error = MainWP.I18n.t('Update failed. Please try again.');
2778 2923 }
2779 2924
2780 2925 updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>');
2781 2926 mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error);
@@ -2837,9 +2982,9 @@
2837 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>');
2838 2983 jQuery.post(ajaxurl, data, function (response) {
2839 2984 if (response.result) {
2840 2985 parent.attr('dismissed', '-1');
2841 - 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>'));
2842 2987
2843 2988 } else {
2844 2989 parent.find('td:last-child').html(getErrorMessage(response.error));
2845 2990 }
@@ -2886,9 +3031,9 @@
2886 3031 siteElement.remove();
2887 3032
2888 3033 if (parent.children('tr').length == 0) {
2889 3034 jQuery('#mainwp-unignore-detail-all').addClass('disabled');
2890 - 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>');
2891 3036 }
2892 3037 }
2893 3038 }
2894 3039 }(what, slug, id), 'json');
@@ -2908,9 +3053,9 @@
2908 3053 return function (response) {
2909 3054 if (response.result) {
2910 3055 let tableElement = jQuery('#ignored-abandoned-' + pWhat + 's-list');
2911 3056 tableElement.find('tr').remove();
2912 - 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>');
2913 3058 jQuery('#mainwp-unignore-detail-all').addClass('disabled');
2914 3059 }
2915 3060 }
2916 3061 }(what), 'json');
@@ -2951,9 +3096,9 @@
2951 3096 if (response.result) {
2952 3097 let tableElement = jQuery('#ignored-globally-abandoned-plugins-list');
2953 3098 tableElement.find('tr').remove();
2954 3099 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
2955 - 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>');
2956 3101 }
2957 3102 }, 'json');
2958 3103
2959 3104 return false;
@@ -2975,9 +3120,9 @@
2975 3120 let parent = ignoreElement.parent();
2976 3121 ignoreElement.remove();
2977 3122 if (parent.children('tr').length == 0) {
2978 3123 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
2979 - 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>');
2980 3125 }
2981 3126 }
2982 3127 }, 'json');
2983 3128 return false;
@@ -3016,9 +3161,9 @@
3016 3161 if (response.result) {
3017 3162 let tableElement = jQuery('#globally-ignored-themes-list');
3018 3163 tableElement.find('tr').remove();
3019 3164 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
3020 - 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>');
3021 3166 }
3022 3167 }, 'json');
3023 3168
3024 3169 return false;
@@ -3038,9 +3183,9 @@
3038 3183 let parent = ignoreElement.parent();
3039 3184 ignoreElement.remove();
3040 3185 if (parent.children('tr').length == 0) {
3041 3186 jQuery('.mainwp-unignore-globally-all').addClass('disabled');
3042 - 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>');
3043 3188 }
3044 3189 }
3045 3190 }, 'json');
3046 3191
@@ -3078,9 +3223,9 @@
3078 3223 } else {
3079 3224 jQuery('#wp_http_response_code_' + id).removeClass('http-response-ok');
3080 3225 }
3081 3226 } else {
3082 - 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!'));
3083 3228 }
3084 3229 }, 'json');
3085 3230 return false;
3086 3231 };
@@ -3163,9 +3308,9 @@
3163 3308 let parent = siteElement.parent();
3164 3309 mainwp_responsive_fix_remove_child_row(siteElement);
3165 3310 siteElement.remove();
3166 3311 if (parent.children('tr').length == 0) {
3167 - 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>');
3168 3313 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3169 3314 }
3170 3315 }
3171 3316 }
@@ -3186,9 +3331,9 @@
3186 3331 return function (response) {
3187 3332 if (response.result) {
3188 3333 let tableElement = jQuery('#ignored-' + pWhat + 's-list');
3189 3334 tableElement.find('tr').remove();
3190 - 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>');
3191 3336 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3192 3337 }
3193 3338 }
3194 3339 }(what), 'json');
@@ -3198,9 +3343,9 @@
3198 3343 /**Plugins part**/
3199 3344 let updatesoverview_plugins_ignore_detail = function (slug, name, id, obj, ignore_ver) {
3200 3345 const row = jQuery(obj).closest("tr");
3201 3346 const site_name = jQuery(row).attr("site_name");
3202 - let msg = __(
3347 + let msg = MainWP.I18n.t(
3203 3348 "Are you sure you want to ignore %1 plugin updates on %2? The updates will no longer be visible in your MainWP Dashboard.",
3204 3349 decodeURIComponent(name),
3205 3350 site_name ?? ''
3206 3351 );
@@ -3219,9 +3364,9 @@
3219 3364 let updatesoverview_plugins_unignore_detail_all = function () {
3220 3365 return updatesoverview_unignore_plugintheme_by_site_all('plugin');
3221 3366 };
3222 3367 let updatesoverview_themes_ignore_detail = function (slug, name, id, obj, ignore_ver) {
3223 - 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);
3224 3369 mainwp_confirm(msg, function () {
3225 3370 return updatesoverview_ignore_plugintheme_by_site('theme', slug, name, id, obj, ignore_ver);
3226 3371 }, false);
3227 3372 return false;
@@ -3236,14 +3381,14 @@
3236 3381 const row = jQuery(obj).closest("tr");
3237 3382 const site_name = jQuery(row).attr("site_name");
3238 3383 let msg = '';
3239 3384 if (site_name === undefined) {
3240 - msg = __(
3385 + msg = MainWP.I18n.t(
3241 3386 "Are you sure you want to ignore the %1 plugin updates? The updates will no longer be visible in your MainWP Dashboard.",
3242 3387 decodeURIComponent(name)
3243 3388 );
3244 3389 } else {
3245 - msg = __(
3390 + msg = MainWP.I18n.t(
3246 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.",
3247 3392 decodeURIComponent(name),
3248 3393 site_name
3249 3394 );
@@ -3287,9 +3432,9 @@
3287 3432 if (response.result) {
3288 3433 let tableElement = jQuery('#globally-ignored-plugins-list');
3289 3434 tableElement.find('tr').remove();
3290 3435 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3291 - 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>');
3292 3437 }
3293 3438 }, 'json');
3294 3439 return false;
3295 3440 };
@@ -3308,9 +3453,9 @@
3308 3453 let parent = ignoreElement.parent();
3309 3454 ignoreElement.remove();
3310 3455 if (parent.children('tr').length == 0) {
3311 3456 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3312 - 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>');
3313 3458 }
3314 3459 }
3315 3460 }, 'json');
3316 3461 return false;
@@ -3316,9 +3461,9 @@
3316 3461 return false;
3317 3462 };
3318 3463
3319 3464 let updatesoverview_themes_ignore_all = function (slug, name, obj, ver) {
3320 - 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);
3321 3466 mainwp_confirm(msg, function () {
3322 3467
3323 3468 let data = mainwp_secure_data({
3324 3469 action: 'mainwp_ignorepluginsthemes', // ignore global or this version global.
@@ -3358,9 +3503,9 @@
3358 3503 if (response.result) {
3359 3504 let tableElement = jQuery('#globally-ignored-themes-list');
3360 3505 tableElement.find('tr').remove();
3361 3506 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3362 - 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>');
3363 3508 }
3364 3509 }, 'json');
3365 3510
3366 3511 return false;
@@ -3380,9 +3525,9 @@
3380 3525 let parent = ignoreElement.parent();
3381 3526 ignoreElement.remove();
3382 3527 if (parent.children('tr').length == 0) {
3383 3528 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3384 - 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>');
3385 3530 }
3386 3531 }
3387 3532 }, 'json');
3388 3533 return false;
@@ -3462,9 +3607,9 @@
3462 3607 let parent = siteElement.parent();
3463 3608 mainwp_responsive_fix_remove_child_row(siteElement);
3464 3609 siteElement.remove();
3465 3610 if (parent.children('tr').length == 0) {
3466 - 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>');
3467 3612 jQuery('#mainwp-unignore-cores-detail-all').addClass('disabled');
3468 3613 }
3469 3614 }
3470 3615 }
@@ -3483,9 +3628,9 @@
3483 3628 return function (response) {
3484 3629 if (response.result && 'success' == response.result) {
3485 3630 let parent = jQuery('#ignored-cores-list');
3486 3631 parent.find('tr').remove();
3487 - 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>');
3488 3633 jQuery('.mainwp-unignore-detail-all').addClass('disabled');
3489 3634 }
3490 3635 }
3491 3636 }, 'json');
@@ -3504,9 +3649,9 @@
3504 3649 let parent = ignoreElement.parent();
3505 3650 ignoreElement.remove();
3506 3651 if (parent.children('tr').length == 0) {
3507 3652 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3508 - 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>');
3509 3654 }
3510 3655 }
3511 3656 }, 'json');
3512 3657 return false;
@@ -3524,9 +3669,9 @@
3524 3669 if (response.result) {
3525 3670 let tableElement = jQuery('#globally-ignored-cores-list');
3526 3671 tableElement.find('tr').remove();
3527 3672 jQuery('#mainwp-unignore-globally-all').addClass('disabled');
3528 - 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>');
3529 3674 }
3530 3675 }, 'json');
3531 3676 return false;
3532 3677 };
@@ -3531,9 +3676,9 @@
3531 3676 return false;
3532 3677 };
3533 3678
3534 3679 let updatesoverview_upgrade_translation = function (id, slug) {
3535 - 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?');
3536 3681 mainwp_confirm(msg, function () {
3537 3682 return updatesoverview_translations_upgrade_int(slug, id);
3538 3683 }, false, 1);
3539 3684 };
@@ -3538,9 +3683,9 @@
3538 3683 }, false, 1);
3539 3684 };
3540 3685
3541 3686 let updatesoverview_translations_upgrade = function (slug, websiteid) {
3542 - 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?');
3543 3688 mainwp_confirm(msg, function () {
3544 3689 return updatesoverview_translations_upgrade_int(slug, websiteid);
3545 3690 }, false, 1);
3546 3691 };
@@ -3545,9 +3690,9 @@
3545 3690 }, false, 1);
3546 3691 };
3547 3692
3548 3693 let updatesoverview_plugins_upgrade = function (slug, websiteid) {
3549 - 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?');
3550 3695 mainwp_confirm(msg, function () {
3551 3696 return updatesoverview_plugins_upgrade_int(slug, websiteid);
3552 3697 }, false, 1);
3553 3698 };
@@ -3552,9 +3697,9 @@
3552 3697 }, false, 1);
3553 3698 };
3554 3699
3555 3700 let updatesoverview_themes_upgrade = function (slug, websiteid) {
3556 - 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?');
3557 3702 mainwp_confirm(msg, function () {
3558 3703 return updatesoverview_themes_upgrade_int(slug, websiteid);
3559 3704 }, false, 1);
3560 3705 };
@@ -3573,11 +3718,11 @@
3573 3718 return updatesoverview_upgrade_plugintheme('translation', id, slug, groupId);
3574 3719 };
3575 3720
3576 3721 let updatesoverview_upgrade_translation_all = function (id, updatesSelected) {
3577 - 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?');
3578 3723 if (updatesSelected !== undefined && updatesSelected) {
3579 - msg = __('Are you sure you want to update selected translations?');
3724 + msg = MainWP.I18n.t('Are you sure you want to update selected translations?');
3580 3725 }
3581 3726 mainwp_confirm(msg, function () {
3582 3727 return updatesoverview_upgrade_plugintheme_all('translation', id, false, updatesSelected);
3583 3728 }, false, 2);
@@ -3584,11 +3729,11 @@
3584 3729 return false;
3585 3730 };
3586 3731
3587 3732 let updatesoverview_group_upgrade_translation_all = function (id, groupId, updatesSelected) {
3588 - 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?');
3589 3734 if (updatesSelected !== undefined && updatesSelected) {
3590 - msg = __('Are you sure you want to update selected translations?');
3735 + msg = MainWP.I18n.t('Are you sure you want to update selected translations?');
3591 3736 }
3592 3737 mainwp_confirm(msg, function () {
3593 3738 return updatesoverview_group_upgrade_plugintheme_all('translation', id, false, groupId, updatesSelected);
3594 3739 }, false, 2);
@@ -3595,9 +3740,9 @@
3595 3740 return false;
3596 3741 };
3597 3742
3598 3743 let updatesoverview_upgrade_plugin = function (id, slug) {
3599 - 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?');
3600 3745 mainwp_confirm(msg, function () {
3601 3746 return updatesoverview_upgrade_plugintheme('plugin', id, slug);
3602 3747 }, false, 1);
3603 3748 };
@@ -3602,11 +3747,11 @@
3602 3747 }, false, 1);
3603 3748 };
3604 3749
3605 3750 let updatesoverview_upgrade_plugin_all = function (id, updatesSelected) {
3606 - 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?');
3607 3752 if (updatesSelected !== undefined && updatesSelected) {
3608 - msg = __('Are you sure you want to update selected plugins?');
3753 + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?');
3609 3754 }
3610 3755 mainwp_confirm(msg, function () {
3611 3756 return updatesoverview_upgrade_plugintheme_all('plugin', id, false, updatesSelected);
3612 3757 }, false, 2);
@@ -3613,11 +3758,11 @@
3613 3758 return false;
3614 3759 };
3615 3760
3616 3761 let updatesoverview_group_upgrade_plugin_all = function (id, groupId, updatesSelected) {
3617 - 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?');
3618 3763 if (updatesSelected !== undefined && updatesSelected) {
3619 - msg = __('Are you sure you want to update selected plugins?');
3764 + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?');
3620 3765 }
3621 3766 mainwp_confirm(msg, function () {
3622 3767 return updatesoverview_group_upgrade_plugintheme_all('plugin', id, false, groupId, updatesSelected);
3623 3768 }, false, 2);
@@ -3624,17 +3769,17 @@
3624 3769 return false;
3625 3770 };
3626 3771
3627 3772 let updatesoverview_upgrade_theme = function (id, slug) {
3628 - 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?');
3629 3774 mainwp_confirm(msg, function () {
3630 3775 return updatesoverview_upgrade_plugintheme('theme', id, slug);
3631 3776 }, false, 1);
3632 3777 };
3633 3778 let updatesoverview_upgrade_theme_all = function (id, updatesSelected) {
3634 - 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?');
3635 3780 if (updatesSelected !== undefined && updatesSelected) {
3636 - msg = __('Are you sure you want to update selected themes?');
3781 + msg = MainWP.I18n.t('Are you sure you want to update selected themes?');
3637 3782 }
3638 3783 mainwp_confirm(msg, function () {
3639 3784 return updatesoverview_upgrade_plugintheme_all('theme', id, false, updatesSelected);
3640 3785 }, false, 2);
@@ -3641,11 +3786,11 @@
3641 3786 return false;
3642 3787 };
3643 3788
3644 3789 let updatesoverview_group_upgrade_theme_all = function (id, groupId, updatesSelected) {
3645 - 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?');
3646 3791 if (updatesSelected !== undefined && updatesSelected) {
3647 - msg = __('Are you sure you want to update selected themes?');
3792 + msg = MainWP.I18n.t('Are you sure you want to update selected themes?');
3648 3793 }
3649 3794 mainwp_confirm(msg, function () {
3650 3795 return updatesoverview_group_upgrade_plugintheme_all('theme', id, false, groupId, updatesSelected);
3651 3796 }, false, 2);
@@ -3759,9 +3904,9 @@
3759 3904 }
3760 3905
3761 3906 const icon_success =
3762 3907 '<span data-inverted="" data-position="left center" data-tooltip="' +
3763 - __('Update successful.', 'mainwp') +
3908 + MainWP.I18n.t('Update successful.', 'mainwp') +
3764 3909 '"><i class="green check icon"></i></span>';
3765 3910
3766 3911 const handleFinalIcon = function (regression_icon_final) {
3767 3912 const html_final = icon_success + regression_icon_final;
@@ -3785,9 +3930,9 @@
3785 3930 let newList = [];
3786 3931
3787 3932 // Show icon waiting
3788 3933 const regression_waiting_icon = render_html_regression_waiting_icon();
3789 - 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...');
3790 3935 if (regression_waiting_icon && "" !== regression_waiting_icon) {
3791 3936 waiting_icon += regression_waiting_icon;
3792 3937 }
3793 3938
@@ -3839,9 +3984,9 @@
3839 3984 parent.find('td:last-child').html(extErr);
3840 3985 } else {
3841 3986 let res = response.result;
3842 3987 let res_error = response.result_error;
3843 - 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>';
3844 3989 if (mainwp_get_result_entry(res, item)) {
3845 3990 parent.find('td:last-child').html(icon_success);
3846 3991 lastResult = res;
3847 3992 lastSuccessParent = parent;
@@ -3883,54 +4028,100 @@
3883 4028 let updateCount = list.length;
3884 4029 if (updateCount == 0)
3885 4030 return;
3886 4031
3887 - let updateWhat = what == 'theme' ? __('themes') : __('translations');
3888 - 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;
3889 4034
3890 4035 mainwpPopup('#mainwp-sync-sites-modal').clearList();
3891 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>');
3892 4037
3893 4038 let initData = {
3894 - title: __('Updating all'),
4039 + title: MainWP.I18n.t('Updating all'),
3895 4040 progressMax: 1
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 () {
@@ -4127,13 +4377,9 @@
4127 4377 icon_html = '<i class="fire alternate red icon updates-regression-score-red-flag"></i>'; // Major differences.
4128 4378 }
4129 4379
4130 4380 if (icon_html !== "" && Number.isInteger(website_id)) {
4131 - let msg = 'Change score changed. Click to review changes.';
4132 - // eslint-disable-next-line no-constant-condition
4133 - if (typeof mainwpTranslations) {
4134 - msg = mainwpTranslations?.Change_score_changed_Click_to_review_changes || msg;
4135 - }
4381 + const msg = MainWP.I18n.t('Change score changed. Click to review changes.');
4136 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>`;
4137 4383 }
4138 4384
4139 4385 return icon_html;
@@ -4143,9 +4389,9 @@
4143 4389 const render_html_regression_icon = function (result, onDone) {
4144 4390 if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
4145 4391 return '';
4146 4392 }
4147 - 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>`;
4148 4394 setTimeout(() => {
4149 4395 let _icon = '';
4150 4396 if (
4151 4397 result?.html_regression_max_scope &&
@@ -4174,11 +4420,11 @@
4174 4420 if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") {
4175 4421 return '';
4176 4422 }
4177 4423
4178 - 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>`;
4179 4425 }
4180 4426
4181 4427 // Render Tooltip Loading Icon.
4182 4428 const render_tooltip_loading_icon = function (icon_html) {
4183 - 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>`
4184 4430 }