first commit

This commit is contained in:
Roman Pyrih
2026-04-21 15:48:41 +02:00
commit 7483681901
10216 changed files with 3236626 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
<?php
/**
* Duplicator messages sections
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
use Duplicator\Controllers\SchedulePageController;
use Duplicator\Core\Controllers\ControllersManager;
use Duplicator\Models\ScheduleEntity;
use Duplicator\Models\Storages\AbstractStorageEntity;
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
* @var array<string, mixed> $tplData
* @var AbstractStorageEntity $storage
*/
$blur = $tplData['blur'];
$schedule = $tplData['schedule'];
$copyScheduleList = ScheduleEntity::getAll(
0,
0,
null,
fn(ScheduleEntity $s): bool => $s->getId() != $schedule->getId()
);
$schedulesListURL = ControllersManager::getMenuLink(
ControllersManager::SCHEDULES_SUBMENU_SLUG
);
$scheduleCopyBaseURL = SchedulePageController::getInstance()->getCopyActionUrl($schedule->getId());
$countList = count($copyScheduleList);
?>
<div class="dup-toolbar <?php echo ($blur ? 'dup-mock-blur' : ''); ?>">
<label for="dup-copy-source-id-select" class="screen-reader-text">Copy storage action</label>
<select
id="dup-schedule-copy-select"
name="dupli-source-schedule-id"
class="small"
<?php disabled($countList, 0); ?>>
<option value="-1" selected="selected" disabled="true">
<?php esc_html_e('Copy From', 'duplicator-pro'); ?>
</option>
<?php foreach ($copyScheduleList as $copy_schedule) { ?>
<option value="<?php echo (int) $copy_schedule->getId(); ?>">
<?php echo esc_html($copy_schedule->name); ?>
</option>
<?php } ?>
</select>
<input
id="dup-schedule-copy-btn"
type="button"
class="button hollow secondary small action"
value="<?php esc_html_e("Apply", 'duplicator-pro') ?>"
disabled>
<span class="separator"></span>
<a
href="<?php echo esc_url($schedulesListURL); ?>"
class="button hollow secondary small "
title="<?php esc_attr_e('Back to Schedules list.', 'duplicator-pro'); ?>">
<i class="far fa-clock fa-sm"></i> <?php esc_html_e('Schedules', 'duplicator-pro'); ?>
</a>
</div>
<script>
jQuery(document).ready(function($) {
$('#dup-schedule-copy-select').on('change', function(e) {
let copyId = parseInt($(this).val());
$('#dup-schedule-copy-btn').prop('disabled', (copyId <= 0));
});
/*$('#dup-schedule-copy-select').change(function (evente) {
event.preventDefault();
alert('changed val ' + $(this).val());
$('#dup-schedule-copy-btn').prop('disabled', ($(this).val() > 0));
});*/
$('#dup-schedule-copy-btn').click(function(event) {
event.preventDefault();
let copyId = $('#dup-schedule-copy-select').val();
document.location.href = <?php echo json_encode($scheduleCopyBaseURL); ?> + '&dupli-source-schedule-id=' + copyId;
});
});
</script>
<hr class="dup-toolbar-divider" />

View File

