PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 3.0.2
WP STAGING – WordPress Backups, Restore, Migration & Clone v3.0.2
4.11.1 4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / assets / js / dist / wpstg.js
wp-staging / assets / js / dist Last commit date
backup 3 years ago wpstg-admin-beta.js 3 years ago wpstg-admin-beta.js.map 3 years ago wpstg-admin-beta.min.js 5 years ago wpstg-admin-beta.min.js.map 3 years ago wpstg-admin-corrupt-settings.js 3 years ago wpstg-admin-corrupt-settings.js.map 3 years ago wpstg-admin-corrupt-settings.min.js 3 years ago wpstg-admin-corrupt-settings.min.js.map 3 years ago wpstg-admin-plugins.js 3 years ago wpstg-admin-plugins.js.map 3 years ago wpstg-admin-plugins.min.js 3 years ago wpstg-admin-plugins.min.js.map 3 years ago wpstg-admin-rating.js 3 years ago wpstg-admin-rating.js.map 3 years ago wpstg-admin-rating.min.js 3 years ago wpstg-admin-rating.min.js.map 3 years ago wpstg-admin.js 3 years ago wpstg-admin.js.map 3 years ago wpstg-admin.min.js 3 years ago wpstg-admin.min.js.map 3 years ago wpstg-blank-loader.js 3 years ago wpstg-blank-loader.js.map 3 years ago wpstg-blank-loader.min.js 3 years ago wpstg-blank-loader.min.js.map 3 years ago wpstg-sweetalert2.js 3 years ago wpstg-sweetalert2.js.map 3 years ago wpstg-sweetalert2.min.js 3 years ago wpstg-sweetalert2.min.js.map 3 years ago wpstg.js 3 years ago wpstg.js.map 3 years ago wpstg.min.js 3 years ago wpstg.min.js.map 3 years ago
wpstg.js
509 lines
1 /**
2 * version: 3.0.2
3 */
4 (function () {
5 'use strict';
6
7 /**
8 * This is a namespaced port of https://github.com/tristen/hoverintent,
9 * with slight modification to accept selector with dynamically added element in dom,
10 * instead of just already present element.
11 *
12 * @param {HTMLElement} parent
13 * @param {string} selector
14 * @param {CallableFunction} onOver
15 * @param {CallableFunction} onOut
16 *
17 * @return {object}
18 */
19 function wpstgHoverIntent (parent, selector, onOver, onOut) {
20 var x;
21 var y;
22 var pX;
23 var pY;
24 var mouseOver = false;
25 var focused = false;
26 var h = {};
27 var state = 0;
28 var timer = 0;
29 var options = {
30 sensitivity: 7,
31 interval: 100,
32 timeout: 0,
33 handleFocus: false
34 };
35 function delay(el, e) {
36 if (timer) {
37 timer = clearTimeout(timer);
38 }
39 state = 0;
40 return focused ? undefined : onOut(el, e);
41 }
42 function tracker(e) {
43 x = e.clientX;
44 y = e.clientY;
45 }
46 function compare(el, e) {
47 if (timer) timer = clearTimeout(timer);
48 if (Math.abs(pX - x) + Math.abs(pY - y) < options.sensitivity) {
49 state = 1;
50 return focused ? undefined : onOver(el, e);
51 } else {
52 pX = x;
53 pY = y;
54 timer = setTimeout(function () {
55 compare(el, e);
56 }, options.interval);
57 }
58 }
59
60 // Public methods
61 h.options = function (opt) {
62 var focusOptionChanged = opt.handleFocus !== options.handleFocus;
63 options = Object.assign({}, options, opt);
64 if (focusOptionChanged) {
65 options.handleFocus ? addFocus() : removeFocus();
66 }
67 return h;
68 };
69 function dispatchOver(el, e) {
70 mouseOver = true;
71 if (timer) {
72 timer = clearTimeout(timer);
73 }
74 el.removeEventListener('mousemove', tracker, false);
75 if (state !== 1) {
76 pX = e.clientX;
77 pY = e.clientY;
78 el.addEventListener('mousemove', tracker, false);
79 timer = setTimeout(function () {
80 compare(el, e);
81 }, options.interval);
82 }
83 return this;
84 }
85
86 /**
87 * Newly added method,
88 * A wrapper around dispatchOver to support dynamically added elements to dom
89 */
90 function onMouseOver(event) {
91 if (event.target.matches(selector + ', ' + selector + ' *')) {
92 dispatchOver(event.target.closest(selector), event);
93 }
94 }
95 function dispatchOut(el, e) {
96 mouseOver = false;
97 if (timer) {
98 timer = clearTimeout(timer);
99 }
100 el.removeEventListener('mousemove', tracker, false);
101 if (state === 1) {
102 timer = setTimeout(function () {
103 delay(el, e);
104 }, options.timeout);
105 }
106 return this;
107 }
108
109 /**
110 * Newly added method,
111 * A wrapper around dispatchOut to support dynamically added elements to dom
112 */
113 function onMouseOut(event) {
114 if (event.target.matches(selector + ', ' + selector + ' *')) {
115 dispatchOut(event.target.closest(selector), event);
116 }
117 }
118 function dispatchFocus(el, e) {
119 if (!mouseOver) {
120 focused = true;
121 onOver(el, e);
122 }
123 }
124
125 /**
126 * Newly added method,
127 * A wrapper around dispatchFocus to support dynamically added elements to dom
128 */
129 function onFocus(event) {
130 if (event.target.matches(selector + ', ' + selector + ' *')) {
131 dispatchFocus(event.target.closest(selector), event);
132 }
133 }
134 function dispatchBlur(el, e) {
135 if (!mouseOver && focused) {
136 focused = false;
137 onOut(el, e);
138 }
139 }
140
141 /**
142 * Newly added method,
143 * A wrapper around dispatchBlur to support dynamically added elements to dom
144 */
145 function onBlur(event) {
146 if (event.target.matches(selector + ', ' + selector + ' *')) {
147 dispatchBlur(event.target.closest(selector), event);
148 }
149 }
150
151 /**
152 * Modified to support dynamically added element
153 */
154 function addFocus() {
155 parent.addEventListener('focus', onFocus, false);
156 parent.addEventListener('blur', onBlur, false);
157 }
158
159 /**
160 * Modified to support dynamically added element
161 */
162 function removeFocus() {
163 parent.removeEventListener('focus', onFocus, false);
164 parent.removeEventListener('blur', onBlur, false);
165 }
166
167 /**
168 * Modified to support dynamically added element
169 */
170 h.remove = function () {
171 if (!parent) {
172 return;
173 }
174 parent.removeEventListener('mouseover', onMouseOver, false);
175 parent.removeEventListener('mouseout', onMouseOut, false);
176 removeFocus();
177 };
178
179 /**
180 * Modified to support dynamically added element
181 */
182 if (parent) {
183 parent.addEventListener('mouseover', onMouseOver, false);
184 parent.addEventListener('mouseout', onMouseOut, false);
185 }
186 return h;
187 }
188
189 var wpstg = (function ($) {
190 var WPStagingCommon = {
191 continueErrorHandle: true,
192 retry: {
193 currentDelay: 0,
194 count: 0,
195 max: 10,
196 retryOnErrors: [401, 403, 404, 429, 502, 503, 504],
197 performingRequest: false,
198 incrementRetry: function incrementRetry(incrementRatio) {
199 if (incrementRatio === void 0) {
200 incrementRatio = 1.25;
201 }
202 WPStagingCommon.retry.performingRequest = true;
203 if (WPStagingCommon.retry.currentDelay === 0) {
204 // start with a delay of 1sec
205 WPStagingCommon.retry.currentDelay = 1000;
206 WPStagingCommon.retry.count = 1;
207 }
208 WPStagingCommon.retry.currentDelay += 500 * WPStagingCommon.retry.count * incrementRatio;
209 WPStagingCommon.retry.count++;
210 },
211 canRetry: function canRetry() {
212 return WPStagingCommon.retry.count < WPStagingCommon.retry.max;
213 },
214 reset: function reset() {
215 WPStagingCommon.retry.currentDelay = 0;
216 WPStagingCommon.retry.count = 0;
217 WPStagingCommon.retry.performingRequest = false;
218 }
219 },
220 memoryExhaustArticleLink: 'https://wp-staging.com/docs/php-fatal-error-allowed-memory-size-of-134217728-bytes-exhausted/',
221 cache: {
222 elements: [],
223 get: function get(selector) {
224 // It is already cached!
225 if ($.inArray(selector, this.elements) !== -1) {
226 return this.elements[selector];
227 }
228
229 // Create cache and return
230 this.elements[selector] = $(selector);
231 return this.elements[selector];
232 },
233 refresh: function refresh(selector) {
234 selector.elements[selector] = $(selector);
235 }
236 },
237 setJobId: function setJobId(jobId) {
238 localStorage.setItem('jobIdBeingProcessed', jobId);
239 },
240 getJobId: function getJobId() {
241 return localStorage.getItem('jobIdBeingProcessed');
242 },
243 listenTooltip: function listenTooltip() {
244 wpstgHoverIntent(document, '.wpstg--tooltip', function (target, event) {
245 target.querySelector('.wpstg--tooltiptext').style.visibility = 'visible';
246 }, function (target, event) {
247 target.querySelector('.wpstg--tooltiptext').style.visibility = 'hidden';
248 });
249 },
250 // Get the custom themed Swal Modal for WP Staging
251 // Easy to maintain now in one place now
252 getSwalModal: function getSwalModal(isContentCentered, customClasses) {
253 if (isContentCentered === void 0) {
254 isContentCentered = false;
255 }
256 if (customClasses === void 0) {
257 customClasses = {};
258 }
259 // common style for all swal modal used in WP Staging
260 var defaultCustomClasses = {
261 confirmButton: 'wpstg--btn--confirm wpstg-blue-primary wpstg-button wpstg-link-btn wpstg-100-width',
262 cancelButton: 'wpstg--btn--cancel wpstg-blue-primary wpstg-link-btn wpstg-100-width',
263 actions: 'wpstg--modal--actions',
264 popup: isContentCentered ? 'wpstg-swal-popup centered-modal' : 'wpstg-swal-popup'
265 };
266
267 // If a attribute exists in both default and additional attributes,
268 // The class(es) of the additional attribute will overrite the default one.
269 var options = {
270 customClass: Object.assign(defaultCustomClasses, customClasses),
271 buttonsStyling: false,
272 reverseButtons: true,
273 showClass: {
274 popup: 'wpstg--swal2-show wpstg-swal-show'
275 }
276 };
277 return wpstgSwal.mixin(options);
278 },
279 showSuccessModal: function showSuccessModal(htmlContent) {
280 this.getSwalModal().fire({
281 showConfirmButton: false,
282 showCancelButton: true,
283 cancelButtonText: 'OK',
284 icon: 'success',
285 title: 'Success!',
286 html: '<div class="wpstg--grey" style="text-align: left; margin-top: 8px;">' + htmlContent + '</div>'
287 });
288 },
289 showWarningModal: function showWarningModal(htmlContent) {
290 this.getSwalModal().fire({
291 showConfirmButton: false,
292 showCancelButton: true,
293 cancelButtonText: 'OK',
294 icon: 'warning',
295 title: '',
296 html: '<div class="wpstg--grey" style="text-align: left; margin-top: 8px;">' + htmlContent + '</div>'
297 });
298 },
299 showErrorModal: function showErrorModal(htmlContent) {
300 this.getSwalModal().fire({
301 showConfirmButton: false,
302 showCancelButton: true,
303 cancelButtonText: 'OK',
304 icon: 'error',
305 title: 'Error!',
306 html: '<div class="wpstg--grey" style="text-align: left; margin-top: 8px;">' + htmlContent + '</div>'
307 });
308 },
309 getSwalContainer: function getSwalContainer() {
310 return wpstgSwal.getContainer();
311 },
312 closeSwalModal: function closeSwalModal() {
313 wpstgSwal.close();
314 },
315 /**
316 * Treats a default response object generated by WordPress's
317 * wp_send_json_success() or wp_send_json_error() functions in
318 * PHP, parses it in JavaScript, and either throws if it's an error,
319 * or returns the data if the response is successful.
320 *
321 * @param {object} response
322 * @return {*}
323 */
324 getDataFromWordPressResponse: function getDataFromWordPressResponse(response) {
325 if (typeof response !== 'object') {
326 throw new Error('Unexpected response (ERR 1341)');
327 }
328 if (!response.hasOwnProperty('success')) {
329 throw new Error('Unexpected response (ERR 1342)');
330 }
331 if (!response.hasOwnProperty('data')) {
332 throw new Error('Unexpected response (ERR 1343)');
333 }
334 if (response.success === false) {
335 if (response.data instanceof Array && response.data.length > 0) {
336 throw new Error(response.data.shift());
337 } else {
338 throw new Error('Response was not successful');
339 }
340 } else {
341 // Successful response. Return the data.
342 return response.data;
343 }
344 },
345 isLoading: function isLoading(_isLoading) {
346 if (!_isLoading || _isLoading === false) {
347 WPStagingCommon.cache.get('.wpstg-loader').hide();
348 } else {
349 WPStagingCommon.cache.get('.wpstg-loader').show();
350 }
351 },
352 /**
353 * Convert the given url to make it slug compatible
354 * @param {string} url
355 * @return {string}
356 */
357 slugify: function slugify(url) {
358 return url.toString().toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '').replace(/\s+/g, '-').replace(/&/g, '-and-').replace(/[^a-z0-9\-]/g, '').replace(/-+/g, '-').replace(/^-*/, '').replace(/-*$/, '');
359 },
360 showAjaxFatalError: function showAjaxFatalError(response, prependMessage, appendMessage) {
361 prependMessage = prependMessage ? prependMessage + '<br/><br/>' : 'Something went wrong! <br/><br/>';
362 appendMessage = appendMessage ? appendMessage + '<br/><br/>' : '<br/><br/>Please try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.';
363 if (response === false) {
364 WPStagingCommon.showError(prependMessage + ' Error: No response.' + appendMessage);
365 window.removeEventListener('beforeunload', WPStaging.warnIfClosingDuringProcess);
366 return;
367 }
368 if (typeof response.error !== 'undefined' && response.error) {
369 WPStagingCommon.showError(prependMessage + ' Error: ' + response.message + appendMessage);
370 window.removeEventListener('beforeunload', WPStaging.warnIfClosingDuringProcess);
371 return;
372 }
373 },
374 handleFetchErrors: function handleFetchErrors(response) {
375 if (!response.ok) {
376 WPStagingCommon.showError('Error: ' + response.status + ' - ' + response.statusText + '. Please try again or contact support.');
377 }
378 return response;
379 },
380 showError: function showError(message) {
381 // If retry request no need to show Error;
382 if (WPStagingCommon.retry.performingRequest) {
383 return;
384 }
385 WPStagingCommon.cache.get('#wpstg-try-again').css('display', 'inline-block');
386 WPStagingCommon.cache.get('#wpstg-cancel-cloning').text('Reset');
387 WPStagingCommon.cache.get('#wpstg-resume-cloning').show();
388 WPStagingCommon.cache.get('#wpstg-error-wrapper').show();
389 WPStagingCommon.cache.get('#wpstg-error-details').show().html(message);
390 WPStagingCommon.cache.get('#wpstg-removing-clone').removeClass('loading');
391 WPStagingCommon.cache.get('.wpstg-loader').hide();
392 $('.wpstg--modal--process--generic-problem').show().html(message);
393 },
394 resetErrors: function resetErrors() {
395 WPStagingCommon.cache.get('#wpstg-error-details').hide().html('');
396 },
397 /**
398 * Ajax Requests
399 * @param {Object} data
400 * @param {Function} callback
401 * @param {string} dataType
402 * @param {bool} showErrors
403 * @param {int} tryCount
404 * @param {float} incrementRatio
405 * @param {function} errorCallback
406 */
407 ajax: function ajax(data, callback, dataType, showErrors, tryCount, incrementRatio, errorCallback) {
408 if (incrementRatio === void 0) {
409 incrementRatio = null;
410 }
411 if (errorCallback === void 0) {
412 errorCallback = null;
413 }
414 if ('undefined' === typeof dataType) {
415 dataType = 'json';
416 }
417 if (false !== showErrors) {
418 showErrors = true;
419 }
420 tryCount = 'undefined' === typeof tryCount ? 0 : tryCount;
421 var retryLimit = 10;
422 var retryTimeout = 10000 * tryCount;
423 incrementRatio = parseInt(incrementRatio);
424 if (!isNaN(incrementRatio)) {
425 retryTimeout *= incrementRatio;
426 }
427 $.ajax({
428 url: ajaxurl + '?action=wpstg_processing&_=' + Date.now() / 1000,
429 type: 'POST',
430 dataType: dataType,
431 cache: false,
432 data: data,
433 error: function error(xhr, textStatus, errorThrown) {
434 console.log(xhr.status + ' ' + xhr.statusText + '---' + textStatus);
435 if (typeof errorCallback === 'function') {
436 // Custom error handler
437 errorCallback(xhr, textStatus, errorThrown);
438 if (!WPStagingCommon.continueErrorHandle) {
439 // Reset state
440 WPStagingCommon.continueErrorHandle = true;
441 return;
442 }
443 }
444
445 // Default error handler
446 tryCount++;
447 if (tryCount <= retryLimit) {
448 setTimeout(function () {
449 WPStagingCommon.ajax(data, callback, dataType, showErrors, tryCount, incrementRatio);
450 return;
451 }, retryTimeout);
452 } else {
453 var errorCode = 'undefined' === typeof xhr.status ? 'Unknown' : xhr.status;
454 WPStagingCommon.showError('Fatal Error: ' + errorCode + ' Please try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.');
455 }
456 },
457 success: function success(data) {
458 if ('function' === typeof callback) {
459 callback(data);
460 }
461 },
462 statusCode: {
463 404: function _() {
464 if (tryCount >= retryLimit) {
465 WPStagingCommon.showError('Error 404 - Can\'t find ajax request URL! Please try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.');
466 }
467 },
468 500: function _() {
469 if (tryCount >= retryLimit) {
470 WPStagingCommon.showError('Fatal Error 500 - Internal server error while processing the request! Please try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.');
471 }
472 },
473 504: function _() {
474 if (tryCount > retryLimit) {
475 WPStagingCommon.showError('Error 504 - It looks like your server is rate limiting ajax requests. Please try to resume after a minute. If this still not works try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.\n\ ');
476 }
477 },
478 502: function _() {
479 if (tryCount >= retryLimit) {
480 WPStagingCommon.showError('Error 502 - It looks like your server is rate limiting ajax requests. Please try to resume after a minute. If this still not works try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.\n\ ');
481 }
482 },
483 503: function _() {
484 if (tryCount >= retryLimit) {
485 WPStagingCommon.showError('Error 503 - It looks like your server is rate limiting ajax requests. Please try to resume after a minute. If this still not works try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.\n\ ');
486 }
487 },
488 429: function _() {
489 if (tryCount >= retryLimit) {
490 WPStagingCommon.showError('Error 429 - It looks like your server is rate limiting ajax requests. Please try to resume after a minute. If this still not works try the <a href=\'https://wp-staging.com/docs/wp-staging-settings-for-small-servers/\' target=\'_blank\'>WP Staging Small Server Settings</a> or submit an error report and contact us.\n\ ');
491 }
492 },
493 403: function _() {
494 if (tryCount >= retryLimit) {
495 WPStagingCommon.showError('Refresh page or login again! The process should be finished successfully. \n\ ');
496 }
497 }
498 }
499 });
500 }
501 };
502 return WPStagingCommon;
503 })(jQuery);
504
505 return wpstg;
506
507 })();
508 //# sourceMappingURL=wpstg.js.map
509