if (!defined('ABSPATH')) die('No direct access allowed');
class UpdraftPlus_Temporary_Clone_Status {
* Data is uploaded and is restoring
* The current status number
* Constructor for the class.
public function __construct() {
add_action('init', array($this, 'init'));
* This function is called via the WordPress init action, it will check if the page is not the admin backend and output the clone status
if (is_admin() || (defined('WP_CLI') && WP_CLI) || 'GET' != $_SERVER['REQUEST_METHOD']) return;
$this->output_status_page();
* Outputs the clone status
* @param bool $die - Defines if should die at the end
public function output_status_page($die = true) {
$this->current_status = $this->get_status();
echo '<div class="updraftclone_content_container">';
echo '<img class="updraftclone_logo" alt="UpdraftClone Logo" src="'.trailingslashit(UPDRAFTPLUS_URL).'images/updraftclone_logo_white.png">';
echo $this->get_content();
<section class="progress">
<div class="progress-item <?php echo $this->get_progress_item_class(self::INSTALLED); ?>">
<div class="progress-item__bar"></div>
<span class="icon"><?php echo $this->get_progress_item_icon(self::INSTALLED); ?></span>
<?php _e('WordPress installed', 'updraftplus'); ?>
<div class="progress-item <?php echo $this->get_progress_item_class(self::UPLOADING); ?>">
<div class="progress-item__bar"></div>
<span class="icon"><?php echo $this->get_progress_item_icon(self::UPLOADING); ?></span>
if (self::UPLOADING >= $this->current_status) {
_e('Receiving site data', 'updraftplus');
_e('Site data received', 'updraftplus');
<div class="progress-item <?php echo $this->get_progress_item_class(self::RESTORING); ?>">
<div class="progress-item__bar"></div>
<span class="icon"><?php echo $this->get_progress_item_icon(self::RESTORING); ?></span>
if (self::RESTORING >= $this->current_status) {
_e('Deploying site data', 'updraftplus');
_e('Site data has been deployed', 'updraftplus');
<div class="progress-item">
<div class="progress-item__bar"></div>
<span class="icon"><?php echo $this->get_progress_item_icon(); ?></span>
_e('Clone ready', 'updraftplus');
<?php echo '<p class="status-description">' . $this->get_status_description() . '</p>'; ?>
* This function will output the start of the updraftclone status page
public function page_start() {
<html xmlns="http://www.w3.org/1999/xhtml" class="wp-toolbar" lang="en-US">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="refresh" content="60">
<meta name="robots" content="noindex, nofollow">
<title>UpdraftClone</title>
@-webkit-keyframes rotateIcon {
-webkit-transform: rotate(0);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
-webkit-transform: rotate(0);
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
background-color: #EDEDED;
.updraftclone_content_container {
font-family: Source Sans Pro, Helvetica, Arial, Lucida, sans-serif;
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
.done .progress-item__bar {
.active .progress-item__bar {
.active .progress-item__bar:before {
border-top: 10px solid #FFF;
border-right: 10px solid #FFF;
-webkit-transform: translateY(-5px) translateX(10px) rotate(45deg);
transform: translateY(-5px) translateX(10px) rotate(45deg);
section.progress:before {
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.21);
-webkit-animation-name: rotateIcon;
animation-name: rotateIcon;
-webkit-animation-duration: 1.8s;
animation-duration: 1.8s;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
.progress-item:not(.done):not(.active) {
border-top: 1px solid #EBEBEB;
@media (max-width: 520px) {
.progress-item:not(.active) {
* This function will output the end of the updraftclone status page
public function page_end() {
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" style="display: none;">
<symbol viewBox="0 0 20 20" id="yes-alt"><title>yes-alt</title><g><path d="M10 2c-4.42 0-8 3.58-8 8s3.58 8 8 8 8-3.58 8-8-3.58-8-8-8zm-.615 12.66h-1.34l-3.24-4.54 1.34-1.25 2.57 2.4 5.14-5.93 1.34.94-5.81 8.38z"/></g></symbol>
<symbol viewBox="0 0 20 20" id="yes"><title>yes</title><g><path d="M14.83 4.89l1.34.94-5.81 8.38H9.02L5.78 9.67l1.34-1.25 2.57 2.4z"/></g></symbol>
<symbol viewBox="0 0 20 20" id="update"><title>update</title><g><path d="M10.2 3.28c3.53 0 6.43 2.61 6.92 6h2.08l-3.5 4-3.5-4h2.32c-.45-1.97-2.21-3.45-4.32-3.45-1.45 0-2.73.71-3.54 1.78L4.95 5.66C6.23 4.2 8.11 3.28 10.2 3.28zm-.4 13.44c-3.52 0-6.43-2.61-6.92-6H.8l3.5-4c1.17 1.33 2.33 2.67 3.5 4H5.48c.45 1.97 2.21 3.45 4.32 3.45 1.45 0 2.73-.71 3.54-1.78l1.71 1.95c-1.28 1.46-3.15 2.38-5.25 2.38z"/></g></symbol>
<symbol viewBox="0 0 20 20" id="clock"><title>clock</title><g><path d="M10 2c4.42 0 8 3.58 8 8s-3.58 8-8 8-8-3.58-8-8 3.58-8 8-8zm0 14c3.31 0 6-2.69 6-6s-2.69-6-6-6-6 2.69-6 6 2.69 6 6 6zm-.71-5.29c.07.05.14.1.23.15l-.02.02L14 13l-3.03-3.19L10 5l-.97 4.81h.01c0 .02-.01.05-.02.09S9 9.97 9 10c0 .28.1.52.29.71z"/></g></symbol>
* This function will get and return the clone status title ready to be displayed on the page
* @return string - the clone status title
public function get_status_title() {
switch ($this->current_status) {
$code = __("WordPress installed", "updraftplus");
$code = __("Receiving site data", "updraftplus");
$code = __("Deploying site data", "updraftplus");
* This function will get and return the clone status description ready to be displayed on the page
* @return string - the clone status description
public function get_status_description() {
switch ($this->current_status) {
$description = __('WordPress installed; now awaiting the site data to be sent.', 'updraftplus');
$backup_details = $this->get_backup_details();
$description = sprintf(__('The sending of the site data has begun. So far %s data archives totalling %s have been received', 'updraftplus'), '<strong>'.$backup_details['sets'].'</strong>', '<strong>'.round($backup_details['uploaded'], 2).' MB</strong>');
UpdraftPlus_Backup_History::rebuild();
$backup_details = $this->get_backup_details();
$description = __('The site data has all been received, and its import has begun.', 'updraftplus').' '.sprintf(__('%s archives remain', 'updraftplus'), '<strong>'.$backup_details['sets'].'</strong>');
* This function will return information about the backup such as the amount of sets and the size of the backup set
* @return array - an array with backup information
public function get_backup_details() {
$backup_history = UpdraftPlus_Backup_History::get_history();
$backupable_entities = $updraftplus->get_backupable_file_entities();
foreach ($backupable_entities as $key => $info) {
foreach ($backup_history as $backup) {
if (isset($backup[$key]) && isset($backup[$key.'-size'])) {
$sets += count($backup[$key]);
$uploaded += $backup[$key.'-size'];
$uploaded = round($uploaded / 1048576, 1);
return array('uploaded' => $uploaded, 'sets' => $sets);
* This function will get and return the clone content ready to be displayed on the page
* @return string - the clone content
public function get_content() {
$content = '<p>'.__('Your UpdraftClone is still setting up.', 'updraftplus').' '.sprintf(__('You can check the progress here or in %s', 'updraftplus'), '<a href="https://updraftplus.com/my-account/clones/" target="_blank">'.__('your UpdraftPlus.com account', 'updraftplus')).'</a></p>';
$content .= '<p><a href="https://updraftplus.com/faq-category/updraftclone/" target="_blank">'.__('To read FAQs/documentation about UpdraftClone, go here.', 'updraftplus').'</a></p>';
* This function will work out what stage the clone is in and return the correct status code
* @return int - the clone status code
public function get_status() {
$backup_history = UpdraftPlus_Backup_History::get_history();
if (empty($backup_history)) return self::INSTALLED;
$updraft_dir = trailingslashit($updraftplus->backups_dir_location());
if (file_exists($updraft_dir.'ready_for_restore')) return self::RESTORING;
* Get the progress item class
* @param int $number The status number
private function get_progress_item_class($number) {
return ($number === $this->current_status) ? 'active' : (($number < $this->current_status) ? 'done' : '');
* Get the progress item icon
* @param int $number The status number
private function get_progress_item_icon($number = 1000) {
$icon = '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">';
$icon .= '<use href="#'.(($number === $this->current_status) ? 'update' : (($number < $this->current_status) ? 'yes' : 'clock')).'" />';
if (defined('UPDRAFTPLUS_THIS_IS_CLONE') && 1 == UPDRAFTPLUS_THIS_IS_CLONE) {
new UpdraftPlus_Temporary_Clone_Status();