@@ -0,0 +1,38 @@
<?php
/**
* Duplicator Daily repeat template
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$runEvery = $tplMng->getDataValueIntRequired('run_every');
$frequency_note = $tplMng->getDataValueString('frequency_note', '');
?>
<label class="lbl-larger">
<?php esc_html_e('Every', 'duplicator-pro'); ?>
</label>
<div>
<select name="_run_every_days" class="width-tiny inline-block margin-0" data-parsley-ui-enabled="false">
<?php for ($i = 1; $i < 30; $i++) { ?>
<option <?php selected($i, $runEvery); ?> value="<?php echo (int) $i; ?>">
<?php echo (int) $i; ?>
</option>
<?php } ?>
</select>
<?php esc_html_e('days', 'duplicator-pro'); ?>
<i
class="fa-solid fa-question-circle fa-sm dark-gray-color"
data-tooltip-title="<?php esc_attr_e("Frequency Note", 'duplicator-pro'); ?>"
data-tooltip="<?php echo esc_attr($frequency_note) ?>">
</i>
</div>

View File

@@ -0,0 +1,49 @@
<?php
/**
* Duplicator Hourly repeat template
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$runEvery = $tplMng->getDataValueIntRequired('run_every');
$frequency_note = $tplMng->getDataValueString('frequency_note', '');
$hour_intervals = [
1,
2,
4,
6,
12,
];
$tipContent = __('Backup will build every x hours starting at 00:00.', 'duplicator-pro') . '<br/><br/>' . $frequency_note;
?>
<label class="lbl-larger">
<?php esc_html_e('Every', 'duplicator-pro'); ?>
</label>
<div>
<select name="_run_every_hours" class="width-tiny inline-block margin-0" data-parsley-ui-enabled="false">
<?php foreach ($hour_intervals as $hour_interval) { ?>
<option <?php selected($hour_interval, $runEvery); ?> value="<?php echo (int) $hour_interval; ?>">
<?php echo (int) $hour_interval; ?>
</option>
<?php } ?>
</select>
<?php
esc_html_e('hours', 'duplicator-pro');
?>
<i
class="fa-solid fa-question-circle fa-sm dark-gray-color"
data-tooltip-title="<?php esc_attr_e("Frequency Note", 'duplicator-pro'); ?>"
data-tooltip="<?php echo esc_attr($tipContent); ?>">
</i>
</div>

View File

@@ -0,0 +1,42 @@
<?php
/**
* Duplicator Monthly repeat template
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$runEvery = $tplMng->getDataValueIntRequired('run_every');
$dayOfMonth = $tplMng->getDataValueIntRequired('day_of_month');
?>
<label class="lbl-larger">
<?php esc_html_e('Day', 'duplicator-pro'); ?>
</label>
<div>
<select name="day_of_month" class="width-tiny inline-block margin-0">
<?php for ($i = 1; $i <= 31; $i++) { ?>
<option <?php selected($i, $dayOfMonth); ?> value="<?php echo (int) $i; ?>">
<?php echo (int) $i; ?>
</option>
<?php } ?>
</select>&nbsp;
<?php esc_html_e('of every', 'duplicator-pro'); ?>&nbsp;
<select name="_run_every_months" data-parsley-ui-enabled="false" class="width-tiny inline-block margin-0">
<?php for ($i = 1; $i <= 12; $i++) { ?>
<option <?php selected($i, $runEvery); ?> value="<?php echo (int) $i; ?>">
<?php echo (int) $i; ?>
</option>
<?php } ?>
</select>&nbsp;
<?php esc_html_e('month(s)', 'duplicator-pro'); ?>
</div>

View File

@@ -0,0 +1,86 @@
<?php
/**
* Duplicator Weekly repeat template
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$weekdays = $tplMng->getDataValueArrayRequired('weekdays');
?>
<label class="lbl-larger">
<?php esc_html_e('Every', 'duplicator-pro'); ?>
</label>
<div>
<!-- RSR Cron does not support counting by week - just days and months so removing (for now?)-->
<div class="weekday-div">
<input
<?php checked($weekdays['mon']); ?>
value="mon" name="weekday[]"
type="checkbox"
id="repeat-weekly-mon"
data-parsley-group="weekly" required data-parsley-class-handler="#repeat-weekly-area"
data-parsley-error-message="<?php esc_attr_e('At least one day must be checked.', 'duplicator-pro'); ?>"
data-parsley-no-focus data-parsley-errors-container="#weekday-errors">
<label for="repeat-weekly-mon"><?php esc_html_e('Monday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div">
<input
<?php checked($weekdays['tue']); ?>
value="tue" name="weekday[]"
type="checkbox"
id="repeat-weekly-tue">
<label for="repeat-weekly-tue"><?php esc_html_e('Tuesday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div">
<input
<?php checked($weekdays['wed']); ?>
value="wed" name="weekday[]"
type="checkbox"
id="repeat-weekly-wed">
<label for="repeat-weekly-wed"><?php esc_html_e('Wednesday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div">
<input
<?php checked($weekdays['thu']); ?>
value="thu" name="weekday[]"
type="checkbox"
id="repeat-weekly-thu">
<label for="repeat-weekly-thu"><?php esc_html_e('Thursday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div" style="clear:both">
<input
<?php checked($weekdays['fri']); ?>
value="fri" name="weekday[]"
type="checkbox"
id="repeat-weekly-fri">
<label for="repeat-weekly-fri"><?php esc_html_e('Friday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div">
<input
<?php checked($weekdays['sat']); ?>
value="sat" name="weekday[]"
type="checkbox"
id="repeat-weekly-sat">
<label for="repeat-weekly-sat"><?php esc_html_e('Saturday', 'duplicator-pro'); ?></label>
</div>
<div class="weekday-div">
<input
<?php checked($weekdays['sun']); ?>
value="sun" name="weekday[]"
type="checkbox"
id="repeat-weekly-sun">
<label for="repeat-weekly-sun"><?php esc_html_e('Sunday', 'duplicator-pro'); ?></label>
</div>
<div style="padding-top:3px; clear:both;" id="weekday-errors"></div>
</div>

View File

@@ -0,0 +1,148 @@
<?php
/**
* Duplicator messages sections
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
use Duplicator\Addons\ProBase\License\License;
use Duplicator\Models\ScheduleEntity;
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$repeatType = $tplMng->getDataValueIntRequired('repeat_type');
$min_frequency = 0;
$max_frequency = (
License::can(License::CAPABILITY_SHEDULE_HOURLY) ?
ScheduleEntity::REPEAT_HOURLY :
ScheduleEntity::REPEAT_MONTHLY
);
$frequencyUpgradMsg = sprintf(
__(
'Hourly frequency isn\'t available at the <b>%1$s</b> license level.',
'duplicator-pro'
),
License::getLicenseToString()
) .
' <b>' .
sprintf(
_x(
'To enable this option %1$supgrade%2$s the License.',
'%1$s and %2$s represents the opening and closing HTML tags for an anchor or link',
'duplicator-pro'
),
'<a href="' . esc_url(License::getUpsellURL()) . '" target="_blank">',
'</a>'
) .
'</b>';
$frequency_note = __(
'If you have a large site, it\'s recommended you schedule backups during lower traffic periods.
If you\'re on a shared host then be aware that running multiple schedules too close together
(i.e. every 10 minutes) may alert your host to a spike in system resource usage.
Be sure that your schedules do not overlap and give them plenty of time to run.',
'duplicator-pro'
);
?>
<div class="dup-settings-wrapper margin-bottom-1">
<label class="lbl-larger"><?php esc_html_e("Repeats", 'duplicator-pro'); ?></label>
<div class="margin-bottom-1">
<select
id="change-mode"
name="repeat_type"
class="width-small margin-0"
onchange="DupliJs.Schedule.ChangeMode()"
data-parsley-range='<?php printf('[%1$s, %2$s]', (int) $min_frequency, (int) $max_frequency); ?>'
data-parsley-error-message="<?php echo esc_attr($frequencyUpgradMsg); ?>">
<option
value="<?php echo (int) ScheduleEntity::REPEAT_HOURLY; ?>"
<?php selected($repeatType, ScheduleEntity::REPEAT_HOURLY) ?>>
<?php esc_html_e("Hourly", 'duplicator-pro'); ?>
</option>
<option
value="<?php echo (int) ScheduleEntity::REPEAT_DAILY; ?>"
<?php selected($repeatType, ScheduleEntity::REPEAT_DAILY) ?>>
<?php esc_html_e("Daily", 'duplicator-pro'); ?>
</option>
<option
value="<?php echo (int) ScheduleEntity::REPEAT_WEEKLY; ?>"
<?php selected($repeatType, ScheduleEntity::REPEAT_WEEKLY) ?>>
<?php esc_html_e("Weekly", 'duplicator-pro'); ?>
</option>
<option
value="<?php echo (int) ScheduleEntity::REPEAT_MONTHLY; ?>"
<?php selected($repeatType, ScheduleEntity::REPEAT_MONTHLY) ?>>
<?php esc_html_e("Monthly", 'duplicator-pro'); ?>
</option>
</select>
</div>
<!-- Repeat Options -->
<div id="repeat-hourly-area" class="repeater-area margin-bottom-1">
<?php $tplMng->render('admin_pages/schedules/parts/repeat_hourly', ['frequency_note' => $frequency_note]); ?>
</div>
<div id="repeat-daily-area" class="repeater-area margin-bottom-1">
<?php $tplMng->render('admin_pages/schedules/parts/repeat_daily', ['frequency_note' => $frequency_note]); ?>
</div>
<div id="repeat-weekly-area" class="repeater-area margin-bottom-1">
<?php $tplMng->render('admin_pages/schedules/parts/repeat_weekly'); ?>
</div>
<div id="repeat-monthly-area" class="repeater-area margin-bottom-1">
<?php $tplMng->render('admin_pages/schedules/parts/repeat_monthly'); ?>
</div>
<!-- Start Time -->
<?php $tplMng->render('admin_pages/schedules/parts/start_time'); ?>
</div>
<script>
jQuery(document).ready(function($) {
DupliJs.Schedule.ChangeMode = function() {
var mode = $("#change-mode option:selected").val();
var animate = 400;
$('#repeat-hourly-area, #repeat-daily-area, #repeat-weekly-area, #repeat-monthly-area').hide();
n = $("#repeat-weekly-area input:checked").length;
if (n == 0) {
// Hack so parsely will ignore weekly if it isnt selected
$('#repeat-weekly-mon').prop("checked", true);
}
switch (mode) {
case "0":
$('#repeat-daily-area').show(animate);
$('#start-time-label, #start-time-content').show(animate);
break;
case "1":
$('#repeat-weekly-area').show(animate);
$('#start-time-label, #start-time-content').show(animate);
break;
case "2":
$('#repeat-monthly-area').show(animate);
$('#start-time-label, #start-time-content').show(animate);
break;
case "3":
$('#repeat-hourly-area').show(animate);
$('#start-time-label, #start-time-content').hide(animate);
break;
}
}
DupliJs.Schedule.ChangeMode();
});
</script>

View File

@@ -0,0 +1,60 @@
<?php
/**
* Duplicator Start Time template
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
*/
$start_hour = $tplMng->getDataValueIntRequired('start_hour');
$start_minute = $tplMng->getDataValueIntRequired('start_minute');
$mins = 0;
?>
<label class="lbl-larger" id="start-time-label">
<?php esc_html_e('Start Time', 'duplicator-pro'); ?>
</label>
<div class="margin-bottom-1" id="start-time-content">
<select name="_start_time" class="width-small inline-display margin-0">
<?php
// Add setting to use 24 hour vs AM/PM the interval for hours is '1'
for ($hours = 0; $hours < 24; $hours++) {
?>
<option <?php selected($hours, $start_hour); ?> value="<?php echo (int) $hours; ?>">
<?php echo esc_html(sprintf('%02d:%02d', $hours, $mins)); ?>
</option>
<?php } ?>
</select>
<i class="dupli-edit-info">
<?php esc_html_e("Current Server Time Stamp is", 'duplicator-pro'); ?>&nbsp;
<?php echo esc_html(date_i18n('Y-m-d H:i:s')); ?>
</i>
</div>
<div class="margin-bottom-1">
<p class="description width-xlarge">
<?php
printf(
esc_html_x(
'%1$sNote:%2$s Schedules require web site traffic in order to start a build.
If you set a start time of 06:00 daily but do not get any traffic till 10:00 then the build will not start until 10:00.
If you have low traffic consider setting up a cron job to periodically hit your site.',
'%1$s and %2$s represent opening and closing bold tags',
'duplicator-pro'
),
'<b>',
'</b>'
);
?>
</p>
</div>

