Changed source root directory

This commit is contained in:
2026-03-05 16:30:11 +01:00
parent dc85447ee1
commit 538f85d7a2
5868 changed files with 749734 additions and 99 deletions

View File

@@ -0,0 +1,220 @@
<?php
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* Used to generate a thick-box inline dialog such as an alert or confirm pop-up
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2
*
* @package Duplicator
* @subpackage classes/ui
* @copyright (c) 2017, Snapcreek LLC
*/
// Exit if accessed directly
if (! defined('DUPLICATOR_VERSION')) {
exit;
}
class DUP_UI_Dialog
{
/**
* The title that shows up in the dialog
*/
public $title;
/**
* The message displayed in the body of the dialog
*/
public $message;
/**
* The width of the dialog the default is used if not set
* Alert = 475px (default) | Confirm = 500px (default)
*/
public $width;
/**
* The height of the dialog the default is used if not set
* Alert = 125px (default) | Confirm = 150px (default)
*/
public $height;
/**
* When the progress meter is running show this text
* Available only on confirm dialogs
*/
public $progressText;
/**
* When true a progress meter will run until page is reloaded
* Available only on confirm dialogs
*/
public $progressOn = true;
/**
* The javascript call back method to call when the 'Yes' button is clicked
* Available only on confirm dialogs
*/
public $jscallback;
/**
*
* @var string
*/
public $okText;
/**
*
* @var string
*/
public $cancelText;
/**
* If true close dialog on confirm
*
* @var bool
*/
public $closeOnConfirm = false;
/**
* The id given to the full dialog
*/
private $id;
/**
* A unique id that is added to all id elements
*/
private $uniqid;
/**
* Init this object when created
*/
public function __construct()
{
add_thickbox();
$this->progressText = __('Processing please wait...', 'duplicator');
$this->uniqid = substr(uniqid('', true), 0, 14) . rand();
$this->id = 'dup-dlg-' . $this->uniqid;
$this->okText = __('OK', 'duplicator');
$this->cancelText = __('Cancel', 'duplicator');
}
/**
* Gets the unique id that is assigned to each instance of a dialog
*
* @return int The unique ID of this dialog
*/
public function getID()
{
return $this->id;
}
/**
* Gets the unique id that is assigned to each instance of a dialogs message text
*
* @return int The unique ID of the message
*/
public function getMessageID()
{
return "{$this->id}_message";
}
/**
* Initialize the alert base html code used to display when needed
*
* @return string The html content used for the alert dialog
*/
public function initAlert()
{
$onClickClose = '';
if (!is_null($this->jscallback)) {
$onClickClose .= $this->jscallback . ';';
}
$onClickClose .= 'tb_remove();';
$hideButton = "";
if (strlen($this->okText) == 0) {
$hideButton = "style='display:none'";
}
$html = '
<div id="' . esc_attr($this->id) . '" style="display:none">
<div class="dup-dlg-alert-txt">
' . $this->message . '
<br/><br/>
</div>
<div class="dup-dlg-alert-btns">
<input type="button" class="button button-large" value="' . esc_attr($this->okText) . '" onclick="' . $onClickClose . '" ' . $hideButton . '/>
</div>
</div>';
echo $html;
}
/**
* Shows the alert base JS code used to display when needed
*
* @return string The javascript content used for the alert dialog
*/
public function showAlert()
{
$this->width = is_numeric($this->width) ? $this->width : 500;
$this->height = is_numeric($this->height) ? $this->height : 175;
$html = "tb_show('" . esc_js($this->title) . "', '#TB_inline?width=" . esc_js($this->width) . "&height=" . esc_js($this->height) . "&inlineId=" . esc_js($this->id) . "');\n" .
"var styleData = jQuery('#TB_window').attr('style') + 'height: " . esc_js($this->height) . "px !important';\n" .
"jQuery('#TB_window').attr('style', styleData);";
echo $html;
}
/**
* Shows the confirm base JS code used to display when needed
*
* @return string The javascript content used for the confirm dialog
*/
public function initConfirm()
{
$progress_data = '';
$progress_func2 = '';
$onClickConfirm = '';
if (!is_null($this->jscallback)) {
$onClickConfirm .= $this->jscallback . ';';
}
//Enable the progress spinner
if ($this->progressOn) {
$progress_func1 = "__DUP_UI_Dialog_" . $this->uniqid;
$progress_func2 = ";{$progress_func1}(this)";
$progress_data = "<div class='dup-dlg-confirm-progress'><i class='fas fa-circle-notch fa-spin fa-lg fa-fw'></i> " . esc_js($this->progressText) . "</div>
<script>
function {$progress_func1}(obj)
{
jQuery(obj).parent().parent().find('.dup-dlg-confirm-progress').show();
jQuery(obj).closest('.dup-dlg-confirm-btns').find('input').attr('disabled', 'true');
}
</script>";
$onClickConfirm .= $progress_func2 . ';';
}
if ($this->closeOnConfirm) {
$onClickConfirm .= 'tb_remove();';
}
$html =
'<div id="' . esc_attr($this->id) . '" style="display:none">
<div class="dup-dlg-confirm-txt">
<span id="' . esc_attr($this->id) . '_message">' . esc_html($this->message) . '</span>
<br/><br/>
' . $progress_data . '
</div>
<div class="dup-dlg-confirm-btns">
<input type="button" class="button button-large" value="' . esc_attr($this->okText) . '" onclick="' . $onClickConfirm . '" />
<input type="button" class="button button-large" value="' . esc_attr($this->cancelText) . '" onclick="tb_remove()" />
</div>
</div>';
echo $html;
}
/**
* Shows the confirm base JS code used to display when needed
*
* @return string The javascript content used for the confirm dialog
*/
public function showConfirm()
{
$this->width = is_numeric($this->width) ? $this->width : 500;
$this->height = is_numeric($this->height) ? $this->height : 225;
$html = "tb_show('" . esc_js($this->title) . "', '#TB_inline?width=" . esc_js($this->width) . "&height=" . esc_js($this->height) . "&inlineId=" . esc_js($this->id) . "');\n" .
"var styleData = jQuery('#TB_window').attr('style') + 'height: " . esc_js($this->height) . "px !important';\n" .
"jQuery('#TB_window').attr('style', styleData);";
echo $html;
}
}

