| @@ -1,14 +1,12 @@ | ||
| 1 | -/* eslint complexity: ["error", 100] */ | |
| 1 | +/* eslint-disable complexity */ | |
| 2 | 2 | // current complexity is the only way to achieve desired results, pull request solutions appreciated. |
| 3 | 3 | |
| 4 | -window.mainwpVars = window.mainwpVars || {}; | |
| 5 | - | |
| 4 | +globalThis.mainwpVars = globalThis.mainwpVars || {}; | |
| 6 | 5 | mainwpVars.errorCount = 0; |
| 7 | - | |
| 8 | 6 | mainwpVars.actionsErrors = {}; |
| 9 | 7 | |
| 10 | -window.mainwp_put_actions_errors_msg = function (action, itemId, msgType, errorMsg) { | |
| 8 | +globalThis.mainwp_put_actions_errors_msg = function (action, itemId, msgType, errorMsg) { | |
| 11 | 9 | mainwpVars.actionsErrors[action] = mainwpVars.actionsErrors?.[action] || {}; |
| 12 | 10 | mainwpVars.actionsErrors[action][itemId] = mainwpVars.actionsErrors[action]?.[itemId] || {}; |
| 13 | 11 | mainwpVars.actionsErrors[action][itemId][msgType] = mainwpVars.actionsErrors[action]?.[itemId]?.[msgType] || []; |
| 14 | 12 | mainwpVars.actionsErrors[action][itemId][msgType].push(errorMsg); |
| @@ -13,20 +11,18 @@ | ||
| 13 | 11 | mainwpVars.actionsErrors[action][itemId][msgType] = mainwpVars.actionsErrors[action]?.[itemId]?.[msgType] || []; |
| 14 | 12 | mainwpVars.actionsErrors[action][itemId][msgType].push(errorMsg); |
| 15 | 13 | } |
| 16 | 14 | |
| 17 | -window.mainwp_get_actions_errors_msg = function (action, itemId, msgType) { | |
| 15 | +globalThis.mainwp_get_actions_errors_msg = function (action, itemId, msgType) { | |
| 18 | 16 | let errors = mainwpVars.actionsErrors?.[action]?.[itemId]?.[msgType] || []; |
| 19 | - let array = errors.map(function (val, idx) { | |
| 17 | + let array = errors.map(function (val) { | |
| 20 | 18 | return val; |
| 21 | 19 | }); |
| 22 | - array = array.filter(function (el) { | |
| 23 | - return el; | |
| 24 | - }); | |
| 20 | + array = array.filter(Boolean); | |
| 25 | 21 | return array.join('<br/>'); |
| 26 | 22 | } |
| 27 | 23 | |
| 28 | -window.mainwp_updates_get_rollback_msg = function (error) { | |
| 24 | +globalThis.mainwp_updates_get_rollback_msg = function (error) { | |
| 29 | 25 | if (error && typeof error == "string") { |
| 30 | 26 | if (error.startsWith('[Roll]')) { |
| 31 | 27 | return error.replace('[Roll]', ''); |
| 32 | 28 | } |
| @@ -33,16 +29,72 @@ | ||
| 33 | 29 | } |
| 34 | 30 | return ''; |
| 35 | 31 | } |
| 36 | 32 | |
| 37 | -window.mainwp_init_html_popup = function (popupSelector, content) { | |
| 33 | +globalThis.mainwp_init_html_popup = function (popupSelector, content) { | |
| 38 | 34 | jQuery(popupSelector).popup({ |
| 39 | - inline: true, | |
| 40 | - html: '<div class="mainwp-html-popup-body">' + content + '</div>', | |
| 35 | + html: function () { | |
| 36 | + if (content === undefined) { | |
| 37 | + if (typeof popupSelector !== 'string') { | |
| 38 | + // popup selector is object. | |
| 39 | + content = jQuery(popupSelector).attr('html-popup-content') ?? '' | |
| 40 | + } | |
| 41 | + } | |
| 42 | + return '<div class="mainwp-html-popup-body">' + content + '</div>'; | |
| 43 | + } | |
| 41 | 44 | }); |
| 42 | 45 | }; |
| 43 | 46 | |
| 44 | -// Init Per Group data | |
| 47 | +// Decode slug safely. | |
| 48 | +globalThis.mainwp_decode_slug = function (value, escape ) { // NOSONAR | |
| 49 | + if (typeof value !== 'string' || !value.includes('%')) { | |
| 50 | + return (true === escape && typeof value === 'string') ? mainwp_escape_html(value) : value; | |
| 51 | + } | |
| 52 | + | |
| 53 | + try { | |
| 54 | + value = decodeURIComponent(value); | |
| 55 | + } catch { | |
| 56 | + // nothing. | |
| 57 | + } | |
| 58 | + | |
| 59 | + if(true === escape){ | |
| 60 | + return mainwp_escape_html(value); | |
| 61 | + } | |
| 62 | + | |
| 63 | + return value; | |
| 64 | +}; | |
| 65 | + | |
| 66 | +globalThis.mainwp_escape_html = function (value) { // NOSONAR | |
| 67 | + const div = document.createElement('div'); | |
| 68 | + div.textContent = value ?? ''; | |
| 69 | + | |
| 70 | + return div.innerHTML | |
| 71 | + .replace(/"/g, '"') | |
| 72 | + .replace(/'/g, '''); | |
| 73 | +}; | |
| 74 | + | |
| 75 | + | |
| 76 | +// Normalize slug list to array. | |
| 77 | +globalThis.mainwp_slug_list_to_array = function (value) { // NOSONAR. | |
| 78 | + if (Array.isArray(value)) { | |
| 79 | + return value.filter(function (v) { return v !== null && v !== undefined && String(v).trim() !== ''; }); | |
| 80 | + } | |
| 81 | + if (typeof value !== 'string') { | |
| 82 | + value = (value === null || value === undefined) ? '' : String(value); | |
| 83 | + } | |
| 84 | + if (value === '') return []; | |
| 85 | + return value.split(',').map(function (v) { return v.trim(); }).filter(function (v) { return v !== ''; }); | |
| 86 | +}; | |
| 87 | + | |
| 88 | +// Safely read result/error entries. | |
| 89 | +globalThis.mainwp_get_result_entry = function (obj, key) { // NOSONAR. | |
| 90 | + if (!obj || typeof obj !== 'object') return undefined; | |
| 91 | + if (obj[key] !== undefined) return obj[key]; | |
| 92 | + let enc = encodeURIComponent(key); | |
| 93 | + return obj[enc]; | |
| 94 | +}; | |
| 95 | + | |
| 96 | +// Init Per Group data. | |
| 45 | 97 | let updatesoverview_updates_init_group_view = function () { |
| 46 | 98 | jQuery('.element_ui_view_values').each(function () { |
| 47 | 99 | let parent = jQuery(this).parent(); |
| 48 | 100 | let uid = jQuery(this).attr('elem-uid'); |
| @@ -53,14 +105,14 @@ | ||
| 53 | 105 | // carefully remove this, or it will causing error with display or according sorting |
| 54 | 106 | jQuery(parent).find("[row-uid='" + uid + "']").next().remove(); // remove content according part |
| 55 | 107 | jQuery(parent).find("[row-uid='" + uid + "']").remove(); // remove title according part |
| 56 | 108 | } else { |
| 57 | - jQuery(parent).find("[total-uid='" + uid + "']").html(total + ' ' + (total == 1 ? __('Update') : __('Updates'))); | |
| 109 | + jQuery(parent).find("[total-uid='" + uid + "']").html(total + ' ' + (total == 1 ? MainWP.I18n.t('Update') : MainWP.I18n.t('Updates'))); | |
| 58 | 110 | jQuery(parent).find("[total-uid='" + uid + "']").attr('sort-value', total); |
| 59 | 111 | } |
| 60 | 112 | |
| 61 | 113 | if (can_update) { |
| 62 | - jQuery(parent).find("[btn-all-uid='" + uid + "']").text(total == 1 ? __('Update') : __('Update All')).show(); | |
| 114 | + jQuery(parent).find("[btn-all-uid='" + uid + "']").text(total == 1 ? MainWP.I18n.t('Update') : MainWP.I18n.t('Update All')).show(); | |
| 63 | 115 | } |
| 64 | 116 | }); |
| 65 | 117 | } |
| 66 | 118 | |
| @@ -71,13 +123,18 @@ | ||
| 71 | 123 | let upgradeElement = jQuery(parent).find('#wp-updated-' + id); |
| 72 | 124 | |
| 73 | 125 | if (upgradeElement.val() != 0) |
| 74 | 126 | return false; |
| 127 | + // Show icon waiting | |
| 128 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 129 | + let waiting_icon = ''; | |
| 130 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 131 | + waiting_icon += regression_waiting_icon; | |
| 132 | + } | |
| 75 | 133 | |
| 76 | - | |
| 77 | 134 | updatesoverviewContinueAfterBackup = function (pId, pUpgradeElement) { |
| 78 | 135 | return function () { |
| 79 | - jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + __('Updating. Please wait...')); | |
| 136 | + jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + MainWP.I18n.t('Updating. Please wait...') + waiting_icon); | |
| 80 | 137 | pUpgradeElement.val(1); |
| 81 | 138 | let data = mainwp_secure_data({ |
| 82 | 139 | action: 'mainwp_upgradewp', |
| 83 | 140 | id: pId |
| @@ -88,11 +145,17 @@ | ||
| 88 | 145 | let err_msg = ''; |
| 89 | 146 | if (response.error.extra) { |
| 90 | 147 | err_msg = response.error.extra + ' '; |
| 91 | 148 | } |
| 92 | - jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + err_msg + '"><i class="red times icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pId)); | |
| 149 | + let errIcon = '<i class="pause yellow icon"></i>'; | |
| 150 | + if (response?.error?.errorCode == 'SUSPENDED_SITE') { | |
| 151 | + errIcon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '">' + errIcon + '</span>'; | |
| 152 | + } | |
| 153 | + jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + err_msg + '">' + errIcon + '</span>'); | |
| 93 | 154 | } else { |
| 94 | - jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pId)); | |
| 155 | + | |
| 156 | + jQuery('.mainwp-wordpress-update[site_id="' + pId + '"] > td:last-child').html(response.result); | |
| 157 | + | |
| 95 | 158 | } |
| 96 | 159 | |
| 97 | 160 | |
| 98 | 161 | }, 'json'); |
| @@ -103,9 +166,9 @@ | ||
| 103 | 166 | let siteNames = []; |
| 104 | 167 | |
| 105 | 168 | siteNames[id] = jQuery('.mainwp-wordpress-update[site_id="' + id + '"]').attr('site_name'); |
| 106 | 169 | |
| 107 | - let msg = __('Are you sure you want to update the Wordpress core files on the selected site?'); | |
| 170 | + let msg = MainWP.I18n.t('Are you sure you want to update the Wordpress core files on the selected site?'); | |
| 108 | 171 | mainwp_confirm(msg, function () { |
| 109 | 172 | return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames); |
| 110 | 173 | }, false, 1); |
| 111 | 174 | }; |
| @@ -116,20 +179,26 @@ | ||
| 116 | 179 | let updatesoverviewContinueAfterBackup; |
| 117 | 180 | let limitUpdateAll = 0; |
| 118 | 181 | let continueUpdatesAll = '', continueUpdatesSlug = ''; |
| 119 | 182 | let continueUpdating = false; |
| 120 | - | |
| 121 | 183 | let updatesoverview_update_popup_init = function (data) { |
| 122 | 184 | data = data || {}; |
| 123 | - data.allowMultiple = true; | |
| 124 | - data.callback = function () { | |
| 125 | - mainwpVars.bulkTaskRunning = false; | |
| 126 | - window.location.href = location.href; | |
| 127 | - }; | |
| 128 | - data.statusText = __('updated'); | |
| 129 | - mainwpPopup('#mainwp-sync-sites-modal').init(data); | |
| 185 | + let settings = { | |
| 186 | + allowMultiple: true, | |
| 187 | + statusText: MainWP.I18n.t('updated'), | |
| 188 | + callback: function () { | |
| 189 | + mainwpVars.bulkTaskRunning = false; | |
| 190 | + mainwp_forceReload(); | |
| 191 | + } | |
| 192 | + } | |
| 193 | + jQuery.extend(settings, data); | |
| 194 | + mainwpPopup('#mainwp-sync-sites-modal').init(settings); | |
| 130 | 195 | } |
| 131 | 196 | |
| 197 | +let updatesmanage_link_to_site = function (name, siteid) { | |
| 198 | + return '<a href="admin.php?page=managesites&dashboard=' + siteid + '">' + name + '</a>'; | |
| 199 | +} | |
| 200 | + | |
| 132 | 201 | // Update Group |
| 133 | 202 | let updatesoverview_wordpress_global_upgrade_all = function (groupId, updatesSelected) { |
| 134 | 203 | if (mainwpVars.bulkTaskRunning) |
| 135 | 204 | return; |
| @@ -146,9 +215,9 @@ | ||
| 146 | 215 | |
| 147 | 216 | mainwpPopup('#mainwp-sync-sites-modal').clearList(); |
| 148 | 217 | |
| 149 | 218 | for (let i = 0; i < foundChildren.length; i++) { |
| 150 | - if (limitUpdateAll > 0 && i >= limitUpdateAll && typeof groupId === 'undefined') { | |
| 219 | + if (limitUpdateAll > 0 && i >= limitUpdateAll && groupId === undefined) { | |
| 151 | 220 | continueUpdatesAll = 'wpcore_global_upgrade_all'; |
| 152 | 221 | break; |
| 153 | 222 | } |
| 154 | 223 | |
| @@ -155,9 +224,9 @@ | ||
| 155 | 224 | let child = foundChildren[i]; |
| 156 | 225 | let siteId = jQuery(child).attr('site_id'); |
| 157 | 226 | let siteName = jQuery(child).attr('site_name'); |
| 158 | 227 | |
| 159 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 228 | + if (!sitesToUpdate.includes(siteId)) { | |
| 160 | 229 | sitesCount++; |
| 161 | 230 | sitesToUpdate.push(siteId); |
| 162 | 231 | siteNames[siteId] = siteName; |
| 163 | 232 | } |
| @@ -164,14 +233,14 @@ | ||
| 164 | 233 | } |
| 165 | 234 | |
| 166 | 235 | let _callback = function () { |
| 167 | 236 | for (let id of sitesToUpdate) { |
| 168 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]) + ' (WordPress update)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 237 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id) + ' (WordPress update)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 169 | 238 | } |
| 170 | 239 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate) { |
| 171 | 240 | return function () { |
| 172 | 241 | let initData = { |
| 173 | - title: __('Updating All'), | |
| 242 | + title: MainWP.I18n.t('Updating All'), | |
| 174 | 243 | progressMax: pSitesCount, |
| 175 | 244 | }; |
| 176 | 245 | |
| 177 | 246 | updatesoverview_update_popup_init(initData); |
| @@ -193,9 +262,9 @@ | ||
| 193 | 262 | if (value) { // to fix |
| 194 | 263 | sitesList.push(decodeURIComponent(value)); |
| 195 | 264 | } |
| 196 | 265 | }); |
| 197 | - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('WordPress Core'), sitesList.join('<br />')); | |
| 266 | + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('WordPress Core'), sitesList.join('<br />')); | |
| 198 | 267 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 199 | 268 | } |
| 200 | 269 | return; |
| 201 | 270 | } |
| @@ -226,10 +295,10 @@ | ||
| 226 | 295 | } |
| 227 | 296 | |
| 228 | 297 | let updatesoverview_wordpress_get_global_upgrade_all = function (groupId, updatesSelected) { |
| 229 | 298 | let foundChildren = []; |
| 230 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 231 | - if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 299 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 300 | + if (groupId !== undefined && false !== groupId) { | |
| 232 | 301 | foundChildren = mainwp_updates_get_selected_rows_values('#update_wrapper_wp_upgrades_group_' + groupId, 'tr.mainwp-wordpress-update[updated="0"]'); |
| 233 | 302 | } else { |
| 234 | 303 | foundChildren = mainwp_updates_get_selected_rows_values('tr.mainwp-wordpress-update[updated="0"]'); |
| 235 | 304 | } |
| @@ -236,9 +305,9 @@ | ||
| 236 | 305 | if (foundChildren.length == 0) { |
| 237 | 306 | updates_please_select_items_notice(); |
| 238 | 307 | return false; |
| 239 | 308 | } |
| 240 | - } else if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 309 | + } else if (groupId !== undefined && false !== groupId) { | |
| 241 | 310 | // groups selector is only one for each screen. |
| 242 | 311 | foundChildren = jQuery('#update_wrapper_wp_upgrades_group_' + groupId).find('tr.mainwp-wordpress-update[updated="0"]'); |
| 243 | 312 | } else { |
| 244 | 313 | // childs selector is only one for each screen. |
| @@ -256,9 +325,9 @@ | ||
| 256 | 325 | mainwpVars.bulkTaskRunning = true; |
| 257 | 326 | updatesoverview_wordpress_upgrade_all_loop_next(); |
| 258 | 327 | }; |
| 259 | 328 | let updatesoverview_wordpress_upgrade_all_loop_next = function () { |
| 260 | - while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 329 | + while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 261 | 330 | updatesoverview_wordpress_upgrade_all_upgrade_next(); |
| 262 | 331 | } |
| 263 | 332 | }; |
| 264 | 333 | let updatesoverview_wordpress_upgrade_all_update_site_status = function (siteId, newStatus) { |
| @@ -266,11 +335,17 @@ | ||
| 266 | 335 | }; |
| 267 | 336 | let updatesoverview_wordpress_upgrade_all_upgrade_next = function () { |
| 268 | 337 | mainwpVars.currentThreads++; |
| 269 | 338 | mainwpVars.websitesLeft--; |
| 339 | + // Show icon waiting | |
| 340 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 341 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 342 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 343 | + waiting_icon += regression_waiting_icon; | |
| 344 | + } | |
| 270 | 345 | |
| 271 | 346 | let websiteId = mainwpVars.websitesToUpgrade[mainwpVars.currentWebsite++]; |
| 272 | - updatesoverview_wordpress_upgrade_all_update_site_status(websiteId, __('<i class="notched circle loading icon"></i>')); | |
| 347 | + updatesoverview_wordpress_upgrade_all_update_site_status(websiteId, waiting_icon); | |
| 273 | 348 | |
| 274 | 349 | updatesoverview_wordpress_upgrade_int(websiteId, true); |
| 275 | 350 | }; |
| 276 | 351 | let updatesoverview_wordpress_upgrade_all_update_done = function () { |
| @@ -294,12 +369,16 @@ | ||
| 294 | 369 | let err_msg = ''; |
| 295 | 370 | if (response.error.extra) { |
| 296 | 371 | err_msg = response.error.extra + ' '; |
| 297 | 372 | } |
| 373 | + let errIcon = '<i class="red times icon"></i>'; | |
| 374 | + if (response?.error?.errorCode == 'SUSPENDED_SITE') { | |
| 375 | + errIcon = '<i class="pause yellow icon"></i>'; | |
| 376 | + } | |
| 298 | 377 | if (pBulkMode) |
| 299 | - updatesoverview_wordpress_upgrade_all_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + err_msg + '"><i class="red times icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 378 | + updatesoverview_wordpress_upgrade_all_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + err_msg + '">' + errIcon + '</span>'); | |
| 300 | 379 | } else if (pBulkMode) { |
| 301 | - updatesoverview_wordpress_upgrade_all_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 380 | + updatesoverview_wordpress_upgrade_all_update_site_status(pWebsiteId, response.result); | |
| 302 | 381 | } |
| 303 | 382 | updatesoverview_wordpress_upgrade_all_update_done(); |
| 304 | 383 | } |
| 305 | 384 | }(websiteId, bulkMode), 'json'); |
| @@ -324,9 +403,9 @@ | ||
| 324 | 403 | |
| 325 | 404 | mainwpPopup('#mainwp-sync-sites-modal').clearList(); |
| 326 | 405 | |
| 327 | 406 | for (let i = 0; i < foundChildren.length; i++) { |
| 328 | - if (limitUpdateAll > 0 && i >= limitUpdateAll && typeof groupId === 'undefined') { | |
| 407 | + if (limitUpdateAll > 0 && i >= limitUpdateAll && groupId === undefined) { | |
| 329 | 408 | continueUpdatesAll = 'translations_global_upgrade_all'; |
| 330 | 409 | break; |
| 331 | 410 | } |
| 332 | 411 | let child = jQuery(foundChildren[i]); |
| @@ -335,9 +414,9 @@ | ||
| 335 | 414 | let siteElement; |
| 336 | 415 | let translationElement; |
| 337 | 416 | |
| 338 | 417 | let checkAttr = child.attr('site_id'); |
| 339 | - if ((typeof checkAttr !== 'undefined') && (checkAttr !== false)) { | |
| 418 | + if (checkAttr !== undefined && (checkAttr !== false)) { | |
| 340 | 419 | siteElement = child; |
| 341 | 420 | translationElement = parent; |
| 342 | 421 | } else { |
| 343 | 422 | siteElement = parent; |
| @@ -345,11 +424,11 @@ | ||
| 345 | 424 | } |
| 346 | 425 | |
| 347 | 426 | let siteId = siteElement.attr('site_id'); |
| 348 | 427 | let siteName = siteElement.attr('site_name'); |
| 349 | - let translationSlug = translationElement.attr('translation_slug'); | |
| 428 | + let translationSlug = mainwp_decode_slug(translationElement.attr('translation_slug')); | |
| 350 | 429 | |
| 351 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 430 | + if (!sitesToUpdate.includes(siteId)) { | |
| 352 | 431 | sitesCount++; |
| 353 | 432 | sitesToUpdate.push(siteId); |
| 354 | 433 | siteNames[siteId] = siteName; |
| 355 | 434 | } |
| @@ -367,9 +446,9 @@ | ||
| 367 | 446 | updateCount = 1; |
| 368 | 447 | else |
| 369 | 448 | updateCount = updateCount.length + 1; |
| 370 | 449 | |
| 371 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]) + ' (' + updateCount + ' translations)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 450 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id) + ' (' + updateCount + ' translations)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 372 | 451 | } |
| 373 | 452 | |
| 374 | 453 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesTranslationSlugs) { |
| 375 | 454 | return function () { |
| @@ -374,9 +453,9 @@ | ||
| 374 | 453 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesTranslationSlugs) { |
| 375 | 454 | return function () { |
| 376 | 455 | |
| 377 | 456 | let initData = { |
| 378 | - title: __('Updating all...'), | |
| 457 | + title: MainWP.I18n.t('Updating all...'), | |
| 379 | 458 | progressMax: pSitesCount |
| 380 | 459 | }; |
| 381 | 460 | updatesoverview_update_popup_init(initData); |
| 382 | 461 | |
| @@ -400,9 +479,9 @@ | ||
| 400 | 479 | if (value) { // to fix |
| 401 | 480 | sitesList.push(decodeURIComponent(value)); |
| 402 | 481 | } |
| 403 | 482 | }); |
| 404 | - let confirmMsg = __('You are about to update %1 on the following site(s):\n%2?', 'translations', sitesList.join(', ')); | |
| 483 | + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s):\n%2?', 'translations', sitesList.join(', ')); | |
| 405 | 484 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 406 | 485 | } |
| 407 | 486 | return false; |
| 408 | 487 | } |
| @@ -410,10 +489,10 @@ | ||
| 410 | 489 | }; |
| 411 | 490 | |
| 412 | 491 | let updatesoverview_translations_get_global_upgrade_all = function (groupId, updatesSelected) { |
| 413 | 492 | let foundChildren = []; |
| 414 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 415 | - if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 493 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 494 | + if (groupId !== undefined && false !== groupId) { | |
| 416 | 495 | foundChildren = mainwp_updates_get_selected_rows_values('#update_wrapper_translation_upgrades_group_' + groupId, 'tr.mainwp-translation-update[updated="0"]'); |
| 417 | 496 | } else { |
| 418 | 497 | foundChildren = mainwp_updates_get_selected_rows_values('#translations-updates-global', 'table tr[updated="0"]'); |
| 419 | 498 | } |
| @@ -420,9 +499,9 @@ | ||
| 420 | 499 | if (foundChildren.length == 0) { |
| 421 | 500 | updates_please_select_items_notice(); |
| 422 | 501 | return; |
| 423 | 502 | } |
| 424 | - } else if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 503 | + } else if (groupId !== undefined && false !== groupId) { | |
| 425 | 504 | foundChildren = jQuery('#update_wrapper_translation_upgrades_group_' + groupId).find('tr.mainwp-translation-update[updated="0"]'); |
| 426 | 505 | } else { |
| 427 | 506 | foundChildren = jQuery('#translations-updates-global').find('table tr[updated="0"]'); |
| 428 | 507 | } |
| @@ -455,14 +534,14 @@ | ||
| 455 | 534 | sitesToUpdate.push(siteId); |
| 456 | 535 | } |
| 457 | 536 | |
| 458 | 537 | translationName = decodeURIComponent(translationName); |
| 459 | - translationName = translationName.replace(/\+/g, ' '); | |
| 538 | + translationName = translationName.replaceAll('+', ' '); | |
| 460 | 539 | |
| 461 | 540 | let _callback = function () { |
| 462 | 541 | |
| 463 | 542 | for (let id of sitesToUpdate) { |
| 464 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 543 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 465 | 544 | } |
| 466 | 545 | |
| 467 | 546 | let sitesCount = sitesToUpdate.length; |
| 468 | 547 | |
| @@ -471,9 +550,9 @@ | ||
| 471 | 550 | |
| 472 | 551 | // init and show popup |
| 473 | 552 | |
| 474 | 553 | let initData = { |
| 475 | - title: __('Updating %1', decodeURIComponent(translationName)), | |
| 554 | + title: MainWP.I18n.t('Updating %1', decodeURIComponent(translationName)), | |
| 476 | 555 | progressMax: pSitesCount |
| 477 | 556 | }; |
| 478 | 557 | updatesoverview_update_popup_init(initData); |
| 479 | 558 | //Step 3: start updates |
| @@ -493,9 +572,9 @@ | ||
| 493 | 572 | if (value) { // to fix |
| 494 | 573 | sitesList.push(decodeURIComponent(value)); |
| 495 | 574 | } |
| 496 | 575 | }); |
| 497 | - let confirmMsg = __('You are about to update the %1 translation on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', translationName, sitesList.join('<br />')); | |
| 576 | + let confirmMsg = MainWP.I18n.t('You are about to update the %1 translation on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', translationName, sitesList.join('<br />')); | |
| 498 | 577 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 499 | 578 | } |
| 500 | 579 | return; |
| 501 | 580 | } |
| @@ -513,9 +592,9 @@ | ||
| 513 | 592 | mainwpVars.bulkTaskRunning = true; |
| 514 | 593 | updatesoverview_translations_upgrade_all_loop_next(); |
| 515 | 594 | }; |
| 516 | 595 | let updatesoverview_translations_upgrade_all_loop_next = function () { |
| 517 | - while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 596 | + while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 518 | 597 | updatesoverview_translations_upgrade_all_upgrade_next(); |
| 519 | 598 | } |
| 520 | 599 | }; |
| 521 | 600 | let updatesoverview_translations_upgrade_all_update_site_status = function (siteId, newStatus) { |
| @@ -523,11 +602,17 @@ | ||
| 523 | 602 | }; |
| 524 | 603 | let updatesoverview_translations_upgrade_all_upgrade_next = function () { |
| 525 | 604 | mainwpVars.currentThreads++; |
| 526 | 605 | mainwpVars.websitesLeft--; |
| 606 | + // Show icon waiting | |
| 607 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 608 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 609 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 610 | + waiting_icon += regression_waiting_icon; | |
| 611 | + } | |
| 527 | 612 | |
| 528 | 613 | let websiteId = mainwpVars.websitesToUpdateTranslations[mainwpVars.currentWebsite++]; |
| 529 | - updatesoverview_translations_upgrade_all_update_site_status(websiteId, '<i class="notched circle loading icon"></i>'); | |
| 614 | + updatesoverview_translations_upgrade_all_update_site_status(websiteId, waiting_icon); | |
| 530 | 615 | |
| 531 | 616 | let slugToUpgrade = currentTranslationSlugToUpgrade; |
| 532 | 617 | if (slugToUpgrade == undefined) |
| 533 | 618 | slugToUpgrade = websitesTranslationSlugsToUpgrade[websiteId]; |
| @@ -547,18 +632,42 @@ | ||
| 547 | 632 | } |
| 548 | 633 | |
| 549 | 634 | updatesoverview_translations_upgrade_all_loop_next(); |
| 550 | 635 | }; |
| 551 | -let updatesoverview_translations_upgrade_int = function (slug, websiteId, bulkMode, noCheck) { | |
| 636 | +let updatesoverview_translations_upgrade_int = function (slug, websiteId, bulkMode, noCheck) { //NOSONAR | |
| 552 | 637 | |
| 553 | - updatesoverviewContinueAfterBackup = function () { | |
| 638 | + updatesoverviewContinueAfterBackup = function () { //NOSONAR | |
| 554 | 639 | // need declare variables. |
| 555 | 640 | let pSlug = slug; |
| 556 | 641 | let pWebsiteId = websiteId; |
| 557 | 642 | let pBulkMode = bulkMode; |
| 558 | 643 | |
| 559 | - let slugParts = pSlug.split(','); | |
| 644 | + let slugList = globalThis.mainwp_slug_list_to_array(pSlug); | |
| 560 | 645 | |
| 646 | + const yithSlugList = slugList.filter(slg => slg.startsWith('yith-')); | |
| 647 | + const noneYithSlugs = slugList.filter(slg => !slg.startsWith('yith-')); | |
| 648 | + | |
| 649 | + let currentSlug = ''; | |
| 650 | + let slugParts = []; | |
| 651 | + let remainingSlugs = []; | |
| 652 | + | |
| 653 | + if (noneYithSlugs.length > 0) { | |
| 654 | + currentSlug = noneYithSlugs.join(','); | |
| 655 | + slugParts = noneYithSlugs; | |
| 656 | + remainingSlugs = yithSlugList; | |
| 657 | + } else if (yithSlugList.length > 0) { | |
| 658 | + currentSlug = yithSlugList.shift(); | |
| 659 | + remainingSlugs = yithSlugList; | |
| 660 | + slugParts = [currentSlug]; | |
| 661 | + } | |
| 662 | + | |
| 663 | + // Show icon waiting | |
| 664 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 665 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Updating. Please wait...')); | |
| 666 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 667 | + waiting_icon += regression_waiting_icon; | |
| 668 | + } | |
| 669 | + | |
| 561 | 670 | for (let sid of slugParts) { |
| 562 | 671 | let websiteHolder = jQuery('.translations-bulk-updates[translation_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]'); |
| 563 | 672 | if (!websiteHolder.exists()) { |
| 564 | 673 | websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]'); |
| @@ -563,9 +672,9 @@ | ||
| 563 | 672 | if (!websiteHolder.exists()) { |
| 564 | 673 | websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]'); |
| 565 | 674 | } |
| 566 | 675 | |
| 567 | - websiteHolder.find('td:last-child').html('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...')); | |
| 676 | + websiteHolder.find('td:last-child').html(waiting_icon); | |
| 568 | 677 | } |
| 569 | 678 | |
| 570 | 679 | let data = mainwp_secure_data({ |
| 571 | 680 | action: 'mainwp_upgradeplugintheme', |
| @@ -570,9 +679,9 @@ | ||
| 570 | 679 | let data = mainwp_secure_data({ |
| 571 | 680 | action: 'mainwp_upgradeplugintheme', |
| 572 | 681 | websiteId: pWebsiteId, |
| 573 | 682 | type: 'translation', |
| 574 | - slug: pSlug | |
| 683 | + slug: currentSlug | |
| 575 | 684 | }); |
| 576 | 685 | |
| 577 | 686 | jQuery.ajax({ |
| 578 | 687 | type: "POST", |
| @@ -577,13 +686,20 @@ | ||
| 577 | 686 | jQuery.ajax({ |
| 578 | 687 | type: "POST", |
| 579 | 688 | url: ajaxurl, |
| 580 | 689 | data: data, |
| 581 | - success: function (pSlug, pWebsiteId, pBulkMode) { | |
| 582 | - return function (response) { // NOSONAR - complex. | |
| 583 | - let slugParts = pSlug.split(','); | |
| 690 | + success: function (pSlug, pWebsiteId, pBulkMode) { //NOSONAR | |
| 691 | + return function (response) { //NOSONAR | |
| 692 | + let slugParts = []; | |
| 693 | + if (pSlug.includes(',')) { | |
| 694 | + slugParts = pSlug.split(','); | |
| 695 | + } else { | |
| 696 | + slugParts = [pSlug]; | |
| 697 | + } | |
| 698 | + | |
| 584 | 699 | let done = false; |
| 585 | 700 | for (let sid of slugParts) { |
| 701 | + let _error = ''; | |
| 586 | 702 | let websiteHolder = jQuery('.translations-bulk-updates[translation_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]'); |
| 587 | 703 | if (!websiteHolder.exists()) { |
| 588 | 704 | websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]'); |
| 589 | 705 | } |
| @@ -588,36 +704,70 @@ | ||
| 588 | 704 | websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]'); |
| 589 | 705 | } |
| 590 | 706 | |
| 591 | 707 | if (response.error) { |
| 708 | + mainwpVars.errorCount++; | |
| 709 | + _error = getErrorMessageInfo(response.error); | |
| 710 | + let extErr = getErrorMessageInfo(response.error, 'ui'); | |
| 592 | 711 | if (!done && pBulkMode) |
| 593 | - updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<i class="red times icon"></i>'); | |
| 594 | - websiteHolder.find('td:last-child').html('<i class="red times icon"></i>'); | |
| 712 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, extErr); | |
| 713 | + websiteHolder.find('td:last-child').html(extErr); | |
| 595 | 714 | } else { |
| 596 | 715 | let res = response.result; |
| 597 | - if (res[sid]) { | |
| 598 | - if (!done && pBulkMode) | |
| 599 | - updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>'); | |
| 716 | + if (mainwp_get_result_entry(res, sid)) { | |
| 717 | + // Show icon success + icon loading | |
| 718 | + let regression_loading_icon = render_html_regression_icon(res, function (regression_final_icon) { //NOSONAR | |
| 719 | + // After 1,5s, update the element in the dom with the icon | |
| 720 | + const final_icon = `<i class="green check icon"></i> ${regression_final_icon}`; | |
| 721 | + if (!done && pBulkMode) { | |
| 722 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, final_icon); | |
| 723 | + } | |
| 724 | + websiteHolder.find('td:last-child').html(final_icon); | |
| 725 | + }); | |
| 726 | + | |
| 727 | + const success_icon = `<i class="green check icon"></i> ${regression_loading_icon}`; | |
| 728 | + if (!done && pBulkMode) { | |
| 729 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, success_icon); | |
| 730 | + } | |
| 600 | 731 | websiteHolder.attr('updated', 1); |
| 601 | - websiteHolder.find('td:last-child').html('<i class="green check icon"></i>'); | |
| 732 | + websiteHolder.find('td:last-child').html(success_icon); | |
| 602 | 733 | } else { |
| 603 | - if (!done && pBulkMode) | |
| 604 | - updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<i class="red times icon"></i>'); | |
| 734 | + mainwpVars.errorCount++; | |
| 735 | + _error = MainWP.I18n.t('Update failed. Please try again.'); | |
| 736 | + if (!done && pBulkMode) { | |
| 737 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html=""><i class="red times icon"></i></span>'); | |
| 738 | + mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error); | |
| 739 | + } | |
| 605 | 740 | websiteHolder.find('td:last-child').html('<i class="red times icon"></i>'); |
| 606 | 741 | } |
| 607 | 742 | } |
| 608 | 743 | if (!done && pBulkMode) { |
| 609 | - updatesoverview_translations_upgrade_all_update_done(); | |
| 744 | + if (remainingSlugs && remainingSlugs.length > 0) { | |
| 745 | + updatesoverview_translations_upgrade_int(remainingSlugs, pWebsiteId, pBulkMode, true); | |
| 746 | + } else { | |
| 747 | + if ( | |
| 748 | + !response.error && | |
| 749 | + (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") | |
| 750 | + ) { | |
| 751 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>'); | |
| 752 | + } | |
| 753 | + updatesoverview_translations_upgrade_all_update_done(); | |
| 754 | + } | |
| 610 | 755 | done = true; |
| 611 | 756 | } |
| 612 | 757 | } |
| 613 | 758 | } |
| 614 | - }(pSlug, pWebsiteId, pBulkMode), | |
| 759 | + }(currentSlug, pWebsiteId, pBulkMode), | |
| 615 | 760 | tryCount: 0, |
| 616 | 761 | retryLimit: 3, |
| 617 | 762 | endError: function (pSlug, pWebsiteId, pBulkMode) { |
| 618 | 763 | return function () { |
| 619 | - let slugParts = pSlug.split(','); | |
| 764 | + let slugParts = []; | |
| 765 | + if (pSlug.includes(',')) { | |
| 766 | + slugParts = pSlug.split(','); | |
| 767 | + } else { | |
| 768 | + slugParts = [pSlug]; | |
| 769 | + } | |
| 620 | 770 | let done = false; |
| 621 | 771 | for (let sid of slugParts) { |
| 622 | 772 | let result; |
| 623 | 773 | let websiteHolder = jQuery('.translations-bulk-updates[translation_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]'); |
| @@ -624,11 +774,11 @@ | ||
| 624 | 774 | if (!websiteHolder.exists()) { |
| 625 | 775 | websiteHolder = jQuery('.translations-bulk-updates[site_id="' + pWebsiteId + '"] tr[translation_slug="' + sid + '"]'); |
| 626 | 776 | } |
| 627 | 777 | |
| 628 | - result = __('FAILED'); | |
| 778 | + result = MainWP.I18n.t('FAILED'); | |
| 629 | 779 | if (!done && pBulkMode) { |
| 630 | - updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-red"><i class="exclamation icon"></i> ' + __('FAILED') + '</span>'); | |
| 780 | + updatesoverview_translations_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-red"><i class="exclamation icon"></i> ' + MainWP.I18n.t('FAILED') + '</span>'); | |
| 631 | 781 | updatesoverview_translations_upgrade_all_update_done(); |
| 632 | 782 | done = true; |
| 633 | 783 | } |
| 634 | 784 | |
| @@ -642,15 +792,14 @@ | ||
| 642 | 792 | this.endError(); |
| 643 | 793 | return; |
| 644 | 794 | } |
| 645 | 795 | |
| 646 | - let pRqst = this; | |
| 647 | 796 | let pXhr = xhr; |
| 648 | 797 | |
| 649 | - setTimeout(function () { | |
| 798 | + setTimeout(() => { | |
| 650 | 799 | if (pXhr.status == 404) { |
| 651 | 800 | //handle error |
| 652 | - jQuery.ajax(pRqst); | |
| 801 | + jQuery.ajax(this); | |
| 653 | 802 | } else if (pXhr.status == 500) { |
| 654 | 803 | //handle error |
| 655 | 804 | } else { |
| 656 | 805 | //handle error |
| @@ -693,9 +842,9 @@ | ||
| 693 | 842 | |
| 694 | 843 | mainwpPopup('#mainwp-sync-sites-modal').clearList(); |
| 695 | 844 | |
| 696 | 845 | for (let i = 0; i < foundChildren.length; i++) { |
| 697 | - if (limitUpdateAll > 0 && i >= limitUpdateAll && typeof groupId === 'undefined') { | |
| 846 | + if (limitUpdateAll > 0 && i >= limitUpdateAll && groupId === undefined) { | |
| 698 | 847 | continueUpdatesAll = 'plugins_global_upgrade_all'; |
| 699 | 848 | break; |
| 700 | 849 | } |
| 701 | 850 | let child = jQuery(foundChildren[i]); |
| @@ -704,9 +853,9 @@ | ||
| 704 | 853 | let siteElement; |
| 705 | 854 | let pluginElement; |
| 706 | 855 | |
| 707 | 856 | let checkAttr = child.attr('site_id'); |
| 708 | - if ((typeof checkAttr !== 'undefined') && (checkAttr !== false)) { | |
| 857 | + if (checkAttr !== undefined && (checkAttr !== false)) { | |
| 709 | 858 | siteElement = child; |
| 710 | 859 | pluginElement = parent; |
| 711 | 860 | } else { |
| 712 | 861 | siteElement = parent; |
| @@ -714,11 +863,11 @@ | ||
| 714 | 863 | } |
| 715 | 864 | |
| 716 | 865 | let siteId = siteElement.attr('site_id'); |
| 717 | 866 | let siteName = siteElement.attr('site_name'); |
| 718 | - let pluginSlug = pluginElement.attr('plugin_slug'); | |
| 867 | + let pluginSlug = mainwp_decode_slug(pluginElement.attr('plugin_slug')); | |
| 719 | 868 | |
| 720 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 869 | + if (!sitesToUpdate.includes(siteId)) { | |
| 721 | 870 | sitesCount++; |
| 722 | 871 | sitesToUpdate.push(siteId); |
| 723 | 872 | siteNames[siteId] = siteName; |
| 724 | 873 | } |
| @@ -736,9 +885,9 @@ | ||
| 736 | 885 | if (updateCount == null) |
| 737 | 886 | updateCount = 1; |
| 738 | 887 | else |
| 739 | 888 | updateCount = updateCount.length + 1; |
| 740 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]) + ' (' + updateCount + ' plugins)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 889 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id) + ' (' + updateCount + ' plugins)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 741 | 890 | } |
| 742 | 891 | |
| 743 | 892 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) { |
| 744 | 893 | return function () { |
| @@ -743,9 +892,9 @@ | ||
| 743 | 892 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) { |
| 744 | 893 | return function () { |
| 745 | 894 | |
| 746 | 895 | let initData = { |
| 747 | - title: __('Updating all'), | |
| 896 | + title: MainWP.I18n.t('Updating all'), | |
| 748 | 897 | progressMax: pSitesCount |
| 749 | 898 | }; |
| 750 | 899 | updatesoverview_update_popup_init(initData); |
| 751 | 900 | |
| @@ -768,9 +917,9 @@ | ||
| 768 | 917 | if (value) { // to fix |
| 769 | 918 | sitesList.push(decodeURIComponent(value)); |
| 770 | 919 | } |
| 771 | 920 | }); |
| 772 | - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('plugins'), sitesList.join('<br />')); | |
| 921 | + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('plugins'), sitesList.join('<br />')); | |
| 773 | 922 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 774 | 923 | } |
| 775 | 924 | return; |
| 776 | 925 | } |
| @@ -778,10 +927,10 @@ | ||
| 778 | 927 | }; |
| 779 | 928 | |
| 780 | 929 | let updatesoverview_plugins_get_global_upgrade_all = function (groupId, updatesSelected) { |
| 781 | 930 | let foundChildren = []; |
| 782 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 783 | - if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 931 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 932 | + if (groupId !== undefined && false !== groupId) { | |
| 784 | 933 | foundChildren = mainwp_updates_get_selected_rows_values('#update_wrapper_plugin_upgrades_group_' + groupId, 'tr.mainwp-plugin-update[updated="0"]'); |
| 785 | 934 | } else { |
| 786 | 935 | foundChildren = mainwp_updates_get_selected_rows_values('#plugins-updates-global', 'table tr[updated="0"]'); |
| 787 | 936 | } |
| @@ -788,9 +937,9 @@ | ||
| 788 | 937 | if (foundChildren.length == 0) { |
| 789 | 938 | updates_please_select_items_notice(); |
| 790 | 939 | return; |
| 791 | 940 | } |
| 792 | - } else if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 941 | + } else if (groupId !== undefined && false !== groupId) { | |
| 793 | 942 | foundChildren = jQuery('#update_wrapper_plugin_upgrades_group_' + groupId).find('tr.mainwp-plugin-update[updated="0"]'); |
| 794 | 943 | } else { |
| 795 | 944 | foundChildren = jQuery('#plugins-updates-global').find('table tr[updated="0"]'); |
| 796 | 945 | } |
| @@ -823,14 +972,14 @@ | ||
| 823 | 972 | sitesToUpdate.push(siteId); |
| 824 | 973 | } |
| 825 | 974 | |
| 826 | 975 | pluginName = decodeURIComponent(pluginName); |
| 827 | - pluginName = pluginName.replace(/\+/g, ' '); | |
| 976 | + pluginName = pluginName.replaceAll('+', ' '); | |
| 828 | 977 | |
| 829 | 978 | let _callback = function () { |
| 830 | 979 | |
| 831 | 980 | for (let id of sitesToUpdate) { |
| 832 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<span data-inverted="" data-position="left center" data-tooltip="' + __('Pending', 'mainwp') + '"><i class="clock outline icon"></i></span> ' + '</span>'); | |
| 981 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id), '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Pending', 'mainwp') + '"><i class="clock outline icon"></i></span> ' + '</span>'); | |
| 833 | 982 | } |
| 834 | 983 | |
| 835 | 984 | let sitesCount = sitesToUpdate.length; |
| 836 | 985 | |
| @@ -837,9 +986,9 @@ | ||
| 837 | 986 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSlug, pSitesToUpdate) { |
| 838 | 987 | return function () { |
| 839 | 988 | |
| 840 | 989 | let initData = { |
| 841 | - title: __('Updating %1', decodeURIComponent(pluginName)), | |
| 990 | + title: MainWP.I18n.t('Updating %1', decodeURIComponent(pluginName)), | |
| 842 | 991 | progressMax: pSitesCount |
| 843 | 992 | }; |
| 844 | 993 | updatesoverview_update_popup_init(initData); |
| 845 | 994 | |
| @@ -861,9 +1010,9 @@ | ||
| 861 | 1010 | if (value) { // to fix |
| 862 | 1011 | sitesList.push(decodeURIComponent(value)); |
| 863 | 1012 | } |
| 864 | 1013 | }); |
| 865 | - let confirmMsg = __('You are about to update the %1 plugin on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', pluginName, sitesList.join('<br />')); | |
| 1014 | + let confirmMsg = MainWP.I18n.t('You are about to update the %1 plugin on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', pluginName, sitesList.join('<br />')); | |
| 866 | 1015 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 867 | 1016 | } |
| 868 | 1017 | return; |
| 869 | 1018 | } |
| @@ -871,9 +1020,9 @@ | ||
| 871 | 1020 | }; |
| 872 | 1021 | |
| 873 | 1022 | let updatesoverview_plugins_get_upgrade_all = function (slug, updatesSelected) { |
| 874 | 1023 | let foundChildren = []; |
| 875 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 1024 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 876 | 1025 | jQuery('tr[plugin_slug="' + slug + '"]').find('table tr[updated="0"]').each( |
| 877 | 1026 | function () { |
| 878 | 1027 | if (jQuery(this).find('.child.checkbox').checkbox('is checked')) { |
| 879 | 1028 | foundChildren.push(this); |
| @@ -902,22 +1051,116 @@ | ||
| 902 | 1051 | mainwpVars.bulkTaskRunning = true; |
| 903 | 1052 | updatesoverview_plugins_upgrade_all_loop_next(); |
| 904 | 1053 | }; |
| 905 | 1054 | let updatesoverview_plugins_upgrade_all_loop_next = function () { |
| 906 | - while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 1055 | + while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 907 | 1056 | updatesoverview_plugins_upgrade_all_upgrade_next(); |
| 908 | 1057 | } |
| 909 | 1058 | }; |
| 910 | -let updatesoverview_plugins_upgrade_all_update_site_status = function (siteId, newStatus) { | |
| 911 | - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').html(newStatus); | |
| 1059 | +let updatesoverview_plugins_upgrade_all_update_site_status = function (siteId, newStatus, append) { | |
| 1060 | + const $status = jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]'); | |
| 1061 | + | |
| 1062 | + if (append) { | |
| 1063 | + $status.append(newStatus); | |
| 1064 | + } else { | |
| 1065 | + $status.html(newStatus); | |
| 1066 | + } | |
| 912 | 1067 | }; |
| 1068 | + | |
| 1069 | +/** | |
| 1070 | + * Updates the status popup for a site upgrade item. | |
| 1071 | + * | |
| 1072 | + * @param {number|string} siteId The site ID. | |
| 1073 | + * @param {number} itemnumber The upgrade item number. | |
| 1074 | + * @param {Object} options Options for updating the popup status. | |
| 1075 | + * @param {*} options.status The status content or value. | |
| 1076 | + * @param {boolean} options.ispopup Whether to display the status in a popup. | |
| 1077 | + * @param {*} options.icon The icon to display with the status. | |
| 1078 | + * @param {boolean} options.append Whether to append the content instead of replacing it. | |
| 1079 | + * @param {*} options.addition Additional content or data to include. | |
| 1080 | + * @param {boolean} options.isHidden Whether to hide the status. | |
| 1081 | + * | |
| 1082 | + * @returns {void} | |
| 1083 | + */ | |
| 1084 | +let upgradeall_update_site_popup_multi_status = function (siteId, itemnumber, options = {}) { | |
| 1085 | + if (!siteId) { | |
| 1086 | + return; | |
| 1087 | + } | |
| 1088 | + const { | |
| 1089 | + status = false, | |
| 1090 | + ispopup = false, | |
| 1091 | + icon = false, | |
| 1092 | + append = false, | |
| 1093 | + addition = false, | |
| 1094 | + isHidden = false, | |
| 1095 | + } = options; | |
| 1096 | + | |
| 1097 | + const $sitestatus = jQuery(`.updatesoverview-upgrade-status-wp[siteid="${siteId}"]`); | |
| 1098 | + const clsitem = Number.isInteger(itemnumber) ? `status-item-${itemnumber}` : 'status-item-1'; | |
| 1099 | + const clspop = true === ispopup ? 'mainwp-html-popup' : ''; | |
| 1100 | + | |
| 1101 | + let $item = $sitestatus.find(`.${clspop ? clspop + '.' : ''}${clsitem}`); | |
| 1102 | + | |
| 1103 | + if ( ! $item.length ) { | |
| 1104 | + const item = true === ispopup | |
| 1105 | + ? `<span class="${clspop} ${clsitem}" data-position="left center" data-html=""></span>` | |
| 1106 | + : `<span class="${clsitem}" data-position="left center" data-tooltip=""></span>`; | |
| 1107 | + $sitestatus.append(item); | |
| 1108 | + $item = $sitestatus.find(`.${clspop ? clspop + '.' : ''}${clsitem}`); | |
| 1109 | + } | |
| 1110 | + | |
| 1111 | + if(true === isHidden){ | |
| 1112 | + $item.hide(); | |
| 1113 | + } else { | |
| 1114 | + $item.show(); | |
| 1115 | + } | |
| 1116 | + | |
| 1117 | + if ( typeof icon === 'string' ) { | |
| 1118 | + $item.html(icon); | |
| 1119 | + } | |
| 1120 | + | |
| 1121 | + if ( typeof status === 'string' ) { | |
| 1122 | + if(true === ispopup){ | |
| 1123 | + let content = status; | |
| 1124 | + if (append) { | |
| 1125 | + const existingContent = $item?.attr('data-html') || ''; | |
| 1126 | + content = existingContent | |
| 1127 | + ? `${existingContent}<br>${status}` | |
| 1128 | + : status; | |
| 1129 | + } | |
| 1130 | + $item.attr('data-html', content); | |
| 1131 | + mainwp_init_html_popup($item, content); | |
| 1132 | + } else { | |
| 1133 | + let content = status; | |
| 1134 | + if (append) { | |
| 1135 | + const existingContent = $item?.attr('data-tooltip') || ''; | |
| 1136 | + content = existingContent | |
| 1137 | + ? `${existingContent}; ${status}` | |
| 1138 | + : status; | |
| 1139 | + } | |
| 1140 | + $item.attr('data-tooltip', content); | |
| 1141 | + } | |
| 1142 | + } | |
| 1143 | + | |
| 1144 | + if ( typeof addition === 'string' ) { | |
| 1145 | + $sitestatus.append(addition); | |
| 1146 | + } | |
| 1147 | +}; | |
| 1148 | + | |
| 1149 | + | |
| 913 | 1150 | let updatesoverview_plugins_upgrade_all_upgrade_next = function () { |
| 914 | 1151 | mainwpVars.currentThreads++; |
| 915 | 1152 | mainwpVars.websitesLeft--; |
| 916 | 1153 | |
| 1154 | + // Show icon waiting | |
| 1155 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 1156 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 1157 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 1158 | + waiting_icon += regression_waiting_icon; | |
| 1159 | + } | |
| 917 | 1160 | let websiteId = mainwpVars.websitesToUpdatePlugins[mainwpVars.currentWebsite++]; |
| 918 | 1161 | |
| 919 | - updatesoverview_plugins_upgrade_all_update_site_status(websiteId, '<i class="notched circle loading icon"></i>'); | |
| 1162 | + updatesoverview_plugins_upgrade_all_update_site_status(websiteId, waiting_icon); | |
| 920 | 1163 | |
| 921 | 1164 | let slugToUpgrade = currentPluginSlugToUpgrade; |
| 922 | 1165 | if (slugToUpgrade == undefined) |
| 923 | 1166 | slugToUpgrade = websitesPluginSlugsToUpgrade[websiteId]; |
| @@ -925,13 +1168,18 @@ | ||
| 925 | 1168 | }; |
| 926 | 1169 | |
| 927 | 1170 | let updatesoverview_check_to_continue_updates = function () { |
| 928 | 1171 | mainwpVars.bulkTaskRunning = false; |
| 929 | - setTimeout(function () { | |
| 930 | - if (!mainwpVars?.errorCount) { | |
| 931 | - mainwpPopup('#mainwp-sync-sites-modal').close(true); | |
| 932 | - } | |
| 933 | - }, 3000); | |
| 1172 | + if (!mainwpVars?.errorCount){ | |
| 1173 | + setTimeout(function () { | |
| 1174 | + // wait for generated updates-regression-score-red-flag. | |
| 1175 | + if (jQuery('.updates-regression-score-red-flag').length === 0) { | |
| 1176 | + mainwpPopup('#mainwp-sync-sites-modal').close(true); | |
| 1177 | + } | |
| 1178 | + }, 3000); | |
| 1179 | + } else { | |
| 1180 | + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed')); | |
| 1181 | + } | |
| 934 | 1182 | return false; |
| 935 | 1183 | } |
| 936 | 1184 | |
| 937 | 1185 | let updatesoverview_plugins_upgrade_all_update_done = function () { |
| @@ -949,25 +1197,63 @@ | ||
| 949 | 1197 | |
| 950 | 1198 | updatesoverview_plugins_upgrade_all_loop_next(); |
| 951 | 1199 | }; |
| 952 | 1200 | |
| 1201 | +let mainwp_handle_regression_final_icon = function (pWebsiteId, success_icon) { | |
| 1202 | + return function (regression_final_icon) { | |
| 1203 | + updatesoverview_plugins_upgrade_all_update_site_status( | |
| 1204 | + pWebsiteId, | |
| 1205 | + success_icon + ' ' + regression_final_icon | |
| 1206 | + ); | |
| 1207 | + }; | |
| 1208 | +} | |
| 953 | 1209 | |
| 954 | -let updatesoverview_plugins_upgrade_int_after_backup = function (pSlug, pWebsiteId, pBulkMode) { | |
| 1210 | +let updatesoverview_plugins_upgrade_int_after_backup = function (pSlug, pWebsiteId, pBulkMode, pLastResult, errorHappen) { // NOSONAR - nest functions. | |
| 955 | 1211 | return function () { |
| 956 | - let slugParts = pSlug.split(','); | |
| 1212 | + let slugList = globalThis.mainwp_slug_list_to_array(pSlug); // NOSONAR -- window is ok. | |
| 1213 | + | |
| 1214 | + const yithSlugList = slugList.filter(slg => slg.startsWith('yith-')); | |
| 1215 | + const noneYithSlugs = slugList.filter(slg => !slg.startsWith('yith-')); | |
| 1216 | + | |
| 1217 | + let currentSlug = ''; | |
| 1218 | + let slugParts = []; | |
| 1219 | + let remainingSlugs = []; | |
| 1220 | + | |
| 1221 | + if (noneYithSlugs.length > 0) { | |
| 1222 | + currentSlug = noneYithSlugs.join(','); | |
| 1223 | + slugParts = noneYithSlugs; | |
| 1224 | + remainingSlugs = yithSlugList; | |
| 1225 | + } else if (yithSlugList.length > 0) { | |
| 1226 | + currentSlug = yithSlugList.shift(); | |
| 1227 | + remainingSlugs = yithSlugList; | |
| 1228 | + slugParts = [currentSlug]; | |
| 1229 | + } | |
| 1230 | + | |
| 1231 | + let lastResult = pLastResult || null; | |
| 1232 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 1233 | + let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> '; | |
| 1234 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 1235 | + waiting_icon += regression_waiting_icon; | |
| 1236 | + } | |
| 1237 | + | |
| 957 | 1238 | for (let sid of slugParts) { |
| 958 | 1239 | let websiteHolder = jQuery('.plugins-bulk-updates[plugin_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]'); |
| 959 | 1240 | if (!websiteHolder.exists()) { |
| 960 | 1241 | websiteHolder = jQuery('.plugins-bulk-updates[site_id="' + pWebsiteId + '"] tr[plugin_slug="' + sid + '"]'); |
| 961 | 1242 | } |
| 962 | - websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + __('Updating. Please wait...')); | |
| 1243 | + websiteHolder.find('td:last-child').html(waiting_icon); | |
| 963 | 1244 | } |
| 964 | 1245 | |
| 1246 | + if( errorHappen === undefined ){ | |
| 1247 | + errorHappen = false; | |
| 1248 | + } | |
| 1249 | + | |
| 965 | 1250 | let data = mainwp_secure_data({ |
| 966 | 1251 | action: 'mainwp_upgradeplugintheme', |
| 967 | 1252 | websiteId: pWebsiteId, |
| 968 | 1253 | type: 'plugin', |
| 969 | - slug: pSlug | |
| 1254 | + slug: currentSlug, | |
| 1255 | + bulkUpdate: mainwpVars.websitesTotal > 1 ? 1 : 0 | |
| 970 | 1256 | }); |
| 971 | 1257 | jQuery.ajax({ |
| 972 | 1258 | type: "POST", |
| 973 | 1259 | url: ajaxurl, |
| @@ -972,12 +1258,18 @@ | ||
| 972 | 1258 | type: "POST", |
| 973 | 1259 | url: ajaxurl, |
| 974 | 1260 | data: data, |
| 975 | 1261 | success: function (pSlug, pWebsiteId, pBulkMode) { |
| 976 | - return function (response) { // NOSONAR - complex. | |
| 977 | - let slugParts = pSlug.split(','); | |
| 1262 | + return function (response) { //NOSONAR | |
| 1263 | + let slugParts = []; | |
| 1264 | + if (pSlug.includes(',')) { | |
| 1265 | + slugParts = pSlug.split(','); | |
| 1266 | + } else { | |
| 1267 | + slugParts = [pSlug]; | |
| 1268 | + } | |
| 978 | 1269 | let done = false; |
| 979 | 1270 | let bulk_errors = []; |
| 1271 | + let res_started; | |
| 980 | 1272 | let _icon = '<i class="red times icon"></i>'; |
| 981 | 1273 | for (let sid of slugParts) { |
| 982 | 1274 | let websiteHolder = jQuery('.plugins-bulk-updates[plugin_slug="' + sid + '"] tr[site_id="' + pWebsiteId + '"]'); |
| 983 | 1275 | if (!websiteHolder.exists()) { |
| @@ -989,29 +1281,41 @@ | ||
| 989 | 1281 | if (!done && pBulkMode) |
| 990 | 1282 | updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, extErr); |
| 991 | 1283 | websiteHolder.find('td:last-child').html(extErr); |
| 992 | 1284 | mainwpVars.errorCount++; |
| 1285 | + errorHappen = true; | |
| 993 | 1286 | } else { |
| 994 | 1287 | let res = response.result; |
| 995 | 1288 | let res_error = response.result_error; |
| 996 | - if (res[sid]) { | |
| 997 | - if (!done && pBulkMode) | |
| 998 | - updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 1289 | + res_started = response.result_started; // for backward compatibility. | |
| 1290 | + if (mainwp_get_result_entry(res, sid)) { | |
| 1291 | + lastResult = res; | |
| 1292 | + let _success_icon = `<i class="green check icon"></i>`; | |
| 1293 | + let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful', 'mainwp') + '">' + _success_icon + '</span>'; | |
| 999 | 1294 | websiteHolder.attr('updated', 1); |
| 1000 | - websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 1001 | - } else if (res_error[sid]) { | |
| 1002 | - let _error = res_error[sid]; | |
| 1295 | + websiteHolder.find('td:last-child').html(success_icon + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 1296 | + } else if (mainwp_get_result_entry(res_started, sid)) { // for backward compatibility. | |
| 1297 | + let _success_icon = `<i class="green check icon"></i>`; | |
| 1298 | + let success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + _success_icon + '</span>'; | |
| 1299 | + websiteHolder.attr('updated', 1); | |
| 1300 | + websiteHolder.find('td:last-child').html(success_icon + ' ' + mainwp_links_visit_site_and_admin('', pWebsiteId)); | |
| 1301 | + } else if (mainwp_get_result_entry(res_error, sid)) { | |
| 1302 | + let _error = mainwp_get_result_entry(res_error, sid); | |
| 1003 | 1303 | let roll_error = mainwp_updates_get_rollback_msg(_error); |
| 1304 | + let roll_icon = _icon; | |
| 1004 | 1305 | if (roll_error) { |
| 1005 | 1306 | _error = roll_error; |
| 1006 | - _icon = mainwpParams.roll_ui_icon; | |
| 1307 | + roll_icon = mainwpParams.roll_ui_icon; | |
| 1007 | 1308 | } |
| 1008 | - bulk_errors.push(_error); | |
| 1009 | - websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + _error + '">' + _icon + '</span>'); | |
| 1309 | + bulk_errors.push(mainwp_escape_html(_error)); | |
| 1310 | + websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + mainwp_escape_html(_error) + '">' + roll_icon + '</span>'); | |
| 1010 | 1311 | mainwpVars.errorCount++; |
| 1312 | + errorHappen = true; | |
| 1011 | 1313 | } else { |
| 1314 | + bulk_errors.push(MainWP.I18n.t('Update failed. Please try again.')); | |
| 1012 | 1315 | websiteHolder.find('td:last-child').html('<i class="red times icon"></i>'); |
| 1013 | 1316 | mainwpVars.errorCount++; |
| 1317 | + errorHappen = true; | |
| 1014 | 1318 | } |
| 1015 | 1319 | } |
| 1016 | 1320 | } |
| 1017 | 1321 | |
| @@ -1019,8 +1323,45 @@ | ||
| 1019 | 1323 | jQuery('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"]').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>'); |
| 1020 | 1324 | mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', bulk_errors.join('<br />')); |
| 1021 | 1325 | } |
| 1022 | 1326 | |
| 1327 | + if (remainingSlugs && remainingSlugs.length > 0) { | |
| 1328 | + updatesoverview_plugins_upgrade_int_after_backup(remainingSlugs, pWebsiteId, pBulkMode, lastResult, errorHappen)(); | |
| 1329 | + return; | |
| 1330 | + } | |
| 1331 | + if ( | |
| 1332 | + pBulkMode && | |
| 1333 | + !bulk_errors.length && | |
| 1334 | + !response.error && | |
| 1335 | + !response.notices && | |
| 1336 | + !errorHappen | |
| 1337 | + ) { | |
| 1338 | + if ( | |
| 1339 | + lastResult && | |
| 1340 | + typeof mainwp_html_regression !== "undefined" && | |
| 1341 | + mainwp_html_regression.use_after_updates === "1" | |
| 1342 | + ) { | |
| 1343 | + let success_icon = '<i class="green check icon"></i>'; | |
| 1344 | + const regressionCallback = mainwp_handle_regression_final_icon(pWebsiteId, success_icon); | |
| 1345 | + const regression_icon_loading = render_html_regression_icon(lastResult, regressionCallback); | |
| 1346 | + | |
| 1347 | + updatesoverview_plugins_upgrade_all_update_site_status( | |
| 1348 | + pWebsiteId, | |
| 1349 | + success_icon + ' ' + regression_icon_loading | |
| 1350 | + ); | |
| 1351 | + } else if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") { | |
| 1352 | + let success_icon = `<i class="green check icon"></i>`; | |
| 1353 | + // for backward compatibility. | |
| 1354 | + if ( | |
| 1355 | + res_started !== null && | |
| 1356 | + typeof res_started === 'object' && | |
| 1357 | + Object.keys(res_started).length > 0 | |
| 1358 | + ) { | |
| 1359 | + success_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + success_icon + '</span>'; | |
| 1360 | + } | |
| 1361 | + updatesoverview_plugins_upgrade_all_update_site_status(pWebsiteId, success_icon); | |
| 1362 | + } | |
| 1363 | + } | |
| 1023 | 1364 | if (pBulkMode) { |
| 1024 | 1365 | updatesoverview_plugins_upgrade_all_update_done(); |
| 1025 | 1366 | } |
| 1026 | 1367 | } |
| @@ -1028,9 +1369,14 @@ | ||
| 1028 | 1369 | tryCount: 0, |
| 1029 | 1370 | retryLimit: 3, |
| 1030 | 1371 | endError: function (pSlug, pWebsiteId, pBulkMode) { |
| 1031 | 1372 | return function () { |
| 1032 | - let slugParts = pSlug.split(','); | |
| 1373 | + let slugParts = []; | |
| 1374 | + if (pSlug.includes(',')) { | |
| 1375 | + slugParts = pSlug.split(','); | |
| 1376 | + } else { | |
| 1377 | + slugParts = [pSlug]; | |
| 1378 | + } | |
| 1033 | 1379 | let done = false; |
| 1034 | 1380 | for (let sid of slugParts) { |
| 1035 | 1381 | //Siteview |
| 1036 | 1382 | let websiteHolder = jQuery('div[plugin_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); |
| @@ -1049,17 +1395,17 @@ | ||
| 1049 | 1395 | }(pSlug, pWebsiteId, pBulkMode), |
| 1050 | 1396 | error: function (xhr) { |
| 1051 | 1397 | this.tryCount++; |
| 1052 | 1398 | if (this.tryCount >= this.retryLimit) { |
| 1399 | + mainwpVars.errorCount++; | |
| 1053 | 1400 | this.endError(); |
| 1054 | 1401 | return; |
| 1055 | 1402 | } |
| 1056 | - let pRqst = this; | |
| 1057 | 1403 | let pXhr = xhr; |
| 1058 | - setTimeout(function () { | |
| 1404 | + setTimeout(() => { | |
| 1059 | 1405 | if (pXhr.status == 404) { |
| 1060 | 1406 | //handle error |
| 1061 | - jQuery.ajax(pRqst); | |
| 1407 | + jQuery.ajax(this); | |
| 1062 | 1408 | } else if (pXhr.status == 500) { |
| 1063 | 1409 | //handle error |
| 1064 | 1410 | } else { |
| 1065 | 1411 | //handle error |
| @@ -1101,16 +1447,18 @@ | ||
| 1101 | 1447 | let sitesToUpdate = []; |
| 1102 | 1448 | let siteNames = {}; |
| 1103 | 1449 | let sitesPluginSlugs = {}; |
| 1104 | 1450 | let foundChildren = updatesoverview_themes_get_global_upgrade_all(groupId, updatesSelected); |
| 1105 | - if (foundChildren.length == 0) | |
| 1106 | - return; | |
| 1451 | + if (foundChildren.length == 0) { | |
| 1452 | + updates_please_select_items_notice(); | |
| 1453 | + return false; | |
| 1454 | + } | |
| 1107 | 1455 | let sitesCount = 0; |
| 1108 | 1456 | |
| 1109 | 1457 | mainwpPopup('#mainwp-sync-sites-modal').clearList(); |
| 1110 | 1458 | |
| 1111 | 1459 | for (let i = 0; i < foundChildren.length; i++) { |
| 1112 | - if (limitUpdateAll > 0 && i >= limitUpdateAll && typeof groupId === 'undefined') { | |
| 1460 | + if (limitUpdateAll > 0 && i >= limitUpdateAll && groupId === undefined) { | |
| 1113 | 1461 | continueUpdatesAll = 'themes_global_upgrade_all'; |
| 1114 | 1462 | break; |
| 1115 | 1463 | } |
| 1116 | 1464 | let child = jQuery(foundChildren[i]); |
| @@ -1119,9 +1467,9 @@ | ||
| 1119 | 1467 | let siteElement; |
| 1120 | 1468 | let themeElement; |
| 1121 | 1469 | |
| 1122 | 1470 | let checkAttr = child.attr('site_id'); |
| 1123 | - if ((typeof checkAttr !== 'undefined') && (checkAttr !== false)) { | |
| 1471 | + if ((checkAttr !== undefined) && (checkAttr !== false)) { | |
| 1124 | 1472 | siteElement = child; |
| 1125 | 1473 | themeElement = parent; |
| 1126 | 1474 | } else { |
| 1127 | 1475 | siteElement = parent; |
| @@ -1129,11 +1477,11 @@ | ||
| 1129 | 1477 | } |
| 1130 | 1478 | |
| 1131 | 1479 | let siteId = siteElement.attr('site_id'); |
| 1132 | 1480 | let siteName = siteElement.attr('site_name'); |
| 1133 | - let themeSlug = themeElement.attr('theme_slug'); | |
| 1481 | + let themeSlug = mainwp_decode_slug(themeElement.attr('theme_slug')); | |
| 1134 | 1482 | |
| 1135 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 1483 | + if (!sitesToUpdate.includes(siteId)) { | |
| 1136 | 1484 | sitesCount++; |
| 1137 | 1485 | sitesToUpdate.push(siteId); |
| 1138 | 1486 | siteNames[siteId] = siteName; |
| 1139 | 1487 | } |
| @@ -1151,9 +1499,9 @@ | ||
| 1151 | 1499 | if (updateCount == null) |
| 1152 | 1500 | updateCount = 1; |
| 1153 | 1501 | else |
| 1154 | 1502 | updateCount = updateCount.length + 1; |
| 1155 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[id]) + ' (' + updateCount + ' themes)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 1503 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', id) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[id]), id) + ' (' + updateCount + ' themes)', '<span class="updatesoverview-upgrade-status-wp" siteid="' + id + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 1156 | 1504 | } |
| 1157 | 1505 | |
| 1158 | 1506 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) { |
| 1159 | 1507 | return function () { |
| @@ -1158,9 +1506,9 @@ | ||
| 1158 | 1506 | updatesoverviewContinueAfterBackup = function (pSitesCount, pSitesToUpdate, pSitesPluginSlugs) { |
| 1159 | 1507 | return function () { |
| 1160 | 1508 | |
| 1161 | 1509 | let initData = { |
| 1162 | - title: __('Updating all...'), | |
| 1510 | + title: MainWP.I18n.t('Updating all...'), | |
| 1163 | 1511 | progressMax: pSitesCount |
| 1164 | 1512 | }; |
| 1165 | 1513 | updatesoverview_update_popup_init(initData); |
| 1166 | 1514 | |
| @@ -1182,9 +1530,9 @@ | ||
| 1182 | 1530 | if (value) { // to fix |
| 1183 | 1531 | sitesList.push(decodeURIComponent(value)); |
| 1184 | 1532 | } |
| 1185 | 1533 | }); |
| 1186 | - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', __('themes'), sitesList.join('<br />')); | |
| 1534 | + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', MainWP.I18n.t('themes'), sitesList.join('<br />')); | |
| 1187 | 1535 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 1188 | 1536 | } |
| 1189 | 1537 | return; |
| 1190 | 1538 | } |
| @@ -1192,10 +1540,10 @@ | ||
| 1192 | 1540 | }; |
| 1193 | 1541 | |
| 1194 | 1542 | let updatesoverview_themes_get_global_upgrade_all = function (groupId, updatesSelected) { |
| 1195 | 1543 | let foundChildren = []; |
| 1196 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 1197 | - if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 1544 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 1545 | + if (groupId !== undefined && false !== groupId) { | |
| 1198 | 1546 | jQuery('#update_wrapper_theme_upgrades_group_' + groupId).find('tr.mainwp-theme-update[updated="0"]').each( |
| 1199 | 1547 | function () { |
| 1200 | 1548 | if (jQuery(this).find('.child.checkbox').checkbox('is checked')) { |
| 1201 | 1549 | foundChildren.push(this); |
| @@ -1210,13 +1558,9 @@ | ||
| 1210 | 1558 | } |
| 1211 | 1559 | } |
| 1212 | 1560 | ); |
| 1213 | 1561 | } |
| 1214 | - if (foundChildren.length == 0) { | |
| 1215 | - updates_please_select_items_notice(); | |
| 1216 | - return false; | |
| 1217 | - } | |
| 1218 | - } else if (typeof groupId !== 'undefined' && false !== groupId) { | |
| 1562 | + } else if (groupId !== undefined && false !== groupId) { | |
| 1219 | 1563 | foundChildren = jQuery('#update_wrapper_theme_upgrades_group_' + groupId).find('tr.mainwp-theme-update[updated="0"]'); |
| 1220 | 1564 | } else { |
| 1221 | 1565 | foundChildren = jQuery('#themes-updates-global').find('table tr[updated="0"]'); |
| 1222 | 1566 | } |
| @@ -1223,9 +1567,9 @@ | ||
| 1223 | 1567 | return foundChildren; |
| 1224 | 1568 | } |
| 1225 | 1569 | |
| 1226 | 1570 | let updates_please_select_items_notice = function () { |
| 1227 | - let msg = __('Please, select items to update.'); | |
| 1571 | + let msg = MainWP.I18n.t('Please, select items to update.'); | |
| 1228 | 1572 | jQuery('#mainwp-modal-confirm-select .content-massage').html(msg); |
| 1229 | 1573 | jQuery('#mainwp-modal-confirm-select').modal('show'); |
| 1230 | 1574 | return false; |
| 1231 | 1575 | } |
| @@ -1254,13 +1598,13 @@ | ||
| 1254 | 1598 | let siteId = jQuery(child).attr('site_id'); |
| 1255 | 1599 | let siteName = jQuery(child).attr('site_name'); |
| 1256 | 1600 | siteNames[siteId] = siteName; |
| 1257 | 1601 | sitesToUpdate.push(siteId); |
| 1258 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteName), '<span class="updatesoverview-upgrade-status-wp" siteid="' + siteId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 1602 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', siteId) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteName), siteId), '<span class="updatesoverview-upgrade-status-wp" siteid="' + siteId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 1259 | 1603 | } |
| 1260 | 1604 | |
| 1261 | 1605 | themeName = decodeURIComponent(themeName); |
| 1262 | - themeName = themeName.replace(/\+/g, ' '); | |
| 1606 | + themeName = themeName.replaceAll('+', ' '); | |
| 1263 | 1607 | |
| 1264 | 1608 | let _callback = function () { |
| 1265 | 1609 | |
| 1266 | 1610 | let sitesCount = sitesToUpdate.length; |
| @@ -1268,9 +1612,9 @@ | ||
| 1268 | 1612 | return function () { |
| 1269 | 1613 | //Step 2: show form |
| 1270 | 1614 | |
| 1271 | 1615 | let initData = { |
| 1272 | - title: __('Updating %1', decodeURIComponent(themeName)), | |
| 1616 | + title: MainWP.I18n.t('Updating %1', decodeURIComponent(themeName)), | |
| 1273 | 1617 | progressMax: pSitesCount |
| 1274 | 1618 | }; |
| 1275 | 1619 | updatesoverview_update_popup_init(initData); |
| 1276 | 1620 | |
| @@ -1292,9 +1636,9 @@ | ||
| 1292 | 1636 | if (value) { // to fix |
| 1293 | 1637 | sitesList.push(decodeURIComponent(value)); |
| 1294 | 1638 | } |
| 1295 | 1639 | }); |
| 1296 | - let confirmMsg = __('You are about to update the %1 theme on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', themeName, sitesList.join('<br />')); | |
| 1640 | + let confirmMsg = MainWP.I18n.t('You are about to update the %1 theme on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', themeName, sitesList.join('<br />')); | |
| 1297 | 1641 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 1298 | 1642 | } |
| 1299 | 1643 | return; |
| 1300 | 1644 | } |
| @@ -1302,9 +1646,9 @@ | ||
| 1302 | 1646 | }; |
| 1303 | 1647 | |
| 1304 | 1648 | let updatesoverview_themes_get_upgrade_all = function (slug, updatesSelected) { |
| 1305 | 1649 | let foundChildren = []; |
| 1306 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 1650 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 1307 | 1651 | jQuery('tr[theme_slug="' + slug + '"]').find('table tr[updated="0"]').each( |
| 1308 | 1652 | function () { |
| 1309 | 1653 | if (jQuery(this).find('.child.checkbox').checkbox('is checked')) { |
| 1310 | 1654 | foundChildren.push(this); |
| @@ -1333,9 +1677,9 @@ | ||
| 1333 | 1677 | mainwpVars.bulkTaskRunning = true; |
| 1334 | 1678 | updatesoverview_themes_upgrade_all_loop_next(); |
| 1335 | 1679 | }; |
| 1336 | 1680 | let updatesoverview_themes_upgrade_all_loop_next = function () { |
| 1337 | - while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 1681 | + while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 1338 | 1682 | updatesoverview_themes_upgrade_all_upgrade_next(); |
| 1339 | 1683 | } |
| 1340 | 1684 | }; |
| 1341 | 1685 | let updatesoverview_themes_upgrade_all_update_site_status = function (siteId, newStatus) { |
| @@ -1343,11 +1687,15 @@ | ||
| 1343 | 1687 | }; |
| 1344 | 1688 | let updatesoverview_themes_upgrade_all_upgrade_next = function () { |
| 1345 | 1689 | mainwpVars.currentThreads++; |
| 1346 | 1690 | mainwpVars.websitesLeft--; |
| 1347 | - | |
| 1691 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 1692 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 1693 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 1694 | + waiting_icon += regression_waiting_icon; | |
| 1695 | + } | |
| 1348 | 1696 | let websiteId = mainwpVars.websitesToUpdate[mainwpVars.currentWebsite++]; |
| 1349 | - updatesoverview_themes_upgrade_all_update_site_status(websiteId, '<i class="notched circle loading icon"></i>'); | |
| 1697 | + updatesoverview_themes_upgrade_all_update_site_status(websiteId, waiting_icon); | |
| 1350 | 1698 | |
| 1351 | 1699 | let slugToUpgrade = currentThemeSlugToUpgrade; |
| 1352 | 1700 | if (slugToUpgrade == undefined) |
| 1353 | 1701 | slugToUpgrade = websitesThemeSlugsToUpgrade[websiteId]; |
| @@ -1367,17 +1715,42 @@ | ||
| 1367 | 1715 | } |
| 1368 | 1716 | |
| 1369 | 1717 | updatesoverview_themes_upgrade_all_loop_next(); |
| 1370 | 1718 | }; |
| 1371 | -let updatesoverview_themes_upgrade_int = function (slug, websiteId, bulkMode) { | |
| 1372 | - let slugParts = slug.split(','); | |
| 1719 | +let updatesoverview_themes_upgrade_int = function (slug, websiteId, bulkMode, lastResult) { | |
| 1720 | + let slugList = globalThis.mainwp_slug_list_to_array(slug); // NOSONAR -- window is ok. | |
| 1721 | + | |
| 1722 | + const yithSlugList = slugList.filter(slg => slg.startsWith('yith-')); | |
| 1723 | + const noneYithSlugs = slugList.filter(slg => !slg.startsWith('yith-')); | |
| 1724 | + | |
| 1725 | + let currentSlug = ''; | |
| 1726 | + let slugParts = []; | |
| 1727 | + let remainingSlugs = []; | |
| 1728 | + | |
| 1729 | + if (noneYithSlugs.length > 0) { | |
| 1730 | + currentSlug = noneYithSlugs.join(','); | |
| 1731 | + slugParts = noneYithSlugs; | |
| 1732 | + remainingSlugs = yithSlugList; | |
| 1733 | + } else if (yithSlugList.length > 0) { | |
| 1734 | + currentSlug = yithSlugList.shift(); | |
| 1735 | + remainingSlugs = yithSlugList; | |
| 1736 | + slugParts = [currentSlug]; | |
| 1737 | + } | |
| 1738 | + | |
| 1739 | + let lastResultFinal = lastResult || null; | |
| 1740 | + // Show icon waiting | |
| 1741 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 1742 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i> ' + MainWP.I18n.t('Updating. Please wait...')); | |
| 1743 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 1744 | + waiting_icon += regression_waiting_icon; | |
| 1745 | + } | |
| 1746 | + | |
| 1373 | 1747 | for (let sid of slugParts) { |
| 1374 | 1748 | let websiteHolder = jQuery('.themes-bulk-updates[theme_slug="' + sid + '"] tr[site_id="' + websiteId + '"]'); |
| 1375 | 1749 | if (!websiteHolder.exists()) { |
| 1376 | 1750 | websiteHolder = jQuery('.themes-bulk-updates[site_id="' + websiteId + '"] tr[theme_slug="' + sid + '"]'); |
| 1377 | 1751 | } |
| 1378 | - websiteHolder.find('td:last-child').html('<i class="notched circle loading icon"></i> ' + __('Updating. Please wait...')); | |
| 1379 | - | |
| 1752 | + websiteHolder.find('td:last-child').html(waiting_icon); | |
| 1380 | 1753 | } |
| 1381 | 1754 | |
| 1382 | 1755 | let data = mainwp_secure_data({ |
| 1383 | 1756 | action: 'mainwp_upgradeplugintheme', |
| @@ -1382,9 +1755,9 @@ | ||
| 1382 | 1755 | let data = mainwp_secure_data({ |
| 1383 | 1756 | action: 'mainwp_upgradeplugintheme', |
| 1384 | 1757 | websiteId: websiteId, |
| 1385 | 1758 | type: 'theme', |
| 1386 | - slug: slug | |
| 1759 | + slug: currentSlug | |
| 1387 | 1760 | }); |
| 1388 | 1761 | jQuery.ajax({ |
| 1389 | 1762 | type: "POST", |
| 1390 | 1763 | url: ajaxurl, |
| @@ -1390,9 +1763,14 @@ | ||
| 1390 | 1763 | url: ajaxurl, |
| 1391 | 1764 | data: data, |
| 1392 | 1765 | success: function (pSlug, pWebsiteId, pBulkMode) { |
| 1393 | 1766 | return function (response) { // NOSONAR - complex. |
| 1394 | - let slugParts = pSlug.split(','); | |
| 1767 | + let slugParts = []; | |
| 1768 | + if (pSlug.includes(',')) { | |
| 1769 | + slugParts = pSlug.split(','); | |
| 1770 | + } else { | |
| 1771 | + slugParts = [pSlug]; | |
| 1772 | + } | |
| 1395 | 1773 | let done = false; |
| 1396 | 1774 | |
| 1397 | 1775 | let bulk_errors = []; |
| 1398 | 1776 | let bulk_icon = '<i class="red times icon"></i>'; |
| @@ -1406,22 +1784,23 @@ | ||
| 1406 | 1784 | let extErr = getErrorMessageInfo(response.error, 'ui') |
| 1407 | 1785 | if (!done && pBulkMode) |
| 1408 | 1786 | updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, extErr); |
| 1409 | 1787 | websiteHolder.find('td:last-child').html(extErr); |
| 1788 | + mainwpVars.errorCount++; | |
| 1410 | 1789 | } else { |
| 1411 | 1790 | let res = response.result; |
| 1412 | 1791 | let res_error = response.result_error; |
| 1413 | - | |
| 1414 | - if (res[sid]) { | |
| 1415 | - if (!done && pBulkMode) | |
| 1416 | - updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, '<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', websiteId)); | |
| 1792 | + if (mainwp_get_result_entry(res, sid)) { | |
| 1793 | + lastResultFinal = res; | |
| 1794 | + let _success_icon = `<i class="green check icon"></i>`; | |
| 1795 | + const success_icon = `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Update successful', 'mainwp')}">${_success_icon}</span>`; | |
| 1417 | 1796 | websiteHolder.attr('updated', 1); |
| 1418 | - websiteHolder.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful', 'mainwp') + '"><i class="green check icon"></i></span>' + ' ' + mainwp_links_visit_site_and_admin('', websiteId)); | |
| 1797 | + websiteHolder.find('td:last-child').html(success_icon); | |
| 1419 | 1798 | } else { |
| 1420 | 1799 | let _error = ''; |
| 1421 | 1800 | let _icon = ''; |
| 1422 | - if (res_error[sid]) { | |
| 1423 | - _error = res_error[sid]; | |
| 1801 | + if (mainwp_get_result_entry(res_error, sid)) { | |
| 1802 | + _error = mainwp_get_result_entry(res_error, sid); | |
| 1424 | 1803 | _icon = '<i class="red times icon"></i>'; |
| 1425 | 1804 | let roll_error = mainwp_updates_get_rollback_msg(_error); |
| 1426 | 1805 | if (roll_error) { |
| 1427 | 1806 | _error = roll_error; |
| @@ -1427,14 +1806,14 @@ | ||
| 1427 | 1806 | _error = roll_error; |
| 1428 | 1807 | _icon = mainwpParams.roll_ui_icon; |
| 1429 | 1808 | bulk_icon = mainwpParams.roll_ui_icon; |
| 1430 | 1809 | } |
| 1431 | - bulk_errors.push(_error); | |
| 1810 | + bulk_errors.push(mainwp_escape_html(_error)); | |
| 1432 | 1811 | mainwpVars.errorCount++; |
| 1433 | 1812 | } |
| 1434 | 1813 | if (_error) { |
| 1435 | 1814 | websiteHolder.find('td:last-child').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>'); |
| 1436 | - mainwp_init_html_popup(websiteHolder.find('td:last-child').find('.mainwp-html-popup'), _error); | |
| 1815 | + mainwp_init_html_popup(websiteHolder.find('td:last-child').find('.mainwp-html-popup'), mainwp_escape_html(_error)); | |
| 1437 | 1816 | } |
| 1438 | 1817 | } |
| 1439 | 1818 | } |
| 1440 | 1819 | |
| @@ -1446,18 +1825,46 @@ | ||
| 1446 | 1825 | mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', bulk_errors.join('<br />')); |
| 1447 | 1826 | } |
| 1448 | 1827 | } |
| 1449 | 1828 | |
| 1829 | + if (remainingSlugs && remainingSlugs.length > 0) { | |
| 1830 | + updatesoverview_themes_upgrade_int(remainingSlugs, websiteId, bulkMode, lastResultFinal); | |
| 1831 | + return; | |
| 1832 | + } | |
| 1833 | + if ( | |
| 1834 | + pBulkMode && | |
| 1835 | + !bulk_errors.length && | |
| 1836 | + !response.error | |
| 1837 | + ) { | |
| 1838 | + if ( | |
| 1839 | + lastResultFinal && | |
| 1840 | + typeof mainwp_html_regression !== "undefined" && | |
| 1841 | + mainwp_html_regression.use_after_updates === "1" | |
| 1842 | + ) { | |
| 1843 | + let success_icon = '<i class="green check icon"></i>'; | |
| 1844 | + let regression_icon_loading = render_html_regression_icon(lastResultFinal, function (regression_icon_final) { | |
| 1845 | + updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, success_icon + ' ' + regression_icon_final); | |
| 1846 | + }); | |
| 1847 | + updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, success_icon + ' ' + regression_icon_loading); | |
| 1848 | + } else if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") { | |
| 1849 | + updatesoverview_themes_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>'); | |
| 1850 | + } | |
| 1851 | + } | |
| 1450 | 1852 | if (pBulkMode) { |
| 1451 | 1853 | updatesoverview_themes_upgrade_all_update_done(); |
| 1452 | 1854 | } |
| 1453 | 1855 | } |
| 1454 | - }(slug, websiteId, bulkMode), | |
| 1856 | + }(currentSlug, websiteId, bulkMode), | |
| 1455 | 1857 | tryCount: 0, |
| 1456 | 1858 | retryLimit: 3, |
| 1457 | 1859 | endError: function (pSlug, pWebsiteId, pBulkMode) { |
| 1458 | 1860 | return function () { |
| 1459 | - let slugParts = pSlug.split(','); | |
| 1861 | + let slugParts = []; | |
| 1862 | + if (pSlug.includes(',')) { | |
| 1863 | + slugParts = pSlug.split(','); | |
| 1864 | + } else { | |
| 1865 | + slugParts = [pSlug]; | |
| 1866 | + } | |
| 1460 | 1867 | let done = false; |
| 1461 | 1868 | for (let sid of slugParts) { |
| 1462 | 1869 | let websiteHolder = jQuery('div[theme_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); |
| 1463 | 1870 | if (!websiteHolder.exists()) { |
| @@ -1475,18 +1882,18 @@ | ||
| 1475 | 1882 | }(slug, websiteId, bulkMode), |
| 1476 | 1883 | error: function (xhr) { |
| 1477 | 1884 | this.tryCount++; |
| 1478 | 1885 | if (this.tryCount >= this.retryLimit) { |
| 1886 | + mainwpVars.errorCount++; | |
| 1479 | 1887 | this.endError(); |
| 1480 | 1888 | return; |
| 1481 | 1889 | } |
| 1482 | 1890 | |
| 1483 | - let pRqst = this; | |
| 1484 | 1891 | let pXhr = xhr; |
| 1485 | - setTimeout(function () { | |
| 1892 | + setTimeout(() => { | |
| 1486 | 1893 | if (pXhr.status == 404) { |
| 1487 | 1894 | //handle error |
| 1488 | - jQuery.ajax(pRqst); | |
| 1895 | + jQuery.ajax(this); | |
| 1489 | 1896 | } else if (pXhr.status == 500) { |
| 1490 | 1897 | //handle error |
| 1491 | 1898 | } else { |
| 1492 | 1899 | //handle error |
| @@ -1498,14 +1905,70 @@ | ||
| 1498 | 1905 | |
| 1499 | 1906 | return false; |
| 1500 | 1907 | }; |
| 1501 | 1908 | |
| 1909 | +const updatesoverview_global_upgrade_all = function (which, current_siteid) { // NOSONAR - Complexity. | |
| 1910 | + if (mainwpVars.bulkTaskRunning) { | |
| 1911 | + return; | |
| 1912 | + } | |
| 1913 | + updatesoverview_global_prepare_upgrade_all(which, current_siteid); | |
| 1914 | +} | |
| 1502 | 1915 | |
| 1916 | +const updatesoverview_global_prepare_upgrade_all = function (which, current_siteid) { // NOSONAR - Complexity. | |
| 1917 | + if (mainwpVars.bulkTaskRunning) { | |
| 1918 | + return; | |
| 1919 | + } | |
| 1920 | + const onPrepared = () => updatesoverview_global_run_upgrade_all(which); | |
| 1921 | + | |
| 1922 | + updatesoverview_global_prepare_data_upgrade_all(which, onPrepared, current_siteid); | |
| 1923 | +} | |
| 1924 | + | |
| 1925 | +const updatesoverview_global_prepare_data_upgrade_all = function (which, onPrepared, current_siteid) { | |
| 1926 | + | |
| 1927 | + let initData = { | |
| 1928 | + title: MainWP.I18n.t('Updating All'), | |
| 1929 | + initVisibleContentMsg: true, | |
| 1930 | + contentMsg: MainWP.I18n.t('Preparing update data, please wait...'), | |
| 1931 | + }; | |
| 1932 | + mainwpPopup('#mainwp-prepare-data-modal').init(initData); | |
| 1933 | + | |
| 1934 | + let data = mainwp_secure_data({ | |
| 1935 | + action: 'mainwp_overview_prepare_upgradeall', | |
| 1936 | + which: which, | |
| 1937 | + site_id: current_siteid | |
| 1938 | + }); | |
| 1939 | + | |
| 1940 | + jQuery.ajax({ | |
| 1941 | + type: "POST", | |
| 1942 | + url: ajaxurl, | |
| 1943 | + data: data, | |
| 1944 | + dataType: 'html', | |
| 1945 | + success: function (response) { | |
| 1946 | + if (response && typeof onPrepared === 'function') { | |
| 1947 | + jQuery('#mainwp_prepare_global_update_all_container').html(response); | |
| 1948 | + onPrepared(); | |
| 1949 | + } else { | |
| 1950 | + setTimeout(function () { | |
| 1951 | + mainwp_forceReload(); | |
| 1952 | + }, 2000); | |
| 1953 | + } | |
| 1954 | + }, | |
| 1955 | + error: function (xhr, status, error) { | |
| 1956 | + console.error('Failed to prepare update data:', error); | |
| 1957 | + setTimeout(function () { | |
| 1958 | + mainwp_forceReload(); | |
| 1959 | + }, 2000); | |
| 1960 | + } | |
| 1961 | + }); | |
| 1962 | +} | |
| 1963 | + | |
| 1964 | + | |
| 1503 | 1965 | /* eslint-disable complexity */ |
| 1504 | -let updatesoverview_global_upgrade_all = function (which) { // NOSONAR - Complexity. | |
| 1966 | +const updatesoverview_global_run_upgrade_all = function (which) { // NOSONAR - Complexity. | |
| 1505 | 1967 | |
| 1506 | - if (mainwpVars.bulkTaskRunning) | |
| 1968 | + if (mainwpVars.bulkTaskRunning) { | |
| 1507 | 1969 | return; |
| 1970 | + } | |
| 1508 | 1971 | |
| 1509 | 1972 | //Step 1: build form |
| 1510 | 1973 | let sitesToUpdate = []; |
| 1511 | 1974 | let sitesToUpgrade = []; |
| @@ -1512,11 +1975,10 @@ | ||
| 1512 | 1975 | let sitesPluginSlugs = {}; |
| 1513 | 1976 | let sitesThemeSlugs = {}; |
| 1514 | 1977 | let sitesTranslationSlugs = {}; |
| 1515 | 1978 | let siteNames = {}; |
| 1979 | + let suspendedWebsites = []; | |
| 1516 | 1980 | |
| 1517 | - mainwpPopup('#mainwp-sync-sites-modal').clearList(); | |
| 1518 | - | |
| 1519 | 1981 | let sitesCount = 0; |
| 1520 | 1982 | let foundChildren; |
| 1521 | 1983 | |
| 1522 | 1984 | if (which == 'all' || which == 'wp') { |
| @@ -1526,15 +1988,20 @@ | ||
| 1526 | 1988 | for (let child of foundChildren) { |
| 1527 | 1989 | let siteElement = jQuery(child); |
| 1528 | 1990 | let siteId = siteElement.attr('site_id'); |
| 1529 | 1991 | let siteName = siteElement.attr('site_name'); |
| 1530 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 1992 | + if (!sitesToUpdate.includes(siteId)) { | |
| 1531 | 1993 | sitesCount++; |
| 1532 | 1994 | sitesToUpdate.push(siteId); |
| 1533 | 1995 | siteNames[siteId] = siteName; |
| 1534 | 1996 | } |
| 1535 | - if (sitesToUpgrade.indexOf(siteId) == -1) | |
| 1997 | + | |
| 1998 | + if (!sitesToUpgrade.includes(siteId)) | |
| 1536 | 1999 | sitesToUpgrade.push(siteId); |
| 2000 | + | |
| 2001 | + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') { | |
| 2002 | + suspendedWebsites.push(siteId); | |
| 2003 | + } | |
| 1537 | 2004 | } |
| 1538 | 2005 | } |
| 1539 | 2006 | } |
| 1540 | 2007 | |
| @@ -1545,11 +2012,11 @@ | ||
| 1545 | 2012 | for (let item of foundChildren) { |
| 1546 | 2013 | let siteElement = jQuery(item); |
| 1547 | 2014 | let siteId = siteElement.attr('site_id'); |
| 1548 | 2015 | let siteName = siteElement.attr('site_name'); |
| 1549 | - let pluginSlug = siteElement.attr('plugin_slug'); | |
| 2016 | + let pluginSlug = mainwp_decode_slug(siteElement.attr('plugin_slug')); | |
| 1550 | 2017 | |
| 1551 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 2018 | + if (!sitesToUpdate.includes(siteId)) { | |
| 1552 | 2019 | sitesCount++; |
| 1553 | 2020 | sitesToUpdate.push(siteId); |
| 1554 | 2021 | siteNames[siteId] = siteName; |
| 1555 | 2022 | } |
| @@ -1558,8 +2025,11 @@ | ||
| 1558 | 2025 | sitesPluginSlugs[siteId] = pluginSlug; |
| 1559 | 2026 | } else { |
| 1560 | 2027 | sitesPluginSlugs[siteId] += ',' + pluginSlug; |
| 1561 | 2028 | } |
| 2029 | + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') { | |
| 2030 | + suspendedWebsites.push(siteId); | |
| 2031 | + } | |
| 1562 | 2032 | } |
| 1563 | 2033 | } |
| 1564 | 2034 | } |
| 1565 | 2035 | |
| @@ -1570,11 +2040,11 @@ | ||
| 1570 | 2040 | for (let item of foundChildren) { |
| 1571 | 2041 | let siteElement = jQuery(item); |
| 1572 | 2042 | let siteId = siteElement.attr('site_id'); |
| 1573 | 2043 | let siteName = siteElement.attr('site_name'); |
| 1574 | - let themeSlug = siteElement.attr('theme_slug'); | |
| 2044 | + let themeSlug = mainwp_decode_slug(siteElement.attr('theme_slug')); | |
| 1575 | 2045 | |
| 1576 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 2046 | + if (!sitesToUpdate.includes(siteId)) { | |
| 1577 | 2047 | sitesCount++; |
| 1578 | 2048 | sitesToUpdate.push(siteId); |
| 1579 | 2049 | siteNames[siteId] = siteName; |
| 1580 | 2050 | } |
| @@ -1583,8 +2053,11 @@ | ||
| 1583 | 2053 | sitesThemeSlugs[siteId] = themeSlug; |
| 1584 | 2054 | } else { |
| 1585 | 2055 | sitesThemeSlugs[siteId] += ',' + themeSlug; |
| 1586 | 2056 | } |
| 2057 | + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') { | |
| 2058 | + suspendedWebsites.push(siteId); | |
| 2059 | + } | |
| 1587 | 2060 | } |
| 1588 | 2061 | } |
| 1589 | 2062 | } |
| 1590 | 2063 | |
| @@ -1595,11 +2068,11 @@ | ||
| 1595 | 2068 | for (let item of foundChildren) { |
| 1596 | 2069 | let siteElement = jQuery(item); |
| 1597 | 2070 | let siteId = siteElement.attr('site_id'); |
| 1598 | 2071 | let siteName = siteElement.attr('site_name'); |
| 1599 | - let transSlug = siteElement.attr('translation_slug'); | |
| 2072 | + let transSlug = mainwp_decode_slug(siteElement.attr('translation_slug')); | |
| 1600 | 2073 | |
| 1601 | - if (sitesToUpdate.indexOf(siteId) == -1) { | |
| 2074 | + if (!sitesToUpdate.includes(siteId)) { | |
| 1602 | 2075 | sitesCount++; |
| 1603 | 2076 | sitesToUpdate.push(siteId); |
| 1604 | 2077 | siteNames[siteId] = siteName; |
| 1605 | 2078 | } |
| @@ -1608,17 +2081,21 @@ | ||
| 1608 | 2081 | sitesTranslationSlugs[siteId] = transSlug; |
| 1609 | 2082 | } else { |
| 1610 | 2083 | sitesTranslationSlugs[siteId] += ',' + transSlug; |
| 1611 | 2084 | } |
| 2085 | + if (!suspendedWebsites.includes(siteId) && siteElement.attr('is-suspended') == '1') { | |
| 2086 | + suspendedWebsites.push(siteId); | |
| 2087 | + } | |
| 1612 | 2088 | } |
| 1613 | 2089 | } |
| 1614 | 2090 | } |
| 1615 | 2091 | |
| 1616 | 2092 | let _callback = function () { // NOSONAR - Complexity. |
| 2093 | + mainwpPopup('#mainwp-sync-sites-modal').clearList(); | |
| 1617 | 2094 | //Build form |
| 1618 | 2095 | for (let siteId of sitesToUpdate) { |
| 1619 | 2096 | let whatToUpgrade = ''; |
| 1620 | - if (sitesToUpgrade.indexOf(siteId) != -1) | |
| 2097 | + if (sitesToUpgrade.includes(siteId)) | |
| 1621 | 2098 | whatToUpgrade = '<span class="wordpress">WordPress core files</span>'; |
| 1622 | 2099 | |
| 1623 | 2100 | if (sitesPluginSlugs[siteId] != undefined) { |
| 1624 | 2101 | let updateCount = sitesPluginSlugs[siteId].match(/,/g); |
| @@ -1656,22 +2133,25 @@ | ||
| 1656 | 2133 | whatToUpgrade += ', '; |
| 1657 | 2134 | |
| 1658 | 2135 | whatToUpgrade += '<span class="translation">' + updateCount + ' translation' + (updateCount > 1 ? 's' : '') + '</span>'; |
| 1659 | 2136 | } |
| 1660 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(siteNames[siteId]) + ' (' + whatToUpgrade + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + siteId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 2137 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', siteId) + ' ' + updatesmanage_link_to_site(decodeURIComponent(siteNames[siteId]), siteId) + ' (' + whatToUpgrade + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + siteId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 1661 | 2138 | } |
| 1662 | 2139 | |
| 1663 | - updatesoverviewContinueAfterBackup = updatesoverview_global_upgrade_all_after_backup(sitesCount, sitesToUpdate, sitesToUpgrade, sitesPluginSlugs, sitesThemeSlugs, sitesTranslationSlugs); | |
| 2140 | + updatesoverviewContinueAfterBackup = updatesoverview_global_upgrade_all_after_backup(sitesCount, sitesToUpdate, sitesToUpgrade, sitesPluginSlugs, sitesThemeSlugs, sitesTranslationSlugs, suspendedWebsites); | |
| 1664 | 2141 | return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames); |
| 1665 | 2142 | } // end _callback() |
| 1666 | - | |
| 1667 | - updatesoverview_global_upgrade_all_start(which, siteNames, _callback); | |
| 1668 | - | |
| 2143 | + if (Object.keys(siteNames).length === 0) { | |
| 2144 | + mainwpVars.bulkTaskRunning = false; | |
| 2145 | + mainwpPopup('#mainwp-prepare-data-modal').getContentMsgEl().html('<div class="ui yellow message">' + MainWP.I18n.t('There are no updates available to process. Please try again.') + '</div>'); | |
| 2146 | + } else { | |
| 2147 | + updatesoverview_global_upgrade_all_start(which, siteNames, _callback); | |
| 2148 | + } | |
| 1669 | 2149 | }; |
| 1670 | 2150 | |
| 1671 | 2151 | let updatesoverview_global_upgrade_all_start = function (which, siteNames, _callback) { |
| 1672 | 2152 | // new confirm message |
| 1673 | - if (jQuery(siteNames).length > 0) { | |
| 2153 | + if (Object.keys(siteNames).length) { | |
| 1674 | 2154 | let sitesList = []; |
| 1675 | 2155 | jQuery.each(siteNames, function (index, value) { |
| 1676 | 2156 | if (value) { // to fix |
| 1677 | 2157 | sitesList.push(decodeURIComponent(value)); |
| @@ -1677,37 +2157,37 @@ | ||
| 1677 | 2157 | sitesList.push(decodeURIComponent(value)); |
| 1678 | 2158 | } |
| 1679 | 2159 | }); |
| 1680 | 2160 | |
| 1681 | - let whichUpdates = __('WordPress core files, plugins, themes and translations'); | |
| 2161 | + let whichUpdates = MainWP.I18n.t('WordPress core files, plugins, themes and translations'); | |
| 1682 | 2162 | if (which == 'wp') { |
| 1683 | - whichUpdates = __('WordPress core files'); | |
| 2163 | + whichUpdates = MainWP.I18n.t('WordPress core files'); | |
| 1684 | 2164 | } else if (which == 'plugin') { |
| 1685 | - whichUpdates = __('plugins'); | |
| 2165 | + whichUpdates = MainWP.I18n.t('plugins'); | |
| 1686 | 2166 | } else if (which == 'theme') { |
| 1687 | - whichUpdates = __('themes'); | |
| 2167 | + whichUpdates = MainWP.I18n.t('themes'); | |
| 1688 | 2168 | } else if (which == 'translation') { |
| 1689 | - whichUpdates = __('translations'); | |
| 2169 | + whichUpdates = MainWP.I18n.t('translations'); | |
| 1690 | 2170 | } |
| 1691 | 2171 | |
| 1692 | - let confirmMsg = __('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', whichUpdates, sitesList.join('<br />')); | |
| 2172 | + let confirmMsg = MainWP.I18n.t('You are about to update %1 on the following site(s): <br/><div class="ui message">%2</div> <strong>Do you want to proceed?</strong>', whichUpdates, sitesList.join('<br />')); | |
| 1693 | 2173 | |
| 1694 | 2174 | mainwp_confirm(confirmMsg, _callback, false, 2); |
| 1695 | 2175 | } |
| 1696 | 2176 | } |
| 1697 | 2177 | |
| 1698 | -let updatesoverview_global_upgrade_all_after_backup = function (pSitesCount, pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs) { | |
| 2178 | +let updatesoverview_global_upgrade_all_after_backup = function (pSitesCount, pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended) { | |
| 1699 | 2179 | return function () { |
| 1700 | 2180 | //Step 2: show form |
| 1701 | 2181 | |
| 1702 | 2182 | let initData = { |
| 1703 | - title: __('Updating All'), | |
| 1704 | - progressMax: pSitesCount | |
| 2183 | + title: MainWP.I18n.t('Updating All'), | |
| 2184 | + progressMax: pSitesCount, | |
| 1705 | 2185 | }; |
| 1706 | 2186 | updatesoverview_update_popup_init(initData); |
| 1707 | 2187 | |
| 1708 | 2188 | //Step 3: start updates |
| 1709 | - updatesoverview_upgrade_all_int(pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs); | |
| 2189 | + updatesoverview_upgrade_all_int(pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended); | |
| 1710 | 2190 | |
| 1711 | 2191 | updatesoverviewContinueAfterBackup = undefined; |
| 1712 | 2192 | }; |
| 1713 | 2193 | } |
| @@ -1714,10 +2194,11 @@ | ||
| 1714 | 2194 | |
| 1715 | 2195 | /* eslint-enable complexity */ |
| 1716 | 2196 | let websitesTransSlugsToUpgrade; |
| 1717 | 2197 | |
| 1718 | -let updatesoverview_upgrade_all_int = function (pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs) { | |
| 2198 | +let updatesoverview_upgrade_all_int = function (pSitesToUpdate, pSitesToUpgrade, pSitesPluginSlugs, pSitesThemeSlugs, psitesTranslationSlugs, pSitesSuspended) { | |
| 1719 | 2199 | mainwpVars.websitesToUpdate = pSitesToUpdate; |
| 2200 | + mainwpVars.websitesSuspended = pSitesSuspended; | |
| 1720 | 2201 | |
| 1721 | 2202 | mainwpVars.websitesToUpgrade = pSitesToUpgrade; |
| 1722 | 2203 | |
| 1723 | 2204 | websitesPluginSlugsToUpgrade = pSitesPluginSlugs; |
| @@ -1734,13 +2215,15 @@ | ||
| 1734 | 2215 | mainwpVars.websitesTotal = mainwpVars.websitesLeft = mainwpVars.websitesToUpdate.length; |
| 1735 | 2216 | |
| 1736 | 2217 | mainwpVars.bulkTaskRunning = true; |
| 1737 | 2218 | |
| 2219 | + console.log('Suspended sites: ' + mainwpVars.websitesSuspended.join(', ')); | |
| 2220 | + | |
| 1738 | 2221 | updatesoverview_upgrade_all_loop_next(); |
| 1739 | 2222 | }; |
| 1740 | 2223 | |
| 1741 | 2224 | let updatesoverview_upgrade_all_loop_next = function () { |
| 1742 | - while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 2225 | + while (mainwpVars.bulkTaskRunning && (mainwpVars.currentThreads < mainwpVars.maxUpdateThreads) && (mainwpVars.websitesLeft > 0)) { | |
| 1743 | 2226 | updatesoverview_upgrade_all_upgrade_next(); |
| 1744 | 2227 | } |
| 1745 | 2228 | }; |
| 1746 | 2229 | let updatesoverview_upgrade_all_update_site_status = function (siteId, newStatus) { |
| @@ -1745,23 +2228,45 @@ | ||
| 1745 | 2228 | }; |
| 1746 | 2229 | let updatesoverview_upgrade_all_update_site_status = function (siteId, newStatus) { |
| 1747 | 2230 | jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').html(newStatus); |
| 1748 | 2231 | }; |
| 1749 | -let updatesoverview_upgrade_all_update_site_bold = function (siteId, sub) { | |
| 1750 | - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').parent().parent().find('.' + sub).css('font-weight', 'bold'); | |
| 2232 | +let updatesoverview_upgrade_all_update_site_bold = function (siteId, sub, msg) { | |
| 2233 | + if (msg) { | |
| 2234 | + jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').html(msg); | |
| 2235 | + } | |
| 2236 | + if (false !== sub) { | |
| 2237 | + jQuery('.updatesoverview-upgrade-status-wp[siteid="' + siteId + '"]').parent().parent().find('.' + sub).css('font-weight', 'bold'); | |
| 2238 | + } | |
| 1751 | 2239 | }; |
| 1752 | 2240 | let updatesoverview_upgrade_all_upgrade_next = function () { |
| 1753 | 2241 | mainwpVars.currentThreads++; |
| 1754 | 2242 | mainwpVars.websitesLeft--; |
| 2243 | + // Show icon waiting | |
| 2244 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 2245 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 2246 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 2247 | + waiting_icon += regression_waiting_icon; | |
| 2248 | + } | |
| 1755 | 2249 | |
| 1756 | 2250 | let websiteId = mainwpVars.websitesToUpdate[mainwpVars.currentWebsite++]; |
| 1757 | - updatesoverview_upgrade_all_update_site_status(websiteId, '<i class="notched circle loading icon"></i>'); | |
| 2251 | + updatesoverview_upgrade_all_update_site_status(websiteId, waiting_icon); | |
| 1758 | 2252 | |
| 2253 | + console.log('Starting upgrade process for site ' + websiteId); | |
| 2254 | + | |
| 2255 | + // process suspended site here to avoid starting the upgrade process and then showing the error after few seconds, also to avoid retrying the upgrade process for suspended sites in case of retry mechanism is triggered for some reason. | |
| 2256 | + if (mainwpVars.websitesSuspended.includes(websiteId)) { | |
| 2257 | + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>'; | |
| 2258 | + updatesoverview_upgrade_all_update_site_bold(websiteId, false, msgUI); | |
| 2259 | + mainwpVars.errorCount++; | |
| 2260 | + updatesoverview_upgrade_all_update_done(); | |
| 2261 | + return; | |
| 2262 | + } | |
| 2263 | + | |
| 1759 | 2264 | let params = { |
| 1760 | 2265 | 'websiteId': websiteId, |
| 1761 | 2266 | 'pThemeSlugToUpgrade': websitesThemeSlugsToUpgrade[websiteId], |
| 1762 | 2267 | 'pPluginSlugToUpgrade': websitesPluginSlugsToUpgrade[websiteId], |
| 1763 | - 'pWordpressUpgrade': mainwpVars.websitesToUpgrade.indexOf(websiteId) != -1, | |
| 2268 | + 'pWordpressUpgrade': mainwpVars.websitesToUpgrade.includes(websiteId), | |
| 1764 | 2269 | 'pTransSlugToUpgrade': websitesTransSlugsToUpgrade[websiteId], |
| 1765 | 2270 | }; |
| 1766 | 2271 | updatesoverview_upgrade_int(params); |
| 1767 | 2272 | }; |
| @@ -1802,8 +2307,10 @@ | ||
| 1802 | 2307 | setTimeout(function () { |
| 1803 | 2308 | // close and refresh page |
| 1804 | 2309 | mainwpPopup('#mainwp-sync-sites-modal').close(true); |
| 1805 | 2310 | }, 3000); |
| 2311 | + } else { | |
| 2312 | + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed')); | |
| 1806 | 2313 | } |
| 1807 | 2314 | return; |
| 1808 | 2315 | } |
| 1809 | 2316 | |
| @@ -1809,9 +2316,11 @@ | ||
| 1809 | 2316 | |
| 1810 | 2317 | updatesoverview_upgrade_all_loop_next(); |
| 1811 | 2318 | }; |
| 1812 | 2319 | |
| 1813 | -let updatesoverview_upgrade_int_flow = function (params) { | |
| 2320 | +/* eslint-disable complexity */ | |
| 2321 | +let updatesoverview_upgrade_int_flow = function (params) { // NOSONAR - complex. | |
| 2322 | + mainwpVars.lastUpdateResultBySite = mainwpVars.lastUpdateResultBySite || {}; | |
| 1814 | 2323 | let pWebsiteId = params['pWebsiteId']; |
| 1815 | 2324 | let pThemeSlugToUpgrade = params['pThemeSlugToUpgrade']; |
| 1816 | 2325 | let pPluginSlugToUpgrade = params['pPluginSlugToUpgrade']; |
| 1817 | 2326 | let pWordpressUpgrade = params['pWordpressUpgrade']; |
| @@ -1820,14 +2329,31 @@ | ||
| 1820 | 2329 | let pUpgradeDone = params['pUpgradeDone']; |
| 1821 | 2330 | let pErrorMessage = params['pErrorMessage']; |
| 1822 | 2331 | let pTransSlugToUpgrade = params['pTransSlugToUpgrade']; |
| 1823 | 2332 | let pTransDone = params['pTransDone']; |
| 2333 | + let bulkErrorCode = params['bulkErrorCode']; | |
| 2334 | + | |
| 1824 | 2335 | if (!pThemeDone) { |
| 2336 | + let themeSlugList = globalThis.mainwp_slug_list_to_array(pThemeSlugToUpgrade); | |
| 2337 | + | |
| 2338 | + const yithSlugList = themeSlugList.filter(slg => slg.startsWith('yith-')); | |
| 2339 | + let currentThemeSlug = ''; | |
| 2340 | + let remainingThemeSlugs = ''; | |
| 2341 | + | |
| 2342 | + if (yithSlugList.length > 0) { | |
| 2343 | + currentThemeSlug = themeSlugList.shift(); | |
| 2344 | + remainingThemeSlugs = themeSlugList.join(','); | |
| 2345 | + } else { | |
| 2346 | + currentThemeSlug = pThemeSlugToUpgrade; | |
| 2347 | + remainingThemeSlugs = ''; | |
| 2348 | + } | |
| 2349 | + | |
| 1825 | 2350 | let data = mainwp_secure_data({ |
| 1826 | 2351 | action: 'mainwp_upgradeplugintheme', |
| 1827 | 2352 | websiteId: pWebsiteId, |
| 1828 | 2353 | type: 'theme', |
| 1829 | - slug: pThemeSlugToUpgrade | |
| 2354 | + slug: currentThemeSlug, | |
| 2355 | + bulkUpdate: mainwpVars.websitesTotal > 1 ? 1 : 0 | |
| 1830 | 2356 | }); |
| 1831 | 2357 | |
| 1832 | 2358 | jQuery.ajax({ |
| 1833 | 2359 | type: "POST", |
| @@ -1835,57 +2361,69 @@ | ||
| 1835 | 2361 | data: data, |
| 1836 | 2362 | success: function (pWebsiteId, pSlug, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible. |
| 1837 | 2363 | return function (response) { // NOSONAR - complex ok. |
| 1838 | 2364 | let slugParts = pSlug.split(','); |
| 1839 | - for (let sid of slugParts) { | |
| 1840 | - let result; | |
| 1841 | - let websiteHolder = jQuery('div[theme_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 1842 | - if (!websiteHolder.exists()) { | |
| 1843 | - websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[theme_slug="' + sid + '"]'); | |
| 1844 | - } | |
| 2365 | + if (response?.error?.errorCode == 'SUSPENDED_SITE') { | |
| 2366 | + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>'; | |
| 2367 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI); | |
| 2368 | + pPluginDone = true; | |
| 2369 | + pUpgradeDone = true; | |
| 2370 | + pTransDone = true; | |
| 2371 | + pThemeDone = true; | |
| 2372 | + mainwpVars.errorCount++; | |
| 2373 | + } else { | |
| 2374 | + for (let sid of slugParts) { | |
| 2375 | + let result; | |
| 2376 | + let websiteHolder = jQuery('div[theme_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 2377 | + if (!websiteHolder.exists()) { | |
| 2378 | + websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[theme_slug="' + sid + '"]'); | |
| 2379 | + } | |
| 1845 | 2380 | |
| 1846 | 2381 | |
| 1847 | - let isError = true; | |
| 1848 | - if (response.error) { | |
| 1849 | - result = getErrorMessage(response.error); | |
| 1850 | - pErrorMessage = result; | |
| 1851 | - } else { | |
| 1852 | - let res = response.result; | |
| 1853 | - | |
| 1854 | - if (res[sid]) { | |
| 1855 | - websiteHolder.attr('updated', 1); | |
| 1856 | - isError = false; | |
| 2382 | + let isError = true; | |
| 2383 | + if (response.error) { | |
| 2384 | + result = getErrorMessage(response.error); | |
| 2385 | + pErrorMessage = result; | |
| 2386 | + mainwpVars.errorCount++; | |
| 1857 | 2387 | } else { |
| 1858 | - result = __('Update failed!'); | |
| 1859 | - pErrorMessage = result; | |
| 2388 | + let res = response.result; | |
| 2389 | + if (mainwp_get_result_entry(res, sid)) { | |
| 2390 | + mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result; | |
| 2391 | + websiteHolder.attr('updated', 1); | |
| 2392 | + isError = false; | |
| 2393 | + } else { | |
| 2394 | + result = MainWP.I18n.t('Update failed!'); | |
| 2395 | + pErrorMessage = result; | |
| 2396 | + } | |
| 1860 | 2397 | } |
| 1861 | - } | |
| 1862 | 2398 | |
| 1863 | - if (isError) { | |
| 1864 | - let res_error = response?.result_error ? response.result_error : ''; | |
| 1865 | - if (res_error ? res_error[encodeURIComponent(sid)] : false) { | |
| 1866 | - let _msg = res_error[encodeURIComponent(sid)]; | |
| 1867 | - let roll_error = mainwp_updates_get_rollback_msg(_msg); | |
| 1868 | - mainwp_put_actions_errors_msg('updateall', pWebsiteId, (roll_error ? 'roll' : 'default'), roll_error || _msg);// save errors to show later. | |
| 2399 | + if (isError) { | |
| 2400 | + let res_error = response?.result_error ? response.result_error : ''; | |
| 2401 | + if (mainwp_get_result_entry(res_error, sid)) { | |
| 2402 | + let _msg = mainwp_get_result_entry(res_error, sid); | |
| 2403 | + let roll_error = mainwp_updates_get_rollback_msg(_msg); | |
| 2404 | + mainwp_put_actions_errors_msg('updateall', pWebsiteId, (roll_error ? 'roll' : 'default'), roll_error || _msg);// save errors to show later. | |
| 2405 | + } | |
| 1869 | 2406 | } |
| 2407 | + | |
| 1870 | 2408 | } |
| 1871 | - | |
| 2409 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'theme'); | |
| 1872 | 2410 | } |
| 1873 | - updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'theme'); | |
| 1874 | 2411 | |
| 1875 | 2412 | //If all done: continue, else delay 400ms to not stress the server |
| 1876 | 2413 | let fnc = function () { |
| 1877 | 2414 | let params = { |
| 1878 | 2415 | 'pWebsiteId': pWebsiteId, |
| 1879 | - 'pThemeSlugToUpgrade': pSlug, | |
| 2416 | + 'pThemeSlugToUpgrade': remainingThemeSlugs, | |
| 1880 | 2417 | 'pPluginSlugToUpgrade': pPluginSlugToUpgrade, |
| 1881 | 2418 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 1882 | - 'pThemeDone': true, | |
| 2419 | + 'pThemeDone': pThemeDone ? true : remainingThemeSlugs === '', | |
| 1883 | 2420 | 'pPluginDone': pPluginDone, |
| 1884 | 2421 | 'pUpgradeDone': pUpgradeDone, |
| 1885 | 2422 | 'pErrorMessage': pErrorMessage, |
| 1886 | 2423 | 'pTransSlugToUpgrade': pTransSlugToUpgrade, |
| 1887 | - 'pTransDone': pTransDone | |
| 2424 | + 'pTransDone': pTransDone, | |
| 2425 | + 'bulkErrorCode': bulkErrorCode | |
| 1888 | 2426 | }; |
| 1889 | 2427 | updatesoverview_upgrade_int_loop_flow(params); |
| 1890 | 2428 | }; |
| 1891 | 2429 | |
| @@ -1893,40 +2431,55 @@ | ||
| 1893 | 2431 | fnc(); |
| 1894 | 2432 | else |
| 1895 | 2433 | setTimeout(fnc, 400); |
| 1896 | 2434 | } |
| 1897 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone), | |
| 2435 | + }(pWebsiteId, currentThemeSlug, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone), | |
| 1898 | 2436 | tryCount: 0, |
| 1899 | 2437 | retryLimit: 3, |
| 1900 | - endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade) { | |
| 2438 | + endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone) { | |
| 1901 | 2439 | return function () { |
| 2440 | + let remainingThemeSlugs = globalThis.mainwp_slug_list_to_array(pThemeSlugToUpgrade); | |
| 2441 | + | |
| 2442 | + const yithSlugList = remainingThemeSlugs.filter(slg => slg.startsWith('yith-')); | |
| 2443 | + | |
| 2444 | + let pThemeDone = true; | |
| 2445 | + | |
| 2446 | + if (yithSlugList.length > 0) { | |
| 2447 | + remainingThemeSlugs.shift(); | |
| 2448 | + remainingThemeSlugs = remainingThemeSlugs.join(','); | |
| 2449 | + pThemeDone = remainingThemeSlugs === ''; | |
| 2450 | + } else { | |
| 2451 | + remainingThemeSlugs = pThemeSlugToUpgrade; | |
| 2452 | + } | |
| 2453 | + | |
| 2454 | + | |
| 1902 | 2455 | let params = { |
| 1903 | 2456 | 'pWebsiteId': pWebsiteId, |
| 1904 | - 'pThemeSlugToUpgrade': pThemeSlugToUpgrade, | |
| 2457 | + 'pThemeSlugToUpgrade': remainingThemeSlugs, | |
| 1905 | 2458 | 'pPluginSlugToUpgrade': pPluginSlugToUpgrade, |
| 1906 | 2459 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 1907 | - 'pThemeDone': true, | |
| 1908 | - 'pPluginDone': true, | |
| 1909 | - 'pUpgradeDone': true, | |
| 2460 | + 'pThemeDone': pThemeDone, | |
| 2461 | + 'pPluginDone': pPluginDone, | |
| 2462 | + 'pUpgradeDone': pUpgradeDone, | |
| 1910 | 2463 | 'pErrorMessage': 'Error processing request', |
| 1911 | 2464 | 'pTransSlugToUpgrade': pTransSlugToUpgrade, |
| 1912 | - 'pTransDone': true | |
| 2465 | + 'pTransDone': pTransDone | |
| 1913 | 2466 | }; |
| 1914 | 2467 | updatesoverview_upgrade_int_loop_flow(params); |
| 1915 | 2468 | } |
| 1916 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade), | |
| 2469 | + }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pPluginDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone), | |
| 1917 | 2470 | error: function (xhr) { |
| 1918 | 2471 | this.tryCount++; |
| 1919 | 2472 | if (this.tryCount >= this.retryLimit) { |
| 2473 | + mainwpVars.errorCount++; | |
| 1920 | 2474 | this.endError(); |
| 1921 | 2475 | return; |
| 1922 | 2476 | } |
| 1923 | - let pRqst = this; | |
| 1924 | 2477 | let pXhr = xhr; |
| 1925 | - setTimeout(function () { | |
| 2478 | + setTimeout(() => { | |
| 1926 | 2479 | if (pXhr.status == 404) { |
| 1927 | 2480 | //handle error |
| 1928 | - jQuery.ajax(pRqst); | |
| 2481 | + jQuery.ajax(this); | |
| 1929 | 2482 | } else if (pXhr.status == 500) { |
| 1930 | 2483 | //handle error |
| 1931 | 2484 | } else { |
| 1932 | 2485 | //handle error |
| @@ -1935,13 +2488,28 @@ | ||
| 1935 | 2488 | }, |
| 1936 | 2489 | dataType: 'json' |
| 1937 | 2490 | }); |
| 1938 | 2491 | } else if (!pPluginDone) { |
| 2492 | + let pluginSlugList = globalThis.mainwp_slug_list_to_array(pPluginSlugToUpgrade); | |
| 2493 | + | |
| 2494 | + const yithSlugList = pluginSlugList.filter(slg => slg.startsWith('yith-')); | |
| 2495 | + let currentPluginSlug = ''; | |
| 2496 | + let remainingPluginSlugs = ''; | |
| 2497 | + | |
| 2498 | + if (yithSlugList.length > 0) { | |
| 2499 | + currentPluginSlug = pluginSlugList.shift(); | |
| 2500 | + remainingPluginSlugs = pluginSlugList.join(','); | |
| 2501 | + } else { | |
| 2502 | + currentPluginSlug = pPluginSlugToUpgrade; | |
| 2503 | + remainingPluginSlugs = ''; | |
| 2504 | + } | |
| 2505 | + | |
| 1939 | 2506 | let data = mainwp_secure_data({ |
| 1940 | 2507 | action: 'mainwp_upgradeplugintheme', |
| 1941 | 2508 | websiteId: pWebsiteId, |
| 1942 | 2509 | type: 'plugin', |
| 1943 | - slug: pPluginSlugToUpgrade | |
| 2510 | + slug: currentPluginSlug, | |
| 2511 | + bulkUpdate: 1 | |
| 1944 | 2512 | }); |
| 1945 | 2513 | |
| 1946 | 2514 | jQuery.ajax({ |
| 1947 | 2515 | type: "POST", |
| @@ -1948,35 +2516,56 @@ | ||
| 1948 | 2516 | url: ajaxurl, |
| 1949 | 2517 | data: data, |
| 1950 | 2518 | success: function (pWebsiteId, pThemeSlugToUpgrade, pSlug, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible. |
| 1951 | 2519 | return function (response) { // NOSONAR - complex ok. |
| 1952 | - let slugParts = pSlug.split(','); | |
| 1953 | - for (let sid of slugParts) { | |
| 1954 | - let result; | |
| 1955 | - let websiteHolder = jQuery('div[plugin_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 1956 | - if (!websiteHolder.exists()) { | |
| 1957 | - websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[plugin_slug="' + sid + '"]'); | |
| 2520 | + bulkErrorCode = response?.error?.errorCode ?? ''; | |
| 2521 | + if (bulkErrorCode == 'SUSPENDED_SITE') { | |
| 2522 | + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>'; | |
| 2523 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI); | |
| 2524 | + | |
| 2525 | + pThemeDone = true; | |
| 2526 | + pUpgradeDone = true; | |
| 2527 | + pTransDone = true; | |
| 2528 | + pPluginDone = true; | |
| 2529 | + | |
| 2530 | + mainwpVars.errorCount++; | |
| 2531 | + | |
| 2532 | + } else { | |
| 2533 | + let slugParts = []; | |
| 2534 | + if (pSlug.includes(',')) { | |
| 2535 | + slugParts = pSlug.split(','); | |
| 2536 | + } else { | |
| 2537 | + slugParts = [pSlug]; | |
| 1958 | 2538 | } |
| 1959 | - if (response.error) { | |
| 1960 | - result = getErrorMessage(response.error); | |
| 1961 | - pErrorMessage = result; | |
| 1962 | - } | |
| 1963 | - else { | |
| 1964 | - let res = response.result; // result is an object | |
| 1965 | - let res_error = response.result_error; | |
| 1966 | - if (res[encodeURIComponent(sid)]) { | |
| 1967 | - websiteHolder.attr('updated', 1); | |
| 1968 | - } else if (res_error[encodeURIComponent(sid)]) { | |
| 1969 | - pErrorMessage = res_error[encodeURIComponent(sid)]; | |
| 1970 | - let roll_error = mainwp_updates_get_rollback_msg(pErrorMessage); | |
| 1971 | - mainwp_put_actions_errors_msg('updateall', pWebsiteId, roll_error ? 'roll' : 'default', roll_error || pErrorMessage);// save errors to show later. | |
| 1972 | - } else { | |
| 1973 | - result = __('Update failed!'); | |
| 2539 | + for (let sid of slugParts) { | |
| 2540 | + let result; | |
| 2541 | + let websiteHolder = jQuery('div[plugin_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 2542 | + if (!websiteHolder.exists()) { | |
| 2543 | + websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[plugin_slug="' + sid + '"]'); | |
| 2544 | + } | |
| 2545 | + if (response.error) { | |
| 2546 | + result = getErrorMessage(response.error); | |
| 1974 | 2547 | pErrorMessage = result; |
| 2548 | + mainwpVars.errorCount++; | |
| 1975 | 2549 | } |
| 2550 | + else { | |
| 2551 | + let res = response.result; // result is an object | |
| 2552 | + let res_error = response.result_error; | |
| 2553 | + if (mainwp_get_result_entry(res, sid)) { | |
| 2554 | + mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result; | |
| 2555 | + websiteHolder.attr('updated', 1); | |
| 2556 | + } else if (mainwp_get_result_entry(res_error, sid)) { | |
| 2557 | + pErrorMessage = mainwp_get_result_entry(res_error, sid); | |
| 2558 | + let roll_error = mainwp_updates_get_rollback_msg(pErrorMessage); | |
| 2559 | + mainwp_put_actions_errors_msg('updateall', pWebsiteId, roll_error ? 'roll' : 'default', roll_error || pErrorMessage);// save errors to show later. | |
| 2560 | + } else { | |
| 2561 | + result = MainWP.I18n.t('Update failed!'); | |
| 2562 | + pErrorMessage = result; | |
| 2563 | + } | |
| 2564 | + } | |
| 1976 | 2565 | } |
| 2566 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'plugin'); | |
| 1977 | 2567 | } |
| 1978 | - updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'plugin'); | |
| 1979 | 2568 | |
| 1980 | 2569 | //If all done: continue, else delay 400ms to not stress the server |
| 1981 | 2570 | let fnc = function () { |
| 1982 | 2571 | let params = { |
| @@ -1981,16 +2570,17 @@ | ||
| 1981 | 2570 | let fnc = function () { |
| 1982 | 2571 | let params = { |
| 1983 | 2572 | 'pWebsiteId': pWebsiteId, |
| 1984 | 2573 | 'pThemeSlugToUpgrade': pThemeSlugToUpgrade, |
| 1985 | - 'pPluginSlugToUpgrade': pSlug, | |
| 2574 | + 'pPluginSlugToUpgrade': remainingPluginSlugs, | |
| 1986 | 2575 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 1987 | 2576 | 'pThemeDone': pThemeDone, |
| 1988 | - 'pPluginDone': true, | |
| 2577 | + 'pPluginDone': pPluginDone ? true : remainingPluginSlugs === '', | |
| 1989 | 2578 | 'pUpgradeDone': pUpgradeDone, |
| 1990 | 2579 | 'pErrorMessage': pErrorMessage, |
| 1991 | 2580 | 'pTransSlugToUpgrade': pTransSlugToUpgrade, |
| 1992 | - 'pTransDone': pTransDone | |
| 2581 | + 'pTransDone': pTransDone, | |
| 2582 | + 'bulkErrorCode': bulkErrorCode | |
| 1993 | 2583 | }; |
| 1994 | 2584 | updatesoverview_upgrade_int_loop_flow(params); |
| 1995 | 2585 | }; |
| 1996 | 2586 | |
| @@ -1998,31 +2588,45 @@ | ||
| 1998 | 2588 | fnc(); |
| 1999 | 2589 | else |
| 2000 | 2590 | setTimeout(fnc, 400); |
| 2001 | 2591 | } |
| 2002 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone), | |
| 2592 | + }(pWebsiteId, pThemeSlugToUpgrade, currentPluginSlug, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade, pTransDone), | |
| 2003 | 2593 | tryCount: 0, |
| 2004 | 2594 | retryLimit: 3, |
| 2005 | - endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade) { | |
| 2595 | + endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone) { | |
| 2006 | 2596 | return function () { |
| 2597 | + let remainingPluginSlugs = globalThis.mainwp_slug_list_to_array(pPluginSlugToUpgrade); | |
| 2598 | + const yithSlugList = remainingPluginSlugs.filter(slg => slg.startsWith('yith-')); | |
| 2599 | + | |
| 2600 | + let pPluginDone = true; | |
| 2601 | + | |
| 2602 | + if (yithSlugList.length > 0) { | |
| 2603 | + remainingPluginSlugs.shift(); | |
| 2604 | + remainingPluginSlugs = remainingPluginSlugs.join(','); | |
| 2605 | + pPluginDone = remainingPluginSlugs === ''; | |
| 2606 | + } else { | |
| 2607 | + remainingPluginSlugs = pPluginSlugToUpgrade; | |
| 2608 | + } | |
| 2609 | + | |
| 2007 | 2610 | let params = { |
| 2008 | 2611 | 'pWebsiteId': pWebsiteId, |
| 2009 | 2612 | 'pThemeSlugToUpgrade': pThemeSlugToUpgrade, |
| 2010 | - 'pPluginSlugToUpgrade': pPluginSlugToUpgrade, | |
| 2613 | + 'pPluginSlugToUpgrade': remainingPluginSlugs, | |
| 2011 | 2614 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 2012 | - 'pThemeDone': true, | |
| 2013 | - 'pPluginDone': true, | |
| 2014 | - 'pUpgradeDone': true, | |
| 2615 | + 'pThemeDone': pThemeDone, | |
| 2616 | + 'pPluginDone': pPluginDone, | |
| 2617 | + 'pUpgradeDone': pUpgradeDone, | |
| 2015 | 2618 | 'pErrorMessage': 'Error processing request', |
| 2016 | 2619 | 'pTransSlugToUpgrade': pTransSlugToUpgrade, |
| 2017 | - 'pTransDone': true | |
| 2620 | + 'pTransDone': pTransDone | |
| 2018 | 2621 | }; |
| 2019 | 2622 | updatesoverview_upgrade_int_loop_flow(params); |
| 2020 | 2623 | } |
| 2021 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade), | |
| 2624 | + }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pTransSlugToUpgrade, pTransDone), | |
| 2022 | 2625 | error: function (xhr) { |
| 2023 | 2626 | this.tryCount++; |
| 2024 | 2627 | if (this.tryCount >= this.retryLimit) { |
| 2628 | + mainwpVars.errorCount++; | |
| 2025 | 2629 | this.endError(); |
| 2026 | 2630 | return; |
| 2027 | 2631 | } |
| 2028 | 2632 | setTimeout(function (pRqst, pXhr) { |
| @@ -2051,17 +2655,32 @@ | ||
| 2051 | 2655 | url: ajaxurl, |
| 2052 | 2656 | data: data, |
| 2053 | 2657 | success: function (WebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pErrorMessage, pTransSlugToUpgrade, pTransDone) { // NOSONAR - compatible. |
| 2054 | 2658 | return function (response) { |
| 2055 | - let result; | |
| 2056 | - let websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"]'); | |
| 2057 | - if (response.error) { | |
| 2058 | - result = getErrorMessage(response.error); | |
| 2059 | - pErrorMessage = result; | |
| 2659 | + let bulkErrorCode = response?.error?.errorCode ?? ''; | |
| 2660 | + if (bulkErrorCode == 'SUSPENDED_SITE') { | |
| 2661 | + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>'; | |
| 2662 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI); | |
| 2663 | + | |
| 2664 | + pThemeDone = true; | |
| 2665 | + pPluginDone = true; | |
| 2666 | + pTransDone = true; | |
| 2667 | + | |
| 2668 | + mainwpVars.errorCount++; | |
| 2669 | + | |
| 2060 | 2670 | } else { |
| 2061 | - websiteHolder.attr('updated', 1); | |
| 2671 | + let result; | |
| 2672 | + let websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"]'); | |
| 2673 | + if (response.error) { | |
| 2674 | + result = getErrorMessage(response.error); | |
| 2675 | + pErrorMessage = result; | |
| 2676 | + } else { | |
| 2677 | + mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result; | |
| 2678 | + websiteHolder.attr('updated', 1); | |
| 2679 | + } | |
| 2680 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'wordpress'); | |
| 2681 | + | |
| 2062 | 2682 | } |
| 2063 | - updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'wordpress'); | |
| 2064 | 2683 | |
| 2065 | 2684 | //If all done: continue, else delay 400ms to not stress the server |
| 2066 | 2685 | let fnc = function () { |
| 2067 | 2686 | let params = { |
| @@ -2073,9 +2692,10 @@ | ||
| 2073 | 2692 | 'pPluginDone': pPluginDone, |
| 2074 | 2693 | 'pUpgradeDone': true, |
| 2075 | 2694 | 'pErrorMessage': pErrorMessage, |
| 2076 | 2695 | 'pTransSlugToUpgrade': pTransSlugToUpgrade, |
| 2077 | - 'pTransDone': pTransDone | |
| 2696 | + 'pTransDone': pTransDone, | |
| 2697 | + 'bulkErrorCode': bulkErrorCode | |
| 2078 | 2698 | }; |
| 2079 | 2699 | updatesoverview_upgrade_int_loop_flow(params); |
| 2080 | 2700 | }; |
| 2081 | 2701 | |
| @@ -2125,14 +2745,30 @@ | ||
| 2125 | 2745 | }(this, xhr), 1000); |
| 2126 | 2746 | }, |
| 2127 | 2747 | dataType: 'json' |
| 2128 | 2748 | }); |
| 2129 | - } else if (!pTransDone) { | |
| 2749 | + } else if (!pTransDone) { // NOSONAR - condition ok. | |
| 2750 | + let transSlugList = globalThis.mainwp_slug_list_to_array(pTransSlugToUpgrade); | |
| 2751 | + | |
| 2752 | + const yithSlugList = transSlugList.filter(slg => slg.startsWith('yith-')); | |
| 2753 | + | |
| 2754 | + let currentTransSlug = ''; | |
| 2755 | + let remainingTransSlugs = ''; | |
| 2756 | + | |
| 2757 | + if (yithSlugList.length > 0) { | |
| 2758 | + currentTransSlug = transSlugList.shift(); | |
| 2759 | + remainingTransSlugs = transSlugList.join(','); | |
| 2760 | + } else { | |
| 2761 | + currentTransSlug = pTransSlugToUpgrade; | |
| 2762 | + remainingTransSlugs = ''; | |
| 2763 | + } | |
| 2764 | + | |
| 2130 | 2765 | let data = mainwp_secure_data({ |
| 2131 | 2766 | action: 'mainwp_upgradeplugintheme', |
| 2132 | 2767 | websiteId: pWebsiteId, |
| 2133 | 2768 | type: 'translation', |
| 2134 | - slug: pTransSlugToUpgrade | |
| 2769 | + slug: currentTransSlug, | |
| 2770 | + bulkUpdate: 1 | |
| 2135 | 2771 | }); |
| 2136 | 2772 | |
| 2137 | 2773 | jQuery.ajax({ |
| 2138 | 2774 | type: "POST", |
| @@ -2138,38 +2774,57 @@ | ||
| 2138 | 2774 | type: "POST", |
| 2139 | 2775 | url: ajaxurl, |
| 2140 | 2776 | data: data, |
| 2141 | 2777 | success: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pSlug) { // NOSONAR - compatible. |
| 2142 | - return function (response) { | |
| 2143 | - let slugParts = pSlug.split(','); | |
| 2144 | - for (let sid of slugParts) { | |
| 2145 | - let result; | |
| 2146 | - let websiteHolder = jQuery('div[translation_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 2147 | - if (!websiteHolder.exists()) { | |
| 2148 | - websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[translation_slug="' + sid + '"]'); | |
| 2778 | + return function (response) { // NOSONAR -complex. | |
| 2779 | + let bulkErrorCode = response?.error?.errorCode ?? ''; | |
| 2780 | + if (bulkErrorCode == 'SUSPENDED_SITE') { | |
| 2781 | + let msgUI = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Suspended site.') + '"><i class="pause yellow icon"></i></span>'; | |
| 2782 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, false, msgUI); | |
| 2783 | + | |
| 2784 | + pThemeDone = true; | |
| 2785 | + pPluginDone = true; | |
| 2786 | + pUpgradeDone = true; | |
| 2787 | + pTransDone = true; | |
| 2788 | + | |
| 2789 | + mainwpVars.errorCount++; | |
| 2790 | + | |
| 2791 | + } else { | |
| 2792 | + let slugParts = []; | |
| 2793 | + if (pSlug.includes(',')) { | |
| 2794 | + slugParts = pSlug.split(','); | |
| 2795 | + } else { | |
| 2796 | + slugParts = [pSlug]; | |
| 2149 | 2797 | } |
| 2150 | - if (response.error) { | |
| 2151 | - result = getErrorMessage(response.error); | |
| 2152 | - pErrorMessage = result; | |
| 2153 | - } else { | |
| 2154 | - let res = response.result; | |
| 2155 | - if (res[sid]) { | |
| 2156 | - websiteHolder.attr('updated', 1); | |
| 2798 | + for (let sid of slugParts) { | |
| 2799 | + let result; | |
| 2800 | + let websiteHolder = jQuery('div[translation_slug="' + sid + '"] div[site_id="' + pWebsiteId + '"]'); | |
| 2801 | + if (!websiteHolder.exists()) { | |
| 2802 | + websiteHolder = jQuery('div[site_id="' + pWebsiteId + '"] div[translation_slug="' + sid + '"]'); | |
| 2803 | + } | |
| 2804 | + if (response.error) { | |
| 2805 | + result = getErrorMessage(response.error); | |
| 2806 | + pErrorMessage = result; | |
| 2807 | + mainwpVars.errorCount++; | |
| 2157 | 2808 | } else { |
| 2158 | - result = __('Update failed!'); | |
| 2159 | - pErrorMessage = result; | |
| 2809 | + let res = response.result; | |
| 2810 | + if (mainwp_get_result_entry(res, sid)) { | |
| 2811 | + mainwpVars.lastUpdateResultBySite[pWebsiteId] = response.result; | |
| 2812 | + websiteHolder.attr('updated', 1); | |
| 2813 | + } else { | |
| 2814 | + result = MainWP.I18n.t('Update failed!'); | |
| 2815 | + pErrorMessage = result; | |
| 2816 | + } | |
| 2160 | 2817 | } |
| 2818 | + } | |
| 2161 | 2819 | |
| 2162 | - } | |
| 2820 | + updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'translation'); | |
| 2163 | 2821 | } |
| 2164 | - | |
| 2165 | - updatesoverview_upgrade_all_update_site_bold(pWebsiteId, 'translation'); | |
| 2166 | - | |
| 2167 | 2822 | //If all done: continue, else delay 400ms to not stress the server |
| 2168 | 2823 | let fnc = function () { |
| 2169 | 2824 | let params = { |
| 2170 | 2825 | 'pWebsiteId': pWebsiteId, |
| 2171 | - 'pThemeSlugToUpgrade': pSlug, | |
| 2826 | + 'pThemeSlugToUpgrade': pThemeSlugToUpgrade, | |
| 2172 | 2827 | 'pPluginSlugToUpgrade': pPluginSlugToUpgrade, |
| 2173 | 2828 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 2174 | 2829 | 'pThemeDone': pThemeDone, |
| 2175 | 2830 | 'pPluginDone': pPluginDone, |
| @@ -2174,10 +2829,11 @@ | ||
| 2174 | 2829 | 'pThemeDone': pThemeDone, |
| 2175 | 2830 | 'pPluginDone': pPluginDone, |
| 2176 | 2831 | 'pUpgradeDone': pUpgradeDone, |
| 2177 | 2832 | 'pErrorMessage': pErrorMessage, |
| 2178 | - 'pTransSlugToUpgrade': pSlug, | |
| 2179 | - 'pTransDone': true | |
| 2833 | + 'pTransSlugToUpgrade': remainingTransSlugs, | |
| 2834 | + 'pTransDone': pTransDone ? true : remainingTransSlugs === '', | |
| 2835 | + 'bulkErrorCode': bulkErrorCode | |
| 2180 | 2836 | }; |
| 2181 | 2837 | updatesoverview_upgrade_int_loop_flow(params); |
| 2182 | 2838 | }; |
| 2183 | 2839 | |
| @@ -2185,28 +2841,42 @@ | ||
| 2185 | 2841 | fnc(); |
| 2186 | 2842 | else |
| 2187 | 2843 | setTimeout(fnc, 400); |
| 2188 | 2844 | } |
| 2189 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, pTransSlugToUpgrade), | |
| 2845 | + }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pUpgradeDone, pErrorMessage, currentTransSlug), | |
| 2190 | 2846 | tryCount: 0, |
| 2191 | 2847 | retryLimit: 3, |
| 2192 | - endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade) { | |
| 2848 | + endError: function (pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pUpgradeDone, pTransSlugToUpgrade) { | |
| 2193 | 2849 | return function () { |
| 2850 | + let remainingTransSlugs = globalThis.mainwp_slug_list_to_array(pTransSlugToUpgrade); | |
| 2851 | + | |
| 2852 | + const yithSlugList = remainingTransSlugs.filter(slg => slg.startsWith('yith-')); | |
| 2853 | + | |
| 2854 | + let pTransDone = true; | |
| 2855 | + | |
| 2856 | + if (yithSlugList.length > 0) { | |
| 2857 | + remainingTransSlugs.shift(); | |
| 2858 | + remainingTransSlugs = remainingTransSlugs.join(','); | |
| 2859 | + pTransDone = remainingTransSlugs === ''; | |
| 2860 | + } else { | |
| 2861 | + remainingTransSlugs = pTransSlugToUpgrade; | |
| 2862 | + } | |
| 2863 | + | |
| 2194 | 2864 | let params = { |
| 2195 | 2865 | 'pWebsiteId': pWebsiteId, |
| 2196 | 2866 | 'pThemeSlugToUpgrade': pThemeSlugToUpgrade, |
| 2197 | 2867 | 'pPluginSlugToUpgrade': pPluginSlugToUpgrade, |
| 2198 | 2868 | 'pWordpressUpgrade': pWordpressUpgrade, |
| 2199 | - 'pThemeDone': true, | |
| 2200 | - 'pPluginDone': true, | |
| 2201 | - 'pUpgradeDone': true, | |
| 2869 | + 'pThemeDone': pThemeDone, | |
| 2870 | + 'pPluginDone': pPluginDone, | |
| 2871 | + 'pUpgradeDone': pUpgradeDone, | |
| 2202 | 2872 | 'pErrorMessage': 'Error processing request', |
| 2203 | - 'pTransSlugToUpgrade': pTransSlugToUpgrade, | |
| 2204 | - 'pTransDone': true | |
| 2873 | + 'pTransSlugToUpgrade': remainingTransSlugs, | |
| 2874 | + 'pTransDone': pTransDone | |
| 2205 | 2875 | }; |
| 2206 | 2876 | updatesoverview_upgrade_int_loop_flow(params); |
| 2207 | 2877 | } |
| 2208 | - }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pTransSlugToUpgrade), | |
| 2878 | + }(pWebsiteId, pThemeSlugToUpgrade, pPluginSlugToUpgrade, pWordpressUpgrade, pThemeDone, pPluginDone, pUpgradeDone, pTransSlugToUpgrade), | |
| 2209 | 2879 | error: function (xhr) { |
| 2210 | 2880 | this.tryCount++; |
| 2211 | 2881 | if (this.tryCount >= this.retryLimit) { |
| 2212 | 2882 | this.endError(); |
| @@ -2227,9 +2897,14 @@ | ||
| 2227 | 2897 | }, |
| 2228 | 2898 | dataType: 'json' |
| 2229 | 2899 | }); |
| 2230 | 2900 | } else { |
| 2231 | - if ((pErrorMessage != undefined) && (pErrorMessage != '')) { | |
| 2901 | + if (bulkErrorCode === 'SUSPENDED_SITE') { | |
| 2902 | + let _icon = '<i class="pause yellow icon"></i>'; | |
| 2903 | + let _error = MainWP.I18n.t('Suspended site.'); | |
| 2904 | + updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>'); | |
| 2905 | + mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error); | |
| 2906 | + } else if ((pErrorMessage != undefined) && (pErrorMessage != '')) { | |
| 2232 | 2907 | mainwpVars.errorCount++; |
| 2233 | 2908 | |
| 2234 | 2909 | let rollErrors = mainwp_get_actions_errors_msg('updateall', pWebsiteId, 'roll'); |
| 2235 | 2910 | let otherErrors = mainwp_get_actions_errors_msg('updateall', pWebsiteId, 'default'); |
| @@ -2242,12 +2917,32 @@ | ||
| 2242 | 2917 | } else { |
| 2243 | 2918 | _error = otherErrors |
| 2244 | 2919 | } |
| 2245 | 2920 | |
| 2921 | + if (_error == '') { | |
| 2922 | + _error = MainWP.I18n.t('Update failed. Please try again.'); | |
| 2923 | + } | |
| 2924 | + | |
| 2246 | 2925 | updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>'); |
| 2247 | 2926 | mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pWebsiteId + '"] .mainwp-html-popup', _error); |
| 2248 | 2927 | } else { |
| 2249 | - updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>'); | |
| 2928 | + let lastResult = mainwpVars.lastUpdateResultBySite ? mainwpVars.lastUpdateResultBySite[pWebsiteId] : null; | |
| 2929 | + if ( | |
| 2930 | + lastResult && | |
| 2931 | + typeof mainwp_html_regression !== "undefined" && | |
| 2932 | + mainwp_html_regression.use_after_updates === "1" | |
| 2933 | + ) { | |
| 2934 | + let success_icon = '<i class="green check icon"></i>'; | |
| 2935 | + let regression_icon_loading = render_html_regression_icon(lastResult, function (regression_final_icon) { | |
| 2936 | + updatesoverview_upgrade_all_update_site_status(pWebsiteId, success_icon + ' ' + regression_final_icon); | |
| 2937 | + }); | |
| 2938 | + updatesoverview_upgrade_all_update_site_status(pWebsiteId, success_icon + ' ' + regression_icon_loading); | |
| 2939 | + } else { | |
| 2940 | + updatesoverview_upgrade_all_update_site_status(pWebsiteId, '<i class="green check icon"></i>'); | |
| 2941 | + } | |
| 2942 | + if (mainwpVars.lastUpdateResultBySite) { | |
| 2943 | + delete mainwpVars.lastUpdateResultBySite[pWebsiteId]; | |
| 2944 | + } | |
| 2250 | 2945 | } |
| 2251 | 2946 | updatesoverview_upgrade_all_update_done(); |
| 2252 | 2947 | |
| 2253 | 2948 | return false; |
| @@ -2252,8 +2947,9 @@ | ||
| 2252 | 2947 | |
| 2253 | 2948 | return false; |
| 2254 | 2949 | } |
| 2255 | 2950 | }; |
| 2951 | +/* eslint-enable complexity */ | |
| 2256 | 2952 | |
| 2257 | 2953 | let updatesoverview_plugins_dismiss_outdate_detail = function (slug, name, id, obj) { |
| 2258 | 2954 | return updatesoverview_dismiss_outdate_plugintheme_by_site('plugin', slug, name, id, obj); |
| 2259 | 2955 | }; |
| @@ -2286,9 +2982,9 @@ | ||
| 2286 | 2982 | parent.find('td:last-child').html('<span data-tooltip="Please wait..." data-position="left center" data-inverted=""><i class="notched circle loading icon"></i></span>'); |
| 2287 | 2983 | jQuery.post(ajaxurl, data, function (response) { |
| 2288 | 2984 | if (response.result) { |
| 2289 | 2985 | parent.attr('dismissed', '-1'); |
| 2290 | - parent.find('td:last-child').html(__('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>')); | |
| 2986 | + parent.find('td:last-child').html(MainWP.I18n.t('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>')); | |
| 2291 | 2987 | |
| 2292 | 2988 | } else { |
| 2293 | 2989 | parent.find('td:last-child').html(getErrorMessage(response.error)); |
| 2294 | 2990 | } |
| @@ -2335,9 +3031,9 @@ | ||
| 2335 | 3031 | siteElement.remove(); |
| 2336 | 3032 | |
| 2337 | 3033 | if (parent.children('tr').length == 0) { |
| 2338 | 3034 | jQuery('#mainwp-unignore-detail-all').addClass('disabled'); |
| 2339 | - parent.append('<tr><td colspan="999">' + __('No ignored abandoned %1s', pWhat) + '</td></tr>'); | |
| 3035 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned %1s', pWhat) + '</td></tr>'); | |
| 2340 | 3036 | } |
| 2341 | 3037 | } |
| 2342 | 3038 | } |
| 2343 | 3039 | }(what, slug, id), 'json'); |
| @@ -2357,9 +3053,9 @@ | ||
| 2357 | 3053 | return function (response) { |
| 2358 | 3054 | if (response.result) { |
| 2359 | 3055 | let tableElement = jQuery('#ignored-abandoned-' + pWhat + 's-list'); |
| 2360 | 3056 | tableElement.find('tr').remove(); |
| 2361 | - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned %1s', pWhat) + '</td></tr>'); | |
| 3057 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned %1s', pWhat) + '</td></tr>'); | |
| 2362 | 3058 | jQuery('#mainwp-unignore-detail-all').addClass('disabled'); |
| 2363 | 3059 | } |
| 2364 | 3060 | } |
| 2365 | 3061 | }(what), 'json'); |
| @@ -2400,9 +3096,9 @@ | ||
| 2400 | 3096 | if (response.result) { |
| 2401 | 3097 | let tableElement = jQuery('#ignored-globally-abandoned-plugins-list'); |
| 2402 | 3098 | tableElement.find('tr').remove(); |
| 2403 | 3099 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2404 | - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned plugins.') + '</td></tr>'); | |
| 3100 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned plugins.') + '</td></tr>'); | |
| 2405 | 3101 | } |
| 2406 | 3102 | }, 'json'); |
| 2407 | 3103 | |
| 2408 | 3104 | return false; |
| @@ -2424,9 +3120,9 @@ | ||
| 2424 | 3120 | let parent = ignoreElement.parent(); |
| 2425 | 3121 | ignoreElement.remove(); |
| 2426 | 3122 | if (parent.children('tr').length == 0) { |
| 2427 | 3123 | jQuery('.mainwp-unignore-globally-all').addClass('disabled'); |
| 2428 | - parent.append('<tr><td colspan="999">' + __('No ignored abandoned plugins.') + '</td></tr>'); | |
| 3124 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned plugins.') + '</td></tr>'); | |
| 2429 | 3125 | } |
| 2430 | 3126 | } |
| 2431 | 3127 | }, 'json'); |
| 2432 | 3128 | return false; |
| @@ -2465,9 +3161,9 @@ | ||
| 2465 | 3161 | if (response.result) { |
| 2466 | 3162 | let tableElement = jQuery('#globally-ignored-themes-list'); |
| 2467 | 3163 | tableElement.find('tr').remove(); |
| 2468 | 3164 | jQuery('.mainwp-unignore-globally-all').addClass('disabled'); |
| 2469 | - tableElement.append('<tr><td colspan="999">' + __('No ignored abandoned themes.') + '</td></tr>'); | |
| 3165 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned themes.') + '</td></tr>'); | |
| 2470 | 3166 | } |
| 2471 | 3167 | }, 'json'); |
| 2472 | 3168 | |
| 2473 | 3169 | return false; |
| @@ -2487,9 +3183,9 @@ | ||
| 2487 | 3183 | let parent = ignoreElement.parent(); |
| 2488 | 3184 | ignoreElement.remove(); |
| 2489 | 3185 | if (parent.children('tr').length == 0) { |
| 2490 | 3186 | jQuery('.mainwp-unignore-globally-all').addClass('disabled'); |
| 2491 | - parent.append('<tr><td colspan="999">' + __('No ignored abandoned themes.') + '</td></tr>'); | |
| 3187 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored abandoned themes.') + '</td></tr>'); | |
| 2492 | 3188 | } |
| 2493 | 3189 | } |
| 2494 | 3190 | }, 'json'); |
| 2495 | 3191 | |
| @@ -2527,9 +3223,9 @@ | ||
| 2527 | 3223 | } else { |
| 2528 | 3224 | jQuery('#wp_http_response_code_' + id).removeClass('http-response-ok'); |
| 2529 | 3225 | } |
| 2530 | 3226 | } else { |
| 2531 | - jQuery('#wp_http_response_code_' + id + ' .http-code').html(__('Undefined error!')); | |
| 3227 | + jQuery('#wp_http_response_code_' + id + ' .http-code').html(MainWP.I18n.t('Undefined error!')); | |
| 2532 | 3228 | } |
| 2533 | 3229 | }, 'json'); |
| 2534 | 3230 | return false; |
| 2535 | 3231 | }; |
| @@ -2572,9 +3268,8 @@ | ||
| 2572 | 3268 | }, 'json'); |
| 2573 | 3269 | return false; |
| 2574 | 3270 | }; |
| 2575 | 3271 | |
| 2576 | - | |
| 2577 | 3272 | // Unignore Plugin / Themse ignored per site |
| 2578 | 3273 | let updatesoverview_unignore_plugintheme_by_site = function (what, slug, id, ver) { |
| 2579 | 3274 | let data = mainwp_secure_data({ |
| 2580 | 3275 | action: 'mainwp_unignoreplugintheme', |
| @@ -2613,9 +3308,9 @@ | ||
| 2613 | 3308 | let parent = siteElement.parent(); |
| 2614 | 3309 | mainwp_responsive_fix_remove_child_row(siteElement); |
| 2615 | 3310 | siteElement.remove(); |
| 2616 | 3311 | if (parent.children('tr').length == 0) { |
| 2617 | - parent.append('<tr><td colspan="999">' + __('No ignored %1s', pWhat) + '</td></tr>'); | |
| 3312 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored %1s', pWhat) + '</td></tr>'); | |
| 2618 | 3313 | jQuery('.mainwp-unignore-detail-all').addClass('disabled'); |
| 2619 | 3314 | } |
| 2620 | 3315 | } |
| 2621 | 3316 | } |
| @@ -2622,9 +3317,8 @@ | ||
| 2622 | 3317 | }(what, slug, id), 'json'); |
| 2623 | 3318 | return false; |
| 2624 | 3319 | }; |
| 2625 | 3320 | |
| 2626 | - | |
| 2627 | 3321 | // Unignore all Plugins / Themses ignored per site |
| 2628 | 3322 | let updatesoverview_unignore_plugintheme_by_site_all = function (what) { |
| 2629 | 3323 | let data = mainwp_secure_data({ |
| 2630 | 3324 | action: 'mainwp_unignoreplugintheme', |
| @@ -2637,9 +3331,9 @@ | ||
| 2637 | 3331 | return function (response) { |
| 2638 | 3332 | if (response.result) { |
| 2639 | 3333 | let tableElement = jQuery('#ignored-' + pWhat + 's-list'); |
| 2640 | 3334 | tableElement.find('tr').remove(); |
| 2641 | - tableElement.append('<tr><td colspan="999">' + __('No ignored %1s', pWhat) + '</td></tr>'); | |
| 3335 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored %1s', pWhat) + '</td></tr>'); | |
| 2642 | 3336 | jQuery('.mainwp-unignore-detail-all').addClass('disabled'); |
| 2643 | 3337 | } |
| 2644 | 3338 | } |
| 2645 | 3339 | }(what), 'json'); |
| @@ -2647,12 +3341,22 @@ | ||
| 2647 | 3341 | }; |
| 2648 | 3342 | |
| 2649 | 3343 | /**Plugins part**/ |
| 2650 | 3344 | let updatesoverview_plugins_ignore_detail = function (slug, name, id, obj, ignore_ver) { |
| 2651 | - let msg = __('Are you sure you want to ignore the %1 plugin updates? The updates will no longer be visible in your MainWP Dashboard.', name); | |
| 2652 | - mainwp_confirm(msg, function () { | |
| 2653 | - return updatesoverview_ignore_plugintheme_by_site('plugin', slug, name, id, obj, ignore_ver); | |
| 2654 | - }, false); | |
| 3345 | + const row = jQuery(obj).closest("tr"); | |
| 3346 | + const site_name = jQuery(row).attr("site_name"); | |
| 3347 | + let msg = MainWP.I18n.t( | |
| 3348 | + "Are you sure you want to ignore %1 plugin updates on %2? The updates will no longer be visible in your MainWP Dashboard.", | |
| 3349 | + decodeURIComponent(name), | |
| 3350 | + site_name ?? '' | |
| 3351 | + ); | |
| 3352 | + mainwp_confirm( | |
| 3353 | + msg, | |
| 3354 | + function () { | |
| 3355 | + return updatesoverview_ignore_plugintheme_by_site('plugin', slug, name, id, obj, ignore_ver); | |
| 3356 | + }, | |
| 3357 | + false | |
| 3358 | + ); | |
| 2655 | 3359 | return false; |
| 2656 | 3360 | }; |
| 2657 | 3361 | let updatesoverview_plugins_unignore_detail = function (slug, id, ver) { |
| 2658 | 3362 | return updatesoverview_unignore_plugintheme_by_site('plugin', slug, id, ver); |
| @@ -2660,9 +3364,9 @@ | ||
| 2660 | 3364 | let updatesoverview_plugins_unignore_detail_all = function () { |
| 2661 | 3365 | return updatesoverview_unignore_plugintheme_by_site_all('plugin'); |
| 2662 | 3366 | }; |
| 2663 | 3367 | let updatesoverview_themes_ignore_detail = function (slug, name, id, obj, ignore_ver) { |
| 2664 | - let msg = __('Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.', name); | |
| 3368 | + let msg = MainWP.I18n.t("Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.", name); | |
| 2665 | 3369 | mainwp_confirm(msg, function () { |
| 2666 | 3370 | return updatesoverview_ignore_plugintheme_by_site('theme', slug, name, id, obj, ignore_ver); |
| 2667 | 3371 | }, false); |
| 2668 | 3372 | return false; |
| @@ -2673,9 +3377,23 @@ | ||
| 2673 | 3377 | let updatesoverview_themes_unignore_detail_all = function () { |
| 2674 | 3378 | return updatesoverview_unignore_plugintheme_by_site_all('theme'); |
| 2675 | 3379 | }; |
| 2676 | 3380 | let updatesoverview_plugins_ignore_all = function (slug, name, obj, ver) { |
| 2677 | - let msg = __('Are you sure you want to ignore the %1 plugin updates? The updates will no longer be visible in your MainWP Dashboard.', name); | |
| 3381 | + const row = jQuery(obj).closest("tr"); | |
| 3382 | + const site_name = jQuery(row).attr("site_name"); | |
| 3383 | + let msg = ''; | |
| 3384 | + if (site_name === undefined) { | |
| 3385 | + msg = MainWP.I18n.t( | |
| 3386 | + "Are you sure you want to ignore the %1 plugin updates? The updates will no longer be visible in your MainWP Dashboard.", | |
| 3387 | + decodeURIComponent(name) | |
| 3388 | + ); | |
| 3389 | + } else { | |
| 3390 | + msg = MainWP.I18n.t( | |
| 3391 | + "Are you sure you want to ignore %1 plugin updates on %2 site? The updates will no longer be visible in your MainWP Dashboard.", | |
| 3392 | + decodeURIComponent(name), | |
| 3393 | + site_name | |
| 3394 | + ); | |
| 3395 | + } | |
| 2678 | 3396 | mainwp_confirm(msg, function () { |
| 2679 | 3397 | let data = mainwp_secure_data({ |
| 2680 | 3398 | action: 'mainwp_ignorepluginsthemes', |
| 2681 | 3399 | type: 'plugin', |
| @@ -2687,14 +3405,12 @@ | ||
| 2687 | 3405 | parent.find('td:last-child').html('<span data-tooltip="Please wait..." data-position="left center" data-inverted=""><i class="notched circle loading icon"></i></span>'); |
| 2688 | 3406 | jQuery.post(ajaxurl, data, function (response) { |
| 2689 | 3407 | if (response.result) { |
| 2690 | 3408 | if (ver != undefined && ver != '') { // ignore this version. |
| 2691 | - console.log('ver' + ver); | |
| 2692 | 3409 | parent.find('td:last-child').html('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'); |
| 2693 | 3410 | jQuery('tr[plugin_slug="' + slug + '"][last-version="' + ver + '"]').find('td:last-child').html('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'); |
| 2694 | 3411 | jQuery('tr[plugin_slug="' + slug + '"][last-version="' + ver + '"]').attr('updated', '-1'); |
| 2695 | 3412 | } else { |
| 2696 | - console.log('not ver'); | |
| 2697 | 3413 | parent.find('td:last-child').html('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'); |
| 2698 | 3414 | jQuery('tr[plugin_slug="' + slug + '"]').find('table tr td:last-child').html('<span data-tooltip="Ignored" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'); |
| 2699 | 3415 | jQuery('tr[plugin_slug="' + slug + '"]').find('table tr').attr('updated', '-1'); |
| 2700 | 3416 | } |
| @@ -2716,9 +3432,9 @@ | ||
| 2716 | 3432 | if (response.result) { |
| 2717 | 3433 | let tableElement = jQuery('#globally-ignored-plugins-list'); |
| 2718 | 3434 | tableElement.find('tr').remove(); |
| 2719 | 3435 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2720 | - tableElement.append('<tr><td colspan="999">' + __('No ignored plugins.') + '</td></tr>'); | |
| 3436 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored plugins.') + '</td></tr>'); | |
| 2721 | 3437 | } |
| 2722 | 3438 | }, 'json'); |
| 2723 | 3439 | return false; |
| 2724 | 3440 | }; |
| @@ -2737,9 +3453,9 @@ | ||
| 2737 | 3453 | let parent = ignoreElement.parent(); |
| 2738 | 3454 | ignoreElement.remove(); |
| 2739 | 3455 | if (parent.children('tr').length == 0) { |
| 2740 | 3456 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2741 | - parent.append('<tr><td colspan="999">' + __('No ignored plugins.') + '</td></tr>'); | |
| 3457 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored plugins.') + '</td></tr>'); | |
| 2742 | 3458 | } |
| 2743 | 3459 | } |
| 2744 | 3460 | }, 'json'); |
| 2745 | 3461 | return false; |
| @@ -2745,9 +3461,9 @@ | ||
| 2745 | 3461 | return false; |
| 2746 | 3462 | }; |
| 2747 | 3463 | |
| 2748 | 3464 | let updatesoverview_themes_ignore_all = function (slug, name, obj, ver) { |
| 2749 | - let msg = __('Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.', name); | |
| 3465 | + let msg = MainWP.I18n.t('Are you sure you want to ignore the %1 theme updates? The updates will no longer be visible in your MainWP Dashboard.', name); | |
| 2750 | 3466 | mainwp_confirm(msg, function () { |
| 2751 | 3467 | |
| 2752 | 3468 | let data = mainwp_secure_data({ |
| 2753 | 3469 | action: 'mainwp_ignorepluginsthemes', // ignore global or this version global. |
| @@ -2787,9 +3503,9 @@ | ||
| 2787 | 3503 | if (response.result) { |
| 2788 | 3504 | let tableElement = jQuery('#globally-ignored-themes-list'); |
| 2789 | 3505 | tableElement.find('tr').remove(); |
| 2790 | 3506 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2791 | - tableElement.append('<tr><td colspan="999">' + __('No ignored themes.') + '</td></tr>'); | |
| 3507 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored themes.') + '</td></tr>'); | |
| 2792 | 3508 | } |
| 2793 | 3509 | }, 'json'); |
| 2794 | 3510 | |
| 2795 | 3511 | return false; |
| @@ -2809,9 +3525,9 @@ | ||
| 2809 | 3525 | let parent = ignoreElement.parent(); |
| 2810 | 3526 | ignoreElement.remove(); |
| 2811 | 3527 | if (parent.children('tr').length == 0) { |
| 2812 | 3528 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2813 | - parent.append('<tr><td colspan="999">' + __('No ignored themes.') + '</td></tr>'); | |
| 3529 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored themes.') + '</td></tr>'); | |
| 2814 | 3530 | } |
| 2815 | 3531 | } |
| 2816 | 3532 | }, 'json'); |
| 2817 | 3533 | return false; |
| @@ -2816,9 +3532,8 @@ | ||
| 2816 | 3532 | }, 'json'); |
| 2817 | 3533 | return false; |
| 2818 | 3534 | }; |
| 2819 | 3535 | |
| 2820 | - | |
| 2821 | 3536 | let manageupdates_ignore_updates = function (what, ignore, slug, name, site_id, ignore_ver, ignored_callback) { |
| 2822 | 3537 | let data = mainwp_secure_data({ |
| 2823 | 3538 | action: 'mainwp_updates_ignore_upgrades', |
| 2824 | 3539 | type: what, |
| @@ -2843,9 +3558,8 @@ | ||
| 2843 | 3558 | manageupdates_ignore_updates('wp', 'this_version', 'core', 'WordPress', site_id, ignore_ver, ignored_callback) |
| 2844 | 3559 | return false; |
| 2845 | 3560 | }; |
| 2846 | 3561 | |
| 2847 | - | |
| 2848 | 3562 | let updatesoverview_upgrade_ignore_this_version_globally = function (ignore_ver) { |
| 2849 | 3563 | let ignored_callback = function () { |
| 2850 | 3564 | jQuery('tr.mainwp-wordpress-update[last-version="' + ignore_ver + '"]').find('td:last-child').html('<span data-tooltip="Ignored this version globally" data-position="left center" data-inverted=""><i class="check green icon"></i></span>'); |
| 2851 | 3565 | jQuery('tr.mainwp-wordpress-update[last-version="' + ignore_ver + '"]').attr('updated', '-1'); |
| @@ -2870,9 +3584,9 @@ | ||
| 2870 | 3584 | ignore_ver: ver |
| 2871 | 3585 | }); |
| 2872 | 3586 | jQuery.post(ajaxurl, data, function (pVer, pId) { |
| 2873 | 3587 | return function (response) { |
| 2874 | - if (response.result && 'success' == response.result ) { | |
| 3588 | + if (response.result && 'success' == response.result) { | |
| 2875 | 3589 | let siteElement = jQuery('tr[site-id="' + pId + '"][ignored-ver="' + pVer + '"]'); |
| 2876 | 3590 | |
| 2877 | 3591 | if (!siteElement.find('div').is(':visible')) { |
| 2878 | 3592 | mainwp_responsive_fix_remove_child_row(siteElement); |
| @@ -2893,9 +3607,9 @@ | ||
| 2893 | 3607 | let parent = siteElement.parent(); |
| 2894 | 3608 | mainwp_responsive_fix_remove_child_row(siteElement); |
| 2895 | 3609 | siteElement.remove(); |
| 2896 | 3610 | if (parent.children('tr').length == 0) { |
| 2897 | - parent.append('<tr><td colspan="999">' + __('No ignored WordPress') + '</td></tr>'); | |
| 3611 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress') + '</td></tr>'); | |
| 2898 | 3612 | jQuery('#mainwp-unignore-cores-detail-all').addClass('disabled'); |
| 2899 | 3613 | } |
| 2900 | 3614 | } |
| 2901 | 3615 | } |
| @@ -2903,29 +3617,27 @@ | ||
| 2903 | 3617 | return false; |
| 2904 | 3618 | }; |
| 2905 | 3619 | |
| 2906 | 3620 | // Unignore all Plugins / Themses ignored per site |
| 2907 | -let updatesoverview_unignore_cores_by_site_all = function (what) { | |
| 3621 | +let updatesoverview_unignore_cores_by_site_all = function () { | |
| 2908 | 3622 | let data = mainwp_secure_data({ |
| 2909 | 3623 | action: 'mainwp_updates_unignore_upgrades', |
| 2910 | 3624 | id: '_ALL_', |
| 2911 | 3625 | }); |
| 2912 | 3626 | |
| 2913 | - jQuery.post(ajaxurl, data, function (pWhat) { | |
| 3627 | + jQuery.post(ajaxurl, data, function () { | |
| 2914 | 3628 | return function (response) { |
| 2915 | - if (response.result && 'success' == response.result ) { | |
| 3629 | + if (response.result && 'success' == response.result) { | |
| 2916 | 3630 | let parent = jQuery('#ignored-cores-list'); |
| 2917 | 3631 | parent.find('tr').remove(); |
| 2918 | - parent.append('<tr><td colspan="999">' + __('No ignored WordPress') + '</td></tr>'); | |
| 3632 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress') + '</td></tr>'); | |
| 2919 | 3633 | jQuery('.mainwp-unignore-detail-all').addClass('disabled'); |
| 2920 | 3634 | } |
| 2921 | 3635 | } |
| 2922 | - }(what), 'json'); | |
| 3636 | + }, 'json'); | |
| 2923 | 3637 | return false; |
| 2924 | 3638 | }; |
| 2925 | 3639 | |
| 2926 | - | |
| 2927 | - | |
| 2928 | 3640 | // Unignore globally ignored cores. |
| 2929 | 3641 | let updatesoverview_cores_unignore_globally = function (ver) { |
| 2930 | 3642 | let data = mainwp_secure_data({ |
| 2931 | 3643 | action: 'mainwp_updates_unignore_global_upgrades', |
| @@ -2937,9 +3649,9 @@ | ||
| 2937 | 3649 | let parent = ignoreElement.parent(); |
| 2938 | 3650 | ignoreElement.remove(); |
| 2939 | 3651 | if (parent.children('tr').length == 0) { |
| 2940 | 3652 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2941 | - parent.append('<tr><td colspan="999">' + __('No ignored WordPress.') + '</td></tr>'); | |
| 3653 | + parent.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress.') + '</td></tr>'); | |
| 2942 | 3654 | } |
| 2943 | 3655 | } |
| 2944 | 3656 | }, 'json'); |
| 2945 | 3657 | return false; |
| @@ -2957,9 +3669,9 @@ | ||
| 2957 | 3669 | if (response.result) { |
| 2958 | 3670 | let tableElement = jQuery('#globally-ignored-cores-list'); |
| 2959 | 3671 | tableElement.find('tr').remove(); |
| 2960 | 3672 | jQuery('#mainwp-unignore-globally-all').addClass('disabled'); |
| 2961 | - tableElement.append('<tr><td colspan="999">' + __('No ignored WordPress.') + '</td></tr>'); | |
| 3673 | + tableElement.append('<tr><td colspan="999">' + MainWP.I18n.t('No ignored WordPress.') + '</td></tr>'); | |
| 2962 | 3674 | } |
| 2963 | 3675 | }, 'json'); |
| 2964 | 3676 | return false; |
| 2965 | 3677 | }; |
| @@ -2964,9 +3676,9 @@ | ||
| 2964 | 3676 | return false; |
| 2965 | 3677 | }; |
| 2966 | 3678 | |
| 2967 | 3679 | let updatesoverview_upgrade_translation = function (id, slug) { |
| 2968 | - let msg = __('Are you sure you want to update the translation on the selected site?'); | |
| 3680 | + let msg = MainWP.I18n.t('Are you sure you want to update the translation on the selected site?'); | |
| 2969 | 3681 | mainwp_confirm(msg, function () { |
| 2970 | 3682 | return updatesoverview_translations_upgrade_int(slug, id); |
| 2971 | 3683 | }, false, 1); |
| 2972 | 3684 | }; |
| @@ -2971,9 +3683,9 @@ | ||
| 2971 | 3683 | }, false, 1); |
| 2972 | 3684 | }; |
| 2973 | 3685 | |
| 2974 | 3686 | let updatesoverview_translations_upgrade = function (slug, websiteid) { |
| 2975 | - let msg = __('Are you sure you want to update the translation on the selected site?'); | |
| 3687 | + let msg = MainWP.I18n.t('Are you sure you want to update the translation on the selected site?'); | |
| 2976 | 3688 | mainwp_confirm(msg, function () { |
| 2977 | 3689 | return updatesoverview_translations_upgrade_int(slug, websiteid); |
| 2978 | 3690 | }, false, 1); |
| 2979 | 3691 | }; |
| @@ -2978,9 +3690,9 @@ | ||
| 2978 | 3690 | }, false, 1); |
| 2979 | 3691 | }; |
| 2980 | 3692 | |
| 2981 | 3693 | let updatesoverview_plugins_upgrade = function (slug, websiteid) { |
| 2982 | - let msg = __('Are you sure you want to update the plugin on the selected site?'); | |
| 3694 | + let msg = MainWP.I18n.t('Are you sure you want to update the plugin on the selected site?'); | |
| 2983 | 3695 | mainwp_confirm(msg, function () { |
| 2984 | 3696 | return updatesoverview_plugins_upgrade_int(slug, websiteid); |
| 2985 | 3697 | }, false, 1); |
| 2986 | 3698 | }; |
| @@ -2985,9 +3697,9 @@ | ||
| 2985 | 3697 | }, false, 1); |
| 2986 | 3698 | }; |
| 2987 | 3699 | |
| 2988 | 3700 | let updatesoverview_themes_upgrade = function (slug, websiteid) { |
| 2989 | - let msg = __('Are you sure you want to update the theme on the selected site?'); | |
| 3701 | + let msg = MainWP.I18n.t('Are you sure you want to update the theme on the selected site?'); | |
| 2990 | 3702 | mainwp_confirm(msg, function () { |
| 2991 | 3703 | return updatesoverview_themes_upgrade_int(slug, websiteid); |
| 2992 | 3704 | }, false, 1); |
| 2993 | 3705 | }; |
| @@ -3006,11 +3718,11 @@ | ||
| 3006 | 3718 | return updatesoverview_upgrade_plugintheme('translation', id, slug, groupId); |
| 3007 | 3719 | }; |
| 3008 | 3720 | |
| 3009 | 3721 | let updatesoverview_upgrade_translation_all = function (id, updatesSelected) { |
| 3010 | - let msg = __('Are you sure you want to update all translations?'); | |
| 3011 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3012 | - msg = __('Are you sure you want to update selected translations?'); | |
| 3722 | + let msg = MainWP.I18n.t('Are you sure you want to update all translations?'); | |
| 3723 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3724 | + msg = MainWP.I18n.t('Are you sure you want to update selected translations?'); | |
| 3013 | 3725 | } |
| 3014 | 3726 | mainwp_confirm(msg, function () { |
| 3015 | 3727 | return updatesoverview_upgrade_plugintheme_all('translation', id, false, updatesSelected); |
| 3016 | 3728 | }, false, 2); |
| @@ -3017,11 +3729,11 @@ | ||
| 3017 | 3729 | return false; |
| 3018 | 3730 | }; |
| 3019 | 3731 | |
| 3020 | 3732 | let updatesoverview_group_upgrade_translation_all = function (id, groupId, updatesSelected) { |
| 3021 | - let msg = __('Are you sure you want to update all translations?'); | |
| 3022 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3023 | - msg = __('Are you sure you want to update selected translations?'); | |
| 3733 | + let msg = MainWP.I18n.t('Are you sure you want to update all translations?'); | |
| 3734 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3735 | + msg = MainWP.I18n.t('Are you sure you want to update selected translations?'); | |
| 3024 | 3736 | } |
| 3025 | 3737 | mainwp_confirm(msg, function () { |
| 3026 | 3738 | return updatesoverview_group_upgrade_plugintheme_all('translation', id, false, groupId, updatesSelected); |
| 3027 | 3739 | }, false, 2); |
| @@ -3028,9 +3740,9 @@ | ||
| 3028 | 3740 | return false; |
| 3029 | 3741 | }; |
| 3030 | 3742 | |
| 3031 | 3743 | let updatesoverview_upgrade_plugin = function (id, slug) { |
| 3032 | - let msg = __('Are you sure you want to update the plugin on the selected site?'); | |
| 3744 | + let msg = MainWP.I18n.t('Are you sure you want to update the plugin on the selected site?'); | |
| 3033 | 3745 | mainwp_confirm(msg, function () { |
| 3034 | 3746 | return updatesoverview_upgrade_plugintheme('plugin', id, slug); |
| 3035 | 3747 | }, false, 1); |
| 3036 | 3748 | }; |
| @@ -3035,11 +3747,11 @@ | ||
| 3035 | 3747 | }, false, 1); |
| 3036 | 3748 | }; |
| 3037 | 3749 | |
| 3038 | 3750 | let updatesoverview_upgrade_plugin_all = function (id, updatesSelected) { |
| 3039 | - let msg = __('Are you sure you want to update all plugins?'); | |
| 3040 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3041 | - msg = __('Are you sure you want to update selected plugins?'); | |
| 3751 | + let msg = MainWP.I18n.t('Are you sure you want to update all plugins?'); | |
| 3752 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3753 | + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?'); | |
| 3042 | 3754 | } |
| 3043 | 3755 | mainwp_confirm(msg, function () { |
| 3044 | 3756 | return updatesoverview_upgrade_plugintheme_all('plugin', id, false, updatesSelected); |
| 3045 | 3757 | }, false, 2); |
| @@ -3046,11 +3758,11 @@ | ||
| 3046 | 3758 | return false; |
| 3047 | 3759 | }; |
| 3048 | 3760 | |
| 3049 | 3761 | let updatesoverview_group_upgrade_plugin_all = function (id, groupId, updatesSelected) { |
| 3050 | - let msg = __('Are you sure you want to update all plugins?'); | |
| 3051 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3052 | - msg = __('Are you sure you want to update selected plugins?'); | |
| 3762 | + let msg = MainWP.I18n.t('Are you sure you want to update all plugins?'); | |
| 3763 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3764 | + msg = MainWP.I18n.t('Are you sure you want to update selected plugins?'); | |
| 3053 | 3765 | } |
| 3054 | 3766 | mainwp_confirm(msg, function () { |
| 3055 | 3767 | return updatesoverview_group_upgrade_plugintheme_all('plugin', id, false, groupId, updatesSelected); |
| 3056 | 3768 | }, false, 2); |
| @@ -3057,17 +3769,17 @@ | ||
| 3057 | 3769 | return false; |
| 3058 | 3770 | }; |
| 3059 | 3771 | |
| 3060 | 3772 | let updatesoverview_upgrade_theme = function (id, slug) { |
| 3061 | - let msg = __('Are you sure you want to update the theme on the selected site?'); | |
| 3773 | + let msg = MainWP.I18n.t('Are you sure you want to update the theme on the selected site?'); | |
| 3062 | 3774 | mainwp_confirm(msg, function () { |
| 3063 | 3775 | return updatesoverview_upgrade_plugintheme('theme', id, slug); |
| 3064 | 3776 | }, false, 1); |
| 3065 | 3777 | }; |
| 3066 | 3778 | let updatesoverview_upgrade_theme_all = function (id, updatesSelected) { |
| 3067 | - let msg = __('Are you sure you want to update all themes?'); | |
| 3068 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3069 | - msg = __('Are you sure you want to update selected themes?'); | |
| 3779 | + let msg = MainWP.I18n.t('Are you sure you want to update all themes?'); | |
| 3780 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3781 | + msg = MainWP.I18n.t('Are you sure you want to update selected themes?'); | |
| 3070 | 3782 | } |
| 3071 | 3783 | mainwp_confirm(msg, function () { |
| 3072 | 3784 | return updatesoverview_upgrade_plugintheme_all('theme', id, false, updatesSelected); |
| 3073 | 3785 | }, false, 2); |
| @@ -3074,11 +3786,11 @@ | ||
| 3074 | 3786 | return false; |
| 3075 | 3787 | }; |
| 3076 | 3788 | |
| 3077 | 3789 | let updatesoverview_group_upgrade_theme_all = function (id, groupId, updatesSelected) { |
| 3078 | - let msg = __('Are you sure you want to update all themes?'); | |
| 3079 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3080 | - msg = __('Are you sure you want to update selected themes?'); | |
| 3790 | + let msg = MainWP.I18n.t('Are you sure you want to update all themes?'); | |
| 3791 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3792 | + msg = MainWP.I18n.t('Are you sure you want to update selected themes?'); | |
| 3081 | 3793 | } |
| 3082 | 3794 | mainwp_confirm(msg, function () { |
| 3083 | 3795 | return updatesoverview_group_upgrade_plugintheme_all('theme', id, false, groupId, updatesSelected); |
| 3084 | 3796 | }, false, 2); |
| @@ -3096,9 +3808,9 @@ | ||
| 3096 | 3808 | return function () { |
| 3097 | 3809 | let list = []; |
| 3098 | 3810 | let slug_att = pWhat + '_slug'; |
| 3099 | 3811 | let slug = ''; |
| 3100 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3812 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3101 | 3813 | jQuery("#wp_" + pWhat + "_upgrades_" + pId + " tr[updated=0]").each(function () { |
| 3102 | 3814 | if (jQuery(this).find('.child.checkbox').checkbox('is checked')) { |
| 3103 | 3815 | slug = jQuery(this).attr(slug_att); |
| 3104 | 3816 | if (slug) { |
| @@ -3145,9 +3857,9 @@ | ||
| 3145 | 3857 | let list = []; |
| 3146 | 3858 | let slug_att = pWhat + '_slug'; |
| 3147 | 3859 | jQuery("#wp_" + pWhat + "_upgrades_" + pId + '_group_' + groupId + " tr[updated=0]").each(function () { |
| 3148 | 3860 | let slug = jQuery(this).attr(slug_att); |
| 3149 | - if (typeof updatesSelected !== 'undefined' && updatesSelected) { | |
| 3861 | + if (updatesSelected !== undefined && updatesSelected) { | |
| 3150 | 3862 | if (jQuery(this).find('.child.checkbox').checkbox('is checked') && slug) { |
| 3151 | 3863 | list.push(slug); |
| 3152 | 3864 | } |
| 3153 | 3865 | if (list.length == 0) { |
| @@ -3158,9 +3870,9 @@ | ||
| 3158 | 3870 | list.push(slug); |
| 3159 | 3871 | } |
| 3160 | 3872 | }); |
| 3161 | 3873 | |
| 3162 | - // proccessed by popup | |
| 3874 | + // processed by popup | |
| 3163 | 3875 | //updatesoverview_upgrade_plugintheme_list( what, pId, list, true, groupId ); |
| 3164 | 3876 | let siteName = jQuery("#wp_" + pWhat + "_upgrades_" + pId + '_group_' + groupId).attr('site_name'); |
| 3165 | 3877 | updatesoverview_upgrade_plugintheme_list_popup(what, pId, siteName, list); |
| 3166 | 3878 | } |
| @@ -3179,23 +3891,62 @@ | ||
| 3179 | 3891 | |
| 3180 | 3892 | return mainwp_updatesoverview_checkBackups(sitesToUpdate, siteNames); |
| 3181 | 3893 | }; |
| 3182 | 3894 | |
| 3183 | -let updatesoverview_upgrade_plugintheme_list = function (what, id, list, noCheck, groupId) { | |
| 3184 | - updatesoverviewContinueAfterBackup = function (pWhat, pId, pList, pGroupId) { | |
| 3185 | - return function () { | |
| 3895 | +let mainwp_render_regression_after_update = function (lastResult, lastSuccessParent) { | |
| 3896 | + | |
| 3897 | + if ( | |
| 3898 | + !lastResult || | |
| 3899 | + !lastSuccessParent || | |
| 3900 | + typeof mainwp_html_regression === "undefined" || | |
| 3901 | + mainwp_html_regression.use_after_updates !== "1" | |
| 3902 | + ) { | |
| 3903 | + return; | |
| 3904 | + } | |
| 3905 | + | |
| 3906 | + const icon_success = | |
| 3907 | + '<span data-inverted="" data-position="left center" data-tooltip="' + | |
| 3908 | + MainWP.I18n.t('Update successful.', 'mainwp') + | |
| 3909 | + '"><i class="green check icon"></i></span>'; | |
| 3910 | + | |
| 3911 | + const handleFinalIcon = function (regression_icon_final) { | |
| 3912 | + const html_final = icon_success + regression_icon_final; | |
| 3913 | + lastSuccessParent.find('td:last-child').html(html_final); | |
| 3914 | + }; | |
| 3915 | + | |
| 3916 | + const regression_icon_loading = render_html_regression_icon(lastResult, handleFinalIcon); | |
| 3917 | + | |
| 3918 | + lastSuccessParent | |
| 3919 | + .find('td:last-child') | |
| 3920 | + .html(icon_success + regression_icon_loading); | |
| 3921 | +} | |
| 3922 | + | |
| 3923 | +let updatesoverview_upgrade_plugintheme_list = function (what, id, list, noCheck, groupId) { //NOSONAR | |
| 3924 | + updatesoverviewContinueAfterBackup = function (pWhat, pId, pList, pGroupId) { //NOSONAR | |
| 3925 | + return function () { //NOSONAR | |
| 3186 | 3926 | let strGroup = ''; |
| 3187 | - if (typeof pGroupId !== 'undefined') { | |
| 3927 | + if (pGroupId !== undefined) { | |
| 3188 | 3928 | strGroup = '_group_' + pGroupId; |
| 3189 | 3929 | } |
| 3190 | 3930 | let newList = []; |
| 3191 | 3931 | |
| 3932 | + // Show icon waiting | |
| 3933 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 3934 | + let waiting_icon = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + MainWP.I18n.t('Updating. Please wait...'); | |
| 3935 | + if (regression_waiting_icon && "" !== regression_waiting_icon) { | |
| 3936 | + waiting_icon += regression_waiting_icon; | |
| 3937 | + } | |
| 3938 | + | |
| 3192 | 3939 | for (let i = pList.length - 1; i >= 0; i--) { |
| 3193 | 3940 | let item = pList[i]; |
| 3194 | 3941 | let elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + item); |
| 3195 | - if (elem && elem.value == 0) { | |
| 3942 | + if (!elem && typeof item === 'string') { | |
| 3943 | + let decoded = mainwp_decode_slug(item); | |
| 3944 | + elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + decoded); | |
| 3945 | + } | |
| 3946 | + if (elem?.value == 0) { | |
| 3196 | 3947 | let parent = jQuery(elem).closest('tr'); |
| 3197 | - parent.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Updating...', 'mainwp') + '"><i class="notched circle loading icon"></i></span> ' + __('Updating. Please wait...')); | |
| 3948 | + parent.find('td:last-child').html(waiting_icon); | |
| 3198 | 3949 | elem.value = 1; |
| 3199 | 3950 | parent.attr('updated', 1); |
| 3200 | 3951 | newList.push(item); |
| 3201 | 3952 | } |
| @@ -3201,31 +3952,47 @@ | ||
| 3201 | 3952 | } |
| 3202 | 3953 | } |
| 3203 | 3954 | |
| 3204 | 3955 | if (newList.length > 0) { |
| 3205 | - let data = mainwp_secure_data({ | |
| 3206 | - action: 'mainwp_upgradeplugintheme', | |
| 3207 | - websiteId: pId, | |
| 3208 | - type: pWhat, | |
| 3209 | - slug: newList.join(',') | |
| 3210 | - }); | |
| 3211 | - jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex ok. | |
| 3212 | - let success = false; | |
| 3213 | - let extErr = ''; | |
| 3214 | - if (response.error) { | |
| 3215 | - extErr = getErrorMessageInfo(response.error, 'ui') | |
| 3956 | + let queue = newList.slice(); | |
| 3957 | + let lastResult = null; | |
| 3958 | + let lastSuccessParent = null; | |
| 3959 | + | |
| 3960 | + let processNext = function () { | |
| 3961 | + if (queue.length === 0) { | |
| 3962 | + mainwp_render_regression_after_update(lastResult, lastSuccessParent); | |
| 3963 | + return; | |
| 3216 | 3964 | } |
| 3217 | - else { | |
| 3218 | - let res = response.result; | |
| 3219 | - let res_error = response.result_error; | |
| 3220 | 3965 | |
| 3221 | - for (let item of newList) { | |
| 3222 | - let elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + item); | |
| 3223 | - let parent = jQuery(elem).closest('tr'); | |
| 3224 | - if (res[item]) { | |
| 3225 | - parent.find('td:last-child').html('<span data-inverted="" data-position="left center" data-tooltip="' + __('Update successful.', 'mainwp') + '"><i class="green check icon"></i></span>'); | |
| 3226 | - } else if ((what == 'plugin' || what == 'theme') && res_error[item]) { | |
| 3227 | - let _error = res_error[item]; | |
| 3966 | + let item = queue.shift(); | |
| 3967 | + let data = mainwp_secure_data({ | |
| 3968 | + action: 'mainwp_upgradeplugintheme', | |
| 3969 | + websiteId: pId, | |
| 3970 | + type: pWhat, | |
| 3971 | + slug: item | |
| 3972 | + }); | |
| 3973 | + jQuery.post(ajaxurl, data, function (response) { //NOSONAR | |
| 3974 | + let extErr = ''; | |
| 3975 | + let elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + item); | |
| 3976 | + if (!elem && typeof item === 'string') { | |
| 3977 | + let decoded = mainwp_decode_slug(item); | |
| 3978 | + elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + decoded); | |
| 3979 | + } | |
| 3980 | + let parent = jQuery(elem).closest('tr'); | |
| 3981 | + | |
| 3982 | + if (response.error) { | |
| 3983 | + extErr = getErrorMessageInfo(response.error, 'ui'); | |
| 3984 | + parent.find('td:last-child').html(extErr); | |
| 3985 | + } else { | |
| 3986 | + let res = response.result; | |
| 3987 | + let res_error = response.result_error; | |
| 3988 | + const icon_success = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Update successful.', 'mainwp') + '"><i class="green check icon"></i></span>'; | |
| 3989 | + if (mainwp_get_result_entry(res, item)) { | |
| 3990 | + parent.find('td:last-child').html(icon_success); | |
| 3991 | + lastResult = res; | |
| 3992 | + lastSuccessParent = parent; | |
| 3993 | + } else if ((what == 'plugin' || what == 'theme') && mainwp_get_result_entry(res_error, item)) { | |
| 3994 | + let _error = mainwp_get_result_entry(res_error, item); | |
| 3228 | 3995 | let _icon = '<i class="red times icon"></i>'; |
| 3229 | 3996 | let roll_error = mainwp_updates_get_rollback_msg(_error); |
| 3230 | 3997 | if (roll_error) { |
| 3231 | 3998 | _error = roll_error; |
| @@ -3235,19 +4002,12 @@ | ||
| 3235 | 4002 | } else { |
| 3236 | 4003 | parent.find('td:last-child').html('<i class="red times icon"></i>'); |
| 3237 | 4004 | } |
| 3238 | 4005 | } |
| 3239 | - success = true; | |
| 3240 | - } | |
| 3241 | - if (!success) { | |
| 3242 | - for (let item of newList) { | |
| 3243 | - let elem = document.getElementById('wp_upgraded_' + pWhat + '_' + pId + strGroup + '_' + item); | |
| 3244 | - let parent = jQuery(elem).closest('tr'); | |
| 3245 | - parent.find('td:last-child').html(extErr); | |
| 3246 | - } | |
| 3247 | - } | |
| 3248 | - }, 'json'); | |
| 3249 | - | |
| 4006 | + processNext(); | |
| 4007 | + }, 'json'); | |
| 4008 | + }; | |
| 4009 | + processNext(); | |
| 3250 | 4010 | } |
| 3251 | 4011 | |
| 3252 | 4012 | updatesoverviewContinueAfterBackup = undefined; |
| 3253 | 4013 | } |
| @@ -3268,61 +4028,199 @@ | ||
| 3268 | 4028 | let updateCount = list.length; |
| 3269 | 4029 | if (updateCount == 0) |
| 3270 | 4030 | return; |
| 3271 | 4031 | |
| 3272 | - let updateWhat = what == 'theme' ? __('themes') : __('translations'); | |
| 3273 | - updateWhat = (what == 'plugin') ? __('plugins') : updateWhat; | |
| 4032 | + let updateWhat = what == 'theme' ? MainWP.I18n.t('themes') : MainWP.I18n.t('translations'); | |
| 4033 | + updateWhat = (what == 'plugin') ? MainWP.I18n.t('plugins') : updateWhat; | |
| 3274 | 4034 | |
| 3275 | 4035 | mainwpPopup('#mainwp-sync-sites-modal').clearList(); |
| 3276 | - mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(decodeURIComponent(pSiteName) + ' (' + updateCount + ' ' + updateWhat + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + pId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 4036 | + mainwpPopup('#mainwp-sync-sites-modal').appendItemsList(mainwp_links_visit_site_and_admin('', pId) + ' ' + updatesmanage_link_to_site(decodeURIComponent(pSiteName), pId) + ' (' + updateCount + ' ' + updateWhat + ')', '<span class="updatesoverview-upgrade-status-wp" siteid="' + pId + '">' + '<i class="clock outline icon"></i> ' + '</span>'); | |
| 3277 | 4037 | |
| 3278 | 4038 | let initData = { |
| 3279 | - title: __('Updating all'), | |
| 4039 | + title: MainWP.I18n.t('Updating all'), | |
| 3280 | 4040 | progressMax: 1 |
| 3281 | 4041 | }; |
| 3282 | 4042 | updatesoverview_update_popup_init(initData); |
| 3283 | - let data = mainwp_secure_data({ | |
| 3284 | - action: 'mainwp_upgradeplugintheme', | |
| 3285 | - websiteId: pId, | |
| 3286 | - type: what, | |
| 3287 | - slug: list.join(',') | |
| 4043 | + | |
| 4044 | + // Show icon waiting | |
| 4045 | + let waiting_icon = render_tooltip_loading_icon('<i class="notched circle loading icon"></i>'); | |
| 4046 | + // init sites status items. | |
| 4047 | + const statuses = [ | |
| 4048 | + { | |
| 4049 | + item: 1, | |
| 4050 | + icon: waiting_icon, | |
| 4051 | + }, | |
| 4052 | + { | |
| 4053 | + item: 2, | |
| 4054 | + ispopup: true, | |
| 4055 | + icon: '<i class="green check icon"></i>', | |
| 4056 | + isHidden: true, | |
| 4057 | + }, | |
| 4058 | + { | |
| 4059 | + item: 3, | |
| 4060 | + ispopup: true, | |
| 4061 | + icon: '<i class="red times icon"></i>', | |
| 4062 | + isHidden: true, | |
| 4063 | + }, | |
| 4064 | + { | |
| 4065 | + item: 5, | |
| 4066 | + ispopup: true, | |
| 4067 | + icon: '', // Reserved for future use. | |
| 4068 | + isHidden: true, | |
| 4069 | + }, | |
| 4070 | + ]; | |
| 4071 | + | |
| 4072 | + const regression_waiting_icon = render_html_regression_waiting_icon(); | |
| 4073 | + | |
| 4074 | + if (regression_waiting_icon) { | |
| 4075 | + statuses.push({ | |
| 4076 | + item: 4, | |
| 4077 | + icon: regression_waiting_icon, | |
| 4078 | + isHidden: true, | |
| 4079 | + }); | |
| 4080 | + } | |
| 4081 | + | |
| 4082 | + updatesoverview_plugins_upgrade_all_update_site_status(pId,''); // clear status first. | |
| 4083 | + | |
| 4084 | + statuses.forEach((status) => { | |
| 4085 | + const { item, ...options } = status; | |
| 4086 | + upgradeall_update_site_popup_multi_status(pId, item, options); | |
| 3288 | 4087 | }); |
| 3289 | 4088 | |
| 3290 | - updatesoverview_plugins_upgrade_all_update_site_status(pId, '<i class="notched circle loading icon"></i>'); | |
| 4089 | + let queue = list.slice(); | |
| 4090 | + let countError = 0; | |
| 4091 | + let lastResult = ''; | |
| 3291 | 4092 | |
| 3292 | - jQuery.post(ajaxurl, data, function (response) { | |
| 3293 | - let res_error = response.result_error; | |
| 3294 | - let bulk_errors = []; | |
| 3295 | - let _icon = '<i class="red times icon"></i>'; | |
| 3296 | - if (response.error) { | |
| 3297 | - let extErr = getErrorMessageInfo(response.error, 'ui'); | |
| 3298 | - updatesoverview_plugins_upgrade_all_update_site_status(pId, extErr); | |
| 3299 | - } else if (res_error) { | |
| 3300 | - for (let item of list) { | |
| 3301 | - if (res_error[item]) { | |
| 3302 | - let _error = res_error[item]; | |
| 3303 | - let roll_error = mainwp_updates_get_rollback_msg(_error); | |
| 3304 | - if (roll_error) { | |
| 3305 | - _error = roll_error; | |
| 3306 | - _icon = mainwpParams.roll_ui_icon; | |
| 4093 | + let processLoop = function (response) { | |
| 4094 | + if (queue.length === 0) { | |
| 4095 | + mainwpPopup('#mainwp-sync-sites-modal').setProgressSite(1); | |
| 4096 | + if ( | |
| 4097 | + lastResult && | |
| 4098 | + typeof mainwp_html_regression !== "undefined" && | |
| 4099 | + mainwp_html_regression.use_after_updates === "1" | |
| 4100 | + ) { | |
| 4101 | + let regression_icon_callback = render_html_regression_icon(lastResult, function (regression_final_icon) { | |
| 4102 | + upgradeall_update_site_popup_multi_status(pId, 4, { | |
| 4103 | + icon: regression_final_icon, | |
| 4104 | + }); | |
| 4105 | + }); | |
| 4106 | + upgradeall_update_site_popup_multi_status(pId, 4, { | |
| 4107 | + icon: regression_icon_callback, | |
| 4108 | + }); | |
| 4109 | + } | |
| 4110 | + upgradeall_update_site_popup_multi_status(pId, 1, { | |
| 4111 | + isHidden: true // hide spinner. | |
| 4112 | + }); | |
| 4113 | + | |
| 4114 | + if ( countError === 0 ) { | |
| 4115 | + setTimeout(function () { | |
| 4116 | + // wait for generated updates-regression-score-red-flag. | |
| 4117 | + if( jQuery('.updates-regression-score-red-flag').length === 0 ) { | |
| 4118 | + mainwpPopup('#mainwp-sync-sites-modal').close(); | |
| 4119 | + globalThis.location.href = location.href; // NOSONAR - window is ok. | |
| 3307 | 4120 | } |
| 3308 | - bulk_errors.push(_error); | |
| 4121 | + }, 3000); | |
| 4122 | + } else { | |
| 4123 | + mainwpPopup('#mainwp-sync-sites-modal').updateStatusLabel(MainWP.I18n.t('processed')); | |
| 4124 | + } | |
| 4125 | + return; | |
| 4126 | + } | |
| 4127 | + | |
| 4128 | + let item = queue.shift(); | |
| 4129 | + let data = mainwp_secure_data({ | |
| 4130 | + action: 'mainwp_upgradeplugintheme', | |
| 4131 | + websiteId: pId, | |
| 4132 | + type: what, | |
| 4133 | + slug: item | |
| 4134 | + }); | |
| 4135 | + let decoded = mainwp_decode_slug(item, true); | |
| 4136 | + jQuery.post(ajaxurl, data, function (response) { // NOSONAR - complex. | |
| 4137 | + let res_error = response.result_error; | |
| 4138 | + let hasError = false; | |
| 4139 | + if (response.error) { | |
| 4140 | + let extErr = getErrorMessageInfo(response.error); | |
| 4141 | + let new_status = decoded + ` - ${mainwp_escape_html(extErr)}`; | |
| 4142 | + upgradeall_update_site_popup_multi_status(pId, 3, { | |
| 4143 | + status:new_status, | |
| 4144 | + append:true, | |
| 4145 | + ispopup: true | |
| 4146 | + }); | |
| 4147 | + hasError = true; | |
| 4148 | + } else if (res_error && mainwp_get_result_entry(res_error, item)) { | |
| 4149 | + let new_status = decoded; | |
| 4150 | + let _error = mainwp_get_result_entry(res_error, item); | |
| 4151 | + let roll_error = mainwp_updates_get_rollback_msg(_error); | |
| 4152 | + if (roll_error) { | |
| 4153 | + new_status += ` - ${mainwp_escape_html(roll_error)}`; | |
| 4154 | + let _icon = mainwpParams.roll_ui_icon; | |
| 4155 | + upgradeall_update_site_popup_multi_status(pId, 5, { | |
| 4156 | + icon: _icon, | |
| 4157 | + ispopup: true, | |
| 4158 | + }); | |
| 4159 | + upgradeall_update_site_popup_multi_status(pId, 5, { | |
| 4160 | + status: new_status, | |
| 4161 | + ispopup: true, | |
| 4162 | + append:true | |
| 4163 | + }); | |
| 4164 | + } else { | |
| 4165 | + new_status += ` - ${mainwp_escape_html(_error)}`; | |
| 4166 | + upgradeall_update_site_popup_multi_status(pId, 3, { | |
| 4167 | + status: new_status, | |
| 4168 | + ispopup: true, | |
| 4169 | + append:true | |
| 4170 | + }); | |
| 3309 | 4171 | } |
| 4172 | + hasError = true; | |
| 4173 | + } else { | |
| 4174 | + let new_status = decoded; | |
| 4175 | + let statusItem = 2; | |
| 4176 | + // for backward compatibility. | |
| 4177 | + if (mainwp_get_result_entry(response.result_started, item)) { | |
| 4178 | + new_status = '<span data-inverted="" data-position="left center" data-tooltip="' + MainWP.I18n.t('Premium update started. Please wait a moment, then sync the data again.') + '">' + new_status + '</span>'; | |
| 4179 | + hasError = true; // Prevent the popup from closing automatically. | |
| 4180 | + } else if (!mainwp_get_result_entry(response.result, item)) { | |
| 4181 | + new_status += ` - ${MainWP.I18n.t('Failed to update. Please try again.')}`; | |
| 4182 | + hasError = true; // Prevent the popup from closing automatically. | |
| 4183 | + statusItem = 3; | |
| 4184 | + } else { | |
| 4185 | + new_status += ` - ${MainWP.I18n.t('Updated successfully')}`; | |
| 4186 | + } | |
| 4187 | + upgradeall_update_site_popup_multi_status(pId, statusItem, { | |
| 4188 | + status: new_status, | |
| 4189 | + ispopup: true, | |
| 4190 | + append:true | |
| 4191 | + }); | |
| 3310 | 4192 | } |
| 3311 | - } | |
| 3312 | - else { | |
| 3313 | - updatesoverview_plugins_upgrade_all_update_site_status(pId, '<i class="green check icon"></i>' + ' ' + mainwp_links_visit_site_and_admin('', pId)); | |
| 3314 | - } | |
| 3315 | 4193 | |
| 3316 | - if (bulk_errors.length) { | |
| 3317 | - jQuery('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"]').html('<span class="mainwp-html-popup" data-position="left center" data-html="">' + _icon + '</span>'); | |
| 3318 | - mainwp_init_html_popup('.updatesoverview-upgrade-status-wp[siteid="' + pId + '"] .mainwp-html-popup', bulk_errors.join('<br />')); | |
| 3319 | - } | |
| 4194 | + if( !hasError ){ | |
| 4195 | + lastResult = response?.result; | |
| 4196 | + } else { | |
| 4197 | + ++countError; | |
| 4198 | + } | |
| 3320 | 4199 | |
| 3321 | - mainwpPopup('#mainwp-sync-sites-modal').setProgressSite(1); | |
| 3322 | - setTimeout(function () { | |
| 3323 | - }, 3000); | |
| 3324 | - }, 'json'); | |
| 4200 | + processLoop(response); | |
| 4201 | + }, 'json').fail(function (jqXHR, textStatus, errorThrown) { | |
| 4202 | + let errorMessage = errorThrown || textStatus || MainWP.I18n.t('Invalid response from the server'); | |
| 4203 | + let new_status = decoded + ` - ${MainWP.I18n.t('Failed to update')}: ${mainwp_escape_html(errorMessage)}`; | |
| 4204 | + | |
| 4205 | + upgradeall_update_site_popup_multi_status(pId, 3, { | |
| 4206 | + status: new_status, | |
| 4207 | + ispopup: true, | |
| 4208 | + append: true | |
| 4209 | + }); | |
| 4210 | + | |
| 4211 | + ++countError; // Prevent the popup from closing automatically. | |
| 4212 | + | |
| 4213 | + processLoop({ | |
| 4214 | + error: errorMessage, | |
| 4215 | + result: {}, | |
| 4216 | + result_error: {}, | |
| 4217 | + result_started: {} | |
| 4218 | + }); | |
| 4219 | + }); | |
| 4220 | + }; | |
| 4221 | + | |
| 4222 | + processLoop(); | |
| 3325 | 4223 | } |
| 3326 | 4224 | |
| 3327 | 4225 | // for semantic ui checkboxes |
| 3328 | 4226 | jQuery(function () { |
| @@ -3380,11 +4278,20 @@ | ||
| 3380 | 4278 | } |
| 3381 | 4279 | ); |
| 3382 | 4280 | |
| 3383 | 4281 | // Main Master Checkboxes. |
| 4282 | + // Move label text outside the checkbox div so clicking the text bubbles to th for column sort, | |
| 4283 | + // while clicking the checkbox icon (empty label) still handles check/uncheck all behavior. | |
| 4284 | + $('.main-master-checkbox .main-master.checkbox').each(function () { | |
| 4285 | + let $label = $(this).find('label'); | |
| 4286 | + let labelText = $label.text().trim(); | |
| 4287 | + if (labelText) { | |
| 4288 | + $label.empty(); | |
| 4289 | + $(this).after('<span class="mainwp-th-sort-label">' + labelText + '</span>'); | |
| 4290 | + } | |
| 4291 | + }); | |
| 3384 | 4292 | $('.main-master-checkbox .main-master.checkbox').checkbox(); |
| 3385 | 4293 | $('.main-master-checkbox .main-master.checkbox').on('click', function (e) { |
| 3386 | - console.log('main-master click'); | |
| 3387 | 4294 | if ($(this).checkbox('is checked')) { |
| 3388 | 4295 | $(this).closest('.main-master-checkbox').next('.main-child-checkbox').find('.checkbox').checkbox('check'); |
| 3389 | 4296 | $(this).closest('.main-master-checkbox').find('.checkbox').checkbox('check'); |
| 3390 | 4297 | } else { |
| @@ -3395,13 +4302,13 @@ | ||
| 3395 | 4302 | }); |
| 3396 | 4303 | |
| 3397 | 4304 | } |
| 3398 | 4305 | // This function need to update when datatable changed it's style. |
| 3399 | -window.mainwp_table_check_columns_init = function () { | |
| 3400 | - jQuery(document).find('table th.check-column .checkbox').checkbox({ // table headers. | |
| 4306 | +globalThis.mainwp_table_check_columns_init = function (pTableSelector = 'table') { | |
| 4307 | + let tblSelect = pTableSelector; | |
| 4308 | + jQuery(document).find(tblSelect + ' th.check-column .checkbox').checkbox({ // table headers. | |
| 3401 | 4309 | // check all children |
| 3402 | 4310 | onChecked: function () { |
| 3403 | - console.log('parent checked.'); | |
| 3404 | 4311 | let $table = jQuery(this).closest('table'); |
| 3405 | 4312 | if ($table.parent().parent().hasClass('dt-scroll-head') || $table.parent().parent().hasClass('dt-scroll-foot')) { |
| 3406 | 4313 | $table = jQuery(this).closest('.dt-scroll'); // to compatible with datatable scroll |
| 3407 | 4314 | } |
| @@ -3428,9 +4335,8 @@ | ||
| 3428 | 4335 | // Fire on load to set parent value |
| 3429 | 4336 | fireOnInit: true, |
| 3430 | 4337 | // Change parent state on each child checkbox change |
| 3431 | 4338 | onChange: function () { |
| 3432 | - console.log('child checked.'); | |
| 3433 | 4339 | let $table = jQuery(this).closest('table'); |
| 3434 | 4340 | |
| 3435 | 4341 | if ($table.parent().hasClass('dt-scroll-body')) |
| 3436 | 4342 | $table = jQuery(this).closest('.dt-scroll'); // to compatible with datatable scroll |
| @@ -3459,4 +4365,66 @@ | ||
| 3459 | 4365 | } |
| 3460 | 4366 | }); |
| 3461 | 4367 | } |
| 3462 | 4368 | |
| 4369 | +// Sync score icon. | |
| 4370 | +const render_html_regression_sync_score_icon = function (score, change_score, website_id) { | |
| 4371 | + score = Number(score) || 0; | |
| 4372 | + change_score = Number(change_score) || 0; | |
| 4373 | + let icon_html = ""; | |
| 4374 | + if (score <= change_score) { | |
| 4375 | + icon_html = '<i class="check green icon"></i>'; // Minimal change. | |
| 4376 | + } else { | |
| 4377 | + icon_html = '<i class="fire alternate red icon updates-regression-score-red-flag"></i>'; // Major differences. | |
| 4378 | + } | |
| 4379 | + | |
| 4380 | + if (icon_html !== "" && Number.isInteger(website_id)) { | |
| 4381 | + const msg = MainWP.I18n.t('Change score changed. Click to review changes.'); | |
| 4382 | + icon_html = `<a href="admin.php?page=ManageSitesHTMLRegression&id=${website_id}" target="_blank" data-tooltip="${msg}" data-inverted="" data-position="left center">${icon_html}</a>`; | |
| 4383 | + } | |
| 4384 | + | |
| 4385 | + return icon_html; | |
| 4386 | +}; | |
| 4387 | + | |
| 4388 | +// Render Icon | |
| 4389 | +const render_html_regression_icon = function (result, onDone) { | |
| 4390 | + if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") { | |
| 4391 | + return ''; | |
| 4392 | + } | |
| 4393 | + const loading_icon = `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Regression scan in progress...', 'mainwp')}"><i class="notched circle loading icon"></i></span>`; | |
| 4394 | + setTimeout(() => { | |
| 4395 | + let _icon = ''; | |
| 4396 | + if ( | |
| 4397 | + result?.html_regression_max_scope && | |
| 4398 | + typeof result.html_regression_max_scope === 'object' && | |
| 4399 | + !Array.isArray(result.html_regression_max_scope) && | |
| 4400 | + Object.keys(result.html_regression_max_scope).length > 0 | |
| 4401 | + ) { | |
| 4402 | + const regression_scope = result.html_regression_max_scope; | |
| 4403 | + _icon = render_html_regression_sync_score_icon( | |
| 4404 | + Number.parseInt(regression_scope.change_score_current), | |
| 4405 | + Number.parseInt(regression_scope.change_score), | |
| 4406 | + regression_scope.website_id | |
| 4407 | + ); | |
| 4408 | + } else { | |
| 4409 | + _icon = '<i class="exclamation circle red icon"></i>'; | |
| 4410 | + } | |
| 4411 | + | |
| 4412 | + onDone(_icon); | |
| 4413 | + }, 1500); | |
| 4414 | + | |
| 4415 | + return loading_icon; | |
| 4416 | +}; | |
| 4417 | + | |
| 4418 | +// Render Waiting Icon. | |
| 4419 | +const render_html_regression_waiting_icon = function () { | |
| 4420 | + if (typeof mainwp_html_regression === "undefined" || mainwp_html_regression.use_after_updates !== "1") { | |
| 4421 | + return ''; | |
| 4422 | + } | |
| 4423 | + | |
| 4424 | + return `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Regression Testing scan will begin after the update is completed.', 'mainwp')}"><i class="hourglass half icon"></i></span>`; | |
| 4425 | +} | |
| 4426 | + | |
| 4427 | +// Render Tooltip Loading Icon. | |
| 4428 | +const render_tooltip_loading_icon = function (icon_html) { | |
| 4429 | + return `<span data-inverted="" data-position="left center" data-tooltip="${MainWP.I18n.t('Update in progress…', 'mainwp')}">${icon_html}</span>` | |
| 4430 | +} | |