View File

@@ -0,0 +1,45 @@
<?php
/**
* Duplicator Backup row in table Backups list
*
* @package Duplicator
* @copyright (c) 2022, Snap Creek LLC
*/
use Duplicator\Controllers\SchedulePageController;
use Duplicator\Core\CapMng;
defined("ABSPATH") or die("");
/**
* Variables
*
* @var \Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var \Duplicator\Core\Views\TplMng $tplMng
* @var array<string, mixed> $tplData
* @var bool $blur
*/
$blur = $tplData['blur'];
if (CapMng::can(CapMng::CAP_SCHEDULE, false) && !$blur) {
$scheduleEditBaseURL = SchedulePageController::getInstance()->getEditBaseUrl();
$tipContent = __(
'Create a new Scheduled Backup.',
'duplicator-pro'
);
?>
<span
class="dup-new-package-wrapper"
data-tooltip="<?php echo esc_attr($tipContent); ?>"
>
<a
href="<?php echo esc_url($scheduleEditBaseURL); ?>"
id="dupli-create-new"
class="button primary tiny font-bold margin-bottom-0"
>
<?php esc_html_e('Add New', 'duplicator-pro'); ?>
</a>
</span>
<?php
}

View File

@@ -0,0 +1,240 @@
<?php
/**
* @package Duplicator
*/
defined("ABSPATH") or die("");
use Duplicator\Controllers\SchedulePageController;
use Duplicator\Controllers\ToolsPageController;
use Duplicator\Core\Controllers\ControllersManager;
use Duplicator\Models\ScheduleEntity;
use Duplicator\Models\TemplateEntity;
/**
* Variables
*
* @var Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var Duplicator\Core\Views\TplMng $tplMng
*/
$blur = $tplMng->getDataValueBool('blur');
$schedule = $tplMng->getDataValueObjRequired('schedule', ScheduleEntity::class);
$templatesPageUrl = ToolsPageController::getInstance()->getMenuLink(ToolsPageController::L2_SLUG_TEMPLATE);
$editTemplateUrl = ControllersManager::getMenuLink(
ControllersManager::TOOLS_SUBMENU_SLUG,
ToolsPageController::L2_SLUG_TEMPLATE,
null,
[ControllersManager::QUERY_STRING_INNER_PAGE => 'edit']
);
?>
<form
id="dup-schedule-form"
class="dup-monitored-form <?php echo ($blur ? 'dup-mock-blur' : ''); ?>"
action="<?php echo esc_url(ControllersManager::getCurrentLink()); ?>"
method="post"
data-parsley-ui-enabled="true">
<?php $tplMng->render('admin_pages/schedules/parts/edit_toolbar'); ?>
<?php $tplMng->getAction(SchedulePageController::ACTION_EDIT_SAVE)->getActionNonceFileds(); ?>
<input type="hidden" name="schedule_id" value="<?php echo (int) $schedule->getId(); ?>">
<!-- ===============================
SETTINGS -->
<table class="form-table">
<tr valign="top">
<th scope="row"><label><?php esc_html_e('Schedule Name', 'duplicator-pro'); ?></label></th>
<td>
<input
type="text"
id="schedule-name"
class="width-medium"
name="name"
value="<?php echo esc_attr($schedule->name); ?>"
required data-parsley-group="standard"
autocomplete="off">
</td>
</tr>
<tr valign="top">
<th scope="row">
<label><?php esc_html_e('Backup Template', 'duplicator-pro'); ?></label>
</th>
<td>
<div class="schedule-template display-flex">
<div>
<select id="schedule-template-selector" name="template_id" class="width-medium margin-bottom-0" required>
<?php
$templates = TemplateEntity::getAllWithoutManualMode();
if (count($templates) == 0) {
$no_templates = __('No Templates Found', 'duplicator-pro');
printf('<option value="">%1$s</option>', esc_html($no_templates));
} else {
echo "<option value='' selected='true'>" . esc_html__("&lt;Choose A Template&gt;", 'duplicator-pro') . "</option>";
foreach ($templates as $template) {
?>
<option
<?php selected($schedule->template_id, $template->getId()); ?>
value="<?php echo (int) $template->getId(); ?>">
<?php echo esc_html($template->name); ?>
</option>
<?php
}
}
?>
</select>
<div class="margin-bottom-1">
<small>
<a href="<?php echo esc_url($templatesPageUrl); ?>" target="edit-template">
[<?php esc_attr_e("Show All Templates", 'duplicator-pro') ?>]
</a>
</small>
</div>
</div>
<div>
<a
id="schedule-template-edit-btn"
href="javascript:void(0)"
onclick="DupliJs.Schedule.EditTemplate()"
style="display:none"
class="pack-temp-btns button hollow secondary small margin-bottom-0"
title="<?php esc_attr_e("Edit Selected Template", 'duplicator-pro') ?>">
<i class="far fa-edit"></i>
</a>
<a
id="schedule-template-add-btn"
href="<?php echo esc_url($editTemplateUrl); ?>"
class="pack-temp-btns button hollow secondary small margin-bottom-0"
title="<?php esc_attr_e("Add New Template", 'duplicator-pro') ?>"
target="edit-template">
<i class="far fa-plus-square"></i>
</a>
<a
id="schedule-template-sync-btn"
href="javascript:window.location.reload()"
class="pack-temp-btns button hollow secondary small margin-bottom-0"
title="<?php esc_attr_e("Refresh Template List", 'duplicator-pro') ?>">
<i class="fas fa-sync-alt"></i>
</a>
&nbsp;
<i
class="fa-solid fa-question-circle fa-sm dark-gray-color"
data-tooltip-title="<?php esc_attr_e("Template Details", 'duplicator-pro'); ?>"
data-tooltip="<?php
esc_attr_e(
'The template specifies which files and database tables should be included in the archive.<br/><br/>
Choose from an existing template or create a new one by clicking the "Add New Template" button.
To edit a template, select it and then click the "Edit Selected Template" button.',
'duplicator-pro'
);
?>">
</i>
</div>
</div>
</td>
</tr>
<tr>
<th scope="row"><label><?php esc_html_e('Storage', 'duplicator-pro'); ?></label></th>
<td>
<!-- ===============================
STORAGE -->
<?php $tplMng->render(
'parts/storage/select_list',
[
'selectedStorageIds' => $schedule->storage_ids,
'showAddNew' => false,
'recoveryPointMsg' => true,
]
); ?>
</td>
</tr>
<tr valign="top">
<td colspan="2">
<?php
$tplMng->render(
'admin_pages/schedules/parts/repeats_options',
[
'repeat_type' => $schedule->repeat_type,
'run_every' => $schedule->run_every,
'day_of_month' => $schedule->day_of_month,
'weekdays' => [
'mon' => $schedule->isDaySet('mon'),
'tue' => $schedule->isDaySet('tue'),
'wed' => $schedule->isDaySet('wed'),
'thu' => $schedule->isDaySet('thu'),
'fri' => $schedule->isDaySet('fri'),
'sat' => $schedule->isDaySet('sat'),
'sun' => $schedule->isDaySet('sun'),
],
'start_hour' => $schedule->getStartTimePiece(0),
'start_minute' => $schedule->getStartTimePiece(1),
]
);
?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label><?php esc_html_e('Recovery Status', 'duplicator-pro'); ?></label></th>
<td class="dup-recovery-template">
<div class="margin-bottom-1">
<?php
if (($template = $schedule->getTemplate()) !== false) {
$schedule->recoveableHtmlInfo();
} else {
esc_html_e('Unavailable', 'duplicator-pro');
?>
<i class="fa-solid fa-question-circle fa-sm dark-gray-color"
data-tooltip-title="<?php esc_attr_e("Recovery Status", 'duplicator-pro'); ?>"
data-tooltip="<?php esc_attr_e('Status is unavailable. Please save the schedule to view recovery status', 'duplicator-pro');
?>"></i>
<?php } ?>
</div>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="schedule-active"><?php esc_html_e('Activated', 'duplicator-pro'); ?></label></th>
<td>
<input name="_active" id="schedule-active" type="checkbox" <?php checked($schedule->isActive()); ?> class="margin-0">
<label for="schedule-active"><?php esc_html_e('Enable This Schedule', 'duplicator-pro'); ?></label><br />
<i class="dupli-edit-info"> <?php esc_html_e('When checked this schedule will run', 'duplicator-pro'); ?></i>
</td>
</tr>
</table><br />
<button
id="dupli-save-schedule"
class="button primary small"
type="submit">
<?php esc_html_e('Save Schedule', 'duplicator-pro'); ?>
</button>
</form>
<script>
jQuery(document).ready(function($) {
DupliJs.Schedule.EditTemplate = function() {
var templateID = $('#schedule-template-selector').val();
var url = <?php echo wp_json_encode($editTemplateUrl); ?> + '&package_template_id=' + templateID;
window.open(url, 'edit-template');
};
DupliJs.Schedule.ToggleTemplateEditBtn = function() {
$('#schedule-template-edit-btn, #schedule-template-add-btn, #schedule-template-sync-btn').hide();
if ($("#schedule-template-selector").val() > 0) {
$('#schedule-template-edit-btn').show();
} else {
$('#schedule-template-add-btn, #schedule-template-sync-btn').show();
}
}
$('#dup-schedule-form').parsley({
excluded: ':disabled'
});
jQuery('#schedule-name').focus().select();
DupliJs.Schedule.ToggleTemplateEditBtn();
$("#schedule-template-selector").change(function() {
DupliJs.Schedule.ToggleTemplateEditBtn()
});
});
</script>

