PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | assets/js/mainwp.js +738 -468 6.0.11 → 6.2.2 View file →
@@ -8,20 +8,20 @@
8 8 if (jQuery('.mainwp-ui-page').length) {
9 9 jQuery('.mainwp-popup-tooltip').popup()
10 10 }
11 11
12 - jQuery(document).on('click', '#mainwp-help-menu-item, #mainwp-help-menu-item-mobile', function () {
13 - jQuery('#mainwp-help-modal').modal({
14 - inverted: true,
15 - blurring: false,
16 - closable: false,
17 - onShow: function() {
18 - jQuery('#mainwp-help-modal').parent('.ui.dimmer').removeClass('dimmer');
19 - jQuery('#mainwp-help-modal').css({
20 - 'top':(jQuery(globalThis).height() - jQuery('#mainwp-help-modal').outerHeight()) / 2 + 'px',
21 - 'left':(jQuery(globalThis).width() - jQuery('#mainwp-help-modal').outerWidth()) / 2 + 'px'
22 - });
23 - },
12 + jQuery(document).on('click', '#mainwp-help-menu-item, #mainwp-help-menu-item-mobile', function () {
13 + jQuery('#mainwp-help-modal').modal({
14 + inverted: true,
15 + blurring: false,
16 + closable: false,
17 + onShow: function () {
18 + jQuery('#mainwp-help-modal').parent('.ui.dimmer').removeClass('dimmer');
19 + jQuery('#mainwp-help-modal').css({
20 + 'top': (jQuery(globalThis).height() - jQuery('#mainwp-help-modal').outerHeight()) / 2 + 'px',
21 + 'left': (jQuery(globalThis).width() - jQuery('#mainwp-help-modal').outerWidth()) / 2 + 'px'
22 + });
23 + },
24 24
25 25 }).modal('show').draggable().resizable({
26 26 handles: "n, e, s, w, ne, nw, se, sw", // Allows resizing from all edges
27 27 minWidth: 300, // Set minimum width
@@ -90,36 +90,111 @@
90 90 });
91 91
92 92 let mainwp_get_remove_calback = function (side_id) {
93 93 return function () {
94 - feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Removing the site. Please wait...', 'mainwp'), '');
94 + feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Removing the site. Please wait...'), '');
95 95 let data = mainwp_secure_data({
96 96 action: 'mainwp_removesite',
97 97 id: side_id
98 98 });
99 99
100 - jQuery.post(ajaxurl, data, function (response) {
100 + jQuery.ajax({
101 + url: ajaxurl,
102 + data: data,
103 + timeout: 180000, // 3 minutes. Slightly longer than the PHP server timeout (2 minutes).
104 + method: 'POST',
105 + success: function (response) {
101 106
102 - let error = false;
107 + const removed_site = response?.removed_site ?? false;
108 + let msg_not_removed = MainWP.I18n.t('Site could not be removed. Please reload the page and try again.');
103 109
104 - if (response.error != undefined) {
105 - error = response.error;
106 - } else if (response.result == 'SUCCESS') {
107 - feedback('mainwp-message-zone', __('The site has been removed and the MainWP Child plugin has been disabled. You will be redirected to the Sites page right away.', 'mainwp'), 'green');
108 - } else if (response.result == 'NOSITE') {
109 - feedback('mainwp-message-zone', __('Site could not be removed. Please reload the page and try again.', 'mainwp'), 'red');
110 - error = true;
111 - } else {
112 - feedback('mainwp-message-zone', __('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.', 'mainwp'), 'green');
113 - }
110 + let error_msg = '';
114 111
115 - if (!error) {
112 + if (typeof response?.error === 'string' && response.error.trim() !== '') {
113 + error_msg = MainWP.I18n.t('Details:') + ' ' + response.error;
114 + msg_not_removed += ' ' + error_msg;
115 + }
116 +
117 + if (response?.undefined_error) {
118 + if (!removed_site) {
119 + feedback(
120 + 'mainwp-message-zone',
121 + msg_not_removed,
122 + 'red'
123 + );
124 + return;
125 + }
126 + feedback(
127 + 'mainwp-message-zone',
128 + MainWP.I18n.t('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.'),
129 + 'red'
130 + );
131 + } else if (!removed_site) {
132 + feedback(
133 + 'mainwp-message-zone',
134 + msg_not_removed,
135 + 'red'
136 + );
137 + return;
138 + } else if (response?.error) {
139 + let message = MainWP.I18n.t('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.');
140 + if (error_msg) {
141 + message += ' ' + error_msg;
142 + }
143 + feedback('mainwp-message-zone', message, 'red');
144 + } else {
145 + switch (response?.result) {
146 + case 'SUCCESS':
147 + feedback(
148 + 'mainwp-message-zone',
149 + MainWP.I18n.t('The site has been removed and the MainWP Child plugin has been disabled. You will be redirected to the Sites page right away.'),
150 + 'green'
151 + );
152 + break;
153 + case 'REMOVED': // for demo sites.
154 + feedback(
155 + 'mainwp-message-zone',
156 + MainWP.I18n.t('The site has been removed. You will be redirected to the Sites page right away.'),
157 + 'green'
158 + );
159 + break;
160 + case 'NOSITE':
161 + feedback(
162 + 'mainwp-message-zone',
163 + msg_not_removed,
164 + 'red'
165 + );
166 + return;
167 + default:
168 + feedback(
169 + 'mainwp-message-zone',
170 + MainWP.I18n.t('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly. You will be redirected to the Sites page right away.'),
171 + 'green'
172 + );
173 + }
174 + }
116 175 setTimeout(function () {
117 176 mainwp_forceReload('admin.php?page=managesites');
118 177 }, 3000);
119 - }
178 + },
179 + error: function (xhr, textStatus) {
180 + if (textStatus === 'timeout') {
181 + feedback(
182 + 'mainwp-message-zone',
183 + MainWP.I18n.t('The request timed out. Please make sure that the MainWP Child plugin has been deactivated properly.'),
184 + 'red'
185 + );
186 + return;
187 + }
120 188
121 - }, 'json');
189 + feedback(
190 + 'mainwp-message-zone',
191 + MainWP.I18n.t('An unexpected error occurred. Please reload the page and try again.'),
192 + 'red'
193 + );
194 + },
195 + dataType: 'json'
196 + });
122 197 }
123 198
124 199 }
125 200
@@ -129,9 +204,9 @@
129 204 } else if (msg_html === '' || msg_html === undefined) {
130 205 jQuery(zone_selector).html('');
131 206 }
132 207
133 - if ( colors !== undefined && colors != '') {
208 + if (colors !== undefined && colors != '') {
134 209 jQuery(zone_selector).removeClass('green yellow red');
135 210 jQuery(zone_selector).addClass(colors);
136 211 } else if (colors === '' || colors === undefined) {
137 212 jQuery(zone_selector).removeClass('green yellow red');
@@ -278,10 +353,10 @@
278 353 return false;
279 354 });
280 355 jQuery(document).on('click', '.mainwp-plugin-delete', function () {
281 356 let name = jQuery(this).closest('.row-manage-item').attr('plugin-title');
282 - let confirmMsg = __('You are about to delete the %1?', name);
283 - mainwp_confirm(confirmMsg, () =>{
357 + let confirmMsg = MainWP.I18n.t('You are about to delete the %1?', name);
358 + mainwp_confirm(confirmMsg, () => {
284 359 pluginAction(jQuery(this), 'delete');
285 360 });
286 361 return false;
287 362 });
@@ -311,9 +386,9 @@
311 386 return false;
312 387 });
313 388 jQuery(document).on('click', '.mainwp-theme-delete', function () {
314 389 let name = jQuery(this).closest('.row-manage-item').children('.themeName').val();
315 - let confirmMsg = __('You are about to delete the %1?', name);
390 + let confirmMsg = MainWP.I18n.t('You are about to delete the %1?', name);
316 391 mainwp_confirm(confirmMsg, () => {
317 392 themeAction(jQuery(this), 'delete');
318 393 });
319 394 return false;
@@ -434,14 +509,14 @@
434 509 console.log(e);
435 510 return false; // it is not or invalid json.
436 511 }
437 512 }
438 - return __('MainWP Child plugin not detected or could not be reached! Ensure the MainWP Child plugin is installed and activated on the child site, and there are no security rules blocking requests. If you continue experiencing this issue, check the MainWP Community for help.');
513 + return MainWP.I18n.t('MainWP Child plugin not detected or could not be reached! Ensure the MainWP Child plugin is installed and activated on the child site, and there are no security rules blocking requests. If you continue experiencing this issue, check the MainWP Community for help.');
439 514 }
440 515
441 516 globalThis.mainwp_get_reconnect_error = function (response, siteId) { // NOSONAR - complexity.
442 517 if ('reconnect_failed' === response) {
443 - return __('Reconnect failed. Please try again from the %1Site Settings page%2.', '<a href="admin.php?page=managesites&id=' + siteId + '">', '</a>');
518 + return MainWP.I18n.t('Reconnect failed. Please try again from the %1Site Settings page%2.', '<a href="admin.php?page=managesites&id=' + siteId + '">', '</a>');
444 519 } else {
445 520 return response;
446 521 }
447 522 }
@@ -712,9 +787,9 @@
712 787 }
713 788 }
714 789 }
715 790 } catch {
716 - result = '<i class="exclamation circle icon"></i> ' + __('Undefined error!');
791 + result = '<i class="exclamation circle icon"></i> ' + MainWP.I18n.t('Undefined error!');
717 792 }
718 793 }
719 794 if (result != '') {
720 795 //show error!
@@ -723,11 +798,11 @@
723 798
724 799 globalThis.updatesoverview_bulk_check_abandoned = function (which) {
725 800 let confirmMsg;
726 801 if ('plugin' == which) {
727 - confirmMsg = __("You are about to check abandoned plugins on the sites?");
802 + confirmMsg = MainWP.I18n.t("You are about to check abandoned plugins on the sites?");
728 803 } else {
729 - confirmMsg = __("You are about to check abandoned themes on the sites?");
804 + confirmMsg = MainWP.I18n.t("You are about to check abandoned themes on the sites?");
730 805 }
731 806 mainwp_confirm(confirmMsg, function () { mainwp_managesites_bulk_check_abandoned('all', which); });
732 807 }
733 808
@@ -770,9 +845,9 @@
770 845 }
771 846 let initData = {
772 847 progressMax: nrOfWebsites,
773 848 title: 'Check abandoned ' + ('plugin' == which ? 'plugins' : 'themes'),
774 - statusText: __('started'),
849 + statusText: MainWP.I18n.t('started'),
775 850 callback: function () {
776 851 mainwpVars.bulkManageSitesTaskRunning = false;
777 852 mainwp_forceReload();
778 853 }
@@ -843,9 +918,9 @@
843 918 * MainWP UI.
844 919 */
845 920 jQuery(function () {
846 921 jQuery('#reset-overview-settings').on('click', function () {
847 - mainwp_confirm(__('Are you sure?'), function () {
922 + mainwp_confirm(MainWP.I18n.t('Are you sure?'), function () {
848 923 let which_set = jQuery('input[name=reset_overview_which_settings]').val();
849 924 if ('sidebar_settings' == which_set) {
850 925 jQuery('#mainwp_sidebarPosition').dropdown('set selected', 1);
851 926 } else if ('overview_settings' == which_set) {
@@ -904,15 +979,15 @@
904 979 globalSync = false;
905 980 }
906 981
907 982 for (let id of allWebsiteIds) {
908 - dashboard_update_site_status(id, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Pending', 'mainwp') + '"><i class="clock outline icon"></i></span>');
983 + dashboard_update_site_status(id, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Pending') + '"><i class="clock outline icon"></i></span>');
909 984 }
910 985
911 986 let nrOfWebsites = allWebsiteIds.length;
912 987
913 988 mainwpPopup('#mainwp-sync-sites-modal').init({
914 - title: (pAction == 'checknow' ? __('Check Now') : __('Data Synchronization')),
989 + title: (pAction == 'checknow' ? MainWP.I18n.t('Check Now') : MainWP.I18n.t('Data Synchronization')),
915 990 progressMax: nrOfWebsites,
916 991 statusText: (pAction == 'checknow' ? 'checked' : 'synced'),
917 992 callback: function () {
918 993 mainwpVars.bulkTaskRunning = false;
@@ -948,8 +1023,10 @@
948 1023 mainwpVars.currentWebsite = 0;
949 1024 mainwpVars.bulkTaskRunning = false;
950 1025 mainwpVars.currentThreads = 0;
951 1026 mainwpVars.maxThreads = mainwpParams['maximumSyncRequests'] == undefined ? 8 : mainwpParams['maximumSyncRequests'];
1027 +mainwpVars.maxUpdateThreads = mainwpParams['maximumInstallUpdateRequests'] == undefined ? 3 : mainwpParams['maximumInstallUpdateRequests'];
1028 +
952 1029 let globalSync = true;
953 1030
954 1031 globalThis.dashboard_update = function (websiteIds, isGlobalSync, pAction) {
955 1032 mainwpVars.websitesToUpdate = websiteIds;
@@ -954,8 +1031,9 @@
954 1031 globalThis.dashboard_update = function (websiteIds, isGlobalSync, pAction) {
955 1032 mainwpVars.websitesToUpdate = websiteIds;
956 1033 mainwpVars.currentWebsite = 0;
957 1034 mainwpVars.websitesDone = 0;
1035 + mainwpVars.successCount = 0;
958 1036 mainwpVars.websitesTotal = mainwpVars.websitesLeft = mainwpVars.websitesToUpdate.length;
959 1037 globalSync = isGlobalSync;
960 1038
961 1039 mainwpVars.bulkTaskRunning = true;
@@ -966,18 +1044,133 @@
966 1044 dashboard_loop_next(pAction);
967 1045 }
968 1046 };
969 1047
970 -globalThis.dashboard_update_site_status = function (siteId, newStatus, isSuccess) {
1048 +(function () {
1049 + // Create global namespace
1050 + const sync = globalThis.dashboardSync = globalThis.dashboardSync || {
1051 + container: null,
1052 + statusMap: new Map(),
1053 + rowMap: new Map(),
1054 +
1055 + data: new Map(),
1056 + queue: [],
1057 +
1058 + scheduled: false,
1059 + initialized: false,
1060 +
1061 + BATCH_SIZE: 50
1062 + };
1063 +
1064 + // -----------------------------
1065 + // INIT CACHE
1066 + // -----------------------------
1067 + function init() {
1068 + if (sync.initialized) return;
1069 +
1070 + sync.container = document.getElementById('sync-sites-status');
1071 + if (!sync.container) return;
1072 +
1073 + const nodes = sync.container.querySelectorAll('.sync-site-status');
1074 +
1075 + for (const el of nodes) {
1076 + const siteId = el.getAttribute('siteid');
1077 + sync.statusMap.set(siteId, el);
1078 + sync.rowMap.set(siteId, el.closest('.item'));
1079 + }
1080 +
1081 + sync.initialized = true;
1082 + }
1083 +
1084 + // Ensure DOM ready
1085 + if (document.readyState === 'loading') {
1086 + document.addEventListener('DOMContentLoaded', init);
1087 + } else {
1088 + init();
1089 + }
1090 +
1091 + // -----------------------------
1092 + // PUBLIC API
1093 + // -----------------------------
1094 + globalThis.dashboard_update_site_status = function (siteId, newStatus, isSuccess) {
1095 + if (!sync.initialized) return;
1096 +
1097 + sync.data.set(siteId, {
1098 + status: newStatus,
1099 + success: isSuccess
1100 + });
1101 +
1102 + sync.queue.push(siteId);
1103 +
1104 + // ✅ increment success count ONCE
1105 + if (isSuccess) {
1106 + mainwpVars.successCount = (mainwpVars.successCount || 0) + 1;
1107 + }
1108 +
1109 + if (!sync.scheduled) {
1110 + sync.scheduled = true;
1111 + requestAnimationFrame(processQueue);
1112 + }
1113 + };
1114 +
1115 + globalThis.dashboard_update_site_hide = function (siteId) {
1116 + const sync = globalThis.dashboardSync;
1117 + if (!sync?.initialized) return;
1118 +
1119 + const rowEl = sync.rowMap.get(siteId);
1120 + if (!rowEl) return;
1121 +
1122 + rowEl.style.display = 'none';
1123 + };
1124 +
1125 + // -----------------------------
1126 + // PROCESS QUEUE (BATCHED)
1127 + // -----------------------------
1128 + function processQueue() {
1129 + sync.scheduled = false;
1130 +
1131 + let count = 0;
1132 +
1133 + while (sync.queue.length && count < sync.BATCH_SIZE) {
1134 + const siteId = sync.queue.shift();
1135 + const data = sync.data.get(siteId);
1136 +
1137 + const statusEl = sync.statusMap.get(siteId);
1138 + const rowEl = sync.rowMap.get(siteId);
1139 +
1140 + if (!statusEl || !rowEl) continue;
1141 +
1142 + // Avoid DOM read → use dataset cache
1143 + if (statusEl.dataset.last !== data.status) {
1144 + statusEl.innerHTML = data.status;
1145 + statusEl.dataset.last = data.status;
1146 + }
1147 +
1148 + // No DOM move → just class toggle
1149 + if (data.success) {
1150 + rowEl.classList.add('is-success');
1151 + }
1152 +
1153 + count++;
1154 + }
1155 +
1156 + // Continue next frame if still pending
1157 + if (sync.queue.length) {
1158 + requestAnimationFrame(processQueue);
1159 + }
1160 + }
1161 +})();
1162 +
1163 +globalThis.dashboard_update_site_status_legacy = function (siteId, newStatus, isSuccess) {
971 1164 jQuery('.sync-site-status[siteid="' + siteId + '"]').html(newStatus);
972 1165 // Move successfully synced site to the bottom of the sync list
973 - if ( isSuccess !== undefined && isSuccess) {
1166 + if (isSuccess !== undefined && isSuccess) {
974 1167 let row = jQuery('.sync-site-status[siteid="' + siteId + '"]').closest('.item');
975 1168 jQuery(row).insertAfter(jQuery("#sync-sites-status .item").not('.disconnected-site').last());
976 1169 }
977 1170 };
978 1171
979 -globalThis.dashboard_update_site_hide = function (siteId) {
1172 +globalThis.dashboard_update_site_hide_legacy = function (siteId) {
980 1173 jQuery('.sync-site-status[siteid="' + siteId + '"]').closest('.item').hide();
981 1174 };
982 1175
983 1176 let dashboard_loop_next = function (pAction) {
@@ -987,8 +1180,42 @@
987 1180 };
988 1181
989 1182 let dashboard_update_done = function (pAction) {
990 1183 mainwpVars.currentThreads--;
1184 +
1185 + if (!mainwpVars.bulkTaskRunning) return;
1186 +
1187 + mainwpVars.websitesDone++;
1188 + if (mainwpVars.websitesDone > mainwpVars.websitesTotal) {
1189 + mainwpVars.websitesDone = mainwpVars.websitesTotal;
1190 + }
1191 +
1192 + // ✅ Cache popup instance (avoid re-query)
1193 + const popup = mainwpVars._popup || (
1194 + mainwpVars._popup = mainwpPopup('#mainwp-sync-sites-modal')
1195 + );
1196 +
1197 + popup.setProgressSite(mainwpVars.websitesDone);
1198 +
1199 + // ✅ Avoid DOM query for success count → track in JS
1200 + if (mainwpVars.websitesDone === mainwpVars.websitesTotal) {
1201 +
1202 + const successSites = mainwpVars.successCount || 0;
1203 +
1204 + mainwpVars.bulkTaskRunning = false;
1205 +
1206 + if (mainwpVars.websitesDone === successSites) {
1207 + setTimeout(() => popup.close(true), 3000);
1208 + }
1209 +
1210 + return;
1211 + }
1212 +
1213 + dashboard_loop_next(pAction);
1214 +};
1215 +
1216 +let dashboard_update_done_legacy = function (pAction) {
1217 + mainwpVars.currentThreads--;
991 1218 if (!mainwpVars.bulkTaskRunning)
992 1219 return;
993 1220 mainwpVars.websitesDone++;
994 1221 if (mainwpVars.websitesDone > mainwpVars.websitesTotal)
@@ -1016,11 +1243,11 @@
1016 1243 mainwpVars.currentThreads++;
1017 1244 mainwpVars.websitesLeft--;
1018 1245 let websiteId = mainwpVars.websitesToUpdate[mainwpVars.currentWebsite++];
1019 1246 if ('checknow' == pAction) {
1020 - dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Checking uptime status...', 'mainwp') + '"><i class="sync alternate loading icon"></i></span>');
1247 + dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Checking uptime status...') + '"><i class="sync alternate loading icon"></i></span>');
1021 1248 } else {
1022 - dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Syncing data...', 'mainwp') + '"><i class="sync alternate loading icon"></i></span>');
1249 + dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Syncing data...') + '"><i class="sync alternate loading icon"></i></span>');
1023 1250 }
1024 1251
1025 1252 let data = mainwp_secure_data({
1026 1253 action: ('checknow' == pAction ? 'mainwp_checksites' : 'mainwp_syncsites'),
@@ -1044,9 +1271,9 @@
1044 1271 if (response.error) {
1045 1272 let extErr = response.error;
1046 1273 dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + extErr + '"><i class="exclamation red icon"></i></span>');
1047 1274 } else {
1048 - dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Synchronization process completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>', true);
1275 + dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Synchronization process completed successfully.') + '"><i class="check green icon"></i></span>', true);
1049 1276 }
1050 1277 dashboard_update_done(pAction);
1051 1278 }
1052 1279 }(websiteId, action),
@@ -1052,9 +1279,9 @@
1052 1279 }(websiteId, action),
1053 1280 error: function (pWebsiteId, pData, pErrors, pAction) {
1054 1281 return function () {
1055 1282 if (pErrors > 5) {
1056 - dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Process timed out. Please try again.', 'mainwp') + '"><i class="exclamation yellow icon"></i></span>');
1283 + dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Process timed out. Please try again.') + '"><i class="exclamation yellow icon"></i></span>');
1057 1284 dashboard_update_done(pAction);
1058 1285 } else {
1059 1286 pErrors++;
1060 1287 dashboard_update_next_int(pWebsiteId, pData, pErrors, pAction);
@@ -1083,9 +1310,9 @@
1083 1310 let mainwp_delete_nonmainwp_data_next = function () {
1084 1311 mainwpVars.currentThreads++;
1085 1312 mainwpVars.websitesLeft--;
1086 1313 let websiteId = mainwpVars.websitesToUpdate[mainwpVars.currentWebsite++];
1087 - dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Deleting...', 'mainwp') + '"><i class="sync alternate loading icon"></i></span>');
1314 + dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Deleting...') + '"><i class="sync alternate loading icon"></i></span>');
1088 1315 let data = mainwp_secure_data({
1089 1316 action: 'mainwp_delete_non_mainwp_actions',
1090 1317 wp_id: websiteId,
1091 1318 });
@@ -1102,9 +1329,9 @@
1102 1329 if (response.error) {
1103 1330 let extErr = response.error;
1104 1331 dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + extErr + '"><i class="exclamation red icon"></i></span>');
1105 1332 } else {
1106 - dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Process completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>', true);
1333 + dashboard_update_site_status(websiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Process completed successfully.') + '"><i class="check green icon"></i></span>', true);
1107 1334 }
1108 1335 mainwp_delete_nonmainwp_data_done();
1109 1336 }
1110 1337 }(websiteId),
@@ -1110,9 +1337,9 @@
1110 1337 }(websiteId),
1111 1338 error: function (pWebsiteId, pData, pErrors) {
1112 1339 return function () {
1113 1340 if (pErrors > 5) {
1114 - dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Process timed out. Please try again.', 'mainwp') + '"><i class="exclamation yellow icon"></i></span>');
1341 + dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Process timed out. Please try again.') + '"><i class="exclamation yellow icon"></i></span>');
1115 1342 mainwp_delete_nonmainwp_data_done();
1116 1343 } else {
1117 1344 pErrors++;
1118 1345 mainwp_delete_nonmainwp_data_next_int(pWebsiteId, pData, pErrors);
@@ -1164,11 +1391,11 @@
1164 1391
1165 1392 let nrOfWebsites = allWebsiteIds.length;
1166 1393
1167 1394 mainwpPopup('#mainwp-sync-sites-modal').init({
1168 - title: __('Disconnect All Sites'),
1395 + title: MainWP.I18n.t('Disconnect All Sites'),
1169 1396 progressMax: nrOfWebsites,
1170 - statusText: __('disconnected'),
1397 + statusText: MainWP.I18n.t('disconnected'),
1171 1398 callback: function () {
1172 1399 mainwp_forceReload();
1173 1400 }
1174 1401 });
@@ -1230,9 +1457,9 @@
1230 1457 dashboard_update_site_status(pWebsiteId, response.error + '<i class="exclamation red icon"></i>');
1231 1458 } else if (response?.result == 'success') {
1232 1459 dashboard_update_site_status(websiteId, '<i class="check green icon"></i>', true);
1233 1460 } else {
1234 - dashboard_update_site_status(pWebsiteId, __('Undefined error!') + ' <i class="exclamation red icon"></i>');
1461 + dashboard_update_site_status(pWebsiteId, MainWP.I18n.t('Undefined error!') + ' <i class="exclamation red icon"></i>');
1235 1462 }
1236 1463 mainwp_tool_disconnect_sites_done();
1237 1464 }
1238 1465 }(websiteId),
@@ -1238,9 +1465,9 @@
1238 1465 }(websiteId),
1239 1466 error: function (pWebsiteId, pData, pErrors) {
1240 1467 return function () {
1241 1468 if (pErrors > 5) {
1242 - dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Process timed out. Please try again.', 'mainwp') + '"><i class="exclamation yellow icon"></i></span>');
1469 + dashboard_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Process timed out. Please try again.') + '"><i class="exclamation yellow icon"></i></span>');
1243 1470 mainwp_tool_disconnect_sites_done();
1244 1471 } else {
1245 1472 pErrors++;
1246 1473 mainwp_tool_disconnect_sites_next_int(pWebsiteId, pData, pErrors);
@@ -1271,12 +1498,14 @@
1271 1498 jQuery('.mainwp-backup-full-exclude').hide();
1272 1499 });
1273 1500 jQuery('.mainwp-checkbox-showhide-elements').on('click', function () {
1274 1501 let hiel = $(this).attr('hide-parent');
1275 - // support multi hide values.
1276 - hiel.split(';').forEach( (hi) => {
1277 - mainwp_showhide_elements(hi, $(this).find('input').is(':checked'));
1278 - });
1502 + if (hiel !== undefined && hiel !== '') {
1503 + // support multi hide values.
1504 + hiel.split(';').forEach((hi) => {
1505 + mainwp_showhide_elements(hi, $(this).find('input').is(':checked'));
1506 + });
1507 + }
1279 1508 let hideEvent = $(this).attr('fire-event-parent') ?? '';
1280 1509 if (hideEvent != '') {
1281 1510 // to sure click events finished.
1282 1511 setTimeout(function () {
@@ -1380,9 +1609,9 @@
1380 1609 mainwp_managesites_cards_reconnect(jQuery(this));
1381 1610 return false;
1382 1611 });
1383 1612
1384 - jQuery('.mainwp-updates-overview-reconnect-site').on('click', function () {
1613 + jQuery(document).on('click', '.mainwp-updates-overview-reconnect-site', function () {
1385 1614 mainwp_site_overview_reconnect(jQuery(this));
1386 1615 return false;
1387 1616 });
1388 1617
@@ -1591,9 +1820,9 @@
1591 1820 if (!valid_input) {
1592 1821 return;
1593 1822 }
1594 1823
1595 - feedback('mainwp-message-zone', __('Adding the site to your MainWP Dashboard. Please wait...'), 'green');
1824 + feedback('mainwp-message-zone', MainWP.I18n.t('Adding the site to your MainWP Dashboard. Please wait...'), 'green');
1596 1825
1597 1826 jQuery('#mainwp_managesites_add').attr('disabled', 'true'); //disable button to add..
1598 1827
1599 1828 //Check if valid user & rulewp is installed?
@@ -1627,9 +1856,9 @@
1627 1856 }
1628 1857
1629 1858 url = url.replaceAll('"', '&quot;');
1630 1859
1631 - let show_resp = __('Click %1here%2 to see response from the child site.', '<a href="javascript:void(0)" class="mainwp-show-response">', '</a>');
1860 + let show_resp = MainWP.I18n.t('Click %1here%2 to see response from the child site.', '<a href="javascript:void(0)" class="mainwp-show-response">', '</a>');
1632 1861
1633 1862 let resp_data = res_things.resp_data ? res_things.resp_data : '';
1634 1863 if ('0' == resp_data) {
1635 1864 resp_data = '';
@@ -1636,16 +1865,16 @@
1636 1865 }
1637 1866 jQuery('#mainwp-response-data-container').attr('resp-data', resp_data);
1638 1867
1639 1868 if (response == 'HTTPERROR') {
1640 - errors.push(__('This site can not be reached! Please use the Test Connection feature and see if the positive response will be returned. For additional help, please review this <a href="https://docs.mainwp.com/troubleshooting/potential-issues/">Knowledgebase document</a>, and if you still have issues, please let us know in the <a href="https://managers.mainwp.com/c/community-support/5">MainWP Community</a>.')); // NOSONAR - noopener - open safe.
1869 + errors.push(MainWP.I18n.t('This site can not be reached! Please use the Test Connection feature and see if the positive response will be returned. For additional help, please review this <a href="https://docs.mainwp.com/troubleshooting/potential-issues/">Knowledgebase document</a>, and if you still have issues, please let us know in the <a href="https://managers.mainwp.com/c/community-support/5">MainWP Community</a>.')); // NOSONAR - noopener - open safe.
1641 1870 } else if (response == 'NOMAINWP') {
1642 1871 errors.push(mainwp_js_get_error_not_detected_connect());
1643 1872 } else if (response.substring(0, 5) == 'ERROR') {
1644 1873 if (response.length == 5) {
1645 - errors.push(__('Undefined error occurred. Please try again. If the issue does not resolve, please review this <a href="https://docs.mainwp.com/troubleshooting/potential-issues/">Knowledgebase document</a>, and if you still have issues, please let us know in the <a href="https://managers.mainwp.com/c/community-support/5">MainWP Community</a>.')); // NOSONAR - noopener - open safe.
1874 + errors.push(MainWP.I18n.t('Undefined error occurred. Please try again. If the issue does not resolve, please review this <a href="https://docs.mainwp.com/troubleshooting/potential-issues/">Knowledgebase document</a>, and if you still have issues, please let us know in the <a href="https://managers.mainwp.com/c/community-support/5">MainWP Community</a>.')); // NOSONAR - noopener - open safe.
1646 1875 } else {
1647 - errors.push(__('Error detected: ') + response.substring(6));
1876 + errors.push(MainWP.I18n.t('Error detected: ') + response.substring(6));
1648 1877 }
1649 1878 } else if (response == 'OK') {
1650 1879 jQuery('#mainwp_managesites_add').attr('disabled', 'true'); //Disable add button
1651 1880
@@ -1763,12 +1992,12 @@
1763 1992
1764 1993 let errors = [];
1765 1994
1766 1995 if (jQuery('#mainwp_managesites_add_wpname').val().trim() == '') {
1767 - errors.push(__('Please enter a name for the website.'));
1996 + errors.push(MainWP.I18n.t('Please enter a name for the website.'));
1768 1997 }
1769 1998 if (jQuery('#mainwp_managesites_add_wpurl').val().trim() == '') {
1770 - errors.push(__('Please enter a valid URL for your site.'));
1999 + errors.push(MainWP.I18n.t('Please enter a valid URL for your site.'));
1771 2000 } else {
1772 2001 let url = jQuery('#mainwp_managesites_add_wpurl').val().trim();
1773 2002 if (!url.endsWith('/')) {
1774 2003 url += '/';
@@ -1776,13 +2005,13 @@
1776 2005
1777 2006 jQuery('#mainwp_managesites_add_wpurl').val(url);
1778 2007
1779 2008 if (!isUrl(jQuery('#mainwp_managesites_add_wpurl_protocol').val() + '://' + jQuery('#mainwp_managesites_add_wpurl').val())) {
1780 - errors.push(__('Please enter a valid URL for your site.'));
2009 + errors.push(MainWP.I18n.t('Please enter a valid URL for your site.'));
1781 2010 }
1782 2011 }
1783 2012 if (jQuery('#mainwp_managesites_add_wpadmin').val().trim() == '') {
1784 - errors.push(__('Please enter a username of the website administrator.'));
2013 + errors.push(MainWP.I18n.t('Please enter a username of the website administrator.'));
1785 2014 }
1786 2015
1787 2016 if (errors.length > 0) {
1788 2017 feedback('mainwp-message-zone', errors.join('<br />'), 'yellow');
@@ -1838,18 +2067,18 @@
1838 2067 selected_by: 'site',
1839 2068 };
1840 2069
1841 2070 workingEl.show();
1842 - statusEl.html(__('Preparing for installation...'));
2071 + statusEl.html(MainWP.I18n.t('Preparing for installation...'));
1843 2072
1844 2073 jQuery.post(ajaxurl, data, function (response) {
1845 2074 workingEl.hide();
1846 2075 if (response?.sites[pSiteId] === undefined) {
1847 2076 statusEl.css('color', 'red');
1848 - statusEl.html(__('Error while preparing the installation. Please, try again.'));
2077 + statusEl.html(MainWP.I18n.t('Error while preparing the installation. Please, try again.'));
1849 2078 bulkInstallCurrentThreads--;
1850 2079 } else {
1851 - statusEl.html(__('Installing...'));
2080 + statusEl.html(MainWP.I18n.t('Installing...'));
1852 2081 let data = mainwp_secure_data({
1853 2082 action: 'mainwp_ext_performinstallplugintheme',
1854 2083 type: 'plugin',
1855 2084 url: response.url,
@@ -1863,9 +2092,9 @@
1863 2092 let apply_settings = false;
1864 2093 let syc_msg = '';
1865 2094 let _success = false;
1866 2095 if ((response?.ok[pSiteId] != undefined)) {
1867 - syc_msg = __('Installation successful!');
2096 + syc_msg = MainWP.I18n.t('Installation successful!');
1868 2097 statusEl.html(syc_msg);
1869 2098 apply_settings = pPluginToInstall.find(".sync-options input[type='checkbox']:checked").length > 0;
1870 2099 if (apply_settings) {
1871 2100 mainwp_extension_apply_plugin_settings(pPluginToInstall, pSiteId, false);
@@ -1871,13 +2100,13 @@
1871 2100 mainwp_extension_apply_plugin_settings(pPluginToInstall, pSiteId, false);
1872 2101 }
1873 2102 _success = true;
1874 2103 } else if (response?.errors[pSiteId] === undefined) {
1875 - syc_msg = __('Installation failed!');
2104 + syc_msg = MainWP.I18n.t('Installation failed!');
1876 2105 statusEl.html(syc_msg);
1877 2106 statusEl.css('color', 'red');
1878 2107 } else {
1879 - syc_msg = __('Installation failed!') + ': ' + response.errors[pSiteId][1];
2108 + syc_msg = MainWP.I18n.t('Installation failed!') + ': ' + response.errors[pSiteId][1];
1880 2109 statusEl.html(syc_msg);
1881 2110 statusEl.css('color', 'red');
1882 2111 }
1883 2112
@@ -1911,9 +2140,9 @@
1911 2140 siteId: pSiteId
1912 2141 });
1913 2142
1914 2143 workingEl.show();
1915 - statusEl.html(__('Applying settings...'));
2144 + statusEl.html(MainWP.I18n.t('Applying settings...'));
1916 2145 jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex.
1917 2146 workingEl.hide();
1918 2147 let syc_msg = '';
1919 2148 let _success = false;
@@ -1922,15 +2151,15 @@
1922 2151 let msg = '';
1923 2152 if (response.message != undefined) {
1924 2153 msg = ' ' + response.message;
1925 2154 }
1926 - statusEl.html(__('Applying settings successful!') + msg);
1927 - syc_msg = __('Successful');
2155 + statusEl.html(MainWP.I18n.t('Applying settings successful!') + msg);
2156 + syc_msg = MainWP.I18n.t('Successful');
1928 2157 _success = true
1929 2158 } else if (response.error === undefined) {
1930 - statusEl.html(__('Applying settings failed!'));
2159 + statusEl.html(MainWP.I18n.t('Applying settings failed!'));
1931 2160 statusEl.css('color', 'red');
1932 - syc_msg = __('failed');
2161 + syc_msg = MainWP.I18n.t('failed');
1933 2162 } else {
1934 2163 statusEl.html(response.error);
1935 2164 statusEl.css('color', 'red');
1936 2165 syc_msg = response.error;
@@ -1935,11 +2164,11 @@
1935 2164 statusEl.css('color', 'red');
1936 2165 syc_msg = response.error;
1937 2166 }
1938 2167 } else {
1939 - statusEl.html(__('Undefined error!'));
2168 + statusEl.html(MainWP.I18n.t('Undefined error!'));
1940 2169 statusEl.css('color', 'red');
1941 - syc_msg = __('failed');
2170 + syc_msg = MainWP.I18n.t('failed');
1942 2171 }
1943 2172
1944 2173 if (syc_msg != '') {
1945 2174 if (_success)
@@ -1946,11 +2175,11 @@
1946 2175 syc_msg = '<span style="color:#0073aa">' + syc_msg + '!</span>';
1947 2176 else
1948 2177 syc_msg = '<span style="color:red">' + syc_msg + '!</span>';
1949 2178 if (pGlobal) {
1950 - syc_msg = __('Apply global %1 options', pPluginToInstall.attr('ext_name')) + ' ' + syc_msg;
2179 + syc_msg = MainWP.I18n.t('Apply global %1 options', pPluginToInstall.attr('ext_name')) + ' ' + syc_msg;
1951 2180 } else {
1952 - syc_msg = __('Apply %1 settings', pPluginToInstall.find('.sync-install-plugin').attr('plugin_name')) + ' ' + syc_msg;
2181 + syc_msg = MainWP.I18n.t('Apply %1 settings', pPluginToInstall.find('.sync-install-plugin').attr('plugin_name')) + ' ' + syc_msg;
1953 2182 }
1954 2183 jQuery('#mainwp-message-zone').append('<br/>' + syc_msg);
1955 2184 }
1956 2185 bulkInstallCurrentThreads--;
@@ -1963,9 +2192,9 @@
1963 2192
1964 2193 let errors = [];
1965 2194
1966 2195 if (jQuery('#mainwp_managesites_add_wpurl').val().trim() == '') {
1967 - errors.push(__('Please enter a valid URL for your site.'));
2196 + errors.push(MainWP.I18n.t('Please enter a valid URL for your site.'));
1968 2197 } else {
1969 2198 let clean_url = jQuery('#mainwp_managesites_add_wpurl').val().trim();
1970 2199 let protocol = jQuery('#mainwp_managesites_add_wpurl_protocol').val();
1971 2200 let url = protocol + '://' + clean_url;
@@ -1973,9 +2202,9 @@
1973 2202 url += '/';
1974 2203 }
1975 2204
1976 2205 if (!isUrl(url)) {
1977 - errors.push(__('Please enter a valid URL for your site'));
2206 + errors.push(MainWP.I18n.t('Please enter a valid URL for your site'));
1978 2207 }
1979 2208 }
1980 2209
1981 2210 if (errors.length > 0) {
@@ -2010,33 +2239,33 @@
2010 2239 if (response.error) {
2011 2240 if (response.httpCode) {
2012 2241 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2013 2242 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2014 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection failed!'));
2015 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + ' - ' + __('HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : '') + ' - ' + __('Error message: ') + ' ' + response.error);
2243 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection failed!'));
2244 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + ' - ' + MainWP.I18n.t('HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : '') + ' - ' + MainWP.I18n.t('Error message: ') + ' ' + response.error);
2016 2245 } else {
2017 2246 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2018 2247 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2019 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2020 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('Error message:') + ' ' + response.error);
2248 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2249 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('Error message:') + ' ' + response.error);
2021 2250 }
2022 2251 } else if (response.httpCode) {
2023 2252 if (response.httpCode == '200') {
2024 2253 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2025 2254 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('green check');
2026 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection successful!'));
2027 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + __('Received HTTP-code') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2255 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection successful!'));
2256 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + MainWP.I18n.t('Received HTTP-code') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2028 2257 } else {
2029 2258 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2030 2259 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2031 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2032 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + __('Received HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2260 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2261 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + MainWP.I18n.t('Received HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2033 2262 }
2034 2263 } else {
2035 2264 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show('');
2036 2265 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2037 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2038 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('Invalid response from the server, please try again.'));
2266 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2267 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('Invalid response from the server, please try again.'));
2039 2268 }
2040 2269 }, 'json');
2041 2270 }
2042 2271 };
@@ -2076,33 +2305,33 @@
2076 2305 if (response.error) {
2077 2306 if (response.httpCode) {
2078 2307 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2079 2308 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2080 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection failed!'));
2081 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + ' - ' + __('HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : '') + ' - ' + __('Error message: ') + ' ' + response.error);
2309 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection failed!'));
2310 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + ' - ' + MainWP.I18n.t('HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : '') + ' - ' + MainWP.I18n.t('Error message: ') + ' ' + response.error);
2082 2311 } else {
2083 2312 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2084 2313 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2085 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2086 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('Error message:') + ' ' + response.error);
2314 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2315 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('Error message:') + ' ' + response.error);
2087 2316 }
2088 2317 } else if (response.httpCode) {
2089 2318 if (response.httpCode == '200') {
2090 2319 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2091 2320 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('green check');
2092 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection successful!'));
2093 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + __('Received HTTP-code') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2321 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection successful!'));
2322 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + MainWP.I18n.t('Received HTTP-code') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2094 2323 } else {
2095 2324 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show();
2096 2325 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2097 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2098 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + __('Received HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2326 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2327 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('URL:') + ' ' + response.host + (response.ip === undefined ? '' : ' (IP: ' + response.ip + ')') + ' - ' + MainWP.I18n.t('Received HTTP-code:') + ' ' + response.httpCode + (response.httpCodeString ? ' (' + response.httpCodeString + ')' : ''));
2099 2328 }
2100 2329 } else {
2101 2330 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result').show('');
2102 2331 jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result i').addClass('red times');
2103 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(__('Connection test failed.'));
2104 - jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(__('Invalid response from the server, please try again.'));
2332 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content span').html(MainWP.I18n.t('Connection test failed.'));
2333 + jQuery('#mainwp-test-connection-modal .content #mainwp-test-connection-result .content .sub.header').html(MainWP.I18n.t('Invalid response from the server, please try again.'));
2105 2334 }
2106 2335 }, 'json');
2107 2336 };
2108 2337
@@ -2111,9 +2340,9 @@
2111 2340
2112 2341 let name = jQuery(obj).attr('site-name');
2113 2342 let id = jQuery(obj).attr('site-id');
2114 2343
2115 - let msg = __('Are you sure you want to remove', 'mainwp') + ' ' + name + ' ' + __('from your MainWP Dashboard?', 'mainwp');
2344 + let msg = MainWP.I18n.t('Are you sure you want to remove') + ' ' + name + ' ' + MainWP.I18n.t('from your MainWP Dashboard?');
2116 2345
2117 2346 mainwp_confirm(msg, function () {
2118 2347 jQuery('tr#child-site-' + id).html('<td colspan="999"><i class="notched circle loading icon"></i> ' + 'Removing and deactivating the MainWP Child plugin! Please wait...' + '</td>');
2119 2348 let data = mainwp_secure_data({
@@ -2130,13 +2359,13 @@
2130 2359
2131 2360 if (response.error != undefined) {
2132 2361 error = response.error;
2133 2362 } else if (response.result == 'SUCCESS') {
2134 - result = '<i class="close icon"></i>' + __('The site has been removed and the MainWP Child plugin has been disabled.');
2363 + result = '<i class="close icon"></i>' + MainWP.I18n.t('The site has been removed and the MainWP Child plugin has been disabled.');
2135 2364 } else if (response.result == 'NOSITE') {
2136 - error = '<i class="close icon"></i>' + __('The requested site has not been found.');
2365 + error = '<i class="close icon"></i>' + MainWP.I18n.t('The requested site has not been found.');
2137 2366 } else {
2138 - result = '<i class="close icon"></i>' + __('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly.');
2367 + result = '<i class="close icon"></i>' + MainWP.I18n.t('The site has been removed. Please make sure that the MainWP Child plugin has been deactivated properly.');
2139 2368 }
2140 2369
2141 2370 if (error != '') {
2142 2371 feedback('mainwp-message-zone', error, 'red');
@@ -2181,8 +2410,21 @@
2181 2410 jQuery(document).on('click', '#mainwp_managesites_edit_test', function () {
2182 2411 mainwp_managesites_edit_test();
2183 2412 });
2184 2413
2414 + // Use detected URL (Edit Site Page): set the protocol and www selectors to the child-reported address; no autosave.
2415 + jQuery(document).on('click', '#mainwp_managesites_edit_use_detected', function () {
2416 + let scheme = jQuery(this).attr('data-scheme');
2417 + let with_www = jQuery(this).attr('data-www');
2418 + if (scheme === 'http' || scheme === 'https') {
2419 + jQuery('#mainwp_managesites_edit_siteurl_protocol').dropdown('set selected', scheme);
2420 + }
2421 + if (with_www === 'www' || with_www === 'none-www') {
2422 + jQuery('#mainwp-edit-site-edit-url-www').dropdown('set selected', with_www);
2423 + }
2424 + return false;
2425 + });
2426 +
2185 2427 // Handle submit add multi website
2186 2428 jQuery(document).on('click', '#mainwp_managesites_add_multi_site', function () {
2187 2429 let error_messages = [];
2188 2430 let has_table_data = false;
@@ -2204,19 +2446,19 @@
2204 2446
2205 2447 /**
2206 2448 * Add new user
2207 2449 */
2208 - function mainwp_gen_passsword(len = 24) {
2450 +function mainwp_gen_passsword(len = 24) {
2209 2451 const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()_+{}[]<>?';
2210 2452 const arr = new Uint32Array(len);
2211 2453 crypto.getRandomValues(arr);
2212 2454 return Array.from(arr, x => chars[x % chars.length]).join('');
2213 - }
2455 +}
2214 2456
2215 - jQuery('.mainwp-generate-password-button').on('click', function (e) {
2457 +jQuery('.mainwp-generate-password-button').on('click', function (e) {
2216 2458 e.preventDefault();
2217 2459 jQuery('#createuser #password, #mainwp-update-admin-password-form #password').val(mainwp_gen_passsword(24)).trigger('change');
2218 - });
2460 +});
2219 2461
2220 2462 jQuery(function () {
2221 2463 jQuery(document).on('click', '#bulk_add_createuser', function () {
2222 2464 mainwp_createuser();
@@ -2228,19 +2470,19 @@
2228 2470
2229 2471 let mainwp_createuser = function () {
2230 2472 let cont = true;
2231 2473 if (jQuery('#user_login').val() == '') {
2232 - feedback('mainwp-message-zone', __('Username field is required! Please enter a username.'), 'yellow');
2474 + feedback('mainwp-message-zone', MainWP.I18n.t('Username field is required! Please enter a username.'), 'yellow');
2233 2475 cont = false;
2234 2476 }
2235 2477
2236 2478 if (jQuery('#email').val() == '') {
2237 - feedback('mainwp-message-zone', __('E-mail field is required! Please enter an email address.'), 'yellow');
2479 + feedback('mainwp-message-zone', MainWP.I18n.t('E-mail field is required! Please enter an email address.'), 'yellow');
2238 2480 cont = false;
2239 2481 }
2240 2482
2241 2483 if (jQuery('#password').val() == '') {
2242 - feedback('mainwp-message-zone', __('Password field is required! Please enter the wanted password or generate a random one.'), 'yellow');
2484 + feedback('mainwp-message-zone', MainWP.I18n.t('Password field is required! Please enter the wanted password or generate a random one.'), 'yellow');
2243 2485 cont = false;
2244 2486 }
2245 2487
2246 2488 let selected_sites = [];
@@ -2251,9 +2493,9 @@
2251 2493 jQuery("input[name='selected_sites[]']:checked").each(function () {
2252 2494 selected_sites.push(jQuery(this).val());
2253 2495 });
2254 2496 if (selected_sites.length == 0) {
2255 - feedback('mainwp-message-zone', __('Please select at least one website or group or client.'), 'yellow');
2497 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or group or client.'), 'yellow');
2256 2498 cont = false;
2257 2499 }
2258 2500 } else if (jQuery('input[name="select_by"]').val() == 'client') {
2259 2501 jQuery("input[name='selected_clients[]']:checked").each(function () {
@@ -2259,9 +2501,9 @@
2259 2501 jQuery("input[name='selected_clients[]']:checked").each(function () {
2260 2502 selected_clients.push(jQuery(this).val());
2261 2503 });
2262 2504 if (selected_clients.length == 0) {
2263 - feedback('mainwp-message-zone', __('Please select at least one website or group or client.'), 'yellow');
2505 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or group or client.'), 'yellow');
2264 2506 cont = false;
2265 2507 }
2266 2508 } else {
2267 2509 jQuery("input[name='selected_groups[]']:checked").each(function () {
@@ -2267,15 +2509,15 @@
2267 2509 jQuery("input[name='selected_groups[]']:checked").each(function () {
2268 2510 selected_groups.push(jQuery(this).val());
2269 2511 });
2270 2512 if (selected_groups.length == 0) {
2271 - feedback('mainwp-message-zone', __('Please select at least one website or group or client.'), 'yellow');
2513 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or group or client.'), 'yellow');
2272 2514 cont = false;
2273 2515 }
2274 2516 }
2275 2517
2276 2518 if (cont) {
2277 - mainwp_set_message_zone('#mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Creating the user. Please wait...'), '', true);
2519 + mainwp_set_message_zone('#mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Creating the user. Please wait...'), '', true);
2278 2520 jQuery('#bulk_add_createuser').attr('disabled', 'disabled');
2279 2521 const is_send_password = jQuery('#send_password').is(':checked') ? 1 : 0;
2280 2522 //Add user via ajax!!
2281 2523 let data = mainwp_secure_data({
@@ -2315,11 +2557,11 @@
2315 2557 }
2316 2558 }
2317 2559 } else {
2318 2560 jQuery('#mainwp-add-new-user-form').append(response);
2319 - jQuery('#mainwp-creating-new-user-modal').modal( {
2561 + jQuery('#mainwp-creating-new-user-modal').modal({
2320 2562 closable: false,
2321 - } ).modal( 'show' );
2563 + }).modal('show');
2322 2564 }
2323 2565 });
2324 2566 }
2325 2567 };
@@ -2365,9 +2607,9 @@
2365 2607 let act = jQuery(this).attr('bulk-action');
2366 2608 if (act == 'install') {
2367 2609 let selected = jQuery("input[type='radio'][name='install-plugin']:checked");
2368 2610 if (selected.length == 0) {
2369 - feedback('mainwp-message-zone', __('Please select plugin to install files.'), 'yellow');
2611 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select plugin to install files.'), 'yellow');
2370 2612 } else {
2371 2613 let selectedId = /^install-([^-]*)-(.*)$/.exec(selected.attr('id'));
2372 2614 if (selectedId) {
2373 2615 mainwp_install_bulk('plugin', selectedId[2], selected.attr('plugin-name'));
@@ -2384,9 +2626,9 @@
2384 2626 let act = jQuery(this).attr('bulk-action');
2385 2627 if (act == 'install') {
2386 2628 let selected = jQuery("input[type='radio'][name='install-theme']:checked");
2387 2629 if (selected.length == 0) {
2388 - feedback('mainwp-message-zone', __('Please select theme to install files.'), 'yellow');
2630 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select theme to install files.'), 'yellow');
2389 2631 } else {
2390 2632 let selectedId = /^install-([^-]*)-(.*)$/.exec(selected.attr('id'));
2391 2633 if (selectedId)
2392 2634 mainwp_install_bulk('theme', selectedId[2], selected.attr('theme-name'));
@@ -2439,9 +2681,9 @@
2439 2681 selected_sites.push(jQuery(this).val());
2440 2682 });
2441 2683
2442 2684 if (selected_sites.length == 0) {
2443 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2685 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2444 2686 return;
2445 2687 }
2446 2688
2447 2689 data['selected_sites[]'] = selected_sites;
@@ -2454,9 +2696,9 @@
2454 2696 selected_clients.push(jQuery(this).val());
2455 2697 });
2456 2698
2457 2699 if (selected_clients.length == 0) {
2458 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2700 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2459 2701 return;
2460 2702 }
2461 2703
2462 2704 data['selected_clients[]'] = selected_clients;
@@ -2468,9 +2710,9 @@
2468 2710 selected_groups.push(jQuery(this).val());
2469 2711 });
2470 2712
2471 2713 if (selected_groups.length == 0) {
2472 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2714 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2473 2715 return;
2474 2716 }
2475 2717
2476 2718 data['selected_groups[]'] = selected_groups;
@@ -2489,10 +2731,10 @@
2489 2731 let site = response.sites[siteId];
2490 2732 installQueueContent +=
2491 2733 '<div class="siteBulkInstall item" siteid="' + siteId + '" status="queue">' +
2492 2734 '<div class="right floated content">' +
2493 - '<span class="queue" data-inverted="" data-position="left center" data-tooltip="' + __('Queued') + '"><i class="clock outline icon"></i></span>' +
2494 - '<span class="progress" data-inverted="" data-position="left center" data-tooltip="' + __('Installing...') + '" style="display:none"><i class="notched circle loading icon"></i></span>' +
2735 + '<span class="queue" data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Queued') + '"><i class="clock outline icon"></i></span>' +
2736 + '<span class="progress" data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Installing...') + '" style="display:none"><i class="notched circle loading icon"></i></span>' +
2495 2737 '<span class="status"></span>' +
2496 2738 '</div>' +
2497 2739 '<div class="content">' + mainwp_links_visit_site_and_admin('', siteId) + ' ' + '<a href="' + site['url'] + '">' + site.name.replace(/\\(.)/g, '$1') + '</a></div>' + // NOSONAR - no safe replaceAll alternative.
2498 2740 '</div>';
@@ -2588,9 +2830,9 @@
2588 2830 if (response.error != undefined) {
2589 2831 statusEl.html(response.error);
2590 2832 statusEl.css('color', 'red');
2591 2833 } else if (response?.ok[siteToInstall.attr('siteid')]) {
2592 - statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Installation completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>');
2834 + statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Installation completed successfully.') + '"><i class="check green icon"></i></span>');
2593 2835 if (installResults.installed_sites == undefined) {
2594 2836 installResults.installed_sites = [];
2595 2837 }
2596 2838 installResults.installed_sites.push(siteToInstall.attr('siteid'));
@@ -2596,9 +2838,9 @@
2596 2838 installResults.installed_sites.push(siteToInstall.attr('siteid'));
2597 2839 } else if (response?.errors[siteToInstall.attr('siteid')]) {
2598 2840 _error = response.errors[siteToInstall.attr('siteid')][1];
2599 2841 } else {
2600 - _error = __('Undefined error occurred. Please try again.', 'mainwp');
2842 + _error = MainWP.I18n.t('Undefined error occurred. Please try again.');
2601 2843 }
2602 2844
2603 2845 if (_error !== '') {
2604 2846 statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + _error + '"><i class="times red icon"></i></span>');
@@ -2607,9 +2849,9 @@
2607 2849 bulkInstallCurrentThreads--;
2608 2850 bulkInstallDone++;
2609 2851
2610 2852 jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').progress('set progress', bulkInstallDone);
2611 - jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + __('Installed'));
2853 + jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + MainWP.I18n.t('Installed'));
2612 2854 mainwp_install_bulk_start_next(type, url, activatePlugin, overwrite, slug, installResults);
2613 2855 }
2614 2856 }(type, url, activatePlugin, overwrite, siteToInstall), 'json');
2615 2857 };
@@ -2619,27 +2861,27 @@
2619 2861 let msg = '';
2620 2862 if (mainwpParams.installedBulkSettingsManager && mainwpParams.installedBulkSettingsManager == 1) {
2621 2863 if (type == 'plugin') {
2622 2864 if (total == 1)
2623 - msg = __('Would you like to use the Bulk Settings Manager with this plugin? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2865 + msg = MainWP.I18n.t('Would you like to use the Bulk Settings Manager with this plugin? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2624 2866 else
2625 - msg = __('Would you like to use the Bulk Settings Manager with these plugins? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2867 + msg = MainWP.I18n.t('Would you like to use the Bulk Settings Manager with these plugins? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2626 2868 } else if (type == 'theme') {
2627 2869 if (total == 1)
2628 - msg = __('Would you like to use the Bulk Settings Manager with this theme? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2870 + msg = MainWP.I18n.t('Would you like to use the Bulk Settings Manager with this theme? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2629 2871 else
2630 - msg = __('Would you like to use the Bulk Settings Manager with these themes? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2872 + msg = MainWP.I18n.t('Would you like to use the Bulk Settings Manager with these themes? Check out the %1Documentation%2.', '<a href="https://docs.mainwp.com/add-ons/administrative/bulk-settings-manager-extension" target="_blank">', '</a>'); // NOSONAR - noopener - open safe.
2631 2873 }
2632 2874 } else if (type == 'plugin') {
2633 2875 if (total == 1)
2634 - msg = __('Did you know with the %1 you can control the settings of this plugin directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2876 + msg = MainWP.I18n.t('Did you know with the %1 you can control the settings of this plugin directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2635 2877 else
2636 - msg = __('Did you know with the %1 you can control the settings of these plugins directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2878 + msg = MainWP.I18n.t('Did you know with the %1 you can control the settings of these plugins directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2637 2879 } else if (type == 'theme') {
2638 2880 if (total == 1)
2639 - msg = __('Did you know with the %1 you can control the settings of this theme directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2881 + msg = MainWP.I18n.t('Did you know with the %1 you can control the settings of this theme directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2640 2882 else
2641 - msg = __('Did you know with the %1 you can control the settings of these themes directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2883 + msg = MainWP.I18n.t('Did you know with the %1 you can control the settings of these themes directly from your MainWP Dashboard?', '<a href="https://mainwp.com/add-on/bulk-settings-manager/" target="_blank">Bulk Settings Extension</a>'); // NOSONAR - noopener - open safe.
2642 2884 }
2643 2885 return msg;
2644 2886 }
2645 2887
@@ -2669,11 +2911,11 @@
2669 2911 });
2670 2912
2671 2913 if (files.length == 0) {
2672 2914 if (type == 'plugin') {
2673 - feedback('mainwp-message-zone', __('Please upload at least one plugin to install.', 'mainwp'), 'yellow');
2915 + feedback('mainwp-message-zone', MainWP.I18n.t('Please upload at least one plugin to install.'), 'yellow');
2674 2916 } else {
2675 - feedback('mainwp-message-zone', __('Please upload at least one theme to install.', 'mainwp'), 'yellow');
2917 + feedback('mainwp-message-zone', MainWP.I18n.t('Please upload at least one theme to install.'), 'yellow');
2676 2918 }
2677 2919 return;
2678 2920 }
2679 2921
@@ -2691,9 +2933,9 @@
2691 2933 selected_sites.push(jQuery(this).val());
2692 2934 });
2693 2935
2694 2936 if (selected_sites.length == 0) {
2695 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2937 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2696 2938 return;
2697 2939 }
2698 2940 data['selected_sites[]'] = selected_sites;
2699 2941 } else if (jQuery('input[name="select_by"]').val() == 'client') {
@@ -2702,9 +2944,9 @@
2702 2944 selected_clients.push(jQuery(this).val());
2703 2945 });
2704 2946
2705 2947 if (selected_clients.length == 0) {
2706 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2948 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2707 2949 return;
2708 2950 }
2709 2951 data['selected_clients[]'] = selected_clients;
2710 2952 } else {
@@ -2712,9 +2954,9 @@
2712 2954 jQuery("input[name='selected_groups[]']:checked").each(function () {
2713 2955 selected_groups.push(jQuery(this).val());
2714 2956 });
2715 2957 if (selected_groups.length == 0) {
2716 - feedback('mainwp-message-zone', __('Please select at least one website or a group or client.', 'mainwp'), 'yellow');
2958 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website or a group or client.'), 'yellow');
2717 2959 return;
2718 2960 }
2719 2961 data['selected_groups[]'] = selected_groups;
2720 2962 }
@@ -2736,10 +2978,10 @@
2736 2978
2737 2979 installQueue +=
2738 2980 '<div class="siteBulkInstall item" siteid="' + siteId + '" status="queue">' +
2739 2981 '<div class="right floated content">' +
2740 - '<span class="queue" data-inverted="" data-position="left center" data-tooltip="' + __('Queued', 'mainwp') + '"><i class="clock outline icon"></i></span>' +
2741 - '<span class="progress" data-inverted="" data-position="left center" data-tooltip="' + __('Installing...', 'mainwp') + '" style="display:none"><i class="notched circle loading icon"></i></span>' +
2982 + '<span class="queue" data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Queued') + '"><i class="clock outline icon"></i></span>' +
2983 + '<span class="progress" data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Installing...') + '" style="display:none"><i class="notched circle loading icon"></i></span>' +
2742 2984 '<span class="status"></span>' +
2743 2985 '</div>' +
2744 2986 '<div class="content">' + mainwp_links_visit_site_and_admin('', siteId) + ' ' + '<a href="' + site['url'] + '">' + site.name.replace(/\\(.)/g, '$1') + '</a></div>' + // NOSONAR - no safe replaceAll alternative.
2745 2987 '<div class="installation-entries"></div>' +
@@ -2817,9 +3059,9 @@
2817 3059 if (cost_tracker_items.length > 0) {
2818 3060 jQuery('.mainwp-cost-tracker-assistant-add-buttons-wrapper').html('');
2819 3061 let multiAddTo = cost_tracker_items.length > 1 ? 1 : 0;
2820 3062 cost_tracker_items.forEach(item => {
2821 - jQuery('.mainwp-cost-tracker-assistant-add-buttons-wrapper').append('<a href="javascript:void(0)" item-type="' + item.type + '" item-slug="' + item.slug + '" cost-id="' + item.cost_id + '" item-name="' + item.name + '" installed-sites="' + item.sites_ids.join(',') + '" multi-add-to="' + multiAddTo + '" class="ui mini button mainwp-cost-tracker-assistant-add-to-cost-tracker-button">' + ((item.cost_id != undefined && item.cost_id > 0) ? __('Edit Cost Tracker') + ' (' + item.name + ')' : __('Add to Cost Tracker') + ' (' + item.name + ')') + '</a>');
3063 + jQuery('.mainwp-cost-tracker-assistant-add-buttons-wrapper').append('<a href="javascript:void(0)" item-type="' + item.type + '" item-slug="' + item.slug + '" cost-id="' + item.cost_id + '" item-name="' + item.name + '" installed-sites="' + item.sites_ids.join(',') + '" multi-add-to="' + multiAddTo + '" class="ui mini button mainwp-cost-tracker-assistant-add-to-cost-tracker-button">' + ((item.cost_id != undefined && item.cost_id > 0) ? MainWP.I18n.t('Edit Cost Tracker') + ' (' + item.name + ')' : MainWP.I18n.t('Add to Cost Tracker') + ' (' + item.name + ')') + '</a>');
2822 3064 });
2823 3065 }
2824 3066 }
2825 3067 }
@@ -2878,11 +3120,11 @@
2878 3120 jQuery('div[siteId="' + siteid + '"] .installation-entries').html(results);
2879 3121 if (response.cost_tracker_installed_info != undefined) { // to support add to cost tracker pro.
2880 3122 jQuery('div[siteId="' + siteid + '"] .installation-entries').after(response.cost_tracker_installed_info);
2881 3123 }
2882 - statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Installation completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>');
3124 + statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Installation completed successfully.') + '"><i class="check green icon"></i></span>');
2883 3125 } else if (response?.errors[siteid] === undefined) {
2884 - statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Undefined error occurred. Please try again.', 'mainwp') + '"><i class="times red icon"></i></span>');
3126 + statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Undefined error occurred. Please try again.') + '"><i class="times red icon"></i></span>');
2885 3127 } else {
2886 3128 statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + response.errors[siteid][1] + '"><i class="times red icon"></i></span>');
2887 3129 }
2888 3130
@@ -2888,9 +3130,9 @@
2888 3130
2889 3131 bulkInstallCurrentThreads--;
2890 3132 bulkInstallDone++;
2891 3133 jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').progress('set progress', bulkInstallDone);
2892 - jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + __('Installed'));
3134 + jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + MainWP.I18n.t('Installed'));
2893 3135 mainwp_upload_bulk_start_next(type, urls, activatePlugin, overwrite);
2894 3136 }
2895 3137 }(type, urls, activatePlugin, overwrite, siteToInstall), 'json');
2896 3138 };
@@ -2916,9 +3158,9 @@
2916 3158 }
2917 3159
2918 3160 $('#mainwp-plugin-details-modal')
2919 3161 .modal({
2920 - onHide: function () {},
3162 + onHide: function () { },
2921 3163 onShow: () => {
2922 3164 $('#mainwp-plugin-details-modal')
2923 3165 .find('.ui.embed')
2924 3166 .embed({
@@ -2944,29 +3186,29 @@
2944 3186 let themeChangesLoadData = {};
2945 3187
2946 3188 jQuery(function ($) {
2947 3189
2948 - $(document).on('click', '.mainwp-show-history', function (e) {
3190 + $(document).on('click', '.mainwp-show-history', function (e) {
2949 3191
2950 - e.preventDefault();
2951 - e.stopPropagation();
3192 + e.preventDefault();
3193 + e.stopPropagation();
2952 3194
2953 - const view = $(this).attr('history-view');
2954 - let parent = false;
2955 - let type = 'plugin'; // default.
2956 - let title = '';
2957 - let info = '';
2958 - let name = '';
2959 - let slug = '';
2960 - let siteId = 0;
3195 + const view = $(this).attr('history-view');
3196 + let parent = false;
3197 + let type = 'plugin'; // default.
3198 + let title = '';
3199 + let info = '';
3200 + let name = '';
3201 + let slug = '';
3202 + let siteId = 0;
2961 3203
2962 - switch (view) {
3204 + switch (view) {
2963 3205 case 'update-plugins-individual':
2964 3206 parent = $(this).closest('.plugins-bulk-updates');
2965 3207 siteId = $(parent).attr('site_id');
2966 3208 info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
2967 3209 title = $(this).closest('tr').attr('plugin_name');
2968 - slug = decodeURIComponent( $(this).closest('tr').attr('plugin_slug') );
3210 + slug = decodeURIComponent($(this).closest('tr').attr('plugin_slug'));
2969 3211 name = $(this).closest('tr').attr('plugin_name');
2970 3212 break;
2971 3213 case 'update-themes-individual':
2972 3214 parent = $(this).closest('.themes-bulk-updates');
@@ -2976,111 +3218,111 @@
2976 3218 slug = $(this).closest('tr').attr('theme_slug');
2977 3219 name = $(this).closest('tr').attr('theme_name');
2978 3220 type = 'theme';
2979 3221 break;
2980 - case 'manage-plugins-per-sites':
2981 - case 'manage-plugins-per-items':
2982 - parent = $(this).closest('.mainwp-manage-plugin-item-website');
2983 - title = $(parent).attr('plugin-name');
2984 - info = $(parent).attr('site-name') + ' (' + $(parent).attr('site-url') + ') ' + $(parent).attr('tz-info');
2985 - slug = decodeURIComponent($(parent).attr('plugin-slug'));
2986 - siteId = $(parent).attr('site-id');
2987 - break;
2988 - case 'manage-themes-per-sites':
2989 - case 'manage-themes-per-items':
2990 - parent = $(this).closest('.mainwp-manage-theme-item-website');
2991 - title = $(parent).attr('theme-name');
2992 - name = $(parent).attr('theme-name');
2993 - info = $(parent).attr('site-name') + ' (' + $(parent).attr('site-url') + ') ' + $(parent).attr('tz-info');
2994 - slug = decodeURIComponent($(parent).attr('theme-slug'));
2995 - siteId = $(parent).attr('site-id');
2996 - type = 'theme';
2997 - break;
2998 - case 'widget-plugins':
2999 - parent = $(this).closest('.row-manage-item');
3000 - title = $(parent).attr('plugin-name');
3001 - info = $('#mainwp-widget-active-plugins').attr('site-info');
3002 - slug = $(parent).attr('plugin-slug');
3003 - siteId = $('#mainwp-widget-active-plugins').attr('site-id');
3004 - break;
3005 - case 'widget-themes':
3006 - parent = $(this).closest('.row-manage-item');
3007 - title = $(parent).find('.themeName').val();
3008 - info = $('#mainwp-widget-inactive-themes').attr('site-info');
3009 - slug = $(parent).find('.themeSlug').val();
3010 - name = $(parent).find('.themeName').val();
3011 - siteId = $('#mainwp-widget-inactive-themes').attr('site-id');
3012 - type = 'theme';
3013 - break;
3014 - case 'update-plugin-per-item':
3015 - parent = $(this).closest('tr');
3016 - siteId = $(parent).attr('site_id');
3017 - info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3018 - title = $(parent).attr('plugin_name');
3019 - slug = decodeURIComponent($(parent).attr('plugin_slug'));
3020 - break;
3021 - case 'update-theme-per-item':
3022 - parent = $(this).closest('tr');
3023 - siteId = $(parent).attr('site_id');
3024 - info = $(parent).attr('site_name') + ' (' + decodeURIComponent( $(parent).attr('site_url') ) + ') ' + $(parent).attr('tz-info');
3025 - title = $(parent).attr('theme_name');
3026 - name = $(parent).attr('theme_name');
3027 - slug = decodeURIComponent($(parent).attr('theme_slug'));
3028 - type = 'theme';
3029 - break;
3030 - case 'update-plugin-per-site': // NOSONAR - same as above.
3031 - parent = $(this).closest('.plugins-bulk-updates');
3032 - siteId = $(parent).attr('site_id');
3033 - info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3034 - title = $(this).closest('tr').attr('plugin_name');
3035 - slug = decodeURIComponent( $(this).closest('tr').attr('plugin_slug') );
3036 - name = $(this).closest('tr').attr('plugin_name');
3037 - break;
3038 - case 'update-theme-per-site': // NOSONAR - same above.
3039 - parent = $(this).closest('.themes-bulk-updates');
3040 - siteId = $(parent).attr('site_id');
3041 - info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3042 - title = $(this).closest('tr').attr('theme_name');
3043 - slug = $(this).closest('tr').attr('theme_slug');
3044 - name = $(this).closest('tr').attr('theme_name');
3045 - type = 'theme';
3046 - break;
3047 - case 'update-plugin-per-tag':
3048 - parent = $(this).closest('.plugins-bulk-updates');
3049 - siteId = $(parent).attr('site_id');
3050 - info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3051 - title = $(this).closest('tr').attr('plugin_name');
3052 - slug = decodeURIComponent($(this).closest('tr').attr('plugin_slug'));
3053 - break;
3054 - case 'update-theme-per-tag':
3055 - parent = $(this).closest('.themes-bulk-updates');
3056 - siteId = $(parent).attr('site_id');
3057 - info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3058 - title = $(this).closest('tr').attr('theme_name');
3059 - name = $(this).closest('tr').attr('theme_name');
3060 - slug = $(this).closest('tr').attr('theme_slug');
3061 - type = 'theme';
3062 - break;
3063 - }
3222 + case 'manage-plugins-per-sites':
3223 + case 'manage-plugins-per-items':
3224 + parent = $(this).closest('.mainwp-manage-plugin-item-website');
3225 + title = $(parent).attr('plugin-name');
3226 + info = $(parent).attr('site-name') + ' (' + $(parent).attr('site-url') + ') ' + $(parent).attr('tz-info');
3227 + slug = decodeURIComponent($(parent).attr('plugin-slug'));
3228 + siteId = $(parent).attr('site-id');
3229 + break;
3230 + case 'manage-themes-per-sites':
3231 + case 'manage-themes-per-items':
3232 + parent = $(this).closest('.mainwp-manage-theme-item-website');
3233 + title = $(parent).attr('theme-name');
3234 + name = $(parent).attr('theme-name');
3235 + info = $(parent).attr('site-name') + ' (' + $(parent).attr('site-url') + ') ' + $(parent).attr('tz-info');
3236 + slug = decodeURIComponent($(parent).attr('theme-slug'));
3237 + siteId = $(parent).attr('site-id');
3238 + type = 'theme';
3239 + break;
3240 + case 'widget-plugins':
3241 + parent = $(this).closest('.row-manage-item');
3242 + title = $(parent).attr('plugin-name');
3243 + info = $('#mainwp-widget-active-plugins').attr('site-info');
3244 + slug = $(parent).attr('plugin-slug');
3245 + siteId = $('#mainwp-widget-active-plugins').attr('site-id');
3246 + break;
3247 + case 'widget-themes':
3248 + parent = $(this).closest('.row-manage-item');
3249 + title = $(parent).find('.themeName').val();
3250 + info = $('#mainwp-widget-inactive-themes').attr('site-info');
3251 + slug = $(parent).find('.themeSlug').val();
3252 + name = $(parent).find('.themeName').val();
3253 + siteId = $('#mainwp-widget-inactive-themes').attr('site-id');
3254 + type = 'theme';
3255 + break;
3256 + case 'update-plugin-per-item':
3257 + parent = $(this).closest('tr');
3258 + siteId = $(parent).attr('site_id');
3259 + info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3260 + title = $(parent).attr('plugin_name');
3261 + slug = decodeURIComponent($(parent).attr('plugin_slug'));
3262 + break;
3263 + case 'update-theme-per-item':
3264 + parent = $(this).closest('tr');
3265 + siteId = $(parent).attr('site_id');
3266 + info = $(parent).attr('site_name') + ' (' + decodeURIComponent($(parent).attr('site_url')) + ') ' + $(parent).attr('tz-info');
3267 + title = $(parent).attr('theme_name');
3268 + name = $(parent).attr('theme_name');
3269 + slug = decodeURIComponent($(parent).attr('theme_slug'));
3270 + type = 'theme';
3271 + break;
3272 + case 'update-plugin-per-site': // NOSONAR - same as above.
3273 + parent = $(this).closest('.plugins-bulk-updates');
3274 + siteId = $(parent).attr('site_id');
3275 + info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3276 + title = $(this).closest('tr').attr('plugin_name');
3277 + slug = decodeURIComponent($(this).closest('tr').attr('plugin_slug'));
3278 + name = $(this).closest('tr').attr('plugin_name');
3279 + break;
3280 + case 'update-theme-per-site': // NOSONAR - same above.
3281 + parent = $(this).closest('.themes-bulk-updates');
3282 + siteId = $(parent).attr('site_id');
3283 + info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3284 + title = $(this).closest('tr').attr('theme_name');
3285 + slug = $(this).closest('tr').attr('theme_slug');
3286 + name = $(this).closest('tr').attr('theme_name');
3287 + type = 'theme';
3288 + break;
3289 + case 'update-plugin-per-tag':
3290 + parent = $(this).closest('.plugins-bulk-updates');
3291 + siteId = $(parent).attr('site_id');
3292 + info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3293 + title = $(this).closest('tr').attr('plugin_name');
3294 + slug = decodeURIComponent($(this).closest('tr').attr('plugin_slug'));
3295 + break;
3296 + case 'update-theme-per-tag':
3297 + parent = $(this).closest('.themes-bulk-updates');
3298 + siteId = $(parent).attr('site_id');
3299 + info = $(parent).attr('site_name') + ' (' + $(parent).attr('site_url') + ') ' + $(parent).attr('tz-info');
3300 + title = $(this).closest('tr').attr('theme_name');
3301 + name = $(this).closest('tr').attr('theme_name');
3302 + slug = $(this).closest('tr').attr('theme_slug');
3303 + type = 'theme';
3304 + break;
3305 + }
3064 3306
3065 - if (type === 'plugin') {
3066 - pluginChangesLoadData = mainwp_secure_data({
3067 - action: 'mainwp_changes_logs_get_item_changes',
3068 - type: 'plugin',
3069 - slug: slug,
3070 - siteId: siteId,
3071 - from_date: '' // current date.
3072 - });
3073 - } else if (type === 'theme') {
3074 - themeChangesLoadData = mainwp_secure_data({
3075 - action: 'mainwp_changes_logs_get_item_changes',
3076 - type: 'theme',
3077 - slug: slug,
3078 - siteId: siteId,
3079 - name: name,
3080 - from_date: '' // current date.
3081 - });
3082 - }
3307 + if (type === 'plugin') {
3308 + pluginChangesLoadData = mainwp_secure_data({
3309 + action: 'mainwp_changes_logs_get_item_changes',
3310 + type: 'plugin',
3311 + slug: slug,
3312 + siteId: siteId,
3313 + from_date: '' // current date.
3314 + });
3315 + } else if (type === 'theme') {
3316 + themeChangesLoadData = mainwp_secure_data({
3317 + action: 'mainwp_changes_logs_get_item_changes',
3318 + type: 'theme',
3319 + slug: slug,
3320 + siteId: siteId,
3321 + name: name,
3322 + from_date: '' // current date.
3323 + });
3324 + }
3083 3325
3084 3326 $('#mainwp-plugin-theme-history-changes-modal').modal({
3085 3327 onHide: function () {
3086 3328 },
@@ -3092,21 +3334,21 @@
3092 3334 }).modal('show');
3093 3335 });
3094 3336 });
3095 3337
3096 -let mainwp_changes_history_box_init = function ( type, title, info ) {
3338 +let mainwp_changes_history_box_init = function (type, title, info) {
3097 3339 const hd = jQuery('#mainwp-plugin-theme-history-changes-modal > div.header');
3098 - hd.find('.main-text').text(title + ' ' + __('History')); // safe for escape.
3340 + hd.find('.main-text').text(title + ' ' + MainWP.I18n.t('History')); // safe for escape.
3099 3341 hd.find('.sub.header').text(info).show();
3100 3342 jQuery('#mainwp-plugin-theme-history-changes-modal').attr('history-type', type);
3101 3343 jQuery('#mainwp-plugin-theme-history-changes-modal').find('.scrolling.content').html('');
3102 3344 }
3103 3345
3104 -let mainwp_item_changes_load = function ( btnObj, load_more_date = '' ) {
3346 +let mainwp_item_changes_load = function (btnObj, load_more_date = '') {
3105 3347
3106 3348 let md = jQuery('#mainwp-plugin-theme-history-changes-modal');
3107 3349 let parentContent = false;
3108 - if(btnObj){
3350 + if (btnObj) {
3109 3351 parentContent = jQuery(btnObj).closest('.ui.accordion').find('.ui.content');
3110 3352 } else {
3111 3353 parentContent = jQuery(md).find('.scrolling.content')
3112 3354 }
@@ -3117,12 +3359,12 @@
3117 3359 const type = jQuery(md).attr('history-type');
3118 3360 let load_more = false;
3119 3361
3120 3362 // set load date if provided
3121 - if(typeof load_more_date === 'string' && load_more_date !== ''){
3122 - if('theme' === type){
3363 + if (typeof load_more_date === 'string' && load_more_date !== '') {
3364 + if ('theme' === type) {
3123 3365 themeChangesLoadData.from_date = load_more_date;
3124 - }else{
3366 + } else {
3125 3367 pluginChangesLoadData.from_date = load_more_date;
3126 3368 }
3127 3369 load_more = true;
3128 3370 }
@@ -3132,19 +3374,19 @@
3132 3374
3133 3375 jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex.
3134 3376 jQuery(md).find('.history-actions-loading').remove();
3135 3377 if (response?.error) {
3136 - if(parentContent){
3378 + if (parentContent) {
3137 3379 let err_content = '<div class="ui message red">' + response.error + '</div>';
3138 3380 jQuery(parentContent).html(err_content);
3139 3381 }
3140 3382 } else if (response?.list) {
3141 3383 if (response.list.length == 0) {
3142 - let msg = __('This plugin has no recorded activity in Dashboard Insights.') ;
3143 - if('theme' === type){
3144 - msg = __('This theme has no recorded activity in Dashboard Insights.') ;
3384 + let msg = MainWP.I18n.t('This plugin has no recorded activity in Dashboard Insights.');
3385 + if ('theme' === type) {
3386 + msg = MainWP.I18n.t('This theme has no recorded activity in Dashboard Insights.');
3145 3387 }
3146 - if(parentContent){
3388 + if (parentContent) {
3147 3389 let msg_content = '<div class="ui info message">' + msg + '</div>';
3148 3390 jQuery(parentContent).html(msg_content);
3149 3391 }
3150 3392 } else {
@@ -3159,9 +3401,9 @@
3159 3401 <i class="dropdown icon"></i>
3160 3402 ${dt}
3161 3403 </div>
3162 3404 <div class="six wide column right aligned">
3163 - <button type="button" class="ui circular blue mini button mainwp-day-history-switch-view">` + __('Day History') + `</button> <button class="ui basic mini button actions-count1">${records.length} ` + __('Actions') + `</button>
3405 + <button type="button" class="ui circular blue mini button mainwp-day-history-switch-view">` + MainWP.I18n.t('Day History') + `</button> <button class="ui basic mini button actions-count1">${records.length} ` + MainWP.I18n.t('Actions') + `</button>
3164 3406 </div>
3165 3407 </div>
3166 3408 </div>
3167 3409 </div>
@@ -3170,9 +3412,9 @@
3170 3412 content += `<div class="item" log-id="${record.details.log_id}">
3171 3413 <div class="ui grid">
3172 3414 <div class="eight wide column middle aligned">
3173 3415 <i class="` + get_icon_history_event(record.details.action) + ` icon"></i>
3174 - <span class="ui text ` + get_color_changes_event(record.details.action) + `">${record.details.event}</span> ` + __('by') + ` <strong>${record.details.author_name}</strong> ` + __('from') + `
3416 + <span class="ui text ` + get_color_changes_event(record.details.action) + `">${record.details.event}</span> ` + MainWP.I18n.t('by') + ` <strong>${record.details.author_name}</strong> ` + MainWP.I18n.t('from') + `
3175 3417 <strong>${record.details.source}</strong>
3176 3418 </div>
3177 3419 <div class="six wide column middle aligned">
3178 3420 ` + (record.details?.old_version && record.details?.version ? record.details.old_version + '&rarr;' + record.details.version : '') + `
@@ -3199,9 +3441,9 @@
3199 3441 name_title = response.name_title;
3200 3442 }
3201 3443
3202 3444 if (name_title != '') {
3203 - jQuery(md).find('.ui.header .main-text').text(name_title + ' ' + __('History'));
3445 + jQuery(md).find('.ui.header .main-text').text(name_title + ' ' + MainWP.I18n.t('History'));
3204 3446 }
3205 3447
3206 3448 if (load_more) {
3207 3449 jQuery(md).find('.scrolling.content').append(accordWrapper);
@@ -3208,11 +3450,11 @@
3208 3450 } else {
3209 3451 jQuery(md).find('.scrolling.content').html(accordWrapper);
3210 3452 }
3211 3453
3212 - jQuery('#change-history-according-wrapper .ui.accordion').accordion({exclusive: true});
3454 + jQuery('#change-history-according-wrapper .ui.accordion').accordion({ exclusive: true });
3213 3455
3214 - jQuery('.mainwp-day-history-switch-view').off('click.accordionFix').on('click.accordionFix', function(e){
3456 + jQuery('.mainwp-day-history-switch-view').off('click.accordionFix').on('click.accordionFix', function (e) {
3215 3457 e.preventDefault();
3216 3458 e.stopPropagation(); // now it runs before ancestor handlers
3217 3459 dayHistory_SwitchViewHandler(this);
3218 3460 return false;
@@ -3218,23 +3460,23 @@
3218 3460 return false;
3219 3461 });
3220 3462 }
3221 3463
3222 - if ( response?.onward_date ) {
3464 + if (response?.onward_date) {
3223 3465 jQuery(md).find('.actions .col-left').html('Data available from ' + response.onward_date + ' onward.');
3224 3466 }
3225 - if ( response?.more_date ) {
3226 - jQuery(md).find('.actions .col-right').html('<a href="javascript:void(0);" onclick="mainwp_item_changes_load(false,\'' + ( response.more_date ?? get_local_date_string() ) + '\');return false;">' + __('Load More') + '</a>');
3467 + if (response?.more_date) {
3468 + jQuery(md).find('.actions .col-right').html('<a href="javascript:void(0);" onclick="mainwp_item_changes_load(false,\'' + (response.more_date ?? get_local_date_string()) + '\');return false;">' + MainWP.I18n.t('Load More') + '</a>');
3227 3469 }
3228 3470 }
3229 - } else if(parentContent){
3230 - let err_content = '<div class="ui message red">' + __('Undefined error occurred. Please try again.') + '</div>';
3471 + } else if (parentContent) {
3472 + let err_content = '<div class="ui message red">' + MainWP.I18n.t('Undefined error occurred. Please try again.') + '</div>';
3231 3473 jQuery(parentContent).html(err_content);
3232 3474 }
3233 3475 }, 'json');
3234 3476 }
3235 3477
3236 -let get_icon_history_event = function( act ){
3478 +let get_icon_history_event = function (act) {
3237 3479 let icon = '';
3238 3480
3239 3481 if (act === 'delete' || act === 'deleted') {
3240 3482 icon = 'trash red';
@@ -3252,16 +3494,16 @@
3252 3494
3253 3495 return icon;
3254 3496 }
3255 3497
3256 -let get_color_changes_event = function( act ){
3498 +let get_color_changes_event = function (act) {
3257 3499 const actColorMap = {
3258 - red: ['deleted','removed','revoked','delete','deactivated','disabled','suspended','deactivate'],
3259 - orange: ['updated','modified','update'],
3500 + red: ['deleted', 'removed', 'revoked', 'delete', 'deactivated', 'disabled', 'suspended', 'deactivate'],
3501 + orange: ['updated', 'modified', 'update'],
3260 3502 grey: ['opened'],
3261 - blue: ['logged-in','logged-out'],
3262 - teal: ['sync','installed','install','uploaded'],
3263 - green: ['activated','activate','created','published','enabled','added']
3503 + blue: ['logged-in', 'logged-out'],
3504 + teal: ['sync', 'installed', 'install', 'uploaded'],
3505 + green: ['activated', 'activate', 'created', 'published', 'enabled', 'added']
3264 3506 };
3265 3507
3266 3508 let color = '';
3267 3509
@@ -3305,16 +3547,16 @@
3305 3547 if (response.error != undefined) {
3306 3548 dayContent.append('<div class="ui message red changes-history-status">' + response.error + '</div>');
3307 3549 } else if (response?.list) {
3308 3550 if (response.list.length == 0) {
3309 - let msg = __('This plugin has no recorded activity in Dashboard Insights.');
3551 + let msg = MainWP.I18n.t('This plugin has no recorded activity in Dashboard Insights.');
3310 3552 if ('theme' === type && '' === dt) {
3311 - msg = __('This theme has no recorded activity in Dashboard Insights.');
3553 + msg = MainWP.I18n.t('This theme has no recorded activity in Dashboard Insights.');
3312 3554 } else if ('' !== dt) {
3313 3555 if ('plugin' === type) {
3314 - msg = __('No history changes found for the plugin on this day.');
3556 + msg = MainWP.I18n.t('No history changes found for the plugin on this day.');
3315 3557 } else {
3316 - msg = __('No history changes found for the theme on this day.');
3558 + msg = MainWP.I18n.t('No history changes found for the theme on this day.');
3317 3559 }
3318 3560 }
3319 3561 dayContent.append('<div class="ui message changes-history-status">' + msg + '</div>');
3320 3562 } else {
@@ -3330,9 +3572,9 @@
3330 3572 <i class="dropdown icon"></i>
3331 3573 ${name}
3332 3574 </div>
3333 3575 <div class="six wide column right aligned">
3334 - <button type="button" class="ui circular blue mini button mainwp-list-history-switch-view">` + ( 'plugin' === type ? __('Plugin History') : __('Theme History') ) + `</button> <button class="ui basic mini button ">${records.length} ` + __('Actions') + `</button>
3576 + <button type="button" class="ui circular blue mini button mainwp-list-history-switch-view">` + ('plugin' === type ? MainWP.I18n.t('Plugin History') : MainWP.I18n.t('Theme History')) + `</button> <button class="ui basic mini button ">${records.length} ` + MainWP.I18n.t('Actions') + `</button>
3335 3577 </div>
3336 3578 </div>
3337 3579 </div>
3338 3580 </div>
@@ -3341,9 +3583,9 @@
3341 3583 content += `<div class="item" log-id="${record.details.log_id}">
3342 3584 <div class="ui grid">
3343 3585 <div class="eight wide column middle aligned">
3344 3586 <i class="` + get_icon_history_event(record.details.action) + ` icon"></i>
3345 - <span class="ui text ` + get_color_changes_event(record.details.action) + `">${record.details.event}</span> ` + __('by') + ` <strong>${record.details.author_name}</strong> ` + __('from') + `
3587 + <span class="ui text ` + get_color_changes_event(record.details.action) + `">${record.details.event}</span> ` + MainWP.I18n.t('by') + ` <strong>${record.details.author_name}</strong> ` + MainWP.I18n.t('from') + `
3346 3588 <strong>${record.details.source}</strong>
3347 3589 </div>
3348 3590 <div class="six wide column middle aligned">
3349 3591 ` + (record.details?.old_version && record.details?.version ? record.details.old_version + '&rarr;' + record.details.version : '') + `
@@ -3359,17 +3601,17 @@
3359 3601 </div>`;
3360 3602 });
3361 3603
3362 3604 if ('' !== content) {
3363 - jQuery(md).find('.ui.header .main-text').text(his_date + ' ' + __('History'));
3605 + jQuery(md).find('.ui.header .main-text').text(his_date + ' ' + MainWP.I18n.t('History'));
3364 3606 let accordWrapper = jQuery("<div>", {
3365 3607 id: "change-history-according-wrapper",
3366 3608 html: content
3367 3609 });
3368 3610 jQuery(md).find('.scrolling.content').html(accordWrapper);
3369 - jQuery('#change-history-according-wrapper .ui.accordion').accordion({exclusive: true});
3611 + jQuery('#change-history-according-wrapper .ui.accordion').accordion({ exclusive: true });
3370 3612
3371 - jQuery('.mainwp-list-history-switch-view').off('click.accordionFix2').on('click.accordionFix2', function(e){
3613 + jQuery('.mainwp-list-history-switch-view').off('click.accordionFix2').on('click.accordionFix2', function (e) {
3372 3614 e.preventDefault();
3373 3615 e.stopPropagation(); // now it runs before ancestor handlers
3374 3616 listHistory_SwitchViewHandler(this);
3375 3617 return false;
@@ -3376,9 +3618,9 @@
3376 3618 });
3377 3619 }
3378 3620 }
3379 3621 } else {
3380 - dayContent.html('<div class="ui message red changes-history-status">' + __('Undefined error occurred. Please try again.') + '</div>');
3622 + dayContent.html('<div class="ui message red changes-history-status">' + MainWP.I18n.t('Undefined error occurred. Please try again.') + '</div>');
3381 3623 }
3382 3624 }, 'json');
3383 3625
3384 3626 return false;
@@ -3395,19 +3637,19 @@
3395 3637
3396 3638 let md = jQuery('#mainwp-plugin-theme-history-changes-modal');
3397 3639 const type = jQuery(md).attr('history-type');
3398 3640
3399 - if('theme' === type){
3641 + if ('theme' === type) {
3400 3642 themeChangesLoadData.slug = jQuery(parent).data('slug');
3401 3643 themeChangesLoadData.name = jQuery(parent).data('name');
3402 3644 themeChangesLoadData.siteId = jQuery(parent).data('siteid');
3403 3645 themeChangesLoadData.from_date = '';
3404 - }else{
3646 + } else {
3405 3647 pluginChangesLoadData.slug = jQuery(parent).data('slug');;
3406 3648 pluginChangesLoadData.siteId = jQuery(parent).data('siteid');;
3407 3649 pluginChangesLoadData.from_date = '';
3408 3650 }
3409 - mainwp_item_changes_load( btn );
3651 + mainwp_item_changes_load(btn);
3410 3652 }
3411 3653
3412 3654
3413 3655 /**
@@ -3417,9 +3659,9 @@
3417 3659
3418 3660 globalThis.mainwp_install_check_plugin_prepare = function (slug) {
3419 3661 let selected = jQuery("input[name='install_checker[]']:checked");
3420 3662 if (selected.length == 0) {
3421 - feedback('mainwp-message-zone-install', __('Please select website to install plugin.'), 'yellow');
3663 + feedback('mainwp-message-zone-install', MainWP.I18n.t('Please select website to install plugin.'), 'yellow');
3422 3664 return;
3423 3665 } else {
3424 3666 selected.each(function () {
3425 3667 jQuery(this).closest('.siteBulkInstall').attr('status', 'queue');
@@ -3469,19 +3711,19 @@
3469 3711 if (response.error != undefined) {
3470 3712 statusEl.html(response.error);
3471 3713 statusEl.css('color', 'red');
3472 3714 } else if (response?.ok[siteToInstall.attr('siteid')]) {
3473 - statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Installation completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>');
3715 + statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Installation completed successfully.') + '"><i class="check green icon"></i></span>');
3474 3716 } else if (response?.errors[siteToInstall.attr('siteid')]) {
3475 3717 statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + response.errors[siteToInstall.attr('siteid')][1] + '"><i class="times red icon"></i></span>');
3476 3718 } else {
3477 - statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Undefined error occurred. Please try again.', 'mainwp') + '"><i class="times red icon"></i></span>');
3719 + statusEl.html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Undefined error occurred. Please try again.') + '"><i class="times red icon"></i></span>');
3478 3720 }
3479 3721
3480 3722 bulkInstallCurrentThreads--;
3481 3723 bulkInstallDone++;
3482 3724 jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').progress('set progress', bulkInstallDone);
3483 - jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + __('Installed'));
3725 + jQuery('#plugintheme-installation-progress-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + MainWP.I18n.t('Installed'));
3484 3726 mainwp_install_check_plugin_start_next(url);
3485 3727 }
3486 3728 }(url, siteToInstall), 'json');
3487 3729 };
@@ -3566,9 +3808,9 @@
3566 3808
3567 3809 jQuery(document).on('click', '.mainwp-edit-site-note', function () {
3568 3810 let id = jQuery(this).attr('id').substring(13);
3569 3811 let note = jQuery('#mainwp-notes-' + id + '-note').html();
3570 - jQuery('#mainwp-notes-html').html(note == '' ? __('No saved notes. Click the Edit button to edit site notes.') : note);
3812 + jQuery('#mainwp-notes-html').html(note == '' ? MainWP.I18n.t('No saved notes. Click the Edit button to edit site notes.') : note);
3571 3813 jQuery('#mainwp-notes-note').val(note);
3572 3814 jQuery('#mainwp-notes-websiteid').val(id);
3573 3815 jQuery('#mainwp-which-note').val('site'); // to fix conflict.
3574 3816 mainwp_notes_show();
@@ -3623,21 +3865,21 @@
3623 3865 websiteid: normalid,
3624 3866 note: newnote
3625 3867 });
3626 3868
3627 - jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + __('Saving note. Please wait...')).show();
3869 + jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Saving note. Please wait...')).show();
3628 3870
3629 3871 jQuery.post(ajaxurl, data, function (response) {
3630 3872 if (response.error != undefined) {
3631 3873 jQuery('#mainwp-notes-status').html(response.error).addClass('red');
3632 3874 } else if (response.result == 'SUCCESS') {
3633 - jQuery('#mainwp-notes-status').html(__('Note saved successfully.')).addClass('green');
3875 + jQuery('#mainwp-notes-status').html(MainWP.I18n.t('Note saved successfully.')).addClass('green');
3634 3876 if (jQuery('#mainwp-notes-' + normalid + '-note').length > 0) {
3635 3877 jQuery('#mainwp-notes-' + normalid + '-note').html(response?.esc_note_content ?? '');
3636 3878 jQuery('#mainwp-notes-html').html(response?.esc_note_content ?? '');
3637 3879 }
3638 3880 } else {
3639 - jQuery('#mainwp-notes-status').html(__('Undefined error occured while saving your note!')).addClass('red');
3881 + jQuery('#mainwp-notes-status').html(MainWP.I18n.t('Undefined error occurred while saving your note!')).addClass('red');
3640 3882 }
3641 3883 }, 'json');
3642 3884
3643 3885 setTimeout(function () {
@@ -3652,9 +3894,9 @@
3652 3894 };
3653 3895
3654 3896 globalThis.getErrorMessage = function (pError, msgOnly) { // NOSONAR - complex.
3655 3897 if (pError.message == 'HTTPERROR') {
3656 - return __('HTTP error') + '! ' + pError.extra;
3898 + return MainWP.I18n.t('HTTP error') + '! ' + pError.extra;
3657 3899 } else if (pError.message == 'NOMAINWP' || pError == 'NOMAINWP') {
3658 3900 return mainwp_js_get_error_not_detected_connect();
3659 3901 } else if (pError.message == 'ERROR') {
3660 3902 return 'ERROR' + ((pError.extra != '') && (pError.extra != undefined) ? ': ' + pError.extra : '');
@@ -3662,9 +3904,9 @@
3662 3904 let extrMsg = (pError.extra != '') && (pError.extra != undefined) ? pError.extra : '';
3663 3905 if (msgOnly != undefined && msgOnly && extrMsg != '') {
3664 3906 return extrMsg;
3665 3907 } else {
3666 - return __('ERROR on the child site') + ': ' + extrMsg;
3908 + return MainWP.I18n.t('ERROR on the child site') + ': ' + extrMsg;
3667 3909 }
3668 3910
3669 3911 } else if (pError.message != undefined && pError.message != '') {
3670 3912 return pError.message;
@@ -3677,10 +3919,10 @@
3677 3919 let msg = '';
3678 3920 let msgUI = '<i class="red times icon"></i>';
3679 3921
3680 3922 if (repError.errorCode != undefined && repError.errorCode == 'SUSPENDED_SITE') {
3681 - msg = __('Suspended site.');
3682 - msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + __('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
3923 + msg = MainWP.I18n.t('Suspended site.');
3924 + msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>';
3683 3925 }
3684 3926
3685 3927 if (repError.errorCode != undefined && repError.errorCode == 'MAINWP_NOTICE') {
3686 3928 if (repError.message != undefined) {
@@ -3745,22 +3987,45 @@
3745 3987 return (this.length !== 0);
3746 3988 };
3747 3989
3748 3990
3749 -function __(text, _var1, _var2, _var3) {
3750 - if (text == undefined || text == '')
3991 +globalThis.MainWP = globalThis.MainWP || {};
3992 +globalThis.MainWP.I18n = globalThis.MainWP.I18n || {};
3993 +
3994 +MainWP.I18n.t = function (text, ...args) {
3995 + if (!text) {
3751 3996 return text;
3752 - let strippedText = text.replaceAll(/\W/g, '_');
3997 + }
3753 3998
3754 - if (strippedText == '')
3755 - return text.replace('%1', _var1).replace('%2', _var2).replace('%3', _var3);
3999 + // Replace non-alphanumeric characters (including Unicode/accented characters) with '_'
4000 + const strippedText = text.replace(/[^\p{L}\p{N}_]/gu, '_');
3756 4001
3757 - if (mainwpTranslations == undefined)
3758 - return text.replace('%1', _var1).replace('%2', _var2).replace('%3', _var3);
3759 - if (mainwpTranslations[strippedText] == undefined)
3760 - return text.replace('%1', _var1).replace('%2', _var2).replace('%3', _var3);
4002 + let translated = text;
3761 4003
3762 - return mainwpTranslations[strippedText].replace('%1', _var1).replace('%2', _var2).replace('%3', _var3);
4004 + if (
4005 + strippedText &&
4006 + typeof mainwpTranslations !== 'undefined' &&
4007 + mainwpTranslations[strippedText] !== undefined
4008 + ) {
4009 + translated = mainwpTranslations[strippedText];
4010 + }
4011 +
4012 + if (args.length === 0) {
4013 + return translated;
4014 + }
4015 +
4016 + // Single-pass replacement to avoid placeholder collision issues
4017 + return translated.replace(/%(\d+)/g, (match, index) => {
4018 + const argIdx = parseInt(index, 10) - 1;
4019 + return args[argIdx] !== undefined ? args[argIdx] : match;
4020 + });
4021 +};
4022 +
4023 +// Deprecated. Remove in a future release.
4024 +if (typeof globalThis.__ !== 'function') {
4025 + globalThis.__ = function (text, ...args) {
4026 + return globalThis.MainWP.I18n.t(text, ...args);
4027 + };
3763 4028 }
3764 4029
3765 4030 globalThis.mainwp_secure_data = function (data, includeDts) {
3766 4031 if (data['action'] == undefined)
@@ -3912,9 +4177,9 @@
3912 4177 let o = i.toString();
3913 4178 if (!s) {
3914 4179 s = '0';
3915 4180 }
3916 - while (o.length < Number.parseInt(l)) {
4181 + while (o.length < Number.parseInt(l)) {
3917 4182 // empty
3918 4183 if (w == 'undefined') {
3919 4184 o = s + o;
3920 4185 } else {
@@ -3981,13 +4246,18 @@
3981 4246
3982 4247 // Hide after installtion notices (PHP version, Trust MainWP Child, Multisite Warning and OpenSSL warning)
3983 4248 jQuery(document).on('click', '.mainwp-notice-dismiss', function () {
3984 4249 let notice_id = jQuery(this).attr('notice-id');
4250 + let shortterm = jQuery(this).attr('shortterm-notice');
4251 +
3985 4252 jQuery(this).closest('.ui.message').fadeOut("slow");
3986 4253 let data = {
3987 4254 action: 'mainwp_notice_status_update'
3988 4255 };
3989 4256 data['notice_id'] = notice_id;
4257 + if(shortterm === '1'){
4258 + data['short_term'] = 1;
4259 + }
3990 4260 jQuery.post(ajaxurl, mainwp_secure_data(data), function () { });
3991 4261 return false;
3992 4262 });
3993 4263
@@ -3996,9 +4266,9 @@
3996 4266 let data = {
3997 4267 action: 'mainwp_notice_status_update'
3998 4268 };
3999 4269 data['notice_id'] = notice_id;
4000 - if ( time_set !== undefined ) {
4270 + if (time_set !== undefined) {
4001 4271 data['time_set'] = time_set ? 1 : 0;
4002 4272 }
4003 4273 jQuery.post(ajaxurl, mainwp_secure_data(data), function () {
4004 4274 });
@@ -4132,14 +4402,14 @@
4132 4402 $('#mainwp_sites_changes_bulk_dismiss_selected_btn').on('click', function () {
4133 4403 if (jQuery('#mainwp-module-log-records-body-table tr').find('input[type="checkbox"]:checked').length == 0) {
4134 4404 return;
4135 4405 }
4136 - let confirmMsg = __("You are about to dismiss the selected changes?");
4406 + let confirmMsg = MainWP.I18n.t("You are about to dismiss the selected changes?");
4137 4407 mainwp_confirm(confirmMsg, function () { mainwp_sites_changes_actions_bulk_action('dismiss-selected'); });
4138 4408 });
4139 4409
4140 4410 $('#mainwp_sites_changes_bulk_dismiss_all_btn').on('click', function () {
4141 - let confirmMsg = __("You are about to dismiss all changes?");
4411 + let confirmMsg = MainWP.I18n.t("You are about to dismiss all changes?");
4142 4412 mainwp_confirm(confirmMsg, function () { mainwp_sites_changes_actions_bulk_action('dismiss-all'); });
4143 4413 });
4144 4414
4145 4415 // Trigger the bulk actions
@@ -4146,9 +4416,9 @@
4146 4416 $('#mainwp_widget_sites_changes_bulk_dismiss_selected_btn').on('click', function () {
4147 4417 if (jQuery('#mainwp-module-log-records-body-table tr').find('input[type="checkbox"]:checked').length == 0) {
4148 4418 return;
4149 4419 }
4150 - let confirmMsg = __("You are about to dismiss the selected changes?");
4420 + let confirmMsg = MainWP.I18n.t("You are about to dismiss the selected changes?");
4151 4421 mainwp_confirm(confirmMsg, function () { mainwp_sites_changes_actions_bulk_action('dismiss-selected', 'widget'); });
4152 4422 });
4153 4423
4154 4424 $(document).on('click', '.insights-actions-row-dismiss', function () {
@@ -4182,9 +4452,9 @@
4182 4452 })
4183 4453
4184 4454 let mainwp_insights_row_actions_dismiss = function (obj) {
4185 4455 let row = jQuery(obj).closest('tr');
4186 - let confirmMsg = __("You are about to dismiss the selected change?");
4456 + let confirmMsg = MainWP.I18n.t("You are about to dismiss the selected change?");
4187 4457
4188 4458 const renderMessage = (icon, message) => {
4189 4459 row.html(
4190 4460 '<td></td><td colspan="999"><i class="' +
@@ -4625,14 +4895,14 @@
4625 4895 });
4626 4896
4627 4897 // Force Dashboard to reestablish connection by destroying sessions - Part 1
4628 4898 let mainwp_force_destroy_sessions = function () {
4629 - let confirmMsg = __('Are you sure you want to force your MainWP Dashboard to reconnect with your child sites?');
4899 + let confirmMsg = MainWP.I18n.t('Are you sure you want to force your MainWP Dashboard to reconnect with your child sites?');
4630 4900 mainwp_confirm(confirmMsg, function () {
4631 4901 mainwp_force_destroy_sessions_websites = jQuery('.dashboard_wp_id[error-status=0]').map(function (indx, el) {
4632 4902 return jQuery(el).val();
4633 4903 });
4634 - mainwpPopup('#mainwp-sync-sites-modal').setTitle(__('Re-establish Connection')); // popup displayed.
4904 + mainwpPopup('#mainwp-sync-sites-modal').setTitle(MainWP.I18n.t('Re-establish Connection')); // popup displayed.
4635 4905 mainwpPopup('#mainwp-sync-sites-modal').init({ progressMax: mainwp_force_destroy_sessions_websites.length });
4636 4906 mainwp_force_destroy_sessions_part_2(0);
4637 4907 });
4638 4908 };
@@ -4663,9 +4933,9 @@
4663 4933 } else if ('success' in response) {
4664 4934 mainwp_force_destroy_sessions_successed += 1;
4665 4935 dashboard_update_site_status(website_id, '<i class="check green icon"></i>', true);
4666 4936 } else {
4667 - dashboard_update_site_status(website_id, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Process timed out. Please try again.', 'mainwp') + '">');
4937 + dashboard_update_site_status(website_id, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Process timed out. Please try again.') + '">');
4668 4938 }
4669 4939 }, 'json').fail(function () {
4670 4940 let counter = id + 1;
4671 4941 mainwp_force_destroy_sessions_part_2(counter);
@@ -4697,9 +4967,9 @@
4697 4967 let mainwp_import_demo_data_action = function (obj) {
4698 4968 let confirmation = "Are you sure you want to import demo content into your MainWP Dashboard?";
4699 4969 let msg_import = (jQuery(obj).attr('page-import') == 'qsw-import') ? '&message=qsw-import' : '';
4700 4970 mainwp_confirm(confirmation, function () {
4701 - feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Importing. Please wait...', 'mainwp'), '');
4971 + feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Importing. Please wait...'), '');
4702 4972 let data = mainwp_secure_data({
4703 4973 action: 'mainwp_import_demo_data',
4704 4974 });
4705 4975
@@ -4705,12 +4975,12 @@
4705 4975
4706 4976 jQuery.post(ajaxurl, data, function (response) {
4707 4977 let error = false;
4708 4978 if (response.count === undefined) {
4709 - error = true;
4710 - feedback('mainwp-message-zone', __('Undefined error. Please try again.', 'mainwp'), 'green');
4979 + error = true;
4980 + feedback('mainwp-message-zone', MainWP.I18n.t('Undefined error. Please try again.'), 'green');
4711 4981 } else {
4712 - feedback('mainwp-message-zone', __('The demo content has been imported into your MainWP Dashboard.', 'mainwp'), 'green');
4982 + feedback('mainwp-message-zone', MainWP.I18n.t('The demo content has been imported into your MainWP Dashboard.'), 'green');
4713 4983 }
4714 4984
4715 4985 if (!error) {
4716 4986 setTimeout(function () {
@@ -4723,9 +4993,9 @@
4723 4993
4724 4994 let mainwp_remove_demo_data_action = function () {
4725 4995 let confirmation = "Are you sure you want to delete demo content from your MainWP Dashboard?";
4726 4996 mainwp_confirm(confirmation, function () {
4727 - feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Deleting. Please wait...', 'mainwp'), '');
4997 + feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Deleting. Please wait...'), '');
4728 4998 let data = mainwp_secure_data({
4729 4999 action: 'mainwp_delete_demo_data',
4730 5000 });
4731 5001 jQuery.post(ajaxurl, data, function (response) {
@@ -4731,11 +5001,11 @@
4731 5001 jQuery.post(ajaxurl, data, function (response) {
4732 5002 let error = false;
4733 5003 if (response.success === undefined) {
4734 5004 error = true;
4735 - feedback('mainwp-message-zone', __('Undefined error. Please try again.', 'mainwp'), 'green');
5005 + feedback('mainwp-message-zone', MainWP.I18n.t('Undefined error. Please try again.'), 'green');
4736 5006 } else {
4737 - feedback('mainwp-message-zone', __('The demo content has been deleted from your MainWP Dashboard.', 'mainwp'), 'green');
5007 + feedback('mainwp-message-zone', MainWP.I18n.t('The demo content has been deleted from your MainWP Dashboard.'), 'green');
4738 5008 }
4739 5009
4740 5010 if (!error) {
4741 5011 setTimeout(function () {
@@ -4790,9 +5060,9 @@
4790 5060 jQuery("input[name='selected_sites[]']:checked").each(function () {
4791 5061 selected_sites.push(jQuery(this).val());
4792 5062 });
4793 5063 if (selected_sites.length == 0) {
4794 - errors.push(__('Please select at least one website to start.'));
5064 + errors.push(MainWP.I18n.t('Please select at least one website to start.'));
4795 5065 }
4796 5066
4797 5067 if (errors.length > 0) {
4798 5068 mainwp_set_message_zone('#mainwp-message-zone-modal', errors.join('<br />'), 'yellow');
@@ -4800,9 +5070,9 @@
4800 5070 } else {
4801 5071 mainwp_set_message_zone('#mainwp-message-zone-modal');
4802 5072 }
4803 5073
4804 - let confirmation = __("This process will create a new OpenSSL Key Pair on your MainWP Dashboard and Set the new Public Key to your Child site(s). Are you sure you want to proceed?");
5074 + let confirmation = MainWP.I18n.t("This process will create a new OpenSSL Key Pair on your MainWP Dashboard and Set the new Public Key to your Child site(s). Are you sure you want to proceed?");
4805 5075
4806 5076 mainwp_confirm(confirmation, function () {
4807 5077 jQuery(objBtn).attr('disabled', true);
4808 5078
@@ -4808,9 +5078,9 @@
4808 5078
4809 5079 jQuery('#mainwp-tool-renew-connect-modal .mainwp-select-sites-wrapper').hide();
4810 5080
4811 5081 let statusEl = jQuery('#mainwp-message-zone-modal');
4812 - statusEl.html('<i class="notched circle loading icon"></i> ' + __('Please wait...'));
5082 + statusEl.html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Please wait...'));
4813 5083 statusEl.show();
4814 5084
4815 5085 let data = mainwp_secure_data({
4816 5086 action: 'mainwp_prepare_renew_connections',
@@ -4838,9 +5108,9 @@
4838 5108 }
4839 5109
4840 5110 if (undefError) {
4841 5111 statusEl.addClass('red');
4842 - statusEl.html(__('Undefined error occurred. Please try again.')).fadeIn();
5112 + statusEl.html(MainWP.I18n.t('Undefined error occurred. Please try again.')).fadeIn();
4843 5113 }
4844 5114 }, 'json');
4845 5115 }, false, false, true);
4846 5116 }
@@ -4866,22 +5136,22 @@
4866 5136 action: 'mainwp_renew_connections',
4867 5137 siteid: siteId
4868 5138 });
4869 5139
4870 - connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Processing...', 'mainwp') + '"><i class="sync alternate loading icon"></i></span>');
5140 + connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Processing...') + '"><i class="sync alternate loading icon"></i></span>');
4871 5141 jQuery.post(ajaxurl, data, function (response) {
4872 5142 if (response.error) {
4873 5143 connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + response.error + '"><i class="times red icon"></i></span>');
4874 5144 } else if (response.result == 'success') {
4875 - connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Renew connnection process completed successfully.', 'mainwp') + '"><i class="check green icon"></i></span>');
5145 + connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Renew connnection process completed successfully.') + '"><i class="check green icon"></i></span>');
4876 5146 } else {
4877 - connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Undefined error.') + '"><i class="times red icon"></i></span>');
5147 + connection_renew_status(siteId, '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Undefined error.') + '"><i class="times red icon"></i></span>');
4878 5148
4879 5149 }
4880 5150 bulkInstallCurrentThreads--;
4881 5151 bulkInstallDone++;
4882 5152 jQuery('#mainwp-tool-renew-connect-modal .mainwp-modal-progress').progress('set progress', bulkInstallDone);
4883 - jQuery('#mainwp-tool-renew-connect-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + __('Processed'));
5153 + jQuery('#mainwp-tool-renew-connect-modal .mainwp-modal-progress').find('.label').html(bulkInstallDone + '/' + mainwpVars.bulkInstallTotal + ' ' + MainWP.I18n.t('Processed'));
4884 5154 mainwp_tool_renew_connections_start_next();
4885 5155 }, 'json');
4886 5156 }
4887 5157
@@ -5013,9 +5283,9 @@
5013 5283 me = $('.settings-field-indicator-wrapper.custom-payment-methods');
5014 5284 }
5015 5285 }
5016 5286
5017 - if(me === undefined) {
5287 + if (me === undefined) {
5018 5288 mainwp_settings_fields_value_on_change(this, val);
5019 5289 } else {
5020 5290 mainwp_settings_fields_value_on_change(me, val);
5021 5291 }
@@ -5054,15 +5324,15 @@
5054 5324 if (!globalThis.mainwpSegmentModalUiHandle) {
5055 5325 globalThis.mainwpSegmentModalUiHandle = (function () {
5056 5326 let _instance = {
5057 5327 loadingStatus: function () {
5058 - $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + __('Loading segments. Please wait...')).show();
5328 + $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Loading segments. Please wait...')).show();
5059 5329 },
5060 5330 savingStatus: function () {
5061 - $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + __('Saving segment. Please wait...')).show();
5331 + $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Saving segment. Please wait...')).show();
5062 5332 },
5063 5333 deletingStatus: function () {
5064 - $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + __('Deleting segment. Please wait...')).show();
5334 + $('#mainwp-common-filter-edit-segment-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Deleting segment. Please wait...')).show();
5065 5335
5066 5336 },
5067 5337 showStatus: function (status, addClass) {
5068 5338 if (addClass) {
@@ -5073,9 +5343,9 @@
5073 5343 hideSegmentStatus: function () {
5074 5344 $('#mainwp-common-filter-edit-segment-status').removeClass('red green').hide();
5075 5345 },
5076 5346 showSegment: function (btnObj) {
5077 - jQuery('#mainwp-common-filter-segment-modal > div.header').html(__('Save Segment'));
5347 + jQuery('#mainwp-common-filter-segment-modal > div.header').html(MainWP.I18n.t('Save Segment'));
5078 5348 jQuery('#mainwp-common-filter-segment-edit-fields').show();
5079 5349 jQuery('#mainwp-common-filter-edit-segment-save').show();
5080 5350 jQuery('#mainwp-common-filter-segment-select-fields').hide();
5081 5351 jQuery('#mainwp-common-filter-select-segment-choose-button').hide();
@@ -5086,9 +5356,9 @@
5086 5356 },
5087 5357 loadSegment: function (loadCallback) {
5088 5358 jQuery('#mainwp-common-filter-segment-edit-fields').hide();
5089 5359 jQuery('#mainwp-common-filter-edit-segment-save').hide();
5090 - jQuery('#mainwp-common-filter-segment-modal > div.header').html(__('Load Segment'));
5360 + jQuery('#mainwp-common-filter-segment-modal > div.header').html(MainWP.I18n.t('Load Segment'));
5091 5361 jQuery('#mainwp-common-filter-segment-select-fields').show();
5092 5362 jQuery('#mainwp-common-filter-select-segment-choose-button').show();
5093 5363 jQuery('#mainwp-common-filter-select-segment-delete-button').show();
5094 5364 this.hideSegmentStatus();
@@ -5142,9 +5412,9 @@
5142 5412 wgids: JSON.stringify(wgIds),
5143 5413 item_id: item_id,
5144 5414 page_widget: page_widget
5145 5415 };
5146 - jQuery.post(ajaxurl, mainwp_secure_data(postVars), function () {});
5416 + jQuery.post(ajaxurl, mainwp_secure_data(postVars), function () { });
5147 5417 }
5148 5418
5149 5419 globalThis.mainwp_init_ui_calendar = ($selectors) => {
5150 5420 jQuery($selectors).calendar({
@@ -5194,12 +5464,12 @@
5194 5464
5195 5465 $(document).on('click', '#delete_uptime_monitor_btn', function () {
5196 5466 let is_sub = $('#monitor_edit_is_sub_url')?.val();
5197 5467
5198 - let confirmation = __("Are you sure you want to delete this uptime monitor?");
5468 + let confirmation = MainWP.I18n.t("Are you sure you want to delete this uptime monitor?");
5199 5469
5200 5470 if (is_sub) {
5201 - confirmation = __("Are you sure you want to delete this uptime sub-page monitor?");
5471 + confirmation = MainWP.I18n.t("Are you sure you want to delete this uptime sub-page monitor?");
5202 5472 }
5203 5473
5204 5474 mainwp_confirm(confirmation, () => {
5205 5475 let wpid = $('#mainwp_edit_monitor_site_id').val();
@@ -5210,9 +5480,9 @@
5210 5480 });
5211 5481
5212 5482 let mainwp_uptime_monitoring_remove = function (wpid, moid) {
5213 5483
5214 - feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Removing Uptime Monitor...'), 'green');
5484 + feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Removing Uptime Monitor...'), 'green');
5215 5485
5216 5486 let data = mainwp_secure_data({
5217 5487 action: 'mainwp_uptime_monitoring_remove_monitor',
5218 5488 wpid: wpid,
@@ -5220,9 +5490,9 @@
5220 5490 });
5221 5491
5222 5492 jQuery.post(ajaxurl, data, function (response) {
5223 5493 if (response?.success) {
5224 - feedback('mainwp-message-zone', __('Monitor have been removed.'), 'green');
5494 + feedback('mainwp-message-zone', MainWP.I18n.t('Monitor have been removed.'), 'green');
5225 5495 setTimeout(function () {
5226 5496 mainwp_forceReload('admin.php?page=managesites&id=' + wpid);
5227 5497 }, 2000);
5228 5498
@@ -5228,9 +5498,9 @@
5228 5498
5229 5499 } else if (response?.error) {
5230 5500 feedback('mainwp-message-zone', response.error, 'red');
5231 5501 } else {
5232 - feedback('mainwp-message-zone', __('Undefined error. Please try again.'), 'red');
5502 + feedback('mainwp-message-zone', MainWP.I18n.t('Undefined error. Please try again.'), 'red');
5233 5503 }
5234 5504 }, 'json');
5235 5505 return false;
5236 5506 };
@@ -5235,9 +5505,9 @@
5235 5505 return false;
5236 5506 };
5237 5507
5238 5508 $(document).on('click', '#increase-connection-security-btn', function () {
5239 - feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + __('Encryption in progress! Securing your OpenSSL private keys, this may take a few moments. Please wait until completed.'), 'green');
5509 + feedback('mainwp-message-zone', '<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Encryption in progress! Securing your OpenSSL private keys, this may take a few moments. Please wait until completed.'), 'green');
5240 5510 let data = mainwp_secure_data({
5241 5511 action: 'mainwp_increase_connection_security',
5242 5512 });
5243 5513 jQuery.post(ajaxurl, data, function (response) {
@@ -5248,16 +5518,16 @@
5248 5518
5249 5519 } else if (response?.error) {
5250 5520 feedback('mainwp-message-zone', response.error, 'red');
5251 5521 } else {
5252 - feedback('mainwp-message-zone', __('Undefined error. Please try again.'), 'red');
5522 + feedback('mainwp-message-zone', MainWP.I18n.t('Undefined error. Please try again.'), 'red');
5253 5523 }
5254 5524 }, 'json');
5255 5525 return false;
5256 5526 });
5257 5527 jQuery('#module-update-logs-db-requirement').on('click', function () {
5258 - let msg = __('Are you sure?');
5259 - mainwp_confirm(msg, () => {
5528 + let msg = MainWP.I18n.t('Are you sure?');
5529 + mainwp_confirm(msg, () => {
5260 5530 jQuery(this).closest('.ui.message').fadeOut();
5261 5531 mainwp_module_logs_start_update_dismissed_db();
5262 5532 });
5263 5533 return false;
@@ -5282,11 +5552,11 @@
5282 5552 let data = mainwp_secure_data({
5283 5553 action: 'mainwp_module_log_update_dismissed_db',
5284 5554 });
5285 5555 if (logs_update_db_cancelled) {
5286 - mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="close icon"></i>' + __("User cancelled the 'Sites Changes' database update process."), 'green');
5556 + mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="close icon"></i>' + MainWP.I18n.t("User cancelled the 'Sites Changes' database update process."), 'green');
5287 5557 } else {
5288 - mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="ui active inline loader tiny"></i> ' + __('Updating the \'Sites Changes\' database. Click %1here%2 to cancel.', '<a href="javascript:void(0);" id="module-update-logs-db-cancel">', '</a>'), 'green');
5558 + mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="ui active inline loader tiny"></i> ' + MainWP.I18n.t('Updating the \'Sites Changes\' database. Click %1here%2 to cancel.', '<a href="javascript:void(0);" id="module-update-logs-db-cancel">', '</a>'), 'green');
5289 5559 }
5290 5560 jQuery.post(ajaxurl, data, function (response) {
5291 5561 let status = response?.status ?? '';
5292 5562 if (response.error) {
@@ -5291,9 +5561,9 @@
5291 5561 let status = response?.status ?? '';
5292 5562 if (response.error) {
5293 5563 mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="close icon"></i>' + response.error, 'red');
5294 5564 } else if (status === 'finished') {
5295 - mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="close icon"></i>' + __('Logs records has been updated successfully.'), 'green');
5565 + mainwp_set_message_zone('#module-log-update-dissmised-logs-running', '<i class="close icon"></i>' + MainWP.I18n.t('Logs records has been updated successfully.'), 'green');
5296 5566 } else if (status === 'running' && !logs_update_db_cancelled) {
5297 5567 setTimeout(function () {
5298 5568 mainwp_module_logs_start_update_dismissed_db();
5299 5569 }, 500);
@@ -5329,126 +5599,126 @@
5329 5599 globalThis.location.href = url;
5330 5600 }
5331 5601
5332 5602 class TablePersistentState {
5333 - constructor(table, options = {}) {
5334 - if (!table || !(table instanceof HTMLElement)) {
5335 - throw new Error('TablePersistentState requires a table element');
5336 - }
5603 + constructor(table, options = {}) {
5604 + if (!table || !(table instanceof HTMLElement)) {
5605 + throw new Error('TablePersistentState requires a table element');
5606 + }
5337 5607
5338 - this.table = table;
5339 - this.tableId = table.id;
5340 - this.headers = table.querySelectorAll(
5341 - options.headerSelector || '.handle-cols-sorting'
5342 - );
5608 + this.table = table;
5609 + this.tableId = table.id;
5610 + this.headers = table.querySelectorAll(
5611 + options.headerSelector || '.handle-cols-sorting'
5612 + );
5343 5613
5344 - this.options = {
5345 - storage: options.storage !== false, // default true
5346 - storagePrefix: options.storagePrefix || 'mainwp_tables_sort_state',
5347 - onPersist: options.onPersist || null,
5348 - defaultSort: options.defaultSort || null, // column, direction
5349 - };
5614 + this.options = {
5615 + storage: options.storage !== false, // default true
5616 + storagePrefix: options.storagePrefix || 'mainwp_tables_sort_state',
5617 + onPersist: options.onPersist || null,
5618 + defaultSort: options.defaultSort || null, // column, direction
5619 + };
5350 5620
5351 - this.init();
5352 - }
5621 + this.init();
5622 + }
5353 5623
5354 - /* ---------- Storage ---------- */
5624 + /* ---------- Storage ---------- */
5355 5625
5356 - get storageKey() {
5357 - return `${this.options.storagePrefix}:${this.tableId}`;
5358 - }
5626 + get storageKey() {
5627 + return `${this.options.storagePrefix}:${this.tableId}`;
5628 + }
5359 5629
5360 - saveState(column, direction) {
5361 - if (!this.options.storage || !this.tableId) return;
5630 + saveState(column, direction) {
5631 + if (!this.options.storage || !this.tableId) return;
5362 5632
5363 - localStorage.setItem(
5364 - this.storageKey,
5365 - JSON.stringify({ column, direction })
5366 - );
5367 - }
5633 + localStorage.setItem(
5634 + this.storageKey,
5635 + JSON.stringify({ column, direction })
5636 + );
5637 + }
5368 5638
5369 - loadState() {
5370 - if (!this.options.storage || !this.tableId) return null;
5639 + loadState() {
5640 + if (!this.options.storage || !this.tableId) return null;
5371 5641
5372 - try {
5373 - return JSON.parse(localStorage.getItem(this.storageKey));
5374 - } catch {
5375 - return null;
5642 + try {
5643 + return JSON.parse(localStorage.getItem(this.storageKey));
5644 + } catch {
5645 + return null;
5646 + }
5376 5647 }
5377 - }
5378 5648
5379 - /* ---------- UI helpers ---------- */
5649 + /* ---------- UI helpers ---------- */
5380 5650
5381 - clearIndicators() {
5382 - this.headers.forEach(th => {
5383 - th.classList.remove('sorted-asc', 'sorted-desc');
5384 - th.removeAttribute('aria-sort');
5385 - });
5386 - }
5651 + clearIndicators() {
5652 + this.headers.forEach(th => {
5653 + th.classList.remove('sorted-asc', 'sorted-desc');
5654 + th.removeAttribute('aria-sort');
5655 + });
5656 + }
5387 5657
5388 - applyIndicator(th, direction) {
5389 - th.classList.add(direction === 'asc' ? 'sorted-asc' : 'sorted-desc');
5390 - th.setAttribute('aria-sort', direction);
5391 - }
5658 + applyIndicator(th, direction) {
5659 + th.classList.add(direction === 'asc' ? 'sorted-asc' : 'sorted-desc');
5660 + th.setAttribute('aria-sort', direction);
5661 + }
5392 5662
5393 - toggleDirection(current) {
5394 - return current === 'asc' ? 'desc' : 'asc';
5395 - }
5663 + toggleDirection(current) {
5664 + return current === 'asc' ? 'desc' : 'asc';
5665 + }
5396 5666
5397 - /* ---------- Sorting flow ---------- */
5667 + /* ---------- Sorting flow ---------- */
5398 5668
5399 - persistState(column, direction, th = null, persist = true, isrestore = false ) {
5400 - if (th) {
5401 - this.clearIndicators();
5402 - this.applyIndicator(th, direction);
5403 - }
5669 + persistState(column, direction, th = null, persist = true, isrestore = false) {
5670 + if (th) {
5671 + this.clearIndicators();
5672 + this.applyIndicator(th, direction);
5673 + }
5404 5674
5405 - if (persist) {
5406 - this.saveState(column, direction);
5407 - }
5675 + if (persist) {
5676 + this.saveState(column, direction);
5677 + }
5408 5678
5409 - if (typeof this.options.onPersist === 'function') {
5410 - this.options.onPersist({
5411 - table: this.table,
5412 - column,
5413 - direction,
5414 - isrestore
5415 - });
5679 + if (typeof this.options.onPersist === 'function') {
5680 + this.options.onPersist({
5681 + table: this.table,
5682 + column,
5683 + direction,
5684 + isrestore
5685 + });
5686 + }
5416 5687 }
5417 - }
5418 5688
5419 - /* ---------- Init ---------- */
5689 + /* ---------- Init ---------- */
5420 5690
5421 - restore() {
5422 - const saved = this.loadState() || this.options.defaultSort;
5423 - if (!saved) return;
5691 + restore() {
5692 + const saved = this.loadState() || this.options.defaultSort;
5693 + if (!saved) return;
5424 5694
5425 - const th = this.table.querySelector(
5426 - `[data-key="${saved.column}"]`
5427 - );
5695 + const th = this.table.querySelector(
5696 + `[data-key="${saved.column}"]`
5697 + );
5428 5698
5429 - if (th) {
5430 - this.persistState(saved.column, saved.direction, th, false, true );
5699 + if (th) {
5700 + this.persistState(saved.column, saved.direction, th, false, true);
5701 + }
5431 5702 }
5432 - }
5433 5703
5434 - bindEvents() {
5435 - this.headers.forEach(th => {
5436 - th.addEventListener('click', () => {
5437 - const column = th.dataset.key;
5438 - const isAsc = th.classList.contains('sorted-asc');
5439 - const direction = this.toggleDirection(isAsc ? 'asc' : 'desc');
5704 + bindEvents() {
5705 + this.headers.forEach(th => {
5706 + th.addEventListener('click', () => {
5707 + const column = th.dataset.key;
5708 + const isAsc = th.classList.contains('sorted-asc');
5709 + const direction = this.toggleDirection(isAsc ? 'asc' : 'desc');
5440 5710
5441 - this.persistState(column, direction, th);
5442 - });
5443 - });
5444 - }
5711 + this.persistState(column, direction, th);
5712 + });
5713 + });
5714 + }
5445 5715
5446 - init() {
5447 - if (!this.tableId && this.options.storage) {
5448 - console.warn('TablePersistentState: table has no id, storage disabled');
5716 + init() {
5717 + if (!this.tableId && this.options.storage) {
5718 + console.warn('TablePersistentState: table has no id, storage disabled');
5719 + }
5720 +
5721 + this.restore();
5722 + this.bindEvents();
5449 5723 }
5450 -
5451 - this.restore();
5452 - this.bindEvents();
5453 - }
5454 5724 }