View File

@@ -0,0 +1,112 @@
<?php
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* Used to generate a thick box inline dialog such as an alert or confirm pop-up
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2
*
* @package Duplicator
* @subpackage classes/ui
* @copyright (c) 2017, Snapcreek LLC
*/
class DUP_UI_Messages
{
const UNIQUE_ID_PREFIX = 'dup_ui_msg_';
const NOTICE = 'updated';
const WARNING = 'update-nag';
const ERROR = 'error';
private static $unique_id = 0;
private $id;
public $type = self::NOTICE;
public $content = '';
public $wrap_cont_tag = 'p';
public $hide_on_init = true;
public $is_dismissible = false;
/**
*
* @var int delay in milliseconds
*/
public $auto_hide_delay = 0;
public $callback_on_show = null;
public $callback_on_hide = null;
public function __construct($content = '', $type = self::NOTICE)
{
self::$unique_id++;
$this->id = self::UNIQUE_ID_PREFIX . self::$unique_id;
$this->content = (string) $content;
$this->type = $type;
}
protected function get_notice_classes($classes = array())
{
if (is_string($classes)) {
$classes = explode(' ', $classes);
} elseif (is_array($classes)) {
} else {
$classes = array();
}
if ($this->is_dismissible) {
$classes[] = 'is-dismissible';
}
$result = array_merge(array('notice', $this->type), $classes);
return trim(implode(' ', $result));
}
public function initMessage()
{
$classes = array();
if ($this->hide_on_init) {
$classes[] = 'no_display';
}
$this->wrap_cont_tag = empty($this->wrap_cont_tag) ? 'p' : $this->wrap_cont_tag;
echo '<div id="' . $this->id . '" class="' . $this->get_notice_classes($classes) . '">' .
'<' . $this->wrap_cont_tag . ' class="msg-content">' .
$this->content .
'</' . $this->wrap_cont_tag . '>' .
'</div>';
}
public function updateMessage($jsVarName, $echo = true)
{
$result = 'jQuery("#' . $this->id . ' > .msg-content").html(' . $jsVarName . ');';
if ($echo) {
echo $result;
} else {
return $result;
}
}
public function showMessage($echo = true)
{
$callStr = !empty($this->callback_on_show) ? $this->callback_on_show . ';' : '';
$result = 'jQuery("#' . $this->id . '").fadeIn( "slow", function() { $(this).removeClass("no_display");' . $callStr . ' });';
if ($this->auto_hide_delay > 0) {
$result .= 'setTimeout(function () { ' . $this->hideMessage(false) . ' }, ' . $this->auto_hide_delay . ');';
}
if ($echo) {
echo $result;
} else {
return $result;
}
}
public function hideMessage($echo = true)
{
$callStr = !empty($this->callback_on_hide) ? $this->callback_on_hide . ';' : '';
$result = 'jQuery("#' . $this->id . '").fadeOut( "slow", function() { $(this).addClass("no_display");' . $callStr . ' });';
if ($echo) {
echo $result;
} else {
return $result;
}
}
}

View File

