PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.3 6.2.3 6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 All 157 releases
← All changes | assets/js/mainwp-plugins-themes.js +568 -479 5.0.2 → 6.2.2 View file →
@@ -1,7 +1,10 @@
1 -/* eslint complexity: ["error", 100] */
1 +/* eslint-disable complexity */
2 +
3 +globalThis.mainwpVars = globalThis.mainwpVars || {};
4 +
2 5 //Ignore plugin
3 -jQuery(document).ready(function () {
6 +jQuery(function () {
4 7 jQuery(document).on('click', 'input[name="plugins"]', function () {
5 8 if (jQuery(this).is(':checked')) {
6 9 jQuery('input[name="plugins"]').attr('checked', 'checked');
7 10 jQuery('input[name="plugin[]"]').attr('checked', 'checked');
@@ -21,23 +24,23 @@
21 24 });
22 25
23 26 jQuery(document).on('click', '#mainwp-bulk-trust-plugins-action-apply', function () {
24 27
25 - var action = jQuery("#mainwp-bulk-actions").dropdown("get value");
28 + let action = jQuery("#mainwp-bulk-actions").dropdown("get value");
26 29
27 30 if (action == 'none')
28 - return false;
31 + return;
29 32
30 - var slugs = jQuery.map(jQuery("input[name='plugin[]']:checked"), function (el) {
33 + let slugs = jQuery.map(jQuery("input[name='plugin[]']:checked"), function (el) {
31 34 return jQuery(el).val();
32 35 });
33 36
34 37 if (slugs.length == 0)
35 - return false;
38 + return;
36 39
37 40 jQuery('#mainwp-bulk-trust-plugins-action-apply').attr('disabled', 'true');
38 41
39 - var data = mainwp_secure_data({
42 + let data = mainwp_secure_data({
40 43 action: 'mainwp_trust_plugin',
41 44 slugs: slugs,
42 45 do: action
43 46 });
@@ -45,25 +48,23 @@
45 48 jQuery.post(ajaxurl, data, function () {
46 49 jQuery('#mainwp-bulk-trust-plugins-action-apply').prop("disabled", false);
47 50 mainwp_fetch_all_active_plugins();
48 51 }, 'json');
49 -
50 - return false;
51 52 });
52 53 jQuery(document).on('click', '#mainwp-bulk-trust-themes-action-apply', function () {
53 - var action = jQuery("#mainwp-bulk-actions").dropdown("get value");
54 + let action = jQuery("#mainwp-bulk-actions").dropdown("get value");
54 55 if (action == 'none')
55 - return false;
56 + return;
56 57
57 - var slugs = jQuery.map(jQuery("input[name='theme[]']:checked"), function (el) {
58 + let slugs = jQuery.map(jQuery("input[name='theme[]']:checked"), function (el) {
58 59 return jQuery(el).val();
59 60 });
60 61 if (slugs.length == 0)
61 - return false;
62 + return;
62 63
63 64 jQuery('#mainwp-bulk-trust-themes-action-apply').attr('disabled', 'true');
64 65
65 - var data = mainwp_secure_data({
66 + let data = mainwp_secure_data({
66 67 action: 'mainwp_trust_theme',
67 68 slugs: slugs,
68 69 do: action
69 70 });
@@ -71,31 +72,113 @@
71 72 jQuery.post(ajaxurl, data, function () {
72 73 jQuery('#mainwp-bulk-trust-themes-action-apply').prop("disabled", false);
73 74 mainwp_fetch_all_themes();
74 75 }, 'json');
76 + });
77 +});
75 78
76 - return false;
79 +
80 +// Manage Plugins -- Fetch plugins
81 +globalThis.mainwp_fetch_plugins = function (notFetchContent) {
82 + let errors = [];
83 + let selected_sites = [];
84 + let selected_groups = [];
85 + let selected_clients = [];
86 +
87 + if (jQuery('input[name="select_by"]').val() == 'site') {
88 + jQuery("input[name='selected_sites[]']:checked").each(function () {
89 + selected_sites.push(jQuery(this).val());
90 + });
91 + if (selected_sites.length == 0) {
92 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
93 + }
94 + } else if (jQuery('input[name="select_by"]').val() == 'client') {
95 + jQuery("input[name='selected_clients[]']:checked").each(function () {
96 + selected_clients.push(jQuery(this).val());
97 + });
98 + if (selected_clients.length == 0) {
99 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
100 + }
101 + } else {
102 + jQuery("input[name='selected_groups[]']:checked").each(function () {
103 + selected_groups.push(jQuery(this).val());
104 + });
105 + if (selected_groups.length == 0) {
106 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
107 + }
108 + }
109 +
110 +
111 + let _status = jQuery("#mainwp_plugins_search_by_status").dropdown("get value");
112 +
113 + if (_status == null) {
114 + errors.push(MainWP.I18n.t('Please select at least one plugin status.'));
115 + }
116 +
117 + if (errors.length > 0) {
118 + mainwp_set_message_zone('#mainwp-message-zone', errors.join('<br />'), 'yellow');
119 + return;
120 + } else {
121 + mainwp_set_message_zone('#mainwp-message-zone');
122 + }
123 + let data = mainwp_secure_data({
124 + action: 'mainwp_plugins_search',
125 + keyword: jQuery('#mainwp_plugin_search_by_keyword').val(),
126 + status: _status,
127 + not_criteria: jQuery('#display_sites_not_meeting_criteria').is(':checked'),
128 + 'groups[]': selected_groups,
129 + 'sites[]': selected_sites,
130 + 'clients[]': selected_clients
77 131 });
78 -});
79 132
133 + if (notFetchContent) {
134 + data.not_fetchdata = 1;
135 + }
80 136
137 + if (!notFetchContent) {
138 + jQuery('#mainwp-loading-plugins-row').show(); //Silience.
139 + }
140 +
141 + jQuery.post(ajaxurl, data, function (response) {
142 + if (!notFetchContent) {
143 + jQuery('#mainwp-loading-plugins-row').hide();
144 + jQuery('#mainwp-plugins-main-content').show();
145 +
146 + if (response?.result) {
147 + jQuery('#mainwp-plugins-content').html(response.result);
148 + jQuery('#mainwp-plugins-bulk-actions-wapper').html(response.bulk_actions);
149 + jQuery('#mainwp-plugins-bulk-actions-wapper .ui.dropdown').dropdown();
150 + }
151 + }
152 + }, 'json');
153 +};
154 +
155 +
81 156 /**
82 157 * MainWP_Plugins.page
83 158 */
84 -jQuery(document).ready(function () {
159 +
160 +let pluginCountSent;
161 +let pluginCountReceived;
162 +let pluginResetAllowed = true;
163 +let pluginCurrentProccesingQueueIndex = 0;
164 +let pluginCountCurrentProcces = 0;
165 +let pluginMaxProcces = mainwpVars.maxThreads;
166 +
167 +jQuery(function () {
85 168 jQuery(document).on('click', '#mainwp-show-plugins', function () {
86 169 mainwp_fetch_plugins();
87 170 });
88 171
89 172 jQuery(document).on('click', '#mainwp-install-to-selected-sites', function () {
90 - var checkedVals = jQuery('.mainwp-manage-plugin-item-website .mainwp-selected-plugin-site:checked').map(function () {
91 - var rowElement = jQuery(this).closest('.mainwp-manage-plugin-item-website');
92 - var val = rowElement.attr("site-id");
173 + let checkedVals = jQuery('.mainwp-manage-plugin-item-website .mainwp-selected-plugin-site:checked').map(function () {
174 + let rowElement = jQuery(this).closest('.mainwp-manage-plugin-item-website');
175 + let val = rowElement.attr("site-id");
93 176 return val;
94 177 }).get();
95 178
96 - var selectedIds = [];
97 - if (checkedVals instanceof Array) {
179 + let selectedIds = [];
180 + if (Array.isArray(checkedVals)) {
98 181 jQuery.grep(checkedVals, function (val) {
99 182 if (jQuery.inArray(val, selectedIds) == -1) {
100 183 selectedIds.push(val);
101 184 }
@@ -100,22 +183,19 @@
100 183 selectedIds.push(val);
101 184 }
102 185 });
103 186 }
104 - console.log(selectedIds);
105 187 if (selectedIds.length == 0) {
106 - feedback('mainwp-message-zone', __('Please select at least one website.'), 'yellow');
107 - return false;
188 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website.'), 'yellow');
108 189 } else {
109 190 jQuery('#mainwp-message-zone').fadeOut(5000);
110 - var ids = selectedIds.join("-");
111 - var kwd = jQuery('#mainwp_plugin_search_by_keyword').val();
191 + let ids = selectedIds.join("-");
192 + let kwd = jQuery('#mainwp_plugin_search_by_keyword').val();
112 193 if ('' != kwd) {
113 194 kwd = '&s=' + encodeURIComponent(kwd);
114 195 }
115 196 location.href = 'admin.php?page=PluginsInstall&selected_sites=' + ids + kwd;
116 197 }
117 - return false;
118 198 });
119 199
120 200 jQuery('#mainwp-plugins-content .checkbox').on('click', function () {
121 201 if (jQuery('.mainwp-manage-plugin-item-website .checkbox.checked').length > 0) {
@@ -129,15 +209,11 @@
129 209 mainwp_fetch_all_active_plugins();
130 210 return false;
131 211 });
132 212
133 - var pluginCountSent;
134 - var pluginCountReceived;
135 - var pluginResetAllowed = true;
136 213
137 214 jQuery(document).on('click', '#mainwp-do-plugins-bulk-actions', function () {
138 - var action = jQuery("#mainwp-bulk-actions").dropdown("get value");
139 - console.log(action);
215 + let action = jQuery("#mainwp-bulk-actions").dropdown("get value");
140 216 if (action == '') {
141 217 return false;
142 218 }
143 219
@@ -145,108 +221,65 @@
145 221 jQuery('#mainwp_bulk_action_loading').show();
146 222 pluginResetAllowed = false;
147 223 pluginCountSent = 0;
148 224 pluginCountReceived = 0;
149 - var selectedSites = [];
150 - var selectedSitePlugins = [];
151 -
225 + let selectedSites = [];
226 + let selectedSitePlugins = [];
227 + pluginCurrentProccesingQueueIndex = 0;
228 + pluginCountCurrentProcces = 0;
152 229 //Find all checked boxes
153 230 jQuery('.mainwp-selected-plugin-site:checked').each(function () {
154 - var rowElement = jQuery(this).closest('.mainwp-manage-plugin-item-website');
155 - var websiteId = jQuery(rowElement).attr('site-id');
156 - var pluginSlug = jQuery(rowElement).attr('plugin-slug');
231 + let rowElement = jQuery(this).closest('.mainwp-manage-plugin-item-website');
232 + let websiteId = jQuery(rowElement).attr('site-id');
233 + let pluginSlug = jQuery(rowElement).attr('plugin-slug');
157 234 selectedSitePlugins.push({ 'siteid': websiteId, 'plugin': pluginSlug });
158 - if (selectedSites.indexOf(websiteId) < 0) {
235 + if (!selectedSites.includes(websiteId)) {
159 236 selectedSites.push(websiteId);
160 237 }
161 238 });
162 239
163 - jQuery(selectedSites).each(function (idx, val) {
164 - var websiteId = val;
165 - var selectedPlugins = [];
166 -
167 - jQuery(selectedSitePlugins).each(function (idx, val) {
168 - if (val.siteid == websiteId) {
169 - if (jQuery('.mainwp-manage-plugin-item-website[site-id="' + val.siteid + '"][plugin-slug="' + val.plugin + '"]').length > 0) {
170 - selectedPlugins.push(jQuery('.mainwp-manage-plugin-item-website[site-id="' + val.siteid + '"][plugin-slug="' + val.plugin + '"]')[0]);
171 - }
172 - }
173 - });
174 -
175 - if (selectedPlugins.length == 0)
176 - return;
177 -
178 -
179 - if ((action == 'activate') || (action == 'delete') || (action == 'deactivate') || (action == 'ignore_updates')) {
180 - var pluginsToSend = [];
181 - var namesToSend = [];
182 - for (var i = 0; i < selectedPlugins.length; i++) {
183 - pluginsToSend.push(jQuery(selectedPlugins[i]).attr('plugin-slug'));
184 - namesToSend.push(jQuery(selectedPlugins[i]).attr('plugin-name'));
185 - }
186 -
187 - var data = mainwp_secure_data({
188 - action: 'mainwp_plugin_' + action,
189 - plugins: pluginsToSend,
190 - websiteId: websiteId
191 - });
192 -
193 - if (action == 'ignore_updates') {
194 - data['names'] = namesToSend;
195 - }
196 -
197 - pluginCountSent++;
198 - jQuery.post(ajaxurl, data, function () {
199 - pluginCountReceived++;
200 - if (pluginResetAllowed && pluginCountReceived == pluginCountSent) {
201 - pluginCountReceived = 0;
202 - pluginCountSent = 0;
203 - jQuery('#mainwp_bulk_action_loading').hide();
204 - mainwp_fetch_plugins();
205 - }
206 - }, 'json');
240 + jQuery(selectedSitePlugins).each(function (idx, val) {
241 + let itselector = '.mainwp-manage-plugin-item-website[site-id="' + val.siteid + '"][plugin-slug="' + val.plugin + '"]';
242 + if (jQuery(itselector).length > 0) {
243 + jQuery(itselector).html('<span><i class="clock outline icon"></i> Please wait…</span>');
207 244 }
208 245 });
209 246
247 + mainwp_manage_plugins_bulk_actions_perform(action, selectedSites, selectedSitePlugins);
210 248 pluginResetAllowed = true;
211 - if (pluginCountReceived == pluginCountSent) {
212 - pluginCountReceived = 0;
213 - pluginCountSent = 0;
214 - jQuery('#mainwp_bulk_action_loading').hide();
215 - mainwp_fetch_plugins();
216 - }
217 249 });
218 250
219 251 jQuery(document).on('click', '.mainwp-edit-plugin-note', function () {
220 - var rowEl = jQuery(jQuery(this).parents('tr')[0]);
221 - var slug = rowEl.attr('plugin-slug');
222 - var name = rowEl.attr('plugin-name');
223 - var note = rowEl.find('.esc-content-note').html();
252 + let rowEl = jQuery(jQuery(this).parents('tr')[0]);
253 + let slug = rowEl.attr('plugin-slug');
254 + let name = rowEl.attr('plugin-name');
255 + let note = rowEl.find('.esc-content-note').html();
224 256 jQuery('#mainwp-notes-title').html(decodeURIComponent(name));
225 - jQuery('#mainwp-notes-html').html(note == '' ? __('No saved notes. Click the Edit button to edit plugin notes.') : note);
257 + jQuery('#mainwp-notes-html').html(note == '' ? MainWP.I18n.t('No saved notes. Click the Edit button to edit plugin notes.') : note);
226 258 jQuery('#mainwp-notes-note').val(note);
227 259 jQuery('#mainwp-notes-slug').val(slug);
228 260 mainwp_notes_show();
229 261 });
230 262
231 - mainwp_notes_plugin_save = function () {
232 - var slug = jQuery('#mainwp-notes-slug').val();
233 - var newnote = jQuery('#mainwp-notes-note').val();
234 - newnote = newnote.replace(/(?:\r\n|\r|\n)/g, '<br>');
235 - var data = mainwp_secure_data({
263 + globalThis.mainwp_notes_plugin_save = function () {
264 + let slug = jQuery('#mainwp-notes-slug').val();
265 + let newnote = jQuery('#mainwp-notes-note').val();
266 + newnote = newnote.replaceAll(/\r\n|\r|\n/g, '<br>');
267 + let data = mainwp_secure_data({
236 268 action: 'mainwp_trusted_plugin_notes_save',
237 269 slug: slug,
238 270 note: newnote
239 271 });
240 272
241 - jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + __('Saving note. Please wait...'));
273 + jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Saving note. Please wait...')).show();
242 274
243 275 jQuery.post(ajaxurl, data, function (pSlug) {
244 276 return function (response) {
245 - var rowEl = jQuery('tr[plugin-slug="' + pSlug + '"]');
277 + let rowEl = jQuery('tr[plugin-slug="' + pSlug + '"]');
246 278 if (response.result == 'SUCCESS') {
247 - jQuery('#mainwp-notes-status').html('<i class="check circle green icon"></i> ' + __('Note saved!'));
248 - rowEl.find('.esc-content-note').html(jQuery('#mainwp-notes-note').val());
279 + jQuery('#mainwp-notes-status').html(MainWP.I18n.t('Note saved successfully.')).addClass('green');
280 + rowEl.find('.esc-content-note').html(response?.esc_note_content??'');
281 + jQuery('#mainwp-notes-html').html(response?.esc_note_content??'');
249 282
250 283 if (newnote == '') {
251 284 rowEl.find('.mainwp-edit-plugin-note').html('<i class="sticky note outline icon"></i>');
252 285 } else {
@@ -252,23 +285,32 @@
252 285 } else {
253 286 rowEl.find('.mainwp-edit-plugin-note').html('<i class="sticky green note icon"></i>');
254 287 }
255 288
256 - } else if (response.error != undefined) {
257 - jQuery('#mainwp-notes-status').html('<i class="times circle red icon"></i> ' + __('Undefined error occured while saving your note') + ': ' + response.error);
289 + } else if (response.error === undefined) {
290 + jQuery('#mainwp-notes-status').html('<i class="times red icon"></i> ' + MainWP.I18n.t('Undefined error occurred while saving your note') + '.');
258 291 } else {
259 - jQuery('#mainwp-notes-status').html('<i class="times circle red icon"></i> ' + __('Undefined error occured while saving your note') + '.');
292 + jQuery('#mainwp-notes-status').html('<i class="times red icon"></i> ' + MainWP.I18n.t('Undefined error occurred while saving your note') + ': ' + response.error);
260 293 }
261 294 }
262 295 }(slug), 'json');
296 + setTimeout(function () {
297 + jQuery('#mainwp-notes-status').fadeOut(300);
298 + }, 3000);
299 +
300 + jQuery('#mainwp-notes-html').show();
301 + jQuery('#mainwp-notes-editor').hide();
302 + jQuery('#mainwp-notes-save').hide();
303 + jQuery('#mainwp-notes-edit').show();
304 +
263 305 return false;
264 306 }
265 307
266 308 jQuery(document).on('click', '.mainwp-edit-theme-note', function () {
267 - var rowEl = jQuery(jQuery(this).parents('tr')[0]);
268 - var slug = rowEl.attr('theme-slug');
269 - var name = rowEl.attr('theme-name');
270 - var note = rowEl.find('.esc-content-note').html();
309 + let rowEl = jQuery(jQuery(this).parents('tr')[0]);
310 + let slug = rowEl.attr('theme-slug');
311 + let name = rowEl.attr('theme-name');
312 + let note = rowEl.find('.esc-content-note').html();
271 313 jQuery('#mainwp-notes-modal').removeClass('edit-mode');
272 314 jQuery('#mainwp-notes-title').html(decodeURIComponent(name));
273 315 jQuery('#mainwp-notes-html').html(note == '' ? 'No saved notes. Click the Edit button to edit theme notes.' : note);
274 316 jQuery('#mainwp-notes-note').val(note);
@@ -275,43 +317,56 @@
275 317 jQuery('#mainwp-notes-slug').val(slug);
276 318 mainwp_notes_show();
277 319 });
278 320
279 - mainwp_notes_theme_save = function () {
280 - var slug = jQuery('#mainwp-notes-slug').val();
281 - var newnote = jQuery('#mainwp-notes-note').val();
282 - newnote = newnote.replace(/(?:\r\n|\r|\n)/g, '<br>');
283 - var data = mainwp_secure_data({
321 + globalThis.mainwp_notes_theme_save = function () {
322 + let slug = jQuery('#mainwp-notes-slug').val();
323 + let newnote = jQuery('#mainwp-notes-note').val();
324 + newnote = newnote.replaceAll(/\r\n|\r|\n/g, '<br>');
325 +
326 + let data = mainwp_secure_data({
284 327 action: 'mainwp_trusted_theme_notes_save',
285 328 slug: slug,
286 329 note: newnote
287 330 });
288 331
289 - jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + __('Saving note. Please wait...'));
332 + jQuery('#mainwp-notes-status').html('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Saving note. Please wait...')).show();
290 333
291 334 jQuery.post(ajaxurl, data, function (pSlug) {
292 335 return function (response) {
293 - var rowEl = jQuery('tr[theme-slug="' + pSlug + '"]');
336 + let rowEl = jQuery('tr[theme-slug="' + pSlug + '"]');
294 337 if (response.result == 'SUCCESS') {
295 - jQuery('#mainwp-notes-status').html('<i class="check circle green icon"></i> ' + __('Note saved!'));
296 - rowEl.find('.esc-content-note').html(jQuery('#mainwp-notes-note').val());
338 + jQuery('#mainwp-notes-status').html(MainWP.I18n.t('Note saved successfully.')).addClass('green');
339 + rowEl.find('.esc-content-note').html(response?.esc_note_content??'');
340 + jQuery('#mainwp-notes-html').html(response?.esc_note_content??'');
297 341 if (newnote == '') {
298 342 rowEl.find('.mainwp-edit-theme-note').html('<i class="sticky note outline icon"></i>');
299 343 } else {
300 344 rowEl.find('.mainwp-edit-theme-note').html('<i class="sticky green note icon"></i>');
301 345 }
302 - } else if (response.error != undefined) {
303 - jQuery('#mainwp-notes-status').html('<i class="times circle red icon"></i> ' + __('Undefined error occured while saving your note!') + ': ' + response.error);
346 + } else if (response.error === undefined) {
347 + jQuery('#mainwp-notes-status').html('<i class="times red icon"></i> ' + MainWP.I18n.t('Undefined error occurred while saving your note!'));
304 348 } else {
305 - jQuery('#mainwp-notes-status').html('<i class="times circle red icon"></i> ' + __('Undefined error occured while saving your note!'));
349 + jQuery('#mainwp-notes-status').html('<i class="times red icon"></i> ' + MainWP.I18n.t('Undefined error occurred while saving your note!') + ': ' + response.error);
306 350 }
307 351 }
308 352 }(slug), 'json');
353 + setTimeout(function () {
354 + jQuery('#mainwp-notes-status').fadeOut(300);
355 + }, 3000);
356 +
357 + jQuery('#mainwp-notes-html').show();
358 + jQuery('#mainwp-notes-editor').hide();
359 + jQuery('#mainwp-notes-save').hide();
360 + jQuery('#mainwp-notes-edit').show();
361 +
309 362 return false;
310 363 }
311 364 });
312 365
313 -mainwp_show_hide_install_to_selected_sites = function (what) {
366 +
367 +
368 +globalThis.mainwp_show_hide_install_to_selected_sites = function (what) {
314 369 if ('plugin' == what) {
315 370 jQuery('#mainwp-plugins-content .checkbox').on('click', function () {
316 371 if (jQuery('.mainwp-manage-plugin-item-website .checkbox.checked').length > 0) {
317 372 jQuery('#mainwp-install-to-selected-sites').show();
@@ -329,82 +384,113 @@
329 384 });
330 385 }
331 386 }
332 387
333 -// Manage Plugins -- Fetch plugins
334 -mainwp_fetch_plugins = function () {
335 - var errors = [];
336 - var selected_sites = [];
337 - var selected_groups = [];
338 - var selected_clients = [];
388 +let mainwp_manage_plugins_bulk_actions_next = function (action, selectedSites, selectedSitePlugins) {
389 + if (pluginCurrentProccesingQueueIndex < selectedSites.length) {
390 + mainwp_manage_plugins_bulk_actions_perform(action, selectedSites, selectedSitePlugins);
391 + }
392 + mainwp_manage_plugins_bulk_actions_check_done();
393 +};
339 394
340 - if (jQuery('#select_by').val() == 'site') {
341 - jQuery("input[name='selected_sites[]']:checked").each(function () {
342 - selected_sites.push(jQuery(this).val());
343 - });
344 - if (selected_sites.length == 0) {
345 - errors.push(__('Please select at least one website or group or client.'));
346 - }
347 - } else if (jQuery('#select_by').val() == 'client') {
348 - jQuery("input[name='selected_clients[]']:checked").each(function () {
349 - selected_clients.push(jQuery(this).val());
350 - });
351 - if (selected_clients.length == 0) {
352 - errors.push(__('Please select at least one website or group or client.'));
353 - }
354 - } else {
355 - jQuery("input[name='selected_groups[]']:checked").each(function () {
356 - selected_groups.push(jQuery(this).val());
357 - });
358 - if (selected_groups.length == 0) {
359 - errors.push(__('Please select at least one website or group or client.'));
360 - }
395 +let mainwp_manage_plugins_bulk_actions_check_done = function () {
396 + if (pluginCountReceived == pluginCountSent) {
397 + pluginCountReceived = 0;
398 + pluginCountSent = 0;
399 + jQuery('#mainwp_bulk_action_loading').hide();
361 400 }
401 +};
362 402
403 +// Bulk processing plugins.
404 +let mainwp_manage_plugins_bulk_actions_perform = function (action, selectedSites, selectedSitePlugins) {
363 405
364 - var _status = jQuery("#mainwp_plugins_search_by_status").dropdown("get value");
406 + let websiteId = 0;
365 407
366 - if (_status == null) {
367 - errors.push(__('Please select at least one plugin status.'));
408 + if (selectedSites[pluginCurrentProccesingQueueIndex]) {
409 + websiteId = selectedSites[pluginCurrentProccesingQueueIndex];
368 410 }
369 411
370 - if (errors.length > 0) {
371 - jQuery('#mainwp-message-zone').html(errors.join('<br />'));
372 - jQuery('#mainwp-message-zone').addClass('yellow');
373 - jQuery('#mainwp-message-zone').show();
412 + pluginCurrentProccesingQueueIndex++;
413 +
414 + if (!websiteId) {
415 + mainwp_manage_plugins_bulk_actions_next(action, selectedSites, selectedSitePlugins);
374 416 return;
375 - } else {
376 - jQuery('#mainwp-message-zone').html('');
377 - jQuery('#mainwp-message-zone').removeClass('yellow');
378 - jQuery('#mainwp-message-zone').hide();
379 417 }
380 - var data = mainwp_secure_data({
381 - action: 'mainwp_plugins_search',
382 - keyword: jQuery('#mainwp_plugin_search_by_keyword').val(),
383 - status: _status,
384 - not_criteria: jQuery('#display_sites_not_meeting_criteria').is(':checked'),
385 - 'groups[]': selected_groups,
386 - 'sites[]': selected_sites,
387 - 'clients[]': selected_clients
418 +
419 + let selectedPlugins = [];
420 +
421 + jQuery(selectedSitePlugins).each(function (idx, val) {
422 + if (val.siteid == websiteId) {
423 + let itselector = '.mainwp-manage-plugin-item-website[site-id="' + val.siteid + '"][plugin-slug="' + val.plugin + '"]';
424 + if (jQuery(itselector).length > 0) {
425 + selectedPlugins.push(jQuery(itselector)[0]);
426 + }
427 + }
388 428 });
389 429
390 - jQuery('#mainwp-loading-plugins-row').show();
430 + if (selectedPlugins.length == 0) {
431 + mainwp_manage_plugins_bulk_actions_next(action, selectedSites, selectedSitePlugins);
432 + return;
433 + }
391 434
392 - jQuery.post(ajaxurl, data, function (response) {
393 - jQuery('#mainwp-loading-plugins-row').hide();
394 - jQuery('#mainwp-plugins-main-content').show();
435 + if ((action == 'activate') || (action == 'delete') || (action == 'deactivate') || (action == 'ignore_updates')) {
436 + let pluginsToSend = [];
437 + let namesToSend = [];
438 + for (let ss of selectedPlugins) {
439 + pluginsToSend.push(jQuery(ss).attr('plugin-slug'));
440 + namesToSend.push(jQuery(ss).attr('plugin-name'));
441 + jQuery(ss).html('<span><i class="ui active inline loader tiny"></i> Please wait…<span>');
442 + }
395 443
396 - if (response && response.result) {
397 - jQuery('#mainwp-plugins-content').html(response.result);
398 - jQuery('#mainwp-plugins-bulk-actions-wapper').html(response.bulk_actions);
399 - jQuery('#mainwp-plugins-bulk-actions-wapper .ui.dropdown').dropdown();
444 + let data = mainwp_secure_data({
445 + action: 'mainwp_plugin_' + action,
446 + plugins: pluginsToSend,
447 + websiteId: websiteId
448 + });
449 +
450 + if (action == 'ignore_updates') {
451 + data['names'] = namesToSend;
400 452 }
401 - }, 'json');
402 -};
453 + pluginCountCurrentProcces++;
454 + pluginCountSent++;
403 455
456 + jQuery.post(ajaxurl, data, function (response) {
457 + pluginCountCurrentProcces--;
458 + pluginCountReceived++;
459 + for (let ss of selectedPlugins) {
460 + let pslug = jQuery(ss).attr('plugin-slug');
461 + let itselector = '.mainwp-manage-plugin-item-website[site-id="' + websiteId + '"][plugin-slug="' + pslug + '"]';
462 + if (jQuery(itselector).length > 0) {
463 + if (response?.error) {
464 + jQuery(itselector).html('<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
465 + } else if (response?.result) {
466 + jQuery(itselector).html('<span><i class="green check icon"></i></span>');
467 + } else {
468 + jQuery(itselector).html('<span data-tooltip="Invalid response from the server, please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
469 + }
470 + }
471 + }
472 + if (response?.result) {
473 + for (let ss of selectedPlugins) {
474 + let pslug = jQuery(ss).attr('plugin-slug');
475 + let itselector = '.mainwp-manage-plugin-item-website[site-id="' + websiteId + '"][plugin-slug="' + pslug + '"]';
476 + setTimeout(function () {
477 + jQuery(itselector).fadeOut(1000);
478 + }, 1000);
479 + }
480 + }
481 + if (pluginCountCurrentProcces < pluginMaxProcces) {
482 + mainwp_manage_plugins_bulk_actions_next(action, selectedSites, selectedSitePlugins);
483 + } else {
484 + mainwp_manage_plugins_bulk_actions_check_done();
485 + }
486 + }, 'json');
487 + }
488 +}
489 +
404 490 // Fetch plugins for the Auto Update feature
405 -mainwp_fetch_all_active_plugins = function () {
406 - var data = mainwp_secure_data({
491 +let mainwp_fetch_all_active_plugins = function () {
492 + let data = mainwp_secure_data({
407 493 action: 'mainwp_plugins_search_all_active',
408 494 keyword: jQuery("#mainwp_au_plugin_keyword").val(),
409 495 status: jQuery("#mainwp_au_plugin_trust_status").val(),
410 496 plugin_status: jQuery("#mainwp_au_plugin_status").val()
@@ -415,14 +501,19 @@
415 501 jQuery.post(ajaxurl, data, function (response) {
416 502 response = response.trim();
417 503 jQuery('#mainwp-auto-updates-plugins-content').find('.dimmer').removeClass('active');
418 504 jQuery('#mainwp-auto-updates-plugins-table-wrapper').html(response);
505 + if (jQuery('#mainwp-auto-updates-plugins-table-wrapper').find('.mainwp-empty-page-placeholder').length > 0) {
506 + jQuery('#mainwp-plugin-auto-updates .mainwp-actions-bar').hide();
507 + } else {
508 + jQuery('#mainwp-plugin-auto-updates .mainwp-actions-bar').show();
509 + }
419 510 });
420 511 };
421 512
422 513 // Fetch themes for the Auto Update feature
423 -mainwp_fetch_all_themes = function () {
424 - var data = mainwp_secure_data({
514 +let mainwp_fetch_all_themes = function () {
515 + let data = mainwp_secure_data({
425 516 action: 'mainwp_themes_search_all',
426 517 keyword: jQuery("#mainwp_au_theme_keyword").val(),
427 518 status: jQuery("#mainwp_au_theme_trust_status").val(),
428 519 theme_status: jQuery("#mainwp_au_theme_status").val()
@@ -432,30 +523,33 @@
432 523
433 524 jQuery.post(ajaxurl, data, function (response) {
434 525 jQuery('#mainwp-auto-updates-themes-content').find('.dimmer').removeClass('active');
435 526 jQuery('#mainwp-auto-updates-themes-table-wrapper').html(response);
527 + if (jQuery('#mainwp-auto-updates-themes-table-wrapper').find('.mainwp-empty-page-placeholder').length > 0) {
528 + jQuery('#mainwp-theme-auto-updates .mainwp-actions-bar').hide();
529 + } else {
530 + jQuery('#mainwp-theme-auto-updates .mainwp-actions-bar').show();
531 + }
436 532 });
437 533 };
438 534
439 -
440 -
441 535 /**
442 536 * MainWP_Themes.page
443 537 */
444 -jQuery(document).ready(function () {
538 +jQuery(function () {
445 539 jQuery(document).on('click', '#mainwp_show_themes', function () {
446 540 mainwp_fetch_themes();
447 541 });
448 542
449 543 jQuery(document).on('click', '#mainwp-install-themes-to-selected-sites', function () {
450 - var checkedVals = jQuery('.mainwp-manage-theme-item-website .mainwp-selected-theme-site:checked').map(function () {
451 - var rowElement = jQuery(this).closest('.mainwp-manage-theme-item-website');
452 - var val = rowElement.attr('site-id');
544 + let checkedVals = jQuery('.mainwp-manage-theme-item-website .mainwp-selected-theme-site:checked').map(function () {
545 + let rowElement = jQuery(this).closest('.mainwp-manage-theme-item-website');
546 + let val = rowElement.attr('site-id');
453 547 return val;
454 548 }).get();
455 549
456 - var selectedIds = [];
457 - if (checkedVals instanceof Array) {
550 + let selectedIds = [];
551 + if (Array.isArray(checkedVals)) {
458 552 jQuery.grep(checkedVals, function (val) {
459 553 if (jQuery.inArray(val, selectedIds) == -1) {
460 554 selectedIds.push(val);
461 555 }
@@ -462,20 +556,18 @@
462 556 });
463 557 }
464 558
465 559 if (selectedIds.length == 0) {
466 - feedback('mainwp-message-zone', __('Please select at least one website.'), 'yellow');
467 - return false;
560 + feedback('mainwp-message-zone', MainWP.I18n.t('Please select at least one website.'), 'yellow');
468 561 } else {
469 562 jQuery('#mainwp-message-zone').fadeOut(5000);
470 - var ids = selectedIds.join("-");
471 - var kwd = jQuery('#mainwp_theme_search_by_keyword').val();
563 + let ids = selectedIds.join("-");
564 + let kwd = jQuery('#mainwp_theme_search_by_keyword').val();
472 565 if ('' != kwd) {
473 566 kwd = '&s=' + encodeURIComponent(kwd);
474 567 }
475 568 location.href = 'admin.php?page=ThemesInstall&selected_sites=' + ids + kwd;
476 569 }
477 - return false;
478 570 });
479 571
480 572 jQuery('#mainwp-themes-content .checkbox').on('click', function () {
481 573 if (jQuery('.mainwp-manage-theme-item-website .checkbox.checked').length > 0) {
@@ -490,15 +582,14 @@
490 582 mainwp_fetch_all_themes();
491 583 return false;
492 584 });
493 585
494 - var themeCountSent;
495 - var themeCountReceived;
496 - var themeResetAllowed = true;
586 + let themeCountSent;
587 + let themeCountReceived;
588 + let themeResetAllowed = true;
497 589
498 590 jQuery(document).on('click', '#mainwp-do-themes-bulk-actions', function () {
499 - var action = jQuery("#mainwp-bulk-actions").dropdown("get value");
500 - console.log(action);
591 + let action = jQuery("#mainwp-bulk-actions").dropdown("get value");
501 592 if (action == '' || action == 'none')
502 593 return;
503 594
504 595 jQuery('#mainwp-do-themes-bulk-actions').attr('disabled', 'true');
@@ -505,26 +596,30 @@
505 596 jQuery('#mainwp_bulk_action_loading').show();
506 597 themeResetAllowed = false;
507 598 themeCountSent = 0;
508 599 themeCountReceived = 0;
509 - var selectedSites = [];
510 - var selectedSiteThemes = [];
600 + let selectedSites = [];
601 + let selectedSiteThemes = [];
511 602
512 603 //Find all checked boxes
513 604 jQuery('.mainwp-selected-theme-site:checked').each(function () {
514 - var rowElement = jQuery(this).closest('.mainwp-manage-theme-item-website');
515 - var websiteId = jQuery(rowElement).attr('site-id');
516 - var theme = jQuery(rowElement).attr('theme-slug');
605 + let rowElement = jQuery(this).closest('.mainwp-manage-theme-item-website');
606 + let websiteId = jQuery(rowElement).attr('site-id');
607 + let theme = jQuery(rowElement).attr('theme-slug');
608 + if (action == 'activate' && jQuery(rowElement).attr('is-actived') == 1) {
609 + jQuery(rowElement).find('.mainwp-selected-theme-site').attr('checked', false);
610 + return;
611 + }
517 612 selectedSiteThemes.push({ 'siteid': websiteId, 'theme': theme });
518 - if (selectedSites.indexOf(websiteId) < 0) {
613 + if (!selectedSites.includes(websiteId)) {
519 614 selectedSites.push(websiteId);
520 615 }
521 616 });
522 617
523 618
524 - jQuery(selectedSites).each(function (idx, val) {
525 - var websiteId = val;
526 - var selectedThemes = [];
619 + jQuery(selectedSites).each(function (idx, val) { // NOSONAR - complex.
620 + let websiteId = val;
621 + let selectedThemes = [];
527 622
528 623 jQuery(selectedSiteThemes).each(function (idx, val) {
529 624 if (val.siteid == websiteId) {
530 625 if (jQuery('.mainwp-manage-theme-item-website[site-id="' + val.siteid + '"][theme-slug="' + val.theme + '"]').length > 0) {
@@ -536,21 +631,21 @@
536 631 if (selectedThemes.length == 0)
537 632 return;
538 633
539 634 if (action == 'activate' || action == 'ignore_updates') {
540 - var themeToActivate = jQuery(selectedThemes[0]).attr('theme-slug');
541 - var themesToSend = [];
542 - var namesToSend = [];
635 + let themeToActivate = jQuery(selectedThemes[0]).attr('theme-slug');
636 + let themesToSend = [];
637 + let namesToSend = [];
543 638
544 - var data = mainwp_secure_data({
639 + let data = mainwp_secure_data({
545 640 action: 'mainwp_theme_' + action,
546 641 websiteId: websiteId
547 642 });
548 643
549 644 if (action == 'ignore_updates') {
550 - for (var i = 0; i < selectedThemes.length; i++) {
551 - themesToSend.push(jQuery(selectedThemes[i]).attr('theme-slug'));
552 - namesToSend.push(jQuery(selectedThemes[i]).attr('theme-name'));
645 + for (let ss of selectedThemes) {
646 + themesToSend.push(jQuery(ss).attr('theme-slug'));
647 + namesToSend.push(jQuery(ss).attr('theme-name'));
553 648 }
554 649 data['themes'] = themesToSend;
555 650 data['names'] = namesToSend;
556 651 } else {
@@ -568,20 +663,20 @@
568 663 mainwp_fetch_themes();
569 664 }
570 665 });
571 666 } else if (action == 'delete') {
572 - var themesToDelete = [];
573 - for (var i = 0; i < selectedThemes.length; i++) {
574 - if (jQuery(selectedThemes[i]).attr('not-delete') == 1) {
575 - jQuery(selectedThemes[i]).find('.mainwp-selected-theme-site').attr('checked', false);
667 + let themesToDelete = [];
668 + for (let ss of selectedThemes) {
669 + if (jQuery(ss).attr('not-delete') == 1 || jQuery(ss).attr('is-actived') == 1) {
670 + jQuery(ss).find('.mainwp-selected-theme-site').attr('checked', false);
576 671 continue;
577 672 }
578 - themesToDelete.push(jQuery(selectedThemes[i]).attr('theme-slug'));
673 + themesToDelete.push(jQuery(ss).attr('theme-slug'));
579 674 }
580 675 if (themesToDelete.length == 0) {
581 676 return;
582 677 }
583 - var data = mainwp_secure_data({
678 + let data = mainwp_secure_data({
584 679 action: 'mainwp_theme_delete',
585 680 themes: themesToDelete,
586 681 websiteId: websiteId
587 682 });
@@ -587,12 +682,12 @@
587 682 });
588 683
589 684 themeCountSent++;
590 685 jQuery.post(ajaxurl, data, function (response) {
591 - if (response.error != undefined && response.error == Object(response.error)) { // check if .error is object.
592 - entries = Object.entries(response.error);
593 - for (var entry of entries) {
594 - warnings = __(entry[0], encodeURIComponent(entry[1])); // entry[0]:id message, entry[1] string value.
686 + if (response.error != undefined && response.error == new Object(response.error)) { // check if .error is object.
687 + let entries = Object.entries(response.error);
688 + for (let entry of entries) {
689 + let warnings = MainWP.I18n.t(entry[0], encodeURIComponent(entry[1])); // entry[0]:id message, entry[1] string value.
595 690 jQuery('#mainwp-message-zone').after('<div class="ui info message yellow"><i class="ui close icon"></i><span>' + warnings + '</span></div>');
596 691 }
597 692 }
598 693 themeCountReceived++;
@@ -620,27 +715,27 @@
620 715 });
621 716
622 717
623 718 // Manage Themes -- Fetch themes from child sites
624 -mainwp_fetch_themes = function () {
625 - var errors = [];
626 - var selected_sites = [];
627 - var selected_groups = [];
628 - var selected_clients = [];
719 +globalThis.mainwp_fetch_themes = function (notFetchContent) {
720 + let errors = [];
721 + let selected_sites = [];
722 + let selected_groups = [];
723 + let selected_clients = [];
629 724
630 - if (jQuery('#select_by').val() == 'site') {
725 + if (jQuery('input[name="select_by"]').val() == 'site') {
631 726 jQuery("input[name='selected_sites[]']:checked").each(function () {
632 727 selected_sites.push(jQuery(this).val());
633 728 });
634 729 if (selected_sites.length == 0) {
635 - errors.push(__('Please select at least one website or group or client.'));
730 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
636 731 }
637 - } else if (jQuery('#select_by').val() == 'client') {
732 + } else if (jQuery('input[name="select_by"]').val() == 'client') {
638 733 jQuery("input[name='selected_clients[]']:checked").each(function () {
639 734 selected_clients.push(jQuery(this).val());
640 735 });
641 736 if (selected_clients.length == 0) {
642 - errors.push(__('Please select at least one website or group or client.'));
737 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
643 738 }
644 739 } else {
645 740 jQuery("input[name='selected_groups[]']:checked").each(function () {
646 741 selected_groups.push(jQuery(this).val());
@@ -645,29 +740,25 @@
645 740 jQuery("input[name='selected_groups[]']:checked").each(function () {
646 741 selected_groups.push(jQuery(this).val());
647 742 });
648 743 if (selected_groups.length == 0) {
649 - errors.push(__('Please select at least one website or group or client.'));
744 + errors.push(MainWP.I18n.t('Please select at least one website or group or client.'));
650 745 }
651 746 }
652 747
653 - var _status = jQuery("#mainwp_themes_search_by_status").dropdown("get value");
748 + let _status = jQuery("#mainwp_themes_search_by_status").dropdown("get value");
654 749 if (_status == null) {
655 - errors.push(__('Please select at least one theme status.'));
750 + errors.push(MainWP.I18n.t('Please select at least one theme status.'));
656 751 }
657 752
658 753 if (errors.length > 0) {
659 - jQuery('#mainwp-message-zone').html(errors.join('<br />'));
660 - jQuery('#mainwp-message-zone').addClass('yellow');
661 - jQuery('#mainwp-message-zone').show();
754 + mainwp_set_message_zone('#mainwp-message-zone', errors.join('<br />'), 'yellow');
662 755 return;
663 756 } else {
664 - jQuery('#mainwp-message-zone').html('');
665 - jQuery('#mainwp-message-zone').removeClass('yellow');
666 - jQuery('#mainwp-message-zone').hide();
757 + mainwp_set_message_zone('#mainwp-message-zone');
667 758 }
668 759
669 - var data = mainwp_secure_data({
760 + let data = mainwp_secure_data({
670 761 action: 'mainwp_themes_search',
671 762 keyword: jQuery('#mainwp_theme_search_by_keyword').val(),
672 763 status: _status,
673 764 not_criteria: jQuery('#display_sites_not_meeting_criteria').is(':checked'),
@@ -675,17 +766,26 @@
675 766 'sites[]': selected_sites,
676 767 'clients[]': selected_clients
677 768 });
678 769
679 - jQuery('#mainwp-loading-themes-row').show();
770 + if (notFetchContent) {
771 + data.not_fetchdata = 1;
772 + }
680 773
774 + if (!notFetchContent) {
775 + jQuery('#mainwp-loading-themes-row').show();
776 + }
777 +
681 778 jQuery.post(ajaxurl, data, function (response) {
682 - jQuery('#mainwp-loading-themes-row').hide();
683 - jQuery('#mainwp-themes-main-content').show();
684 - if (response && response.result) {
685 - jQuery('#mainwp-themes-content').html(response.result);
686 - jQuery('#mainwp-themes-bulk-actions-wapper').html(response.bulk_actions);
687 - jQuery('#mainwp-themes-bulk-actions-wapper .ui.dropdown').dropdown();
779 + if (!notFetchContent) {
780 + jQuery('#mainwp-loading-themes-row').hide();
781 + jQuery('#mainwp-themes-main-content').show();
782 + if (response?.result) {
783 + jQuery('#mainwp-themes-content').html(response.result);
784 + jQuery('#mainwp-themes-bulk-actions-wapper').html(response.bulk_actions);
785 + jQuery('#mainwp-themes-bulk-actions-wapper .ui.dropdown').dropdown();
786 + mainwp_show_hide_install_to_selected_sites( 'theme' );
787 + }
688 788 }
689 789 }, 'json');
690 790 };
691 791
@@ -691,9 +791,9 @@
691 791
692 792 /**
693 793 * Plugins manages.
694 794 */
695 -jQuery(document).ready(function () {
795 +jQuery(function () {
696 796 jQuery(document).on('click', '.mainwp-manage-plugin-deactivate', function () {
697 797 manage_plugin_Action(jQuery(this), 'deactivate');
698 798 return false;
699 799 });
@@ -701,43 +801,48 @@
701 801 manage_plugin_Action(jQuery(this), 'activate');
702 802 return false;
703 803 });
704 804 jQuery(document).on('click', '.mainwp-manage-plugin-delete', function () {
705 - manage_plugin_Action(jQuery(this), 'delete');
805 + let name = jQuery(this).closest('.mainwp-manage-plugin-item-website').attr('plugin-name');
806 + let confirmMsg = MainWP.I18n.t('You are about to delete the %1?', name);
807 + mainwp_confirm(confirmMsg,() => {
808 + manage_plugin_Action(jQuery(this), 'delete');
809 + });
706 810 return false;
707 811 });
708 812 });
709 813
710 -manage_plugin_Action = function (elem, what) {
711 - var rowElement = jQuery(elem).closest('.mainwp-manage-plugin-item-website');
712 - var plugin = rowElement.attr('plugin-slug');
713 - var websiteId = rowElement.attr('site-id');
714 814
715 - var data = mainwp_secure_data({
815 +let manage_plugin_Action = function (elem, what) {
816 + let rowElement = jQuery(elem).closest('.mainwp-manage-plugin-item-website');
817 + let plugin = rowElement.attr('plugin-slug');
818 + let websiteId = rowElement.attr('site-id');
819 +
820 + let data = mainwp_secure_data({
716 821 action: 'mainwp_widget_plugin_' + what, // same with the widgets.
717 822 plugin: plugin,
718 823 websiteId: websiteId
719 824 });
720 - var parent = jQuery(elem).closest('.column.column-actions');
721 - jQuery(parent).html('<i class="notched circle loading icon"></i>' + __('Please wait...') + '</div>');
825 + let start_row = '<div class="one wide center aligned middle aligned column"></div><div class="thirteen wide left aligned middle aligned column">';
826 + let end_row = '</div>';
827 + jQuery(rowElement).html(start_row + '<i class="notched circle loading icon"></i>' + MainWP.I18n.t('Please wait...') + end_row);
722 828 jQuery.post(ajaxurl, data, function (response) {
723 - if (response && response.error) {
724 - jQuery(parent).html('<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
725 - } else if (response && response.result) {
829 + if (response?.error) {
830 + jQuery(rowElement).html(start_row + '<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>' + end_row);
831 + } else if (response?.result) {
726 832 if (what == 'delete') {
727 - jQuery(rowElement).html('<i class="check circle green icon"></i> ' + response.result);
728 - setTimeout(function () {
729 - jQuery(rowElement).fadeOut(1000);
730 - }, 1000);
731 -
833 + jQuery(rowElement).html(start_row + '<i class="green check icon"></i> ' + response.result + '</div>');
732 834 } else {
733 - jQuery(parent).html('<i class="check circle green icon"></i> ' + response.result);
835 + jQuery(rowElement).html(start_row + '<i class="green check icon"></i> ' + response.result + end_row);
734 836 }
735 837 setTimeout(function () {
736 - mainwp_fetch_plugins();
838 + jQuery(rowElement).fadeOut(1000);
839 + }, 1000);
840 + setTimeout(function () {
841 + mainwp_fetch_plugins(true);
737 842 }, 3000);
738 843 } else {
739 - jQuery(parent).html('<span data-tooltip="Undefined error occured. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
844 + jQuery(rowElement).html(start_row + '<span data-tooltip="Undefined error occurred. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>' + end_row);
740 845 }
741 846 }, 'json');
742 847
743 848 return false;
@@ -743,102 +848,102 @@
743 848 return false;
744 849 };
745 850
746 851
747 -manage_plugins_upgrade = function (slug, websiteid) {
748 - var msg = __('Are you sure you want to update the plugin on the selected site?');
852 +let manage_plugins_upgrade = function (slug, websiteid) {
853 + let msg = MainWP.I18n.t('Are you sure you want to update the plugin on the selected site?');
749 854 mainwp_confirm(msg, function () {
750 855 return manage_plugins_upgrade_int(slug, websiteid);
751 856 }, false, 1);
752 857 };
753 858
754 -
755 -manage_plugins_upgrade_int = function (slug, websiteId) {
756 - var websiteHolder = jQuery('.mainwp-manage-plugin-item-website[plugin-slug="' + slug + '"][site-id="' + websiteId + '"]');
757 - websiteHolder.find('.column.update-column').html('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...'));
758 -
759 - manage_plugins_upgrade_continueAfterBackup = function () {
760 - console.log('plugin upgrade continue');
761 - return function () {
762 - var data = mainwp_secure_data({
763 - action: 'mainwp_upgradeplugintheme',
764 - websiteId: websiteId,
765 - type: 'plugin',
766 - slug: slug
767 - });
768 - jQuery.ajax({
769 - type: "POST",
770 - url: ajaxurl,
771 - data: data,
772 - success: function (siteHolder) {
773 - return function (response) {
774 - if (response.error) {
775 - var extErr = getErrorMessageInfo(response.error, 'ui')
776 - siteHolder.find('.column.update-column').html(extErr);
777 - } else {
778 - var res = response.result;
779 - var res_error = response.result_error;
780 - if (res[slug]) {
781 - siteHolder.attr('updated', 1);
782 - siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>');
783 - } else if (res_error[slug]) {
784 - siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + res_error[slug] + '"><i class="red times icon"></i></span>');
785 - } else {
786 - siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
787 - }
788 - setTimeout(function () {
789 - mainwp_fetch_plugins();
790 - }, 3000);
859 +let manage_plugins_upgrade_continueAfterBackup = function (slug, websiteId, websiteHolder) {
860 + let siteHolder = websiteHolder;
861 + return function () {
862 + let data = mainwp_secure_data({
863 + action: 'mainwp_upgradeplugintheme',
864 + websiteId: websiteId,
865 + type: 'plugin',
866 + slug: slug
867 + });
868 + jQuery.ajax({
869 + type: "POST",
870 + url: ajaxurl,
871 + data: data,
872 + success: function (response) {
873 + if (response.error) {
874 + let extErr = getErrorMessageInfo(response.error, 'ui')
875 + siteHolder.find('.column.update-column').html(extErr);
876 + } else {
877 + let res = response.result;
878 + let res_error = response.result_error;
879 + if (res[slug]) {
880 + siteHolder.attr('updated', 1);
881 + siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>');
882 + } else if (res_error[slug]) {
883 + let _error = res_error[slug];
884 + let _icon = '<i class="red times icon"></i>';
885 + let roll_error = mainwp_updates_get_rollback_msg(_error);
886 + if (roll_error) {
887 + _error = roll_error;
888 + _icon = mainwpParams.roll_ui_icon;
791 889 }
792 - }
793 - }(websiteHolder),
794 - tryCount: 0,
795 - retryLimit: 3,
796 - endError: function (siteHolder) {
797 - return function () {
890 + siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + _error + '">' + _icon + '</span>');
891 + } else {
798 892 siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
799 893 }
800 - }(websiteHolder),
801 - error: function (xhr) {
802 - this.tryCount++;
803 - if (this.tryCount >= this.retryLimit) {
804 - this.endError();
805 - return;
894 + setTimeout(function () {
895 + mainwp_fetch_plugins();
896 + }, 3000);
897 + }
898 + },
899 + tryCount: 0,
900 + retryLimit: 3,
901 + endError: function () {
902 + siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
903 + },
904 + error: function (xhr) {
905 + this.tryCount++;
906 + if (this.tryCount >= this.retryLimit) {
907 + this.endError();
908 + return;
909 + }
910 +
911 + setTimeout((pRqst, pXhr) => {
912 + if (pXhr.status == 404) {
913 + //handle error
914 + jQuery.ajax(pRqst);
915 + } else if (pXhr.status == 500) {
916 + //handle error
917 + } else {
918 + //handle error
806 919 }
920 + }, 500, this, xhr);
921 + },
922 + dataType: 'json'
923 + });
924 + }();
925 +}
807 926
808 - var fnc = function (pRqst, pXhr) {
809 - return function () {
810 - if (pXhr.status == 404) {
811 - //handle error
812 - jQuery.ajax(pRqst);
813 - } else if (pXhr.status == 500) {
814 - //handle error
815 - } else {
816 - //handle error
817 - }
818 - }
819 - }(this, xhr);
820 - setTimeout(fnc, 500);
821 - },
822 - dataType: 'json'
823 - });
824 927
825 - manage_plugins_upgrade_continueAfterBackup = undefined;
826 - }();
928 +let manage_plugins_upgrade_int = function (slug, websiteId) {
929 + let websiteHolder = jQuery('.mainwp-manage-plugin-item-website[plugin-slug="' + slug + '"][site-id="' + websiteId + '"]');
930 + websiteHolder.find('.column.update-column').html('<span data-tooltip="Updating..." data-inverted="" data-position="left center"><i class="notched circle loading icon"></i></span>');
931 +
932 + let _callbackAfterBackup = function () {
933 + return manage_plugins_upgrade_continueAfterBackup(slug, websiteId, websiteHolder);
827 934 };
828 935
829 - if (mainwpParams['disable_checkBackupBeforeUpgrade'] == true) {
830 - if (manage_plugins_upgrade_continueAfterBackup != undefined) {
831 - manage_plugins_upgrade_continueAfterBackup();
832 - }
936 + if (mainwpParams['disable_checkBackupBeforeUpgrade']) {
937 + _callbackAfterBackup();
833 938 return false;
834 939 }
835 940
836 - var sitesToUpdate = [websiteId]; var siteNames = []
837 - var siteNames = []
941 + let sitesToUpdate = [websiteId];
942 + let siteNames = [];
838 943 siteNames[websiteId] = jQuery(websiteHolder).attr('site-name');
839 944
840 - return mainwp_manages_checkBackups(sitesToUpdate, siteNames, manage_plugins_upgrade_continueAfterBackup);
945 + return mainwp_manages_checkBackups(sitesToUpdate, siteNames, _callbackAfterBackup);
841 946 };
842 947
843 948
844 949 /**
@@ -843,51 +948,56 @@
843 948
844 949 /**
845 950 * Themes manage.
846 951 */
847 -jQuery(document).ready(function () {
952 +jQuery(function () {
848 953 jQuery(document).on('click', '.mainwp-manages-theme-activate', function () {
849 954 manages_themeAction(jQuery(this), 'activate');
850 955 return false;
851 956 });
852 957 jQuery(document).on('click', '.mainwp-manages-theme-delete', function () {
853 - manages_themeAction(jQuery(this), 'delete');
958 + let name = jQuery(this).closest('.mainwp-manage-theme-item-website').attr('theme-name');
959 + let confirmMsg = MainWP.I18n.t('You are about to delete the %1?', name);
960 + mainwp_confirm(confirmMsg, () => {
961 + manages_themeAction(jQuery(this), 'delete');
962 + });
854 963 return false;
855 964 });
856 965 });
857 966
858 -manages_themeAction = function (elem, what) {
859 - var rowElement = jQuery(elem).closest('.mainwp-manage-theme-item-website');
860 - var theme = rowElement.attr('theme-slug');
861 - var websiteId = rowElement.attr('site-id');
967 +let manages_themeAction = function (elem, what) {
968 + let rowElement = jQuery(elem).closest('.mainwp-manage-theme-item-website');
969 + let theme = rowElement.attr('theme-slug');
970 + let websiteId = rowElement.attr('site-id');
862 971
863 - var data = mainwp_secure_data({
972 + let data = mainwp_secure_data({
864 973 action: 'mainwp_widget_theme_' + what, // same with theme widget.
865 974 theme: theme,
866 975 websiteId: websiteId
867 976 });
868 977
869 - var parent = jQuery(elem).closest('.column.column-actions');
870 - jQuery(parent).html('<i class="notched circle loading icon"></i>' + __('Please wait...') + '</div>');
978 + let start_row = '<div class="one wide center aligned middle aligned column"></div><div class="thirteen wide left aligned middle aligned column">';
979 + let end_row = '</div>';
871 980
981 + jQuery(rowElement).html(start_row + '<i class="notched circle loading icon"></i>' + MainWP.I18n.t('Please wait...') + end_row);
872 982 jQuery.post(ajaxurl, data, function (response) {
873 - if (response && response.error) {
874 - jQuery(parent).html('<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
875 - } else if (response && response.result) {
983 + if (response?.error) {
984 + jQuery(rowElement).html(start_row + '<span data-tooltip="' + response.error + '" data-inverted="" data-position="left center"><i class="times red icon"></i></span>' + end_row);
985 + } else if (response?.result) {
876 986 if (what == 'delete') {
877 - jQuery(rowElement).html('<i class="check circle green icon"></i> ' + response.result);
987 + jQuery(rowElement).html(start_row + '<i class="green check icon"></i> ' + response.result + end_row);
878 988 setTimeout(function () {
879 989 jQuery(rowElement).fadeOut(1000);
880 990 }, 1000);
881 991
882 992 } else {
883 - jQuery(parent).html('<i class="check circle green icon"></i> ' + response.result);
993 + jQuery(rowElement).html(start_row + '<i class="green check icon"></i> ' + response.result + end_row);
884 994 }
885 995 setTimeout(function () {
886 - mainwp_fetch_themes();
887 - }, 3000);
996 + mainwp_fetch_themes(true);
997 + }, 100);
888 998 } else {
889 - jQuery(parent).html('<span data-tooltip="Undefined error occured. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>');
999 + jQuery(rowElement).html(start_row + '<span data-tooltip="Undefined error occurred. Please try again." data-inverted="" data-position="left center"><i class="times red icon"></i></span>' + end_row);
890 1000 }
891 1001 }, 'json');
892 1002
893 1003 return false;
@@ -893,96 +1003,99 @@
893 1003 return false;
894 1004 };
895 1005
896 1006
897 -manage_themes_upgrade_theme = function (slug, websiteid) {
898 - var msg = __('Are you sure you want to update the theme on the selected site?');
1007 +let manage_themes_upgrade_theme = function (slug, websiteid) {
1008 + let msg = MainWP.I18n.t('Are you sure you want to update the theme on the selected site?');
899 1009 mainwp_confirm(msg, function () {
900 1010 return manage_themes_upgrade_int(slug, websiteid);
901 1011 }, false, 1);
902 1012 };
903 1013
904 -
905 -manage_themes_upgrade_int = function (slug, websiteId) {
906 - var websiteHolder = jQuery('.mainwp-manage-theme-item-website[theme-slug="' + slug + '"][site-id="' + websiteId + '"]');
907 - websiteHolder.find('.column.update-column').html('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...'));
908 - manage_themes_upgrade_continueAfterBackup = function () {
909 - console.log('theme upgrade continue');
910 - return function () {
911 - var data = mainwp_secure_data({
912 - action: 'mainwp_upgradeplugintheme',
913 - websiteId: websiteId,
914 - type: 'theme',
915 - slug: slug
916 - });
917 - jQuery.ajax({
918 - type: "POST",
919 - url: ajaxurl,
920 - data: data,
921 - success: function (pSlug, siteHolder) {
922 - return function (response) {
923 - if (response.error) {
924 - var extErr = getErrorMessageInfo(response.error, 'ui')
925 - siteHolder.find('.column.update-column').html(extErr);
926 - } else {
927 - var res = response.result;
928 - if (res[pSlug]) {
929 - siteHolder.attr('updated', 1);
930 - siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>');
931 - } else {
932 - siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
933 - }
934 - setTimeout(function () {
935 - mainwp_fetch_themes();
936 - }, 3000);
1014 +let manage_themes_upgrade_continueAfterBackup = function (slug, websiteId, websiteHolder) {
1015 + let siteHolder = websiteHolder;
1016 + let pSlug = slug;
1017 + return function () {
1018 + let data = mainwp_secure_data({
1019 + action: 'mainwp_upgradeplugintheme',
1020 + websiteId: websiteId,
1021 + type: 'theme',
1022 + slug: slug
1023 + });
1024 + jQuery.ajax({
1025 + type: "POST",
1026 + url: ajaxurl,
1027 + data: data,
1028 + success: function (response) {
1029 + if (response.error) {
1030 + let extErr = getErrorMessageInfo(response.error, 'ui')
1031 + siteHolder.find('.column.update-column').html(extErr);
1032 + } else {
1033 + let res = response.result;
1034 + let res_error = response.result_error;
1035 + if (res[pSlug]) {
1036 + siteHolder.attr('updated', 1);
1037 + siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>');
1038 + } else if (res_error ? res_error[slug] : false) {
1039 + let _error = res_error[slug];
1040 + let _icon = '<i class="red times icon"></i>';
1041 + let roll_error = mainwp_updates_get_rollback_msg(_error);
1042 + if (roll_error) {
1043 + _error = roll_error;
1044 + _icon = mainwpParams.roll_ui_icon;
937 1045 }
938 - }
939 - }(slug, websiteHolder),
940 - tryCount: 0,
941 - retryLimit: 3,
942 - endError: function (siteHolder) {
943 - return function () {
1046 + siteHolder.find('.column.update-column').html('<span data-inverted="" data-position="left center" data-tooltip="' + _error + '">' + _icon + '</span>');
1047 + } else {
944 1048 siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
945 1049 }
946 - }(websiteHolder),
947 - error: function (xhr) {
948 - this.tryCount++;
949 - if (this.tryCount >= this.retryLimit) {
950 - this.endError();
951 - return;
1050 + setTimeout(function () {
1051 + mainwp_fetch_themes();
1052 + }, 3000);
1053 + }
1054 + },
1055 + tryCount: 0,
1056 + retryLimit: 3,
1057 + endError: function () {
1058 + siteHolder.find('.column.update-column').html('<i class="red times icon"></i>');
1059 + },
1060 + error: function (xhr) {
1061 + this.tryCount++;
1062 + if (this.tryCount >= this.retryLimit) {
1063 + this.endError();
1064 + return;
1065 + }
1066 + setTimeout((pRqst, pXhr) => {
1067 + if (pXhr.status == 404) {
1068 + //handle error
1069 + jQuery.ajax(pRqst);
1070 + } else if (pXhr.status == 500) {
1071 + //handle error
1072 + } else {
1073 + //handle error
952 1074 }
953 - var fnc = function (pRqst, pXhr) {
954 - return function () {
955 - if (pXhr.status == 404) {
956 - //handle error
957 - jQuery.ajax(pRqst);
958 - } else if (pXhr.status == 500) {
959 - //handle error
960 - } else {
961 - //handle error
962 - }
963 - }
964 - }(this, xhr);
965 - setTimeout(fnc, 500);
966 - },
967 - dataType: 'json'
968 - });
969 - manage_themes_upgrade_continueAfterBackup = undefined;
970 - }();
971 - };
1075 + }, 500, this, xhr);
1076 + },
1077 + dataType: 'json'
1078 + });
1079 + }();
1080 +}
972 1081
973 - if (mainwpParams['disable_checkBackupBeforeUpgrade'] == true) {
974 - if (manage_themes_upgrade_continueAfterBackup != undefined) {
975 - manage_themes_upgrade_continueAfterBackup();
976 - }
1082 +let manage_themes_upgrade_int = function (slug, websiteId) {
1083 + let websiteHolder = jQuery('.mainwp-manage-theme-item-website[theme-slug="' + slug + '"][site-id="' + websiteId + '"]');
1084 + websiteHolder.find('.column.update-column').html('<span data-tooltip="Updating..." data-inverted="" data-position="left center"><i class="notched circle loading icon"></i></span');
1085 +
1086 + let _callbackAfterBackup = manage_themes_upgrade_continueAfterBackup(slug, websiteId, websiteHolder);
1087 +
1088 + if (mainwpParams['disable_checkBackupBeforeUpgrade']) {
1089 + _callbackAfterBackup();
977 1090 return false;
978 1091 }
979 1092
980 - var sitesToUpdate = [websiteId];
981 - var siteNames = []
1093 + let sitesToUpdate = [websiteId];
1094 + let siteNames = [];
982 1095 siteNames[websiteId] = jQuery(websiteHolder).attr('site-name');
983 1096
984 - return mainwp_manages_checkBackups(sitesToUpdate, siteNames, manage_themes_upgrade_continueAfterBackup);
1097 + return mainwp_manages_checkBackups(sitesToUpdate, siteNames, _callbackAfterBackup);
985 1098 };
986 1099
987 1100
988 1101 /**
@@ -987,27 +1100,27 @@
987 1100
988 1101 /**
989 1102 * Check Backups.
990 1103 */
991 -mainwp_manages_checkBackups = function (sitesToUpdate, siteNames, continueAfterBackup) {
992 - managesitesShowBusyFunction = function () {
993 - var output = __('Checking if a backup is required for the selected updates...');
1104 +let mainwp_manages_checkBackups = function (sitesToUpdate, siteNames, continueAfterBackup) {
1105 + let managesitesShowBusyFunction = function () {
1106 + let output = MainWP.I18n.t('Checking if a backup is required for the selected updates...');
994 1107 mainwpPopup('#managesites-backup-box').getContentEl().html(output);
995 1108 jQuery('#managesites-backup-all').hide();
996 1109 jQuery('#managesites-backup-ignore').hide();
997 1110 mainwpPopup('#managesites-backup-box').init({
998 - title: __("Checking backup settings..."), callback: function () {
999 - bulkManageSitesTaskRunning = false;
1000 - window.location.href = location.href;
1111 + title: MainWP.I18n.t("Checking backup settings..."), callback: function () {
1112 + mainwpVars.bulkManageSitesTaskRunning = false;
1113 + mainwp_forceReload();
1001 1114 }
1002 1115 });
1003 1116
1004 1117 };
1005 1118
1006 - var managesitesShowBusyTimeout = setTimeout(managesitesShowBusyFunction, 300);
1119 + let managesitesShowBusyTimeout = setTimeout(managesitesShowBusyFunction, 300);
1007 1120
1008 1121 //Step 2: Check if backups are ok.
1009 - var data = mainwp_secure_data({
1122 + let data = mainwp_secure_data({
1010 1123 action: 'mainwp_checkbackups',
1011 1124 sites: sitesToUpdate
1012 1125 });
1013 1126
@@ -1019,14 +1132,14 @@
1019 1132 return function (response) {
1020 1133 clearTimeout(managesitesShowBusyTimeout);
1021 1134
1022 1135 mainwpPopup('#managesites-backup-box').close();
1023 - var siteFeedback = undefined;
1136 + let siteFeedback;
1024 1137
1025 - if (response['result'] && response['result']['sites'] != undefined) {
1138 + if (response?.result?.sites) {
1026 1139 siteFeedback = [];
1027 - for (var currSiteId in response['result']['sites']) {
1028 - if (response['result']['sites'][currSiteId] == false) {
1140 + for (let currSiteId in response['result']['sites']) {
1141 + if (!response['result']['sites'][currSiteId]) {
1029 1142 siteFeedback.push(currSiteId);
1030 1143 }
1031 1144 }
1032 1145 if (siteFeedback.length == 0)
@@ -1033,37 +1146,13 @@
1033 1146 siteFeedback = undefined;
1034 1147 }
1035 1148
1036 1149 if (siteFeedback != undefined) {
1037 - var backupPrimary = '';
1038 - if (response['result']['primary_backup'] && response['result']['primary_backup'] != undefined)
1039 - backupPrimary = response['result']['primary_backup'];
1040 -
1041 - if (backupPrimary == '') {
1042 - jQuery('#managesites-backup-all').show();
1043 - jQuery('#managesites-backup-ignore').show();
1044 - } else {
1045 - var backupLink = mainwp_get_primaryBackup_link(backupPrimary);
1046 - jQuery('#managesites-backup-now').attr('href', backupLink).show();
1047 - jQuery('#managesites-backup-ignore').val(__('Proceed with Updates')).show();
1048 - }
1049 -
1050 - var output = '<span class="mainwp-red">' + __('A full backup has not been taken in the last days for the following sites:') + '</span><br /><br />';
1051 - if (backupPrimary == '') { // default backup feature
1052 - for (var j = 0; j < siteFeedback.length; j++) {
1053 - output += '<span class="managesites-backup-site" siteid="' + siteFeedback[j] + '">' + decodeURIComponent(pSiteNames[siteFeedback[j]]) + '</span><br />';
1054 - }
1055 - } else {
1056 - for (var j = 0; j < siteFeedback.length; j++) {
1057 - output += '<span>' + decodeURIComponent(pSiteNames[siteFeedback[j]]) + '</span><br />';
1058 - }
1059 - }
1060 - mainwpPopup('#managesites-backup-box').getContentEl().html(output);
1061 - console.log(typeof continueAfterBackup);
1150 + mainwp_managesites_prepare_backup_popup(response, pSiteNames, siteFeedback);
1062 1151 mainwpPopup('#managesites-backup-box').init({
1063 - title: __("Full backup required!"), callback: function () {
1152 + title: MainWP.I18n.t("Full backup required!"), callback: function () {
1064 1153 continueAfterBackup = undefined;
1065 - window.location.href = location.href;
1154 + mainwp_forceReload();
1066 1155 }
1067 1156 });
1068 1157
1069 1158 return false;