first commit
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Duplicator
|
||||
* @copyright (c) 2022, Snap Creek LLC
|
||||
*/
|
||||
|
||||
use Duplicator\Controllers\ToolsPageController;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Models\Storages\AbstractStorageEntity;
|
||||
use Duplicator\Models\TemplateEntity;
|
||||
|
||||
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'];
|
||||
/** @var TemplateEntity */
|
||||
$template = $tplData['template'];
|
||||
|
||||
if (($templateList = TemplateEntity::getAll()) === false) {
|
||||
$templateList = [];
|
||||
}
|
||||
$tplOptGrouped = [
|
||||
'general' => [
|
||||
'label' => __("General Templates", 'duplicator-pro'),
|
||||
'options' => [],
|
||||
],
|
||||
'existing' => [
|
||||
'label' => __("Existing Templates", 'duplicator-pro'),
|
||||
'options' => [],
|
||||
],
|
||||
];
|
||||
$countCopyList = 0;
|
||||
foreach ($templateList as $copyTemplate) {
|
||||
if ($copyTemplate->getId() == $template->getId()) {
|
||||
continue;
|
||||
}
|
||||
if ($copyTemplate->is_manual) {
|
||||
$tplOptGrouped['general']['options'][$copyTemplate->getId()] = __("Active Build Settings", 'duplicator-pro');
|
||||
} elseif ($copyTemplate->is_default) {
|
||||
$tplOptGrouped['general']['options'][$copyTemplate->getId()] = $copyTemplate->name;
|
||||
} else {
|
||||
$tplOptGrouped['existing']['options'][$copyTemplate->getId()] = $copyTemplate->name;
|
||||
}
|
||||
$countCopyList++;
|
||||
}
|
||||
|
||||
$templateListURL = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE
|
||||
);
|
||||
|
||||
$edit_template_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE,
|
||||
null,
|
||||
['inner_page' => 'edit']
|
||||
);
|
||||
|
||||
$template = $tplData['template'];
|
||||
?>
|
||||
<form id="dupli-template-toolbar-form" class="dup-monitored-form" action="<?php echo esc_url($edit_template_url); ?>" method="post">
|
||||
<?php $tplData['actions'][ToolsPageController::ACTION_COPY_TEMPLATE]->getActionNonceFileds(); ?>
|
||||
<input type="hidden" name="package_template_id" value="<?php echo intval($template->getId()); ?>">
|
||||
<div class="dup-toolbar <?php echo ($blur ? 'dup-mock-blur' : ''); ?>">
|
||||
<label for="dupli-source-template-id" class="screen-reader-text">Copy Template action</label>
|
||||
<select
|
||||
id="dupli-source-template-id"
|
||||
name="dupli-source-template-id"
|
||||
class="small"
|
||||
<?php disabled($countCopyList, 0); ?>>
|
||||
<option value="-1" selected="selected" disabled="true">
|
||||
<?php esc_html_e('Copy From', 'duplicator-pro'); ?>
|
||||
</option>
|
||||
<?php foreach ($tplOptGrouped as $groupKey => $group) {
|
||||
if (empty($group['options'])) {
|
||||
continue;
|
||||
}
|
||||
asort($group['options']);
|
||||
?>
|
||||
<optgroup label="<?php echo esc_attr($group['label']); ?>">
|
||||
<?php foreach ($group['options'] as $id => $val) { ?>
|
||||
<option value="<?php echo (int) $id; ?>"><?php echo esc_html($val); ?></option>
|
||||
<?php } ?>
|
||||
</optgroup>
|
||||
<?php } ?>
|
||||
</select>
|
||||
<input type="submit" class="button hollow secondary small action" value="<?php esc_html_e("Apply", 'duplicator-pro') ?>">
|
||||
<span class="separator"></span>
|
||||
<a
|
||||
href="<?php echo esc_url($templateListURL); ?>"
|
||||
class="button hollow secondary small dup-goto-templates-btn"
|
||||
title="<?php esc_attr_e('Back to Template list.', 'duplicator-pro'); ?>">
|
||||
<i class="far fa-clone"></i> <?php esc_html_e('Templates', 'duplicator-pro'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
<hr class="dup-toolbar-divider" />
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Duplicator Backup row in table Backups list
|
||||
*
|
||||
* @package Duplicator
|
||||
* @copyright (c) 2022, Snap Creek LLC
|
||||
*/
|
||||
|
||||
use Duplicator\Controllers\ToolsPageController;
|
||||
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
|
||||
*/
|
||||
|
||||
if (CapMng::can(CapMng::CAP_CREATE, false)) {
|
||||
$edit_template_url = $ctrlMng::getMenuLink(
|
||||
$ctrlMng::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE,
|
||||
null,
|
||||
['inner_page' => 'edit']
|
||||
);
|
||||
|
||||
$tipContent = __(
|
||||
'Create a new Template.',
|
||||
'duplicator-pro'
|
||||
);
|
||||
?>
|
||||
<span
|
||||
data-tooltip="<?php echo esc_attr($tipContent); ?>"
|
||||
>
|
||||
<a
|
||||
href="<?php echo esc_url($edit_template_url); ?>"
|
||||
id="dupli-create-new"
|
||||
class="button primary small font-bold margin-0"
|
||||
>
|
||||
<?php esc_html_e('Add New', 'duplicator-pro'); ?>
|
||||
</a>
|
||||
</span>
|
||||
<?php
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Duplicator
|
||||
*/
|
||||
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Models\GlobalEntity;
|
||||
use Duplicator\Controllers\ToolsPageController;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Addons\ProBase\License\License;
|
||||
use Duplicator\Controllers\SettingsPageController;
|
||||
use Duplicator\Core\Views\TplMng;
|
||||
use Duplicator\Libs\WpUtils\WpArchiveUtils;
|
||||
use Duplicator\Models\TemplateEntity;
|
||||
use Duplicator\Package\Archive\PackageArchive;
|
||||
use Duplicator\Views\UI\UiDialog;
|
||||
use Duplicator\Views\UI\UiViewState;
|
||||
|
||||
/**
|
||||
* Variables
|
||||
*
|
||||
* @var Duplicator\Core\Controllers\ControllersManager $ctrlMng
|
||||
* @var Duplicator\Core\Views\TplMng $tplMng
|
||||
*/
|
||||
$blur = $tplMng->getDataValueBool('blur');
|
||||
$template = $tplMng->getDataValueObj('template', TemplateEntity::class);
|
||||
|
||||
$templates_tab_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE
|
||||
);
|
||||
$edit_template_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE,
|
||||
null,
|
||||
['inner_page' => 'edit']
|
||||
);
|
||||
|
||||
$bandListUrl = ControllersManager::getMenuLink(
|
||||
ControllersManager::SETTINGS_SUBMENU_SLUG,
|
||||
SettingsPageController::L2_SLUG_PACKAGE_BRAND
|
||||
);
|
||||
|
||||
$brandDefaultEditUrl = ControllersManager::getMenuLink(
|
||||
ControllersManager::SETTINGS_SUBMENU_SLUG,
|
||||
SettingsPageController::L2_SLUG_PACKAGE_BRAND,
|
||||
null,
|
||||
[
|
||||
ControllersManager::QUERY_STRING_INNER_PAGE => SettingsPageController::BRAND_INNER_PAGE_EDIT,
|
||||
'action' => 'default',
|
||||
]
|
||||
);
|
||||
|
||||
$brandBaseEditUrl = ControllersManager::getMenuLink(
|
||||
ControllersManager::SETTINGS_SUBMENU_SLUG,
|
||||
SettingsPageController::L2_SLUG_PACKAGE_BRAND,
|
||||
null,
|
||||
[
|
||||
ControllersManager::QUERY_STRING_INNER_PAGE => SettingsPageController::BRAND_INNER_PAGE_EDIT,
|
||||
'action' => 'edit',
|
||||
]
|
||||
);
|
||||
|
||||
$global = GlobalEntity::getInstance();
|
||||
|
||||
if (($package_templates = TemplateEntity::getAll()) === false) {
|
||||
$package_templates = [];
|
||||
}
|
||||
$package_template_count = count($package_templates);
|
||||
|
||||
// For now not including in filters since don't want to encourage use
|
||||
// with schedules since filtering creates incomplete multisite
|
||||
$displayMultisiteTab = (is_multisite() && License::can(License::CAPABILITY_MULTISITE_PLUS));
|
||||
|
||||
$view_state = UiViewState::getArray();
|
||||
$ui_css_archive = (UiViewState::getValue('dup-template-archive-panel') ? 'display:block' : 'display:none');
|
||||
$ui_css_install = (UiViewState::getValue('dup-template-install-panel') ? 'display:block' : 'display:none');
|
||||
|
||||
$installer_cpnldbaction = $template->installer_opts_cpnl_db_action;
|
||||
$upload_dir = WpArchiveUtils::getArchiveListPaths('uploads');
|
||||
$content_path = WpArchiveUtils::getArchiveListPaths('wpcontent');
|
||||
$archive_format = ($global->getBuildMode() == PackageArchive::BUILD_MODE_DUP_ARCHIVE ? 'daf' : 'zip');
|
||||
?>
|
||||
|
||||
<?php $tplMng->render('admin_pages/templates/parts/template_edit_toolbar'); ?>
|
||||
<form
|
||||
id="dupli-template-form"
|
||||
class="dup-monitored-form <?php echo ($blur ? 'dup-mock-blur' : ''); ?>"
|
||||
data-parsley-validate data-parsley-ui-enabled="true"
|
||||
action="<?php echo esc_url($edit_template_url); ?>"
|
||||
method="post">
|
||||
<?php $tplMng->getAction(ToolsPageController::ACTION_SAVE_TEMPLATE)->getActionNonceFileds(); ?>
|
||||
<input type="hidden" name="package_template_id" value="<?php echo intval($template->getId()); ?>">
|
||||
|
||||
<!-- ====================
|
||||
SUB-TABS -->
|
||||
<div class="dupli-template-general">
|
||||
|
||||
<div>
|
||||
<label class="inline-display">
|
||||
<?php esc_html_e("Recovery Status", 'duplicator-pro'); ?>:
|
||||
</label>
|
||||
<?php $template->recoveableHtmlInfo(); ?> <br /><br />
|
||||
</div>
|
||||
|
||||
<label class="lbl-larger" for="template-name">
|
||||
<?php esc_html_e("Template Name", 'duplicator-pro'); ?>:
|
||||
</label>
|
||||
<input type="text" id="template-name" name="name" data-parsley-errors-container="#template_name_error_container"
|
||||
data-parsley-required="true" value="<?php echo esc_attr($template->name); ?>" autocomplete="off" maxlength="125">
|
||||
<div id="template_name_error_container" class="duplicator-error-container"></div>
|
||||
|
||||
<?php
|
||||
TplMng::getInstance()->render(
|
||||
'admin_pages/packages/setup/name-format-controls',
|
||||
[
|
||||
'nameFormat' => $template->package_name_format,
|
||||
'notes' => $template->notes,
|
||||
]
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$tplMng->render(
|
||||
'parts/packages/filters/section_filters',
|
||||
[
|
||||
'isTemplateEdit' => true,
|
||||
'template' => $template,
|
||||
]
|
||||
);
|
||||
|
||||
$tplMng->render(
|
||||
'parts/packages/filters/section_installer',
|
||||
[
|
||||
'activeBrandId' => $template->installer_opts_brand,
|
||||
'dbHost' => $template->installer_opts_db_host,
|
||||
'dbName' => $template->installer_opts_db_name,
|
||||
'dbUser' => $template->installer_opts_db_user,
|
||||
'cpnlEnable' => $template->installer_opts_cpnl_enable,
|
||||
'cpnlHost' => $template->installer_opts_cpnl_host,
|
||||
'cpnlUser' => $template->installer_opts_cpnl_user,
|
||||
'cpnlDbAction' => $template->installer_opts_cpnl_db_action,
|
||||
'cpnlDbHost' => $template->installer_opts_cpnl_db_host,
|
||||
'cpnlDbName' => $template->installer_opts_cpnl_db_name,
|
||||
'cpnlDbUser' => $template->installer_opts_cpnl_db_user,
|
||||
]
|
||||
);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
<button
|
||||
class="button primary small dup-save-template-btn"
|
||||
type="submit">
|
||||
<?php esc_html_e('Save Template', 'duplicator-pro'); ?>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
|
||||
<?php
|
||||
$alert1 = new UiDialog();
|
||||
$alert1->title = __('Transfer Error', 'duplicator-pro');
|
||||
$alert1->message = __('You can\'t exclude all sites!', 'duplicator-pro');
|
||||
$alert1->initAlert();
|
||||
?>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
var usedPackageFormats = {};
|
||||
|
||||
/* When installer brand changes preview button is updated */
|
||||
DupliJs.Template.BrandChange = function() {
|
||||
var $brand = $("#installer_opts_brand");
|
||||
var $id = $brand.val();
|
||||
var $url = new Array();
|
||||
|
||||
$url = [
|
||||
<?php echo wp_json_encode($brandDefaultEditUrl); ?>,
|
||||
<?php echo wp_json_encode($brandBaseEditUrl); ?> + '&id=' + $id
|
||||
];
|
||||
|
||||
$("#brand-preview").attr('href', $url[$id > 0 ? 1 : 0]);
|
||||
};
|
||||
|
||||
/* Enables strike through on excluded DB table */
|
||||
DupliJs.Template.ExcludeTable = function(check) {
|
||||
var $cb = $(check);
|
||||
if ($cb.is(":checked")) {
|
||||
$cb.closest("label").css('textDecoration', 'line-through');
|
||||
} else {
|
||||
$cb.closest("label").css('textDecoration', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
//INIT
|
||||
$('#template-name').focus().select();
|
||||
// $('#_archive_filter_files').val($('#_archive_filter_files').val().trim());
|
||||
//Default to cPanel tab if used
|
||||
$('#cpnl-enable').is(":checked") ? $('#dupli-cpnl-tab-lbl').trigger("click") : null;
|
||||
DupliJs.EnableInstallerPassword();
|
||||
DupliJs.Template.BrandChange();
|
||||
|
||||
//MU-Transfer buttons
|
||||
$('#mu-include-btn').click(function() {
|
||||
return !$('#mu-exclude option:selected').remove().appendTo('#mu-include');
|
||||
});
|
||||
|
||||
$('#mu-exclude-btn').click(function() {
|
||||
var include_all_count = $('#mu-include option').length;
|
||||
var include_selected_count = $('#mu-include option:selected').length;
|
||||
|
||||
if (include_all_count > include_selected_count) {
|
||||
return !$('#mu-include option:selected').remove().appendTo('#mu-exclude');
|
||||
} else {
|
||||
<?php $alert1->showAlert(); ?>
|
||||
}
|
||||
});
|
||||
|
||||
$('#dupli-template-form').submit(function() {
|
||||
DupliJs.Pack.FillExcludeTablesList();
|
||||
});
|
||||
|
||||
//Defaults to Installer cPanel tab if 'Auto Select cPanel' is checked
|
||||
$('#installer_opts_cpnl_enable').is(":checked") ? $('#dupli-cpnl-tab-lbl').trigger("click") : null;
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,274 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Duplicator
|
||||
*/
|
||||
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Controllers\ToolsPageController;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Models\ScheduleEntity;
|
||||
use Duplicator\Models\TemplateEntity;
|
||||
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'];
|
||||
|
||||
$nonce_action = 'dupli-template-list';
|
||||
$display_edit = false;
|
||||
|
||||
$templates_tab_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE
|
||||
);
|
||||
$edit_template_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::TOOLS_SUBMENU_SLUG,
|
||||
ToolsPageController::L2_SLUG_TEMPLATE,
|
||||
null,
|
||||
['inner_page' => 'edit']
|
||||
);
|
||||
|
||||
if (($package_templates = TemplateEntity::getAllWithoutManualMode()) === false) {
|
||||
$package_templates = [];
|
||||
}
|
||||
$package_template_count = count($package_templates);
|
||||
?>
|
||||
<form
|
||||
id="dup-package-form"
|
||||
class="<?php echo ($blur ? 'dup-mock-blur' : ''); ?>"
|
||||
action="<?php echo esc_url($templates_tab_url); ?>"
|
||||
method="post">
|
||||
<?php $tplData['actions'][ToolsPageController::ACTION_DELETE_TEMPLATE]->getActionNonceFileds(); ?>
|
||||
|
||||
<h2><?php esc_html_e('Templates', 'duplicator-pro'); ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e('Create Backup Templates with Preset Configurations.', 'duplicator-pro'); ?>
|
||||
</p>
|
||||
<hr>
|
||||
|
||||
<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>
|
||||
<?php esc_html_e("Bulk Actions", 'duplicator-pro') ?>
|
||||
</option>
|
||||
<option value="delete" title="Delete selected Backup(s)">
|
||||
<?php esc_html_e("Delete", 'duplicator-pro'); ?>
|
||||
</option>
|
||||
</select>
|
||||
<input
|
||||
type="button"
|
||||
id="dup-pack-bulk-apply"
|
||||
class="button hollow secondary small"
|
||||
value="<?php esc_attr_e("Apply", 'duplicator-pro') ?>"
|
||||
onclick="DupliJs.Template.BulkAction()">
|
||||
<span class="separator"></span>
|
||||
<?php $tplMng->render('admin_pages/templates/template_create_button'); ?>
|
||||
</div>
|
||||
|
||||
|
||||
<table class="widefat dupli-template-list-tbl dup-table-list valign-top">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-check"><input type="checkbox" id="dupli-chk-all" title="Select all Templates" onclick="DupliJs.Template.SetDeleteAll(this)"></th>
|
||||
<th class="col-name"><?php esc_html_e('Name', 'duplicator-pro'); ?></th>
|
||||
<th class="col-recover"><?php esc_html_e('Recovery', 'duplicator-pro'); ?></th>
|
||||
<th class="col-empty"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
foreach ($package_templates as $package_template) :
|
||||
$i++;
|
||||
|
||||
$schedules = ScheduleEntity::getByTemplateId($package_template->getId());
|
||||
$schedule_count = count($schedules);
|
||||
?>
|
||||
<tr class="package-row <?php echo ($i % 2) ? 'alternate' : ''; ?>">
|
||||
<td class="col-check">
|
||||
<?php if ($package_template->is_default == false) : ?>
|
||||
<input name="selected_id[]" type="checkbox" value="<?php echo intval($package_template->getId()); ?>" class="item-chk" />
|
||||
<?php else : ?>
|
||||
<input type="checkbox" disabled />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td class="col-name">
|
||||
<a
|
||||
href="javascript:void(0);"
|
||||
onclick="DupliJs.Template.Edit(<?php echo intval($package_template->getId()); ?>);"
|
||||
class="name"
|
||||
data-template-id="<?php echo intval($package_template->getId()); ?>">
|
||||
<?php echo esc_html($package_template->name); ?>
|
||||
</a>
|
||||
<div class="sub-menu">
|
||||
<a
|
||||
class="dup-edit-template-btn"
|
||||
href="javascript:void(0);"
|
||||
onclick="DupliJs.Template.Edit(<?php echo (int) $package_template->getId(); ?>);">
|
||||
<?php esc_html_e('Edit', 'duplicator-pro'); ?>
|
||||
</a> |
|
||||
<?php $actionCopyUrl = $tplData['actions'][ToolsPageController::ACTION_COPY_TEMPLATE]
|
||||
->getUrl([
|
||||
'dupli-source-template-id' => $package_template->getId(),
|
||||
'tab' => ToolsPageController::L2_SLUG_TEMPLATE,
|
||||
'inner_page' => ToolsPageController::TEMPLATE_INNER_PAGE_EDIT,
|
||||
]); ?>
|
||||
<a
|
||||
class="dup-copy-template-btn"
|
||||
href="<?php echo esc_url($actionCopyUrl); ?>">
|
||||
<?php esc_html_e('Copy', 'duplicator-pro'); ?>
|
||||
</a>
|
||||
<?php if ($package_template->is_default == false) : ?>
|
||||
| <a
|
||||
class="dup-delete-template-btn"
|
||||
href="javascript:void(0);"
|
||||
onclick="DupliJs.Template.Delete(<?php echo (int) $package_template->getId() ?>, <?php echo (int) $schedule_count; ?>);">
|
||||
<?php esc_html_e('Delete', 'duplicator-pro'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-recover">
|
||||
<?php $package_template->recoveableHtmlInfo(true); ?>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="8" style="text-align:right; font-size:12px">
|
||||
<?php echo esc_html__('Total', 'duplicator-pro') . ': ' . (int) $package_template_count; ?>
|
||||
</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->message = __('Please select at least one template to delete!', 'duplicator-pro');
|
||||
$alert2->initAlert();
|
||||
|
||||
$confirm1 = new UiDialog();
|
||||
$confirm1->wrapperClassButtons = 'dup-delete-template-dialog-bulk';
|
||||
$confirm1->title = __('Delete the selected templates?', 'duplicator-pro');
|
||||
$confirm1->message = __('All schedules using this template will be reassigned to the "Default" Template.', 'duplicator-pro');
|
||||
$confirm1->message .= '<br/><br/>';
|
||||
$confirm1->message .= '<small><i>' . __('Note: This action removes all selected custom templates.', 'duplicator-pro') . '</i></small>';
|
||||
$confirm1->progressText = __('Removing Templates, Please Wait...', 'duplicator-pro');
|
||||
$confirm1->jsCallback = 'DupliJs.Storage.BulkDelete()';
|
||||
$confirm1->initConfirm();
|
||||
|
||||
$confirm2 = new UiDialog();
|
||||
$confirm2->wrapperClassButtons = 'dup-delete-template-dialog-single';
|
||||
$confirm2->title = __('Are you sure you want to delete this template?', 'duplicator-pro');
|
||||
$confirm2->message = __('All schedules using this template will be reassigned to the "Default" Template.', 'duplicator-pro');
|
||||
$confirm2->progressText = $confirm1->progressText;
|
||||
$confirm2->jsCallback = 'DupliJs.Template.DeleteThis(this)';
|
||||
$confirm2->initConfirm();
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
|
||||
//Shows detail view
|
||||
DupliJs.Template.View = function(id) {
|
||||
$('#' + id).toggle();
|
||||
}
|
||||
|
||||
// Edit template
|
||||
DupliJs.Template.Edit = function(id) {
|
||||
document.location.href = <?php echo wp_json_encode("$edit_template_url&package_template_id="); ?> + id;
|
||||
};
|
||||
|
||||
//Delets a single record
|
||||
DupliJs.Template.Delete = function(id, schedule_count) {
|
||||
var message = "";
|
||||
<?php $confirm2->showConfirm(); ?>
|
||||
if (schedule_count > 0) {
|
||||
message += "<?php esc_html_e('There currently are', 'duplicator-pro') ?>" + " ";
|
||||
message += schedule_count + " " + "<?php esc_html_e('schedule(s) using this template.', 'duplicator-pro'); ?>" + " ";
|
||||
message += "<?php esc_html_e('All schedules using this template will be reassigned to the \"Default\" template.', 'duplicator-pro') ?>" + " ";
|
||||
$("#<?php echo esc_js($confirm2->getID()); ?>_message").html(message);
|
||||
}
|
||||
$("#<?php echo esc_js($confirm2->getID()); ?>-confirm").attr('data-id', id);
|
||||
}
|
||||
|
||||
DupliJs.Template.DeleteThis = function(e) {
|
||||
var id = $(e).attr('data-id');
|
||||
$("input[name^='selected_id[]'][value='" + id + "']").prop('checked', true);
|
||||
$("#dup-package-form").submit();
|
||||
}
|
||||
|
||||
// Creats a comma seperate list of all selected Backup ids
|
||||
DupliJs.Template.DeleteList = function() {
|
||||
var arr = [];
|
||||
|
||||
$("input[name^='selected_id[]']").each(function(i, index) {
|
||||
var $this = $(index);
|
||||
|
||||
if ($this.is(':checked') == true) {
|
||||
arr[i] = $this.val();
|
||||
}
|
||||
});
|
||||
|
||||
return arr.join(',');
|
||||
}
|
||||
|
||||
// Bulk Action
|
||||
DupliJs.Template.BulkAction = function() {
|
||||
var list = DupliJs.Template.DeleteList();
|
||||
|
||||
if (list.length == 0) {
|
||||
<?php $alert2->showAlert(); ?>
|
||||
return;
|
||||
}
|
||||
|
||||
var action = $('#bulk_action').val(),
|
||||
checked = ($('.item-chk:checked').length > 0);
|
||||
|
||||
if (action != "delete") {
|
||||
<?php $alert1->showAlert(); ?>
|
||||
return;
|
||||
}
|
||||
|
||||
if (checked) {
|
||||
switch (action) {
|
||||
default:
|
||||
<?php $alert2->showAlert(); ?>
|
||||
break;
|
||||
case 'delete':
|
||||
<?php $confirm1->showConfirm(); ?>
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DupliJs.Storage.BulkDelete = function() {
|
||||
$("#dup-package-form").submit();
|
||||
}
|
||||
|
||||
//Sets all for deletion
|
||||
DupliJs.Template.SetDeleteAll = function(chkbox) {
|
||||
$('.item-chk').each(function() {
|
||||
this.checked = chkbox.checked;
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user