@@ -0,0 +1,120 @@
<?php
use Duplicator\Libs\Snap\SnapUtil;
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* The base class for all screen.php files. This class is used to control items that are common
* among all screens, namely the Help tab and Screen Options drop down items. When creating a
* screen object please extent this class.
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2
*
* @package Duplicator
* @subpackage classes/ui
* @copyright (c) 2017, Snapcreek LLC
*/
// Exit if accessed directly
if (!defined('DUPLICATOR_VERSION')) {
exit;
}
class DUP_UI_Screen
{
/**
* Used as a placeholder for the current screen object
*/
public $screen;
/**
* Init this object when created
*/
public function __construct()
{
}
public static function getCustomCss()
{
$screen = get_current_screen();
if (
!in_array($screen->id, array(
'toplevel_page_duplicator',
'duplicator_page_duplicator-tools',
'duplicator_page_duplicator-settings',
'duplicator_page_duplicator-gopro'))
) {
return;
}
$colorScheme = self::getCurrentColorScheme();
$primaryButtonColor = self::getPrimaryButtonColorByScheme();
if ($colorScheme !== false) { ?>
<style>
.link-style {
color: <?php echo $colorScheme->colors[2]; ?>;
}
.link-style:hover {
color: <?php echo $colorScheme->colors[3]; ?>;
}
.dup-radio-button-group-wrapper input[type="radio"] + label {
color: <?php echo $primaryButtonColor; ?>;
}
.dup-radio-button-group-wrapper input[type="radio"] + label:hover,
.dup-radio-button-group-wrapper input[type="radio"]:focus + label,
.dup-radio-button-group-wrapper input[type="radio"]:checked + label {
background: <?php echo $primaryButtonColor; ?>;
border-color: <?php echo $primaryButtonColor; ?>;
}
</style>
<?php
}
}
/**
* Unfortunately not all color schemes take the same color as the buttons so you need to make a custom switch/
*
* @return string
*/
public static function getPrimaryButtonColorByScheme()
{
$colorScheme = self::getCurrentColorScheme();
$name = strtolower($colorScheme->name);
switch ($name) {
case 'blue':
return '#e3af55';
case 'light':
case 'midnight':
return $colorScheme->colors[3];
case 'ocean':
case 'ectoplasm':
case 'coffee':
case 'sunrise':
case 'default':
default:
return $colorScheme->colors[2];
}
}
public static function getCurrentColorScheme()
{
global $_wp_admin_css_colors;
if (!isset($_wp_admin_css_colors) || !is_array($_wp_admin_css_colors)) {
return false;
}
$colorScheme = get_user_option('admin_color');
if (isset($_wp_admin_css_colors[$colorScheme])) {
return $_wp_admin_css_colors[$colorScheme];
} else {
return $_wp_admin_css_colors[SnapUtil::arrayKeyFirst($_wp_admin_css_colors)];
}
}
}

View File

@@ -0,0 +1,87 @@
<?php
defined('ABSPATH') || defined('DUPXABSPATH') || exit;
/**
* Gets the view state of UI elements to remember its viewable state
*
* Standard: PSR-2
*
* @link http://www.php-fig.org/psr/psr-2
*
* @package Duplicator
* @subpackage classes/ui
* @copyright (c) 2017, Snapcreek LLC
*/
// Exit if accessed directly
if (! defined('DUPLICATOR_VERSION')) {
exit;
}
class DUP_UI_ViewState
{
/**
* The key used in the wp_options table
*
* @var string
*/
private static $optionsViewStateKey = 'duplicator_ui_view_state';
/**
* Save the view state of UI elements
*
* @param string $key A unique key to define the UI element
* @param string $value A generic value to use for the view state
*
* @return bool Returns true if the value was successfully saved
*/
public static function save($key, $value)
{
$view_state = array();
$view_state = get_option(self::$optionsViewStateKey);
$view_state[$key] = $value;
$success = update_option(self::$optionsViewStateKey, $view_state);
return $success;
}
/**
* Gets all the values from the settings array
*
* @return array Returns and array of all the values stored in the settings array
*/
public static function getArray()
{
return get_option(self::$optionsViewStateKey);
}
/**
* Sets all the values from the settings array
*
* @param array $view_state states
*
* @return boolean Returns whether updated or not
*/
public static function setArray($view_state)
{
return update_option(self::$optionsViewStateKey, $view_state);
}
/**
* Return the value of the of view state item
*
* @param type $searchKey The key to search on
*
* @return string Returns the value of the key searched or null if key is not found
*/
public static function getValue($searchKey)
{
$view_state = get_option(self::$optionsViewStateKey);
if (is_array($view_state)) {
foreach ($view_state as $key => $value) {
if ($key == $searchKey) {
return $value;
}
}
}
return null;
}
}

View File

@@ -0,0 +1,3 @@
<?php
//silent