View File

@@ -0,0 +1,619 @@
<?php
/**
* @package Duplicator
*/
defined("ABSPATH") or die("");
use Duplicator\Ajax\ServicesSchedule;
use Duplicator\Controllers\PackagesPageController;
use Duplicator\Controllers\SchedulePageController;
use Duplicator\Controllers\SettingsPageController;
use Duplicator\Controllers\ToolsPageController;
use Duplicator\Core\CapMng;
use Duplicator\Core\Controllers\ControllersManager;
use Duplicator\Models\ScheduleEntity;
use Duplicator\Models\Storages\AbstractStorageEntity;
use Duplicator\Models\TemplateEntity;
use Duplicator\Package\DupPackage;
use Duplicator\Views\UI\UiDialog;
/**
* Variables
*
* @var Duplicator\Core\Controllers\ControllersManager $ctrlMng
* @var Duplicator\Core\Views\TplMng $tplMng
* @var array<string, mixed> $tplData
* @var bool $blur
*/
$blur = $tplData['blur'];
$active_schedules = ScheduleEntity::getActive();
$active_count = count($active_schedules);
$schedules = ScheduleEntity::getAll();
$schedule_count = ScheduleEntity::count();
$active_package = DupPackage::getNextActive();
$active_schedule_id = -1;
if ($active_package != null) {
$active_schedule_id = $active_package->getScheduleId();
}
$packagesPageUrl = PackagesPageController::getInstance()->getMenuLink();
$scheduleEditBaseURL = SchedulePageController::getInstance()->getEditBaseUrl();
$scheduleCopyBaseURL = SchedulePageController::getInstance()->getCopyActionUrl();
$settingsScheudleUrl = ControllersManager::getMenuLink(
ControllersManager::SETTINGS_SUBMENU_SLUG,
SettingsPageController::L2_SLUG_SCHEDULE
);
$templatesPageUrl = ToolsPageController::getInstance()->getMenuLink(ToolsPageController::L2_SLUG_TEMPLATE);
$tooltopCreatedContent = __(
'Backup date and time expressed in UTC (Coordinated Universal Time).
The displayed date corresponds to the server\'s international time, independent of local time zones.',
'duplicator-pro'
);
?>
<div class="dup-toolbar <?php echo ($blur ? 'dup-mock-blur' : ''); ?>">
<label for="bulk_action" class="screen-reader-text">Select bulk action</label>
<select id="bulk_action" class="small">
<option value="-1" selected="selected">
<?php esc_html_e("Bulk Actions", 'duplicator-pro'); ?>
</option>
<option value="<?php echo (int) ServicesSchedule::SCHEDULE_BULK_ACTIVATE; ?>" title="Activate selected schedules(s)">
<?php esc_html_e("Activate", 'duplicator-pro'); ?>
</option>
<option value="<?php echo (int) ServicesSchedule::SCHEDULE_BULK_DEACTIVATE; ?>" title="Deactivate selected schedules(s)">
<?php esc_html_e("Deactivate", 'duplicator-pro'); ?>
</option>
<option value="<?php echo (int) ServicesSchedule::SCHEDULE_BULK_DELETE; ?>" title="Delete selected schedules(s)">
<?php esc_html_e("Delete", 'duplicator-pro'); ?>
</option>
</select>
<input
type="button"
id="dup-schedule-bulk-apply"
class="button hollow secondary small action"
value="<?php esc_attr_e("Apply", 'duplicator-pro') ?>"
onclick="DupliJs.Schedule.BulkAction()">
<span class="separator"></span>
<?php if (CapMng::can(CapMng::CAP_SETTINGS, false)) { ?>
<a
href="<?php echo esc_url($settingsScheudleUrl); ?>"
class="button hollow secondary small dup-schedule-settings"
title="<?php esc_attr_e("Settings", 'duplicator-pro') ?>">
<i class="fas fa-sliders-h fa-fw"></i>
</a>
<?php } ?>
<a
href="<?php echo esc_url($templatesPageUrl); ?>"
id="btn-logs-dialog"
class="button hollow secondary small dup-schedule-templates"
title="<?php esc_attr_e("Templates", 'duplicator-pro') ?>">
<i class="far fa-clone"></i>
</a>
</div>
<form
id="dup-schedule-form"
class="<?php echo ($blur ? 'dup-mock-blur' : ''); ?>"
action="<?php echo esc_url(ControllersManager::getCurrentLink()); ?>"
method="post">
<input type="hidden" id="dup-schedule-form-action" name="action" value="" />
<input type="hidden" id="dup-schedule-selected-schedule" name="schedule_id" value="-1" />
<!-- ====================
LIST ALL SCHEDULES -->
<table class="widefat storage-tbl dup-table-list valign-top schedule-tbl">
<thead>
<tr>
<th style='width:10px;'><input type="checkbox" id="dupli-chk-all" title="Select all Backups" onclick="DupliJs.Schedule.SetDeleteAll(this)"></th>
<th style='width:275px;'><?php esc_html_e('Name', 'duplicator-pro'); ?></th>
<th><?php esc_html_e('Storage', 'duplicator-pro'); ?></th>
<th>
<?php esc_html_e('Runs Next', 'duplicator-pro'); ?>&nbsp;
<i
class="fa-solid fa-circle-info"
data-tooltip-title="<?php esc_attr_e('Runs Next Date/Time', 'duplicator-pro'); ?>"
data-tooltip="<?php echo esc_attr($tooltopCreatedContent); ?>"></i>
</th>
<th>
<?php esc_html_e('Last Ran', 'duplicator-pro'); ?>&nbsp;
<i
class="fa-solid fa-circle-info"
data-tooltip-title="<?php esc_attr_e('Last Ran Date/Time', 'duplicator-pro'); ?>"
data-tooltip="<?php echo esc_attr($tooltopCreatedContent); ?>"></i>
</th>
<th><?php esc_html_e('Active', 'duplicator-pro'); ?></th>
<th class="dup-col-recovery"><?php esc_html_e('Recovery', 'duplicator-pro'); ?></th>
</tr>
</thead>
<tbody>
<?php if ($schedule_count <= 0) : ?>
<tr>
<td colspan="7" class="dup-schedules-no-schedule">
<div class="margin-top-1 margin-bottom-1">
<h3 class="margin-bottom-0">
<b><i class="far fa-clock fa-sm"></i> <?php esc_html_e('No Schedules Found', 'duplicator-pro') ?></b>
</h3>
<a href="<?php echo esc_url($scheduleEditBaseURL); ?>">
[<?php esc_html_e('Add New Schedule', 'duplicator-pro') ?>]
</a>
</div>
</td>
</tr>
<?php endif; ?>
<?php
$i = 0;
foreach ($schedules as $schedule) :
$i++;
$icon_display = (($schedule->getId() == $active_schedule_id) ? 'inline' : 'none');
?>
<tr class="schedule-row <?php echo ($i % 2) ? 'alternate' : ''; ?>">
<td>
<input name="selected_id[]" type="checkbox" value="<?php echo (int) $schedule->getId() ?>" class="item-chk" />
</td>
<td>
<i
id="<?php echo "icon-{" . (int) $schedule->getId() . "}-status"; ?>"
class="fas fa-cog fa-spin schedule-status-icon"
style="display:<?php echo esc_attr($icon_display); ?>; margin-right:4px;"
data-tooltip="<?php esc_attr_e('This scheduled backup is currently in progress', 'duplicator-pro'); ?>">
</i>
<a
id="<?php echo "text-{" . (int) $schedule->getId() . "}"; ?>"
href="javascript:void(0);"
onclick="DupliJs.Schedule.Edit('<?php echo (int) $schedule->getId() ?>');"
class="name">
<?php echo esc_html($schedule->name); ?>
</a>
<div class="sub-menu">
<span class="link-style dup-schedule-quick-view" onclick="DupliJs.Schedule.QuickView('<?php echo (int) $schedule->getId() ?>');">
<?php esc_html_e('Quick View', 'duplicator-pro'); ?>
</span> |
<span class="link-style dup-schedule-edit" onclick="DupliJs.Schedule.Edit('<?php echo (int) $schedule->getId() ?>');">
<?php esc_html_e('Edit', 'duplicator-pro'); ?>
</span> |
<span class="link-style dup-schedule-copy" onclick="DupliJs.Schedule.Copy('<?php echo (int) $schedule->getId(); ?>');">
<?php esc_html_e('Copy', 'duplicator-pro'); ?>
</span> |
<span class="link-style dup-schedule-delete" onclick="DupliJs.Schedule.Delete('<?php echo (int) $schedule->getId(); ?>');">
<?php esc_html_e('Delete', 'duplicator-pro'); ?>
</span>
<?php if (CapMng::can(CapMng::CAP_CREATE, false)) : ?>
| <span class="link-style dup-schedule-run-now" onclick="DupliJs.Schedule.RunNow('<?php echo (int) $schedule->getId(); ?>');">
<?php esc_html_e('Run Now', 'duplicator-pro'); ?>
</span>
<?php endif; ?>
</div>
</td>
<td>
<?php
if (count($schedule->storage_ids) > 0 && strlen(implode('', $schedule->storage_ids)) != 0) {
foreach ($schedule->storage_ids as $storage_id) {
if (($storage = AbstractStorageEntity::getById($storage_id)) === false) {
continue;
}
// Check storage validity
$isValid = $storage->isValid();
$isSupported = $storage::isSupported();
if (!$isSupported) {
echo '<span style="opacity: 0.5;" data-tooltip="' . esc_attr($storage::getNotSupportedNotice()) . '">';
echo esc_html($storage->getName());
echo '</span><br/>';
} elseif (!$isValid) {
$tooltipMsg = __('This storage has invalid configuration and cannot be used.', 'duplicator-pro');
echo '<span style="opacity: 0.5;" data-tooltip="' . esc_attr($tooltipMsg) . '">';
echo esc_html($storage->getName());
echo '</span><br/>';
} else {
// Valid storage - display normally
echo esc_html($storage->getName()) . '<br/>';
}
}
} else {
$txt_DeleteStorage = __('No Storage', 'duplicator-pro');
echo "<a href='javascript:void(0)' onclick='DupliJs.Schedule.showDeleteStorageMessage()'>"
. "<i class='fa fa-info-circle fa-fw fa-sm'></i>"
. "<u>" . esc_html($txt_DeleteStorage) . "</u></a>";
}
?>
</td>
<td>
<?php echo esc_html($schedule->getNextRunTimeString()); ?>
</td>
<td id="schedule-<?php echo (int) $schedule->getId() ?>-last-ran-string">
<?php echo esc_html($schedule->getLastRanString()); ?>
</td>
<td>
<b>
<?php if ($schedule->isActive()) { ?>
<span class="green"><?php esc_html_e('Yes', 'duplicator-pro'); ?></span>
<?php } else { ?>
<span class="maroon"><?php esc_html_e('No', 'duplicator-pro'); ?></span>
<?php } ?>
</b>
</td>
<td class="dup-col-recovery">
<?php $schedule->recoveableHtmlInfo(true); ?>
</td>
</tr>
<tr id='detail-<?php echo (int) $schedule->getId() ?>' class='<?php echo ($i % 2) ? 'alternate' : ''; ?> schedule-detail'>
<td colspan="7">
<?php
$template = TemplateEntity::getById($schedule->template_id);
?>
<ul class="no-bullet">
<li>
<b><?php esc_html_e('Backup Template:', 'duplicator-pro'); ?></b>
<?php echo esc_html($template->name); ?>
</li>
<li>
<b><?php esc_html_e('Summary:', 'duplicator-pro'); ?></b>
<?php echo sprintf(esc_html__('Runs %1$s', 'duplicator-pro'), esc_html($schedule->getRepeatText())); ?>
</li>
<li>
<b><?php esc_html_e('Last Ran:', 'duplicator-pro') ?></b>
<?php echo esc_html($schedule->getLastRanString()); ?>
</li>
<li>
<b><?php esc_html_e('Times Run:', 'duplicator-pro') ?></b>
<?php echo (int) $schedule->times_run; ?>
</li>
</ul>
</td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<th colspan="7" style="text-align:right; white-space: nowrap; font-size:12px">
<?php
printf(
esc_html_x(
'Total: %1$s | Active: %2$s | Time: %3$s',
'%1$s represents total schedules, %2$s represents active schedules, %3$s represents current time',
'duplicator-pro'
),
(int) $schedule_count,
(int) $active_count,
'<span id="dupli-clock-container"></span>'
);
?>
</th>
</tr>
</tfoot>
</table>
</form>
<?php
$alert1 = new UiDialog();
$alert1->title = __('Bulk Action Required', 'duplicator-pro');
$alert1->message = __('Please select an action from the "Bulk Actions" drop down menu!', 'duplicator-pro');
$alert1->initAlert();
$alert2 = new UiDialog();
$alert2->title = __('Selection Required', 'duplicator-pro');
$alert2->wrapperClassButtons = 'dupli-dlg-noschedule-sel-bulk-action-btns';
$alert2->message = __('Please select at least one schedule to perform the action on!', 'duplicator-pro');
$alert2->initAlert();
$alert3 = new UiDialog();
$alert3->title = __('No Storage', 'duplicator-pro');
$alert3->message = __('All storage types associated with this schedule have been deleted.&nbsp;', 'duplicator-pro');
$alert3->message .= __('To enable this schedule please assign a valid storage type.', 'duplicator-pro');
$alert3->message .= '<br/><br/>';
$alert3->initAlert();
$confirm1 = new UiDialog();
$confirm1->title = __('Delete Schedule?', 'duplicator-pro');
$confirm1->wrapperClassButtons = 'dupli-dlg-delete-schedules-btns';
$confirm1->message = __('Are you sure you want to delete the selected schedule(s)?', 'duplicator-pro');
$confirm1->message .= '<br/>';
$confirm1->message .= '<small><i>' . __('Note: This action removes all schedules.', 'duplicator-pro') . '</i></small>';
$confirm1->progressText = __('Removing Schedules, Please Wait...', 'duplicator-pro');
$confirm1->jsCallback = 'DupliJs.Schedule.BulkDelete()';
$confirm1->initConfirm();
$confirm4 = new UiDialog();
$confirm4->title = __('Activate Schedule?', 'duplicator-pro');
$confirm4->wrapperClassButtons = 'dupli-dlg-activate-schedules-btns';
$confirm4->message = __('Are you sure you want to activate the selected schedule(s)?', 'duplicator-pro');
$confirm4->message .= '<br/>';
$confirm4->message .= '<small><i>' . __('Note: This action activates all schedules.', 'duplicator-pro') . '</i></small>';
$confirm4->progressText = __('Activating Schedules, Please Wait...', 'duplicator-pro');
$confirm4->jsCallback = 'DupliJs.Schedule.BulkActivate()';
$confirm4->initConfirm();
$confirm5 = new UiDialog();
$confirm5->title = __('Deactivate Schedule?', 'duplicator-pro');
$confirm5->wrapperClassButtons = 'dupli-dlg-deactivate-schedules-btns';
$confirm5->message = __('Are you sure you want to deactivate the selected schedule(s)?', 'duplicator-pro');
$confirm5->message .= '<br/>';
$confirm5->message .= '<small><i>' . __('Note: This action deactivates all schedules.', 'duplicator-pro') . '</i></small>';
$confirm5->progressText = __('Deactivating Schedules, Please Wait...', 'duplicator-pro');
$confirm5->jsCallback = 'DupliJs.Schedule.BulkDeactivate()';
$confirm5->initConfirm();
$confirm2 = new UiDialog();
$confirm2->title = __('RUN SCHEDULE?', 'duplicator-pro');
$confirm2->message = __('Are you sure you want to run schedule now?', 'duplicator-pro');
$confirm2->progressText = __('Running Schedule, Please Wait...', 'duplicator-pro');
$confirm2->jsCallback = 'DupliJs.Schedule.Run(this)';
$confirm2->initConfirm();
$confirm3 = new UiDialog();
$confirm3->title = $confirm1->title;
$confirm3->message = __('Are you sure you want to delete this schedule?', 'duplicator-pro');
$confirm3->progressText = $confirm1->progressText;
$confirm3->jsCallback = 'DupliJs.Schedule.DeleteThis(this)';
$confirm3->initConfirm();
$schedule_bulk_action_nonce = wp_create_nonce('duplicator_schedule_bulk_action');
?>
<script>
jQuery(document).ready(function($) {
/*METHOD: Shows quick view summary */
DupliJs.Schedule.QuickView = function(id) {
$('#detail-' + id).toggle();
};
/*METHOD: Run the schedule now and redirect to backups page */
DupliJs.Schedule.RunNow = function(schedule_id) {
<?php $confirm2->showConfirm(); ?>
$("#<?php echo esc_js($confirm2->getID()); ?>-confirm").attr('data-id', schedule_id);
};
DupliJs.Schedule.Run = function(e) {
var schedule_id = $(e).attr('data-id');
$('#icon-' + schedule_id + '-status').show();
$('#text-' + schedule_id).html("<?php esc_html_e('Queueing Now - Please Wait...', 'duplicator-pro') ?>");
var data = {
action: 'duplicator_run_schedule_now',
schedule_id: schedule_id,
nonce: '<?php echo esc_js(wp_create_nonce('duplicator_run_schedule_now')); ?>'
}
$.ajax({
type: "POST",
url: ajaxurl,
timeout: 10000000,
data: data
}).done(function(respData) {
try {
var data = DupliJs.parseJSON(respData);
} catch (err) {
console.error(err);
console.error('JSON parse failed for response data: ' + respData);
return false;
}
window.location.href = <?php echo wp_json_encode($packagesPageUrl) ?>;
});
};
/*METHOD: Deletes a single schedule */
DupliJs.Schedule.Delete = function(id) {
<?php $confirm3->showConfirm(); ?>
$("#<?php echo esc_js($confirm3->getID()); ?>-confirm").attr('data-id', id);
};
DupliJs.Schedule.DeleteThis = function(e) {
var id = $(e).attr('data-id');
$.ajax({
type: "POST",
url: ajaxurl,
dataType: "json",
data: {
action: 'duplicator_schedule_bulk_action',
perform: <?php echo (int) ServicesSchedule::SCHEDULE_BULK_DELETE; ?>,
schedule_ids: [id],
nonce: '<?php echo esc_js($schedule_bulk_action_nonce); ?>'
},
}).done(function(data) {
$('#dup-schedule-form').submit();
});
};
// Creats a comma seperate list of all selected Backup ids
DupliJs.Schedule.SelectedList = function() {
var arr = [];
$("input[name^='selected_id[]']").each(function() {
if ($(this).is(':checked')) {
arr.push($(this).val());
}
});
return arr;
};
// Bulk delete
DupliJs.Schedule.BulkDelete = function() {
var list = DupliJs.Schedule.SelectedList();
$.ajax({
type: "POST",
url: ajaxurl,
dataType: "json",
data: {
action: 'duplicator_schedule_bulk_action',
perform: <?php echo (int) ServicesSchedule::SCHEDULE_BULK_DELETE; ?>,
schedule_ids: list,
nonce: '<?php echo esc_js($schedule_bulk_action_nonce); ?>'
},
}).done(function(data) {
$('#dup-schedule-form').submit();
});
};
// Bulk activate
DupliJs.Schedule.BulkActivate = function() {
var list = DupliJs.Schedule.SelectedList();
$.ajax({
type: "POST",
url: ajaxurl,
dataType: "json",
data: {
action: 'duplicator_schedule_bulk_action',
perform: <?php echo (int) ServicesSchedule::SCHEDULE_BULK_ACTIVATE; ?>,
schedule_ids: list,
nonce: '<?php echo esc_js($schedule_bulk_action_nonce); ?>'
},
}).done(function(data) {
if (data.success) {
$('#dup-schedule-form').submit();
} else {
if (data.message.length > 0) {
$('#<?php echo esc_js($confirm4->getID()); ?>-progress').hide();
$('#<?php echo esc_js($confirm4->getMessageID()); ?>').html(data.message);
}
}
});
};
// Bulk deactivate
DupliJs.Schedule.BulkDeactivate = function() {
var list = DupliJs.Schedule.SelectedList();
$.ajax({
type: "POST",
url: ajaxurl,
dataType: "json",
data: {
action: 'duplicator_schedule_bulk_action',
perform: <?php echo (int) ServicesSchedule::SCHEDULE_BULK_DEACTIVATE; ?>,
schedule_ids: list,
nonce: '<?php echo esc_js($schedule_bulk_action_nonce); ?>'
},
}).done(function(data) {
$('#dup-schedule-form').submit();
});
};
/*METHOD: Bulk action response */
DupliJs.Schedule.BulkAction = function() {
var list = DupliJs.Schedule.SelectedList();
if (list.length == 0) {
<?php $alert2->showAlert(); ?>
return;
}
var action = $('#bulk_action').val(),
checked = ($('.item-chk:checked').length > 0);
if (action == -1) {
<?php $alert1->showAlert(); ?>
return;
}
if (checked) {
switch (action) {
case '<?php echo (int) ServicesSchedule::SCHEDULE_BULK_DELETE; ?>':
<?php $confirm1->showConfirm(); ?>
break;
case '<?php echo (int) ServicesSchedule::SCHEDULE_BULK_ACTIVATE; ?>':
<?php $confirm4->showConfirm(); ?>
break;
case '<?php echo (int) ServicesSchedule::SCHEDULE_BULK_DEACTIVATE; ?>':
<?php $confirm5->showConfirm(); ?>
break;
default:
<?php $alert2->showAlert(); ?>
break;
}
}
};
/*METHOD: Edit a single schedule */
DupliJs.Schedule.Edit = function(id) {
document.location.href = <?php echo json_encode($scheduleEditBaseURL); ?> + '&schedule_id=' + id;
};
/*METHOD: Copy a schedule */
DupliJs.Schedule.Copy = function(id) {
document.location.href = <?php echo json_encode($scheduleCopyBaseURL); ?> + '&dupli-source-schedule-id=' + id;
};
/*METHOD: Set delete all */
DupliJs.Schedule.SetDeleteAll = function(chkbox) {
$('.item-chk').each(function() {
this.checked = chkbox.checked;
});
};
/*METHOD: Shows the delete storage message*/
DupliJs.Schedule.showDeleteStorageMessage = function() {
<?php $alert3->showAlert(); ?>
};
/*METHOD: Enableds the update flag to track proccessing */
DupliJs.Schedule.SetUpdateInterval = function(period) {
console.log('setting interval to ' + period);
if (DupliJs.Schedule.setIntervalID != -1) {
clearInterval(DupliJs.Schedule.setIntervalID);
DupliJs.Schedule.setIntervalID = -1
}
DupliJs.Schedule.setIntervalID = setInterval(DupliJs.Schedule.UpdateSchedules, period * 1000);
};
/*METHOD: Checks the schedule status */
DupliJs.Schedule.UpdateSchedules = function() {
var data = {
action: 'duplicator_get_schedule_infos',
nonce: '<?php echo esc_js(wp_create_nonce('duplicator_get_schedule_infos')); ?>'
};
$.ajax({
type: "POST",
url: ajaxurl,
data: data,
success: function(schedule_infos) {
activeSchedulePresent = false;
for (schedule_info_key in schedule_infos) {
var schedule_info = schedule_infos[schedule_info_key];
var is_running_selector = "#icon-" + schedule_info.schedule_id + "-status";
var last_ran_selector = "#schedule-" + schedule_info.schedule_id + "-last-ran-string";
if (schedule_info.is_running) {
$(is_running_selector).show();
activeSchedulePresent = true;
} else {
$(is_running_selector).hide();
}
$(last_ran_selector).text(schedule_info.last_ran_string);
}
if (activeSchedulePresent) {
DupliJs.Schedule.SetUpdateInterval(10);
} else {
DupliJs.Schedule.SetUpdateInterval(60);
}
},
error: function(data) {
console.log("error");
console.log(data);
$(".schedule-status-icon").css('display', 'none');
DupliJs.Schedule.SetUpdateInterval(60);
}
});
};
DupliJs.UI.Clock(DupliJs._WordPressInitTime);
DupliJs.Schedule.setIntervalID = -1;
DupliJs.Schedule.UpdateSchedules();
});
</script>