first commit
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user