first commit
This commit is contained in:
@@ -0,0 +1,316 @@
|
||||
<?php
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Addons\ProBase\License\License;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Utils\Settings\MigrateSettings;
|
||||
|
||||
/* FOR PERSONAL LICENSE JUST SHOW MESSAGE */
|
||||
if (!License::can(License::CAPABILITY_IMPORT_SETTINGS)) : ?>
|
||||
<div class="width-large" >
|
||||
<p>
|
||||
<?php _e(
|
||||
"The migrate settings screen allows you to import or export Duplicator Pro settings from one site to another.",
|
||||
'duplicator-pro'
|
||||
); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php _e(
|
||||
"For example, if you have several storage locations that you use on multiple WordPress sites such as Google Drive or
|
||||
Dropbox and you simply want to copy the profiles from this instance of Duplicator Pro to another instance then simply
|
||||
export the data here and import it on the other instance of Duplicator Pro.",
|
||||
'duplicator-pro'
|
||||
); ?>
|
||||
</p>
|
||||
<p>
|
||||
<?php
|
||||
printf(
|
||||
__(
|
||||
'This option isn\'t available at the <b>%1$s</b> license level.',
|
||||
'duplicator-pro'
|
||||
),
|
||||
License::getLicenseToString()
|
||||
);
|
||||
?>
|
||||
<b>
|
||||
<?php
|
||||
printf(
|
||||
_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>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<?php else :
|
||||
/* LET'S PERFORM FREELANCE+ SETTINGS */
|
||||
|
||||
$nonce = wp_create_nonce('duplicator_pro_import_export_settings');
|
||||
|
||||
$view_state = DUP_PRO_UI_ViewState::getArray();
|
||||
$ui_css_export_panel = (isset($view_state['dpro-tools-export-panel']) && $view_state['dpro-tools-export-panel']) ? 'display:block' : 'display:block';
|
||||
$ui_css_import_panel = (isset($view_state['dpro-tools-import-panel']) && $view_state['dpro-tools-import-panel']) ? 'display:block' : 'display:block';
|
||||
|
||||
// POST BACK
|
||||
$_REQUEST['action'] = !empty($_REQUEST['action']) ? $_REQUEST['action'] : 'display';
|
||||
|
||||
$error_message = null;
|
||||
$success_message = null;
|
||||
|
||||
switch ($_REQUEST['action']) {
|
||||
case 'dpro-export':
|
||||
case 'dpro-import':
|
||||
try {
|
||||
if (MigrateSettings::import($_FILES['import-file']['tmp_name'], $_POST['import-opts']) == false) {
|
||||
throw new Exception('Import failed.');
|
||||
}
|
||||
$success_message = 'Successfully imported.';
|
||||
} catch (Exception $ex) {
|
||||
$error_message = 'Import Error: ' . $ex->getMessage() . "<br>\n" . $ex->getFile() . ':' . $ex->getLine();
|
||||
}
|
||||
break;
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
<?php echo isset($css_hide_msg) ? $css_hide_msg : ''; ?>
|
||||
div.dup-box {margin-top:20px}
|
||||
div#message {margin:0px 0px 10px 0px}
|
||||
div.success {color:#4A8254}
|
||||
div.failed {color:#BB1506}
|
||||
table.dpro-check-tbl td {padding:5px 30px 10px 10px}
|
||||
div#message {margin-top:10px !important}
|
||||
div#TB_ajaxContent p {font-size:14px !important}
|
||||
</style>
|
||||
|
||||
<?php
|
||||
if ($error_message !== null) {
|
||||
echo "<div id='message' class='below-h2 error'><p>{$error_message}</p></div>";
|
||||
} elseif ($success_message !== null) {
|
||||
echo "<div id='message' class='below-h2 updated'><p>{$success_message}</p></div>";
|
||||
}
|
||||
?>
|
||||
<br/>
|
||||
|
||||
<?php
|
||||
esc_html_e(
|
||||
"The migrate settings screen allows you to import or export Duplicator Pro settings from one site to another.
|
||||
For example if you have several storage locations
|
||||
that you use on multiple WordPress sites such as Google Drive or Dropbox and you simply want to copy
|
||||
the profiles from this instance of Duplicator Pro to another instance
|
||||
then simply export the data here and import it on the other instance of Duplicator Pro.",
|
||||
'duplicator-pro'
|
||||
); ?>
|
||||
<br>
|
||||
|
||||
<!-- ==============================
|
||||
EXPORT -->
|
||||
<!-- action is unnecessary, uses ajax -->
|
||||
<form id="dup-tools-form-export" method="post">
|
||||
<?php wp_nonce_field('dpro_tools_data_export'); ?>
|
||||
<input type="hidden" name="action" value="dpro-export">
|
||||
<div class="dup-box">
|
||||
<div class="dup-box-title">
|
||||
<i class="fa fa-upload"></i>
|
||||
<?php esc_html_e("Export Settings", 'duplicator-pro') ?>
|
||||
<button class="dup-box-arrow">
|
||||
<span class="screen-reader-text"><?php esc_html_e('Toggle panel:', 'duplicator-pro') ?> <?php esc_html_e('Export Settings', 'duplicator-pro') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="dup-box-panel" id="dpro-tools-export-panel" style="<?php echo esc_attr($ui_css_export_panel); ?>">
|
||||
<?php
|
||||
esc_html_e(
|
||||
"Exports all schedules, storage locations, templates and settings from this Duplicator Pro instance into a downloadable export file.",
|
||||
'duplicator-pro'
|
||||
);
|
||||
?>
|
||||
<br/>
|
||||
<?php
|
||||
esc_html_e(
|
||||
"The export file can then be used to import data settings from this instance of Duplicator Pro into another plugin instance of Duplicator Pro.",
|
||||
'duplicator-pro'
|
||||
);
|
||||
?>
|
||||
<br/><br/><br/>
|
||||
|
||||
<input type="button" class="button button-primary" value="<?php esc_attr_e("Export Data", 'duplicator-pro'); ?>" onclick="return DupPro.Tools.ExportDialog();" />
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- ==============================
|
||||
IMPORT -->
|
||||
<form enctype="multipart/form-data" id="dup-tools-form-import" action="<?php echo ControllersManager::getCurrentLink(); ?>" method="post" data-parsley-validate data-parsley-ui-enabled="true" >
|
||||
<?php wp_nonce_field('dpro_tools_data_import'); ?>
|
||||
<input type="hidden" name="action" value="dpro-import">
|
||||
<div class="dup-box">
|
||||
<div class="dup-box-title">
|
||||
<i class="fa fa-download"></i>
|
||||
<?php esc_html_e("Import Settings", 'duplicator-pro'); ?>
|
||||
<button class="dup-box-arrow">
|
||||
<span class="screen-reader-text"><?php esc_html_e('Toggle panel:', 'duplicator-pro') ?> <?php esc_html_e('Import Settings', 'duplicator-pro') ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="dup-box-panel" id="dpro-tools-import-panel" style="<?php echo esc_attr($ui_css_import_panel); ?>" >
|
||||
<?php _e('Import settings from another Duplicator Pro plugin into this instance of Duplicator Pro.', 'duplicator-pro'); ?>
|
||||
<br>
|
||||
<?php _e('Schedule, storage and template data will be appended to current data, while existing settings will be replaced.', 'duplicator-pro'); ?>
|
||||
<br>
|
||||
<b>
|
||||
<?php _e('For security reasons, capabilities, license data and license visibility will not be imported.', 'duplicator-pro'); ?>
|
||||
</b>
|
||||
<br>
|
||||
<i>
|
||||
<?php
|
||||
_e(
|
||||
"Schedules depend on storage and templates so importing schedules will require that storage and templates be checked.",
|
||||
'duplicator-pro'
|
||||
); ?>
|
||||
</i>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<label for="import-file"><b><?php esc_html_e("Choose Duplicator Data File", 'duplicator-pro'); ?></b> </label><br/>
|
||||
<input type="file" accept=".dup" name="import-file" id="import-file" required="true" />
|
||||
<br/><br/>
|
||||
|
||||
<b><?php esc_html_e("Include in Import", 'duplicator-pro'); ?>:</b>
|
||||
<table class="dpro-check-tbl">
|
||||
<tr>
|
||||
<td>
|
||||
<input onclick="DupPro.Tools.ChangeImportButtonState();DupPro.Tools.SchedulesClicked();" type="checkbox" name="import-opts[]" id="import-schedules" value="schedules" />
|
||||
<label for="import-schedules"><?php esc_html_e("Schedules", 'duplicator-pro'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input onclick="DupPro.Tools.ChangeImportButtonState();" type="checkbox" name="import-opts[]" id="import-storages" value="storages" />
|
||||
<label for="import-storages"><?php esc_html_e("Storage", 'duplicator-pro'); ?></label>
|
||||
</td>
|
||||
<td>
|
||||
<input onclick="DupPro.Tools.ChangeImportButtonState();" type="checkbox" name="import-opts[]" id="import-templates" value="templates" />
|
||||
<label for="import-templates"><?php esc_html_e("Templates", 'duplicator-pro'); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<input onclick="DupPro.Tools.ChangeImportButtonState();" type="checkbox" name="import-opts[]" id="import-settings" value="settings" />
|
||||
<label for="import-settings"><?php esc_html_e("Settings", 'duplicator-pro'); ?></label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<input id="import-button" type="button" class="button button-primary" value="<?php esc_attr_e("Import Data", 'duplicator-pro'); ?>" onclick="return DupPro.Tools.ImportDialog();" disabled/>
|
||||
<br/><br/>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<br/><br/>
|
||||
|
||||
<?php add_thickbox(); ?>
|
||||
|
||||
<!-- EXPORT DIALOG -->
|
||||
<div id="modal-window-export" style="display:none;">
|
||||
<h2><?php esc_html_e("Export Duplicator Pro Data?", 'duplicator-pro') ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e("This process will:", 'duplicator-pro') ?><br/><br/>
|
||||
<i class="far fa-check-circle"></i> <?php esc_html_e("Export schedules, storage and templates to a file for import into another Duplicator instance.", 'duplicator-pro'); ?> <br/>
|
||||
<span style="color:#BB1506"><i class="fas fa-exclamation-triangle fa-sm"></i></i> <?php esc_html_e("For security purposes, restrict access to this file and delete after use.", 'duplicator-pro'); ?></span> <br/>
|
||||
<br/>
|
||||
<?php esc_html_e("Click the 'Run Export' button to generate and download the export file.", 'duplicator-pro') ?><br/><br/>
|
||||
</p>
|
||||
<div style="position:absolute; right:10px; bottom: 10px">
|
||||
<input type="button" class="button" value="<?php esc_attr_e("Run Export", 'duplicator-pro') ?>" onclick="DupPro.Tools.ExportProcess();setTimeout(function() { tb_remove(); }, 4000);" />
|
||||
<input type="button" class="button" value="<?php esc_attr_e("Cancel", 'duplicator-pro') ?>" onclick="tb_remove();" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IMPORT DIALOG -->
|
||||
<div id="modal-window-import" style="display:none;">
|
||||
<h2><?php esc_html_e("Import Duplicator Pro Data?", 'duplicator-pro') ?></h2>
|
||||
<p>
|
||||
<?php esc_html_e("This process will:", 'duplicator-pro') ?><br/><br/>
|
||||
<i class="far fa-check-circle"></i> <?php esc_html_e("Append schedules, storage and templates if those options are checked.", 'duplicator-pro'); ?> <br/>
|
||||
<i class="far fa-check-circle"></i> <?php esc_html_e("Overwrite current settings data if the settings option is checked.", 'duplicator-pro'); ?> <br/>
|
||||
<span style="color:#BB1506"><i class="fas fa-exclamation-triangle fa-sm"></i> <?php esc_html_e("Review templates and local storages after import to ensure correct path values.", 'duplicator-pro'); ?> <br/></span>
|
||||
<br/>
|
||||
<?php esc_html_e("Click the 'Run Import' button to process the import file.", 'duplicator-pro') ?><br/><br/>
|
||||
</p>
|
||||
<div style="position:absolute; right:10px; bottom: 10px">
|
||||
<input type="button" class="button" value="<?php esc_attr_e("Run Import", 'duplicator-pro') ?>" onclick="DupPro.Tools.ImportProcess();" />
|
||||
<input type="button" class="button" value="<?php esc_attr_e("Cancel", 'duplicator-pro') ?>" onclick="tb_remove();" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
DupPro.Tools.ExportProcess = function ()
|
||||
{
|
||||
var actionLocation = ajaxurl + '?action=duplicator_pro_export_settings' + '&nonce=' + '<?php echo $nonce; ?>';
|
||||
location.href = actionLocation;
|
||||
}
|
||||
|
||||
DupPro.Tools.ExportDialog = function ()
|
||||
{
|
||||
var url = "#TB_inline?width=610&height=250&inlineId=modal-window-export";
|
||||
tb_show("<?php esc_html_e("Export Data", 'duplicator-pro') ?>", url);
|
||||
return false;
|
||||
}
|
||||
|
||||
DupPro.Tools.ImportProcess = function ()
|
||||
{
|
||||
jQuery('#dup-tools-form-import').submit();
|
||||
}
|
||||
|
||||
DupPro.Tools.ImportDialog = function ()
|
||||
{
|
||||
var url = "#TB_inline?width=610&height=300&inlineId=modal-window-import";
|
||||
tb_show("<?php esc_html_e("Import Data", 'duplicator-pro') ?>", url);
|
||||
return false;
|
||||
}
|
||||
|
||||
//PAGE INIT
|
||||
jQuery(document).ready(function ($)
|
||||
{
|
||||
DupPro.Tools.ChangeImportButtonState = function()
|
||||
{
|
||||
var filename = $('#import-file').val();
|
||||
var disabled = (filename == '');
|
||||
|
||||
disabled = disabled ||
|
||||
(
|
||||
!document.getElementById('import-templates').checked &&
|
||||
!document.getElementById('import-storages').checked &&
|
||||
!document.getElementById('import-schedules').checked &&
|
||||
!document.getElementById('import-settings').checked
|
||||
);
|
||||
|
||||
$('#import-button').prop('disabled', disabled);
|
||||
}
|
||||
|
||||
DupPro.Tools.SchedulesClicked = function()
|
||||
{
|
||||
if(document.getElementById('import-schedules').checked)
|
||||
{
|
||||
document.getElementById('import-templates').checked = true;
|
||||
document.getElementById('import-storages').checked = true;
|
||||
document.getElementById('import-templates').disabled = true;
|
||||
document.getElementById('import-storages').disabled = true;
|
||||
}
|
||||
else {
|
||||
document.getElementById('import-templates').disabled = false;
|
||||
document.getElementById('import-storages').disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
$("#dpro-tools-import-panel").on("change", "#import-file", function() { DupPro.Tools.ChangeImportButtonState(); });
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,529 @@
|
||||
<?php
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Controllers\SettingsPageController;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Libs\Snap\SnapUtil;
|
||||
use Duplicator\Models\BrandEntity;
|
||||
|
||||
// Let's make impossible - do TinyMCE textarea required
|
||||
add_action('the_editor', function ($editorMarkup) {
|
||||
if (stripos($editorMarkup, 'required') !== false) {
|
||||
$editorMarkup = str_replace('<textarea', '<textarea required="true"', $editorMarkup);
|
||||
}
|
||||
return $editorMarkup;
|
||||
});
|
||||
|
||||
$brand_list_url = ControllersManager::getCurrentLink(array('view' => 'list'));
|
||||
$brand_edit_url = ControllersManager::getCurrentLink(array('view' => 'edit'));
|
||||
|
||||
$was_updated = false;
|
||||
$acceptedActions = array(
|
||||
'new',
|
||||
'edit',
|
||||
'save',
|
||||
'default',
|
||||
);
|
||||
|
||||
//Set proper ID
|
||||
$brandId = SnapUtil::filterInputRequest('id', FILTER_VALIDATE_INT, [ 'options' => ['default' => 0]]);
|
||||
$brandAction = !empty($_REQUEST['action']) && in_array($_REQUEST['action'], $acceptedActions) ? $_REQUEST['action'] : 'new';
|
||||
|
||||
if (
|
||||
(isset($_REQUEST['brand']) && $_REQUEST['brand'] == 'default') ||
|
||||
($brandId <= 0 && !in_array($brandAction, array('new', 'save')))
|
||||
) {
|
||||
$brandAction = 'default';
|
||||
}
|
||||
|
||||
switch ($brandAction) {
|
||||
case 'new':
|
||||
$brand = new BrandEntity();
|
||||
$brand->name = __('New Brand', 'duplicator-pro');
|
||||
break;
|
||||
case 'default':
|
||||
$brand = BrandEntity::getDefaultBrand();
|
||||
$brands = BrandEntity::getAllWithDefault();
|
||||
break;
|
||||
case 'edit':
|
||||
// Redirect to new brand if wrong ID is provided
|
||||
$editId = SnapUtil::filterInputRequest('id', FILTER_VALIDATE_INT, array('options' => array('default' => -1)));
|
||||
if (($brand = BrandEntity::getById($editId)) === false) {
|
||||
$redirect_url = ControllersManager::getMenuLink(
|
||||
ControllersManager::SETTINGS_SUBMENU_SLUG,
|
||||
SettingsPageController::L2_SLUG_PACKAGE,
|
||||
SettingsPageController::L3_SLUG_PACKAGE_BRAND,
|
||||
[
|
||||
'view' => 'edit',
|
||||
'action' => 'new',
|
||||
]
|
||||
);
|
||||
exit('
|
||||
<h1>' . __('This brand is not found or deleted. Please create new one.', 'duplicator-pro') . '</h1>
|
||||
<meta http-equiv="refresh" content="0; url=' . $redirect_url . '">
|
||||
<script type="text/javascript">
|
||||
window.location.href = "' . $redirect_url . '"
|
||||
</script>
|
||||
');
|
||||
}
|
||||
break;
|
||||
case 'save':
|
||||
DUP_PRO_U::verifyNonce($_POST['_wpnonce'], 'duplicator-pro-brand-edit');
|
||||
$was_updated = true;
|
||||
$saveId = filter_input(INPUT_POST, 'id', FILTER_VALIDATE_INT, array('options' => array('default' => -1)));
|
||||
if (($brand = BrandEntity::getById($saveId)) === false) {
|
||||
$brand = new BrandEntity();
|
||||
}
|
||||
$brand->name = DUP_PRO_U::setVal(stripslashes($_POST['name']), __('New Brand', 'duplicator-pro'));
|
||||
$brand->setAttachments(DUP_PRO_U::isEmpty((isset($_POST['attachments']) ? $_POST['attachments'] : array()), array()));
|
||||
$brand->notes = DUP_PRO_U::setVal(stripslashes($_POST['notes']), '');
|
||||
$brand->logo = stripcslashes(DUP_PRO_U::setVal($_POST['logo'], ''));
|
||||
$brand->save();
|
||||
break;
|
||||
default:
|
||||
$brand = new BrandEntity();
|
||||
break;
|
||||
}
|
||||
// DEBUG
|
||||
//echo '<pre>',print_r($_POST),'</pre><hr>';
|
||||
//$a = BrandEntity::get_active();
|
||||
//echo '<pre>',print_r($a),'</pre><hr>';
|
||||
?>
|
||||
|
||||
<style>
|
||||
#dup-storage-form input[type="text"], input[type="password"] { width: 250px;}
|
||||
#dup-storage-form input#name {width:100%; max-width: 500px}
|
||||
#dup-storage-form input#_local_storage_folder {width:100% !important; max-width: 500px}
|
||||
td.dpro-sub-title {padding:0; margin: 0}
|
||||
td.dpro-sub-title b{padding:20px 0; margin: 0; display:block; font-size:1.25em;}
|
||||
input#max_default_store_files {width:50px !important}
|
||||
form#dpro-package-brand-form {padding: 0}
|
||||
form#dpro-package-brand-form input[type="text"] { width:350px;}
|
||||
form#dpro-package-brand-form .readonly {background:transparent; border:none;}
|
||||
textarea#brand-notes {width:350px;}
|
||||
textarea#brand-logo {width:600px; height:120px; font-size: 12px}
|
||||
textarea#brand-default-logo {width:600px;; height:50px; font-size: 12px}
|
||||
div.style-guide-link {text-align: right; width: 100%; display: inline-block; margin:0 0 5px 0}
|
||||
table.form-table {width:800px}
|
||||
div.dpro-dlg-alert-txt {line-height: 20px; font-size: 14px !important}
|
||||
|
||||
div.preview-area {border:2px dashed #CDCDCD; width:95%; height:auto; background:#fff; font-family: Verdana,Arial,sans-serif;}
|
||||
div.preview-box {border:1px solid #CDCDCD; border-radius: 5px; max-width: 750px; margin: 10px auto 0 auto; height:auto; border-bottom: 1px dashed #999}
|
||||
div.preview-header {height:auto; background: #F1F1F1; box-shadow: 0 5px 3px -3px #999;}
|
||||
div.preview-title {font-size:26px; padding:10px 0 7px 15px; font-weight: bold; min-height:30px; display: flex; justify-content: space-between;}
|
||||
div.preview-content {padding:8px 15px 0 15px; clear:both}
|
||||
div.preview-version {white-space:nowrap; color:#777; font-size:11px; font-style:italic; text-align:right; padding:0 15px 5px 0; line-height: 14px; font-weight:normal; align-self: center;}
|
||||
div.preview-version a {color:#999}
|
||||
div.preview-mode {text-align: right; color:#999; font-style: italic; font-size: 12px}
|
||||
div.preview-steps {font-size: 22px; padding: 0 0 5px 0; border-bottom: 1px solid #D3D3D3; font-weight: bold; margin: 15px 0 20px 0;}
|
||||
div.preview-steps b {color:red}
|
||||
div#preview-logo {display: inline-block}
|
||||
#preview-logo img {max-width:100%}
|
||||
div.preview-notes {text-align:center; font-style: italic; font-size: 12px; margin:5px}
|
||||
</style>
|
||||
|
||||
<?php
|
||||
if ($was_updated) {
|
||||
$update_message = 'Brand Saved!';
|
||||
echo "<div class='notice notice-success is-dismissible dpro-wpnotice-box'><p>{$update_message}</p></div>";
|
||||
}
|
||||
?>
|
||||
<!-- ====================
|
||||
TOOL-BAR -->
|
||||
<table class="dpro-edit-toolbar">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<div class="btnnav">
|
||||
<a href="<?php echo $brand_list_url; ?>" class="button"> <i class="far fa-image"></i> <?php esc_html_e('Brands', 'duplicator-pro'); ?></a>
|
||||
<?php if ($brandAction != 'new') : ?>
|
||||
<a href="<?php echo esc_url($brand_edit_url . "&action=new"); ?>" class="button"><?php esc_html_e('Add New', 'duplicator-pro'); ?></a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<hr class="dpro-edit-toolbar-divider"/>
|
||||
|
||||
<form id="dpro-package-brand-form" class="dup-monitored-form" action="<?php echo esc_url($brand_edit_url); ?>" method="post" data-parsley-ui-enabled="true">
|
||||
<?php wp_nonce_field(Duplicator\Controllers\SettingsPageController::NONCE_ACTION); ?>
|
||||
<input type="hidden" name="id" id="brand-id" value="<?php echo $brand->getId(); ?>" />
|
||||
<input type="hidden" name="attachments" id="brand-attachments" value="<?php echo join(";", $brand->attachments); ?>" />
|
||||
<input type="hidden" name="action" id="brand-action" value="<?php echo esc_attr($brandAction); ?>" />
|
||||
|
||||
<?php if ($brandAction == 'default') : ?>
|
||||
<table class="provider form-table">
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Name", 'duplicator-pro'); ?></label></th>
|
||||
<td><?php echo $brand->name; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Notes", 'duplicator-pro'); ?></label></th>
|
||||
<td><?php echo $brand->notes; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Logo", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<div class="style-guide-link">
|
||||
<a href="javascript:void" class="button button-small" onclick="DupPro.Brand.ShowStyleGuide();"><?php esc_html_e("Style Guide", 'duplicator-pro'); ?></a>
|
||||
</div>
|
||||
<textarea id="brand-default-logo" readonly="true"><?php echo $brand->logo; ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Activation", 'duplicator-pro'); ?></label></th>
|
||||
<td><?php esc_html_e("This brand can be activated by using the installer brand drop-down during the package creation process. It can also be set via a template.", 'duplicator-pro'); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<i><?php esc_html_e("The default brand cannot be changed", 'duplicator-pro'); ?></i>
|
||||
<br/><br/>
|
||||
<?php else : ?>
|
||||
<table class="provider form-table">
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Name", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<input type="text" name="name" id="brand-name" value="<?php echo esc_attr($brand->name); ?>" data-parsley-required>
|
||||
<p class="description"><?php esc_html_e("Displayed as the page title of the installer.", 'duplicator-pro'); ?></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Notes", 'duplicator-pro'); ?></label></th>
|
||||
<td><textarea name="notes" id="brand-notes"><?php echo $brand->notes; ?></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Logo", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<div class="style-guide-link">
|
||||
<a href="javascript:void" class="button button-small" onclick="DupPro.Brand.ShowStyleGuide();"><?php esc_html_e("Style Guide", 'duplicator-pro'); ?></a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
wp_editor(
|
||||
$brand->logo,
|
||||
'brand-logo',
|
||||
array(
|
||||
'wpautop' => true,
|
||||
'media_buttons' => true,
|
||||
'textarea_name' => 'logo',
|
||||
'textarea_rows' => 50,
|
||||
'tabindex' => '',
|
||||
'tabfocus_elements' => ':prev,:next',
|
||||
'editor_css' => '',
|
||||
'editor_class' => 'required',
|
||||
'teeny' => false,
|
||||
'dfw' => false,
|
||||
'tinymce' => false,
|
||||
'quicktags' => array('buttons' => 'strong,em,i,ins,close,img,link'),
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Activation", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<?php esc_html_e("This brand can be activated by using the installer brand drop-down during the package creation process. It can also be set via a template.", 'duplicator-pro'); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ================================
|
||||
PREVIEW AREA -->
|
||||
<h2><?php esc_html_e('Preview Area:', 'duplicator-pro'); ?></h2>
|
||||
<div class="preview-area">
|
||||
<div class="preview-box">
|
||||
<div class="preview-header">
|
||||
<div class="preview-title">
|
||||
<div id="preview-logo">
|
||||
<?php echo $brand->logo; ?>
|
||||
</div>
|
||||
<div class="preview-version">
|
||||
<?php esc_html_e("version: ", 'duplicator-pro');
|
||||
echo DUPLICATOR_PRO_VERSION; ?> <br/>
|
||||
» <a href="javascript:void(0)"><?php esc_html_e("info", 'duplicator-pro'); ?></a> » <a href="javascript:void(0)"><?php esc_html_e("help", 'duplicator-pro'); ?></a> <i class="fas fa-question-circle fa-sm"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="preview-content">
|
||||
<div class="preview-mode"><?php esc_html_e("Mode: Standard Install", 'duplicator-pro'); ?></div>
|
||||
<div class="preview-steps">
|
||||
<?php echo __("Step <b>1</b> of 4: Deployment", 'duplicator-pro'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="preview-notes">
|
||||
<?php esc_html_e("Note: Be sure to validate the final results in the installer.php file.", 'duplicator-pro'); ?>
|
||||
</div>
|
||||
</div>
|
||||
<br style="clear:both" />
|
||||
<?php
|
||||
wp_nonce_field('duplicator-pro-brand-edit');
|
||||
?>
|
||||
<button
|
||||
id="dup-save-brand-button"
|
||||
class="button button-primary" type="button"
|
||||
onclick="return DupPro.Settings.Brand.Save();"
|
||||
<?php
|
||||
//$brands is only defined for the default brand
|
||||
if (isset($brands) && $brand->getId() === $brands[0]->getId()) {
|
||||
disabled(true);
|
||||
}
|
||||
?>
|
||||
>
|
||||
<?php esc_html_e('Save Brand', 'duplicator-pro'); ?>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<!-- ==========================================
|
||||
THICK-BOX DIALOGS: -->
|
||||
<?php
|
||||
$guide_msg = __('The brandable area allows for a loose set of html and custom styling. Below is a general guide.', 'duplicator-pro');
|
||||
$guide_msg .= '<br/><br/>';
|
||||
$guide_msg .= __('- <b>Embed Image:</b><br/> <img src="/wp-content/uploads/image.png /> <br/><br/>', 'duplicator-pro');
|
||||
$guide_msg .= __('- <b>Text Only:</b><br/> My Installer Name <br/><br/>', 'duplicator-pro');
|
||||
$guide_msg .= __(
|
||||
'- <b>Text & Font-Awesome:</b><br/> <i class="fa fa-cube"></i>
|
||||
My Company <br/><small>Note: <a href="http://fontawesome.io/icons/" target="_blank">Font-Awesome 4.7</a>
|
||||
is the referenced library</small><br/><br/>',
|
||||
'duplicator-pro'
|
||||
);
|
||||
|
||||
$alert1 = new DUP_PRO_UI_Dialog();
|
||||
$alert1->title = __('Branding Guide', 'duplicator-pro');
|
||||
$alert1->message = $guide_msg;
|
||||
$alert1->width = 650;
|
||||
$alert1->height = 350;
|
||||
$alert1->initAlert();
|
||||
|
||||
$alert2 = new DUP_PRO_UI_Dialog();
|
||||
$alert2->title = __('Brand Name', 'duplicator-pro');
|
||||
$alert2->message = __("WARNING: Brand name cannot be named like <strong>Default</strong> because is a reserved name.", 'duplicator-pro');
|
||||
$alert2->initAlert();
|
||||
|
||||
$alert3 = new DUP_PRO_UI_Dialog();
|
||||
$alert3->title = __('Brand Logo', 'duplicator-pro');
|
||||
$alert3->message = __("WARNING: Brand logo have a wrong URL.", 'duplicator-pro');
|
||||
$alert3->initAlert();
|
||||
?>
|
||||
|
||||
<script>
|
||||
DupPro.Brand = new Object();
|
||||
|
||||
/* Shows the style Guide */
|
||||
DupPro.Brand.ShowStyleGuide = function()
|
||||
{
|
||||
<?php $alert1->showAlert(); ?>
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
jQuery(document).ready(function ($)
|
||||
{
|
||||
/*
|
||||
* CHECK IS IMAGE
|
||||
* @url: https://github.com/CreativForm/CreativeTools
|
||||
*/
|
||||
$.isImage = function(string) {
|
||||
if(null === string || false === string)
|
||||
return false;
|
||||
return ((string.match(/\.(jpeg|jpg|gif|png|bmp|svg|tiff|jfif|exif|ppm|pgm|pbm|pnm|webp|hdr|hif|bpg|img|pam|tga|psd|psp|xcf|cpt|vicar)$/)!=null) ? true : false);
|
||||
};
|
||||
|
||||
/*
|
||||
* CHECK IF IMAGE EXISTS
|
||||
* @url: https://github.com/CreativForm/CreativeTools
|
||||
*/
|
||||
$.imageExists = function(string,callback){
|
||||
if($.isImage(string)){
|
||||
var img = new Image(10,10);
|
||||
img.src = string;
|
||||
img.onload = function() {
|
||||
if(typeof callback == 'function'){
|
||||
callback(true);
|
||||
img = null;
|
||||
}
|
||||
};
|
||||
img.onerror = function() {
|
||||
if(typeof callback == 'function'){
|
||||
callback(false);
|
||||
img = null;
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if(typeof callback == 'function'){
|
||||
callback(false);
|
||||
img = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
var strip_tags = function (input, allowed) {
|
||||
// discuss at: http://phpjs.org/functions/strip_tags/
|
||||
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// improved by: Luke Godfrey
|
||||
// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// input by: Pul
|
||||
// input by: Alex
|
||||
// input by: Marc Palau
|
||||
// input by: Brett Zamir (http://brett-zamir.me)
|
||||
// input by: Bobby Drake
|
||||
// input by: Evertjan Garretsen
|
||||
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// bugfixed by: Onno Marsman
|
||||
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// bugfixed by: Eric Nagel
|
||||
// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
||||
// bugfixed by: Tomasz Wesolowski
|
||||
// revised by: Rafał Kukawski (http://blog.kukawski.pl/)
|
||||
// example 1: strip_tags('<p>Kevin</p> <br /><b>van</b> <i>Zonneveld</i>', '<i><b>');
|
||||
// returns 1: 'Kevin <b>van</b> <i>Zonneveld</i>'
|
||||
// example 2: strip_tags('<p>Kevin <img src="someimage.png" onmouseover="someFunction()">van <i>Zonneveld</i></p>', '<p>');
|
||||
// returns 2: '<p>Kevin van Zonneveld</p>'
|
||||
// example 3: strip_tags("<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>", "<a>");
|
||||
// returns 3: "<a href='http://kevin.vanzonneveld.net'>Kevin van Zonneveld</a>"
|
||||
// example 4: strip_tags('1 < 5 5 > 1');
|
||||
// returns 4: '1 < 5 5 > 1'
|
||||
// example 5: strip_tags('1 <br/> 1');
|
||||
// returns 5: '1 1'
|
||||
// example 6: strip_tags('1 <br/> 1', '<br>');
|
||||
// returns 6: '1 <br/> 1'
|
||||
// example 7: strip_tags('1 <br/> 1', '<br><br/>');
|
||||
// returns 7: '1 <br/> 1'
|
||||
|
||||
var allowed = (((allowed || '') + '')
|
||||
.toLowerCase()
|
||||
.match(/<[a-z][a-z0-9]*>/g) || [])
|
||||
.join(''); // making sure the allowed arg is a string containing only tags in lowercase (<a><b><c>)
|
||||
var tags = /<\/?([a-z][a-z0-9]*)\b[^>]*>/gi,
|
||||
commentsAndPhpTags = /<!--[\s\S]*?-->|<\?(?:php)?[\s\S]*?\?>/gi;
|
||||
return input.replace(commentsAndPhpTags, '').replace(tags, function($0, $1) {
|
||||
return allowed.indexOf('<' + $1.toLowerCase() + '>') > -1 ? $0 : '';
|
||||
});
|
||||
}
|
||||
|
||||
DupPro.Settings.Debounce;
|
||||
DupPro.Settings.Brand.Save = function(e) {
|
||||
clearTimeout(DupPro.Settings.Debounce);
|
||||
if ($('#dpro-package-brand-form').parsley().validate()) {
|
||||
|
||||
var $logo = $("#brand-logo");
|
||||
|
||||
$('#brand-action').val('save');
|
||||
$logo.removeClass('parsley-error');
|
||||
var image_valid = true;
|
||||
// Check is images valid
|
||||
var images = $('<div />').html($logo.val()).children('img').map(function(){
|
||||
var image = $(this).attr('src');
|
||||
return image;
|
||||
}).get();
|
||||
|
||||
for(var i = 0; i < images.length; i++)
|
||||
{
|
||||
$.imageExists(images[i],function(r){
|
||||
if(!r)
|
||||
{
|
||||
image_valid = false;
|
||||
$logo.removeClass('parsley-success').addClass('parsley-error');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
DupPro.Settings.Debounce = setTimeout(function() {
|
||||
// Check is brand name reserved
|
||||
if($('#brand-name') && $.trim($('#brand-name').val()).toLowerCase() == 'default')
|
||||
{
|
||||
<?php $alert2->showAlert(); ?>
|
||||
e.preventDefault();
|
||||
|
||||
}
|
||||
else if (!image_valid)
|
||||
{
|
||||
<?php $alert3->showAlert(); ?>
|
||||
e.preventDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
DupPro.UI.hasUnsavedChanges = false;
|
||||
$('#dpro-package-brand-form').submit();
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
<?php if ($brandAction != 'default') : ?>
|
||||
//INIT
|
||||
$('#dpro-package-brand-form #brand-name').focus();
|
||||
|
||||
// Let's automate this things
|
||||
DupPro.Settings.Automatization = function(e){
|
||||
|
||||
if (e.originalEvent !== undefined)
|
||||
{
|
||||
clearTimeout(DupPro.Settings.Debounce);
|
||||
var $this = $("#dpro-package-brand-form #brand-logo"),
|
||||
$debounce = 800
|
||||
$button = $('#dpro-package-brand-form .button-primary');
|
||||
|
||||
// Smart debounce
|
||||
if(e.currentTarget)
|
||||
{
|
||||
if($(e.currentTarget).hasClass('button')) $debounce = 5;
|
||||
if($(e.currentTarget).hasClass('preview-area')) $debounce = 200;
|
||||
}
|
||||
|
||||
// $button.find('.fa-circle-notch').remove();
|
||||
// if(!$(e.currentTarget).hasClass('button')) $button.prop('disabled',true).prepend('<i class="fas fa-circle-notch fa-spin"></i> ');
|
||||
|
||||
DupPro.Settings.Debounce = setTimeout(function() {
|
||||
var $value = $this.val();
|
||||
|
||||
// $button.prop('disabled',false).find('.fa-circle-notch').remove();
|
||||
$this.val(strip_tags($value,'<a><i><b><u><em><ins><div><img><span><strong>'));
|
||||
|
||||
// Do preview
|
||||
$("#dpro-package-brand-form #preview-logo").html($value);
|
||||
|
||||
// Now we must made array for path of all images (if the are on server) We don't need remote images (CDN is cool thing)
|
||||
// Let's first collect all images
|
||||
var images = $('<div />').html($value).children('img').map(function(){
|
||||
return $(this).attr('src')
|
||||
}).get();
|
||||
images = $.unique(images);
|
||||
$("#dpro-package-brand-form #brand-attachments").val('');
|
||||
|
||||
// New magic trick is to determinate is CDN or uploaded image
|
||||
// - CDN will not be return like path
|
||||
// - Server side images will be returned like image real path
|
||||
if(images.length > 0)
|
||||
{
|
||||
var path = images.map(function(src){
|
||||
|
||||
var hostname = "<?php echo WP_PLUGIN_URL ?>".replace(/https?|\:\/\/|\/wp-content\/plugins/gi,'');
|
||||
|
||||
if(new RegExp('(https?:)?//' + hostname,'ig').test(src))
|
||||
{
|
||||
return src.replace(new RegExp('(https?:)?//' + hostname + '/wp-content|/uploads','ig'), '');
|
||||
}
|
||||
});
|
||||
|
||||
if(path.length > 0) $("#dpro-package-brand-form #brand-attachments").val(path.join(';'));
|
||||
}
|
||||
|
||||
},$debounce);
|
||||
}
|
||||
};
|
||||
// On textarea change
|
||||
$(document).on('change keyup paste input mouseout mouseover propertychange',"#dpro-package-brand-form #brand-logo", DupPro.Settings.Automatization);
|
||||
// On other boxes
|
||||
$(document).on('mouseover',"#dpro-package-brand-form .button-primary, #dpro-package-brand-form .preview-area", DupPro.Settings.Automatization);
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,387 @@
|
||||
<?php
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Addons\ProBase\License\License;
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
use Duplicator\Models\BrandEntity;
|
||||
|
||||
$brand_list_url = ControllersManager::getCurrentLink(array('view' => 'list'));
|
||||
$brand_edit_url = ControllersManager::getCurrentLink(array('view' => 'edit'));
|
||||
|
||||
if (!empty($_REQUEST['action'])) {
|
||||
//check_admin_referer(Duplicator\Controllers\SettingsPageController::NONCE_ACTION);
|
||||
|
||||
$action = $_REQUEST['action'];
|
||||
switch ($action) {
|
||||
case 'bulk-delete':
|
||||
$brand_ids = $_REQUEST['selected_id'];
|
||||
foreach ($brand_ids as $brand_id) {
|
||||
BrandEntity::deleteById($brand_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$brand_id = (int) $_REQUEST['brand_id'];
|
||||
BrandEntity::deleteById($brand_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$brands = BrandEntity::getAllWithDefault();
|
||||
$brand_count = count($brands);
|
||||
?>
|
||||
|
||||
<style>
|
||||
/*Detail Tables */
|
||||
table.brand-tbl td {height: 45px}
|
||||
table.brand-tbl a.name {font-weight: bold}
|
||||
table.brand-tbl input[type='checkbox'] {margin-left: 5px}
|
||||
table.brand-tbl div.sub-menu {margin: 5px 0 0 2px; display: none}
|
||||
table tr.brand-detail {display:none; margin: 0;}
|
||||
table tr.brand-detail td { padding: 3px 0 5px 20px}
|
||||
table tr.brand-detail div {line-height: 20px; padding: 2px 2px 2px 15px}
|
||||
table tr.brand-detail td button {margin:5px 0 5px 0 !important; display: block}
|
||||
tr.brand-detail label {min-width: 150px; display: inline-block; font-weight: bold}
|
||||
form#dup-brand-form {padding:0}
|
||||
</style>
|
||||
|
||||
<div <?php echo (License::can(License::CAPABILITY_BRAND) ? "style='display:none'" : ""); ?>>
|
||||
<h2><?php esc_html_e("Installer Branding", 'duplicator-pro') ?></h2>
|
||||
<hr size="1"/>
|
||||
|
||||
<div style="width:850px">
|
||||
<?php
|
||||
esc_html_e(
|
||||
"Create your own WordPress distribution by adding a custom name and logo to the installer!
|
||||
Installer branding lets you create multiple brands for your installers and then choose
|
||||
which one you want when the package is built (example shown below).",
|
||||
'duplicator-pro'
|
||||
);
|
||||
?>
|
||||
<br/><br/>
|
||||
<?php
|
||||
printf(
|
||||
__(
|
||||
'This option isn\'t available at the <b>%1$s</b> license level.',
|
||||
'duplicator-pro'
|
||||
),
|
||||
License::getLicenseToString()
|
||||
);
|
||||
?>
|
||||
<b>
|
||||
<?php
|
||||
printf(
|
||||
_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>
|
||||
</div>
|
||||
|
||||
<div style="border:0px solid #999; padding: 5px; margin: 5px; border-radius: 5px; width:700px">
|
||||
<img src="<?php echo DUPLICATOR_PRO_IMG_URL ?>/dpro-brand.png" style='' />
|
||||
</div>
|
||||
<br/><br/>
|
||||
</div>
|
||||
|
||||
<!-- ====================
|
||||
TOOL-BAR -->
|
||||
<div <?php echo (License::can(License::CAPABILITY_BRAND) ? "" : "style='display:none'"); ?>>
|
||||
<table class="dpro-edit-toolbar">
|
||||
<tr>
|
||||
<td>
|
||||
<select id="bulk_action">
|
||||
<option value="-1" selected="selected"><?php _e('Bulk Actions', 'duplicator-pro'); ?></option>
|
||||
<option value="delete" title="<?php esc_attr_e('Delete selected brand endpoint(s)', 'duplicator-pro'); ?>"><?php _e('Delete', 'duplicator-pro'); ?></option>
|
||||
</select>
|
||||
<input type="button" class="button action" value="<?php esc_html_e("Apply", 'duplicator-pro') ?>" onclick="DupPro.Settings.Brand.BulkAction()">
|
||||
</td>
|
||||
<td>
|
||||
<div class="btnnav">
|
||||
<a href="javascript:void(0)" onclick="DupPro.Settings.Brand.AddNew()" class="button"><?php esc_html_e('Add New', 'duplicator-pro'); ?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<form id="dup-brand-form" action="<?php echo $brand_list_url; ?>" method="post">
|
||||
<?php wp_nonce_field(Duplicator\Controllers\SettingsPageController::NONCE_ACTION); ?>
|
||||
<input type="hidden" id="dup-brand-form-action" name="action" value=""/>
|
||||
<input type="hidden" id="dup-selected-brand" name="brand_id" value="-1"/>
|
||||
|
||||
<!-- ====================
|
||||
LIST ALL STORAGE -->
|
||||
<table class="widefat brand-tbl">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style='width:10px;'><input type="checkbox" id="dpro-chk-all" title="Select all brand endpoints" onclick="DupPro.Settings.Brand.SetAll(this)"></th>
|
||||
<th style='width:100%;'><?php esc_html_e('Name', 'duplicator-pro'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
ob_start(); // Must transfer data after default brand item
|
||||
$i = 0;
|
||||
foreach ($brands as $x => $brand) :
|
||||
if ($x === 0) {
|
||||
continue; // remove default item in list because is defined out of loop below
|
||||
}
|
||||
$i++;
|
||||
|
||||
//$brand_type = $brand->getModeText();
|
||||
?>
|
||||
<tr id='main-view-<?php echo $brand->getId() ?>' class="brand-row<?php echo ($i % 2) ? ' alternate' : ''; ?>">
|
||||
<td>
|
||||
<?php if ($brand->editable) : ?>
|
||||
<input name="selected_id[]" type="checkbox" value="<?php echo $brand->getId(); ?>" class="item-chk" />
|
||||
<?php else : ?>
|
||||
<input type="checkbox" disabled="disabled" />
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Edit('<?php echo $brand->getId(); ?>')"><b><?php echo esc_html($brand->name); ?></b></a>
|
||||
<?php if ($brand->editable) : ?>
|
||||
<div class="sub-menu">
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Edit('<?php echo $brand->getId(); ?>')"><?php esc_html_e('Edit', 'duplicator-pro') ?></a> |
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.View('<?php echo $brand->getId(); ?>');"><?php esc_html_e('Quick View', 'duplicator-pro') ?></a> |
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Delete('<?php echo $brand->getId(); ?>');"><?php esc_html_e('Delete', 'duplicator-pro') ?></a>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="sub-menu">
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Edit(0)"><?php esc_html_e('View', 'duplicator-pro') ?></a> |
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.View('<?php echo $brand->getId(); ?>');"><?php esc_html_e('Quick View', 'duplicator-pro') ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id='quick-view-<?php echo $brand->getId() ?>' class='<?php echo ($i % 2) ? 'alternate ' : ''; ?>brand-detail'>
|
||||
<td colspan="3">
|
||||
<b><?php esc_html_e('QUICK VIEW', 'duplicator-pro') ?></b> <br/>
|
||||
<div>
|
||||
<label><?php esc_html_e('Name', 'duplicator-pro') ?>:</label>
|
||||
<?php echo esc_html($brand->name); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label><?php esc_html_e('Notes', 'duplicator-pro') ?>:</label>
|
||||
<?php echo (strlen($brand->notes)) ? esc_html($brand->notes) : __('(no notes)', 'duplicator-pro'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label><?php esc_html_e('Logo', 'duplicator-pro') ?>:</label>
|
||||
<?php echo $brand->logo ?>
|
||||
</div>
|
||||
<button type="button" class="button" onclick="DupPro.Settings.Brand.View('<?php echo $brand->getId(); ?>');"><?php esc_html_e('Close', 'duplicator-pro') ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
$display_brand_list = ob_get_clean(); // save generated list into string
|
||||
?>
|
||||
<!-- DEFAULT BRAND ITEM -->
|
||||
<tr id='main-view-<?php echo $brands[0]->getId(); ?>' class="brand-row">
|
||||
<td>
|
||||
<input type="checkbox" disabled="disabled" />
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Edit(0)"><b><?php esc_html_e('Default', 'duplicator-pro'); ?></b></a>
|
||||
<div class="sub-menu">
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.Edit(0)"><?php esc_html_e('View', 'duplicator-pro'); ?></a> |
|
||||
<a href="javascript:void(0);" onclick="DupPro.Settings.Brand.View('<?php echo $brands[0]->getId(); ?>');"><?php esc_html_e('Quick View', 'duplicator-pro'); ?></a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="quick-view-<?php echo $brands[0]->getId() ?>" class="brand-detail">
|
||||
<td colspan="3">
|
||||
<b><?php esc_html_e('QUICK VIEW', 'duplicator-pro') ?></b> <br/>
|
||||
<div>
|
||||
<label><?php esc_html_e('Name', 'duplicator-pro') ?>:</label>
|
||||
<?php echo $brands[0]->name ?>
|
||||
</div>
|
||||
<div>
|
||||
<label><?php esc_html_e('Notes', 'duplicator-pro') ?>:</label>
|
||||
<?php echo (strlen($brands[0]->notes)) ? $brands[0]->notes : __('(no notes)', 'duplicator-pro'); ?>
|
||||
</div>
|
||||
<div>
|
||||
<label><?php esc_html_e('Logo', 'duplicator-pro') ?>:</label>
|
||||
<?php echo $brands[0]->logo ?>
|
||||
</div>
|
||||
<button type="button" class="button" onclick="DupPro.Settings.Brand.View('<?php echo $brands[0]->getId(); ?>');"><?php esc_html_e('Close', 'duplicator-pro') ?></button>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END DEFAULT BRAND ITEM -->
|
||||
|
||||
<!-- DYNAMIC BRAND ITEMS -->
|
||||
<?php echo $display_brand_list; ?>
|
||||
<!-- END DYNAMIC BRAND ITEMS -->
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="8" style="text-align:right; font-size:12px">
|
||||
<?php echo __('Total', 'duplicator-pro') . ': ' . $brand_count; ?>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<!-- ==========================================
|
||||
THICK-BOX DIALOGS: -->
|
||||
<?php
|
||||
$alert1 = new DUP_PRO_UI_Dialog();
|
||||
$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 DUP_PRO_UI_Dialog();
|
||||
$alert2->title = __('Selection Required', 'duplicator-pro');
|
||||
$alert2->message = __('Please select at least one brand to delete!', 'duplicator-pro');
|
||||
$alert2->initAlert();
|
||||
|
||||
$confirm1 = new DUP_PRO_UI_Dialog();
|
||||
$confirm1->title = __('Delete Brand?', 'duplicator-pro');
|
||||
$confirm1->message = __('Are you sure you want to delete the selected brand(s)?', 'duplicator-pro');
|
||||
$confirm1->message .= '<br/>';
|
||||
$confirm1->message .= '<small><i>' . __('Note: This action removes all brands.', 'duplicator-pro') . '</i></small>';
|
||||
$confirm1->progressText = __('Removing Brands, Please Wait...', 'duplicator-pro');
|
||||
$confirm1->jsCallback = 'DupPro.Settings.Brand.BulkDelete()';
|
||||
$confirm1->initConfirm();
|
||||
|
||||
$confirm2 = new DUP_PRO_UI_Dialog();
|
||||
$confirm2->title = __('Delete Brand?', 'duplicator-pro');
|
||||
$confirm2->message = __('Are you sure you want to delete the selected brand(s)?', 'duplicator-pro');
|
||||
$confirm2->progressText = __('Removing Brands, Please Wait...', 'duplicator-pro');
|
||||
$confirm2->jsCallback = 'DupPro.Settings.Brand.DeleteThis(this)';
|
||||
$confirm2->initConfirm();
|
||||
|
||||
$delete_nonce = wp_create_nonce('duplicator_pro_brand_delete');
|
||||
?>
|
||||
<script>
|
||||
jQuery(document).ready(function ($) {
|
||||
|
||||
//Shows detail view
|
||||
DupPro.Settings.Brand.AddNew = function ()
|
||||
{
|
||||
document.location.href = '<?php echo "{$brand_edit_url}&action=new"; ?>';
|
||||
}
|
||||
|
||||
DupPro.Settings.Brand.Edit = function (id)
|
||||
{
|
||||
if (id == 0) {
|
||||
document.location.href = '<?php echo "{$brand_edit_url}&action=default&id="; ?>' + id;
|
||||
} else {
|
||||
document.location.href = '<?php echo "{$brand_edit_url}&action=edit&id="; ?>' + id;
|
||||
}
|
||||
}
|
||||
|
||||
//Shows detail view
|
||||
DupPro.Settings.Brand.View = function (id)
|
||||
{
|
||||
$('#quick-view-' + id).toggle();
|
||||
$('#main-view-' + id).toggle();
|
||||
}
|
||||
|
||||
//Delets a single record
|
||||
DupPro.Settings.Brand.Delete = function (id)
|
||||
{
|
||||
<?php $confirm2->showConfirm(); ?>
|
||||
$("#<?php echo $confirm2->getID(); ?>-confirm").attr('data-id', id);
|
||||
}
|
||||
|
||||
DupPro.Settings.Brand.DeleteThis = function (e)
|
||||
{
|
||||
var id = $(e).attr('data-id');
|
||||
jQuery("#dup-brand-form-action").val('delete');
|
||||
jQuery("#dup-selected-brand").val(id);
|
||||
jQuery("#dup-brand-form").submit()
|
||||
}
|
||||
|
||||
// Creats a comma seperate list of all selected package ids
|
||||
DupPro.Settings.Brand.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;
|
||||
}
|
||||
|
||||
// Bulk delete
|
||||
DupPro.Settings.Brand.BulkDelete = function ()
|
||||
{
|
||||
var list = DupPro.Settings.Brand.DeleteList();
|
||||
var pageCount = $('#current-page-selector').val();
|
||||
var pageItems = $("input[name^='selected_id[]']");
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajaxurl,
|
||||
dataType: "json",
|
||||
data: {
|
||||
action: 'duplicator_pro_brand_delete',
|
||||
brand_ids: list,
|
||||
nonce: '<?php echo $delete_nonce; ?>'
|
||||
},
|
||||
}).done(function (data) {
|
||||
$('#dup-brand-form').submit();
|
||||
});
|
||||
}
|
||||
|
||||
// Confirm bulk action
|
||||
DupPro.Settings.Brand.BulkAction = function ()
|
||||
{
|
||||
var list = DupPro.Settings.Brand.DeleteList();
|
||||
|
||||
if (list.length == 0) {
|
||||
<?php $alert2->showAlert(); ?>
|
||||
return;
|
||||
}
|
||||
|
||||
var action = $('#bulk_action').val();
|
||||
var 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Sets all for deletion
|
||||
DupPro.Settings.Brand.SetAll = function (chkbox) {
|
||||
$('.item-chk').each(function () {
|
||||
this.checked = chkbox.checked;
|
||||
});
|
||||
}
|
||||
|
||||
//Name hover show menu
|
||||
$("tr.brand-row").hover(
|
||||
function () {
|
||||
$(this).find(".sub-menu").show();
|
||||
},
|
||||
function () {
|
||||
$(this).find(".sub-menu").hide();
|
||||
}
|
||||
);
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
//silent
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/* @var $global DUP_PRO_Global_Entity */
|
||||
|
||||
defined("ABSPATH") or die("");
|
||||
?>
|
||||
|
||||
<style>
|
||||
input#package_mysqldump_path_found {margin-top:5px}
|
||||
div.dup-feature-found {padding:0; color: green; display: inline-block;}
|
||||
div.dup-feature-notfound {padding:5px; color: maroon; width:600px;}
|
||||
input#_package_mysqldump_path {width:500px}
|
||||
#dpro-ziparchive-mode-st, #dpro-ziparchive-mode-mt {height: 28px; padding-top:5px; display: none}
|
||||
div.engine-radio {float: left; min-width: 100px}
|
||||
div.engine-sub-opts {padding-top:10px}
|
||||
div.engine-sub-opts fieldset {
|
||||
border: 1px solid #999;
|
||||
padding: 15px ;
|
||||
line-height: 30px;
|
||||
}
|
||||
div.engine-sub-opts label {
|
||||
display: inline-block;
|
||||
min-width: 100px;
|
||||
margin-bottom: 5px;
|
||||
line-height: 30px !important;
|
||||
}
|
||||
div.engine-sub-opts input:not([type=checkbox]):not([type=radio]):not([type=button]),
|
||||
div.engine-sub-opts select {
|
||||
box-sizing: border-box;
|
||||
min-width: 150px;
|
||||
}
|
||||
div#engine-details-match-message {display:none; margin: -5px 0 20px 220px; border: 1px solid silver; padding:5px 8px 5px 8px; background: #dfdfdf; border-radius: 5px; width:650px}
|
||||
|
||||
table#archive-build-schedule {display:none}
|
||||
span#archive-build-schedule-icon {display:none}
|
||||
|
||||
form.dup-settings-pack-basic table.form-table {margin-bottom:50px}
|
||||
</style>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
DupPro.Settings.Brand = new Object();
|
||||
</script>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/* @var $global DUP_PRO_Global_Entity */
|
||||
defined("ABSPATH") or die("");
|
||||
|
||||
use Duplicator\Core\Controllers\ControllersManager;
|
||||
|
||||
$nonce_action = 'duppro-settings-schedule-edit';
|
||||
$action_updated = null;
|
||||
$action_response = __("Schedule Settings Saved", 'duplicator-pro');
|
||||
|
||||
$global = DUP_PRO_Global_Entity::getInstance();
|
||||
|
||||
//SAVE RESULTS
|
||||
if (!empty($_POST['action']) && $_POST['action'] == 'save') {
|
||||
DUP_PRO_U::verifyNonce($_POST['_wpnonce'], $nonce_action);
|
||||
$global->send_email_on_build_mode = (int)$_REQUEST['send_email_on_build_mode'];
|
||||
$global->notification_email_address = stripslashes($_REQUEST['notification_email_address']);
|
||||
$action_updated = $global->save();
|
||||
}
|
||||
?>
|
||||
|
||||
<style>
|
||||
table.form-table tr td { padding-top: 25px; }
|
||||
</style>
|
||||
|
||||
<form id="dup-settings-form" action="<?php echo ControllersManager::getCurrentLink(); ?>" method="post" data-parsley-validate>
|
||||
<?php wp_nonce_field($nonce_action); ?>
|
||||
<input type="hidden" name="action" value="save">
|
||||
|
||||
<?php if ($action_updated) : ?>
|
||||
<div class="notice notice-success is-dismissible dpro-wpnotice-box"><p><?php echo $action_response; ?></p></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- ===============================
|
||||
SCHEDULE SETTINGS -->
|
||||
<h3 class="title"><?php esc_html_e("Notifications", 'duplicator-pro') ?> </h3>
|
||||
<hr size="1" />
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row"><label><?php esc_html_e("Send Build Email", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<input
|
||||
type="radio"
|
||||
name="send_email_on_build_mode"
|
||||
id="send_email_on_build_mode_never"
|
||||
value="<?php echo DUP_PRO_Email_Build_Mode::No_Emails; ?>"
|
||||
<?php checked($global->send_email_on_build_mode, DUP_PRO_Email_Build_Mode::No_Emails); ?>
|
||||
>
|
||||
<label for="send_email_on_build_mode_never"><?php esc_attr_e("Never", 'duplicator-pro'); ?></label>
|
||||
<input
|
||||
type="radio"
|
||||
name="send_email_on_build_mode"
|
||||
id="send_email_on_build_mode_failure"
|
||||
value="<?php echo DUP_PRO_Email_Build_Mode::Email_On_Failure; ?>"
|
||||
<?php checked($global->send_email_on_build_mode, DUP_PRO_Email_Build_Mode::Email_On_Failure); ?>
|
||||
>
|
||||
<label for="send_email_on_build_mode_failure"><?php esc_attr_e("On Failure", 'duplicator-pro'); ?></label>
|
||||
<input
|
||||
type="radio"
|
||||
name="send_email_on_build_mode"
|
||||
id="send_email_on_build_mode_always"
|
||||
value="<?php echo DUP_PRO_Email_Build_Mode::Email_On_All_Builds; ?>"
|
||||
<?php checked($global->send_email_on_build_mode, DUP_PRO_Email_Build_Mode::Email_On_All_Builds); ?>
|
||||
>
|
||||
<label for="send_email_on_build_mode_always"><?php esc_attr_e("Always", 'duplicator-pro'); ?></label>
|
||||
<p class="description">
|
||||
<?php
|
||||
esc_html_e("When to send emails after a scheduled build.", 'duplicator-pro');
|
||||
?>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="top">
|
||||
<th scope="row"><label><?php esc_html_e("Email Address", 'duplicator-pro'); ?></label></th>
|
||||
<td>
|
||||
<input
|
||||
style="display:block;margin-right:6px; width:25em;"
|
||||
data-parsley-errors-container="#notification_email_address_error_container"
|
||||
data-parsley-type="email"
|
||||
type="email"
|
||||
name="notification_email_address"
|
||||
id="notification_email_address" value="<?php echo esc_attr($global->notification_email_address); ?>"
|
||||
>
|
||||
<p class="description"> <?php esc_html_e('Admin email will be used if empty.', 'duplicator-pro'); ?> </p>
|
||||
<div id="notification_email_address_error_container" class="duplicator-error-container"></div>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p class="submit dpro-save-submit">
|
||||
<input type="submit" name="submit" id="submit" class="button-primary" value="<?php esc_attr_e('Save Schedule Settings', 'duplicator-pro') ?>" style="display: inline-block;" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function ($) {
|
||||
//Data
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user