Download all files FTP
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
|
||||
/*! ============================================================================
|
||||
* UI CTRL NAMESPACE: Used to store custom Javascript Controls
|
||||
* =========================================================================== */
|
||||
?><script>
|
||||
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
* Creates a flat tab re-usable tab system
|
||||
*
|
||||
* @param string id The DOM element of the id to generate the tabs
|
||||
* @returns void
|
||||
*
|
||||
* @example:
|
||||
*
|
||||
* <script> Duplicator.UI.Ctrl.tabsFlat('tabs-flat-id'); <script>
|
||||
*
|
||||
* <div id="tabs-flat-id" class="dup-tabs-flat">
|
||||
* <div class="data-tabs">
|
||||
* <a href="javascript:void(0)" class="tab active">tab-1</a>
|
||||
* <a href="javascript:void(0)" class="tab">tab-2</a>
|
||||
* </div>
|
||||
* <div class="data-panels">
|
||||
* <div class="panel">p-1</div>
|
||||
* <div class="panel">p-2</div>
|
||||
* </div>
|
||||
* </div>
|
||||
*
|
||||
*/
|
||||
Duplicator.UI.Ctrl.tabsFlat = function(id) {
|
||||
var keyTabs = `#${id}.dup-tabs-flat > div.data-tabs`;
|
||||
var keyPnls = `#${id}.dup-tabs-flat > div.data-panels`;
|
||||
var $panels = $(`${keyPnls} > div.panel`);
|
||||
var startIndex = $(`${keyTabs} > a.tab.active`).index('a.tab');
|
||||
|
||||
//Register Click Event
|
||||
$(`${keyTabs} > a.tab`).on('click', function() {
|
||||
|
||||
var index = $(this).index('a.tab');
|
||||
|
||||
//Hide all
|
||||
$(`${keyTabs} > a.tab`).removeClass('active');
|
||||
$(`${keyPnls} > div.panel`).hide();
|
||||
|
||||
//Show active
|
||||
$(this).addClass('active');
|
||||
$($panels.get(index)).show();
|
||||
});
|
||||
|
||||
//init
|
||||
$($panels.get(startIndex)).show();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates a vertical tab re-usable tabbing system
|
||||
*
|
||||
* @param string id The DOM element of the id to generate the tabs
|
||||
* @returns void
|
||||
*
|
||||
* @example:
|
||||
*
|
||||
* <script> Duplicator.UI.Ctrl.tabsVert('tab-id'); < /script>
|
||||
*
|
||||
* <div id="tab-id" class="dup-tabs-vert">
|
||||
* <div class="data-tabs">
|
||||
* <div class="void">text</div>
|
||||
* <div class="tab active">tab-1</div>
|
||||
* <div class="tab">tab-2</div>
|
||||
* </div>
|
||||
* <div class="data-panels">
|
||||
* <div class="panel">panel-1</div>
|
||||
* <div class="panel">panel-2</div>
|
||||
* </div>
|
||||
* </div>
|
||||
*
|
||||
*/
|
||||
Duplicator.UI.Ctrl.tabsVert = function(id) {
|
||||
|
||||
var keyTabs = `#${id}.dup-tabs-vert > div.data-tabs`;
|
||||
var keyPnls = `#${id}.dup-tabs-vert > div.data-panels`;
|
||||
var $panels = $(`${keyPnls} > div.panel`);
|
||||
var startIndex = $(`${keyTabs} > div.tab.active`).index('div.tab');
|
||||
|
||||
/*Click Event: */
|
||||
$(`${keyTabs} div.tab`).on('click', function() {
|
||||
|
||||
var index = $(this).index('div.tab');
|
||||
var $panels = $(`${keyPnls} > div.panel`);
|
||||
|
||||
//Hide all
|
||||
$(`${keyTabs} > div.tab`).removeClass('active');
|
||||
$(`${keyPnls} > div.panel`).hide();
|
||||
|
||||
//Show active
|
||||
$(this).addClass('active');
|
||||
$($panels.get(index)).show();
|
||||
});
|
||||
|
||||
//init
|
||||
$($panels.get(startIndex)).show();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Toggles the spinner for the help item
|
||||
*
|
||||
* @param string id The DOM element of the id to generate the spinner
|
||||
* @param string height The CSS height of the spinner control (default 250px)
|
||||
* @param string width The CSS width of the spinner control (default 100%)
|
||||
* @returns void
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* <script> Duplicator.UI.Ctrl.Spinner('spinner-id'); < /script>
|
||||
*
|
||||
* <div id="spinner-id" class="dup-spinner">
|
||||
* <div class="area-left">
|
||||
* <i class="fas fa-chevron-circle-left area-arrow"></i>
|
||||
* </div>
|
||||
* <div class="area-data">
|
||||
* <div class="item active">panel-1</div>
|
||||
* <div class="item">panel-2</div>
|
||||
* </div>
|
||||
* <div class="area-right">
|
||||
* <i class="fas fa-chevron-circle-right"></i>
|
||||
* </div>
|
||||
* <div class="area-nav">
|
||||
* <span class="num"></span>
|
||||
* <progress class="progress"></progress>
|
||||
* </div>
|
||||
* </div>
|
||||
*
|
||||
*/
|
||||
Duplicator.UI.Ctrl.Spinner = class {
|
||||
|
||||
//Setup the Object
|
||||
constructor(id, height='350px', width='100%') {
|
||||
this.id = id;
|
||||
this.height = height;
|
||||
this.width = width;
|
||||
this.items = $(`#${id} > .area-data > .item`);
|
||||
this.maxItems = this.items.length - 1;
|
||||
this.init();
|
||||
}
|
||||
|
||||
//Initilize the object for use
|
||||
init() {
|
||||
var id = this.id;
|
||||
var $items = this.items;
|
||||
var max = this.maxItems
|
||||
var start = $(`#${id} .item.active`).index() + 1;
|
||||
|
||||
/*Click Event: Left/Right */
|
||||
$(`#${id} > .area-right, #${id} > .area-left`).on('click', function() {
|
||||
|
||||
var index = $(`#${id} .item.active`).index();
|
||||
|
||||
//Left or Right
|
||||
index = ($(this).hasClass('area-right'))
|
||||
? (index >= max) ? 0 : index + 1
|
||||
: (index === 0) ? max : index - 1;
|
||||
|
||||
$items.removeClass('active').hide();
|
||||
$($items[index]).addClass('active').show();
|
||||
|
||||
//Progress bar
|
||||
$(`#${id} .num`).html(`${index + 1} of ${max + 1}`);
|
||||
$(`#${id} progress`).val(index + 1);
|
||||
});
|
||||
|
||||
//init
|
||||
$(`#${id} div.area-nav progress`).attr('max', `${max + 1}`);
|
||||
$(`#${id} div.area-nav progress`).attr('value', '1');
|
||||
$(`#${id} div.area-nav .num`).html(`${start} of ${max + 1}`);
|
||||
$(`#${id}.dup-spinner`).css({'height' : this.height, 'width' : this.width});
|
||||
}
|
||||
|
||||
//Set the active panel to the index provided
|
||||
setPanel(index) {
|
||||
this.items.removeClass('active').hide();
|
||||
$(this.items.get(index)).addClass('active').show();
|
||||
$(`#${this.id} .num`).html(`${index + 1} of ${this.maxItems + 1}`);
|
||||
$(`#${this.id} progress`).val(index + 1);
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,177 @@
|
||||
<script>
|
||||
/*! ============================================================================
|
||||
* UI NAMESPACE: All methods at the top of the Duplicator Namespace
|
||||
* =========================================================================== */
|
||||
(function ($) {
|
||||
/**
|
||||
* Indicates if we have any form changes.
|
||||
* Primarily used to prevent the user from navigating away from a page with unsaved changes.
|
||||
* @type {boolean}
|
||||
*/
|
||||
DupPro.UI.hasUnsavedChanges = false;
|
||||
|
||||
/* Stores the state of a view into the database */
|
||||
DupPro.UI.SaveViewStateByPost = function (key, value)
|
||||
{
|
||||
if (key != undefined && value != undefined) {
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
dataType: "json",
|
||||
data: {
|
||||
action: 'DUP_PRO_UI_ViewState_SaveByPost',
|
||||
key: key,
|
||||
value: value,
|
||||
nonce: '<?php echo esc_js(wp_create_nonce('DUP_PRO_UI_ViewState_SaveByPost')); ?>'
|
||||
},
|
||||
success: function (data) {},
|
||||
error: function (data) {}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
DupPro.UI.SaveMulViewStatesByPost = function (states)
|
||||
{
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
dataType: "json",
|
||||
data: {
|
||||
action: 'DUP_PRO_UI_ViewState_SaveByPost',
|
||||
states: states,
|
||||
nonce: '<?php echo esc_js(wp_create_nonce('DUP_PRO_UI_ViewState_SaveByPost')); ?>'
|
||||
},
|
||||
success: function (data) {},
|
||||
error: function (data) {}
|
||||
});
|
||||
}
|
||||
|
||||
DupPro.UI.SetScanMode = function ()
|
||||
{
|
||||
var scanMode = jQuery('#scan-mode').val();
|
||||
|
||||
if (scanMode == <?php echo (int) DUP_PRO_DB::PHPDUMP_MODE_MULTI; ?>) {
|
||||
jQuery('#scan-multithread-size').show();
|
||||
jQuery('#scan-chunk-size-label').show();
|
||||
} else {
|
||||
jQuery('#scan-multithread-size').hide();
|
||||
jQuery('#scan-chunk-size-label').hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DupPro.UI.IsSaveViewState = true;
|
||||
/* Toggle MetaBoxes */
|
||||
DupPro.UI.ToggleMetaBox = function ()
|
||||
{
|
||||
var $title = jQuery(this);
|
||||
var $panel = $title.parent().find('.dup-box-panel');
|
||||
var $arrowParent = $title.parent().find('.dup-box-arrow');
|
||||
var $arrow = $title.parent().find('.dup-box-arrow i');
|
||||
var key = $panel.attr('id');
|
||||
var value = $panel.is(":visible") ? 0 : 1;
|
||||
$panel.toggle();
|
||||
|
||||
if (DupPro.UI.IsSaveViewState) {
|
||||
DupPro.UI.SaveViewStateByPost(key, value);
|
||||
}
|
||||
|
||||
if (value) {
|
||||
$arrowParent.attr("aria-expanded", true);
|
||||
$arrow.removeClass().addClass('fa fa-caret-up');
|
||||
} else {
|
||||
$arrowParent.attr("aria-expanded", false);
|
||||
$arrow.removeClass().addClass('fa fa-caret-down');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
DupPro.UI.ClearTraceLog = function (reload)
|
||||
{
|
||||
var reload = reload || 0;
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
data: {
|
||||
action: 'duplicator_pro_delete_trace_log',
|
||||
nonce: '<?php echo esc_js(wp_create_nonce('duplicator_pro_delete_trace_log')); ?>'
|
||||
},
|
||||
success: function (respData) {
|
||||
if (reload && respData.success) {
|
||||
window.location.reload();
|
||||
}
|
||||
},
|
||||
error: function (data) {}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Toggle Password input */
|
||||
DupPro.UI.TogglePasswordDisplay = function (display, inputID)
|
||||
{
|
||||
if (display) {
|
||||
document.getElementById(inputID).type = "text";
|
||||
} else {
|
||||
document.getElementById(inputID).type = "password";
|
||||
}
|
||||
}
|
||||
|
||||
/* Clock generator, used to show an active clock.
|
||||
* Intended use is to be called once per page load
|
||||
* such as:
|
||||
* <div id="dpro-clock-container"></div>
|
||||
* DupPro.UI.Clock(DupPro._WordPressInitTime); */
|
||||
DupPro.UI.Clock = function ()
|
||||
{
|
||||
var timeDiff;
|
||||
var timeout;
|
||||
|
||||
function addZ(n) {
|
||||
return (n < 10 ? '0' : '') + n;
|
||||
}
|
||||
|
||||
function formatTime(d) {
|
||||
return addZ(d.getHours()) + ':' + addZ(d.getMinutes()) + ':' + addZ(d.getSeconds());
|
||||
}
|
||||
|
||||
return function (s) {
|
||||
|
||||
var now = new Date();
|
||||
var then;
|
||||
// Set lag to just after next full second
|
||||
var lag = 1015 - now.getMilliseconds();
|
||||
|
||||
// Get the time difference when first run
|
||||
if (s) {
|
||||
s = s.split(':');
|
||||
then = new Date(now);
|
||||
then.setHours(+s[0], +s[1], +s[2], 0);
|
||||
timeDiff = now - then;
|
||||
}
|
||||
|
||||
now = new Date(now - timeDiff);
|
||||
jQuery('#dpro-clock-container').html(formatTime(now));
|
||||
timeout = setTimeout(DupPro.UI.Clock, lag);
|
||||
};
|
||||
}();
|
||||
|
||||
/* Runs callback function when form values change */
|
||||
DupPro.UI.formOnChangeValues = function(form, callback) {
|
||||
let previousValues = form.serialize();
|
||||
|
||||
$('form :input').on('change input', function() {
|
||||
if (previousValues !== form.serialize()) {
|
||||
previousValues = form.serialize();
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
||||
$('.dup-pseudo-checkbox, #dbnone, #dball').on('click', function() {
|
||||
// Since the pseudo checkbox is not a form input,
|
||||
// assume the state is changed on click
|
||||
callback();
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/*! ============================================================================
|
||||
* UTIL NAMESPACE: All methods at the top of the Duplicator Namespace
|
||||
* =========================================================================== */
|
||||
defined("ABSPATH") or die("");
|
||||
use Duplicator\Libs\Snap\SnapJson;
|
||||
|
||||
?>
|
||||
|
||||
<script>
|
||||
Duplicator.Util.ajaxProgress = null;
|
||||
|
||||
Duplicator.Util.ajaxProgressShow = function () {
|
||||
if (Duplicator.Util.ajaxProgress === null) {
|
||||
Duplicator.Util.ajaxProgress = jQuery('#dup-pro-ajax-loader')
|
||||
}
|
||||
Duplicator.Util.ajaxProgress
|
||||
.stop(true, true)
|
||||
.css('display', 'block')
|
||||
.delay(1000)
|
||||
.animate({
|
||||
opacity: 1
|
||||
}, 500);
|
||||
}
|
||||
|
||||
Duplicator.Util.ajaxProgressHide = function () {
|
||||
if (Duplicator.Util.ajaxProgress === null) {
|
||||
return;
|
||||
}
|
||||
Duplicator.Util.ajaxProgress
|
||||
.stop(true, true)
|
||||
.delay(500)
|
||||
.animate({
|
||||
opacity: 0
|
||||
}, 300, function () {
|
||||
jQuery(this).css({
|
||||
'display': 'none'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Duplicator.Util.ajaxWrapper = function (ajaxData, callbackSuccess, callbackFail) {
|
||||
jQuery.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
dataType: "json",
|
||||
data: ajaxData,
|
||||
beforeSend: function( xhr ) {
|
||||
Duplicator.Util.ajaxProgressShow();
|
||||
},
|
||||
success: function (result, textStatus, jqXHR) {
|
||||
var message = '';
|
||||
if (result.success) {
|
||||
if (typeof callbackSuccess === "function") {
|
||||
try {
|
||||
message = callbackSuccess(result, result.data, result.data.funcData, textStatus, jqXHR);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
DupPro.addAdminMessage(error.message, 'error');
|
||||
message = '';
|
||||
}
|
||||
} else {
|
||||
message = '<?php echo esc_js(__('RESPONSE SUCCESS', 'duplicator-pro')); ?>';
|
||||
}
|
||||
if (message != null && String(message).length) {
|
||||
DupPro.addAdminMessage(message, 'notice');
|
||||
}
|
||||
} else {
|
||||
if (typeof callbackFail === "function") {
|
||||
try {
|
||||
message = callbackFail(result, result.data, result.data.funcData, textStatus, jqXHR);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
message = error.message;
|
||||
}
|
||||
} else {
|
||||
message = '<?php echo esc_js(__('RESPONSE ERROR!', 'duplicator-pro')); ?>' + '<br><br>' + result.data.message;
|
||||
}
|
||||
if (message != null && String(message).length) {
|
||||
DupPro.addAdminMessage(message, 'error');
|
||||
}
|
||||
}
|
||||
},
|
||||
error: function (result) {
|
||||
DupPro.addAdminMessage(
|
||||
<?php echo wp_json_encode(__('AJAX ERROR! <br> Ajax request error', 'duplicator-pro')); ?>,
|
||||
'error'
|
||||
);
|
||||
},
|
||||
complete: function () {
|
||||
Duplicator.Util.ajaxProgressHide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get human size from bytes number.
|
||||
* Is size is -1 return unknown
|
||||
*
|
||||
* @param {size} int bytes size
|
||||
*/
|
||||
Duplicator.Util.humanFileSize = function(size) {
|
||||
if (size < 0) {
|
||||
return "unknown";
|
||||
}
|
||||
else if (size == 0) {
|
||||
return "0";
|
||||
} else {
|
||||
var i = Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
};
|
||||
|
||||
Duplicator.Util.isEmpty = function (val) {
|
||||
return (val === undefined || val == null || val.length <= 0) ? true : false;
|
||||
};
|
||||
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user