output_status_page();
}
/**
* Outputs the clone status
*
* @param bool $die - Defines if should die at the end
* @return void
*/
public function output_status_page($die = true) {
$this->current_status = $this->get_status();
$this->page_start();
echo '
';
echo '';
$this->get_content(true);
?>
get_progress_item_icon(self::INSTALLED, true); ?>
get_progress_item_icon(self::UPLOADING, true); ?>
= $this->current_status) {
esc_html_e('Receiving site data', 'updraftplus');
} else {
esc_html_e('Site data received', 'updraftplus');
}
?>
get_progress_item_icon(self::RESTORING, true); ?>
= $this->current_status) {
esc_html_e('Deploying site data', 'updraftplus');
} else {
esc_html_e('Site data has been deployed', 'updraftplus');
}
?>
get_progress_item_icon(1000, true); ?>
get_status_description(true); ?>
';
$this->page_end();
if ($die) die();
}
/**
* This function will output the start of the updraftclone status page
*
* @return void
*/
public function page_start() {
echo '
UpdraftClone
';
}
/**
* This function will output the end of the updraftclone status page
*
* @return void
*/
public function page_end() {
?>
current_status) {
case self::INSTALLED:
$code = __("WordPress installed", "updraftplus");
break;
case self::UPLOADING:
$code = __("Receiving site data", "updraftplus");
break;
case self::RESTORING:
$code = __("Deploying site data", "updraftplus");
break;
default:
$code = "";
break;
}
return $code;
}
/**
* This function will get and return the clone status description ready to be displayed on the page
*
* @param bool $echo_instead_of_return Indicate whether the description is to be shown directly (echoed) or just for retrieval
* @return string/void - the clone status description
*/
public function get_status_description($echo_instead_of_return = false) {
if (!$echo_instead_of_return) ob_start();
switch ($this->current_status) {
case self::INSTALLED:
echo esc_html__('WordPress installed; now awaiting the site data to be sent.', 'updraftplus');
break;
case self::UPLOADING:
$backup_details = $this->get_backup_details();
echo esc_html__('The sending of the site data has begun.', 'updraftplus').' '.sprintf(esc_html__('So far %s data archives totalling %s have been received', 'updraftplus'), ''.esc_html($backup_details['sets']).'', ''.esc_html(round($backup_details['uploaded'], 2)).' MB');
break;
case self::RESTORING:
UpdraftPlus_Backup_History::rebuild();
$backup_details = $this->get_backup_details();
echo esc_html__('The site data has all been received, and its import has begun.', 'updraftplus').' '.sprintf(esc_html__('%s archives remain', 'updraftplus'), ''.esc_html($backup_details['sets']).'');
break;
default:
echo "(?)";
break;
}
if (!$echo_instead_of_return) return ob_get_clean();
}
/**
* 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() {
global $updraftplus;
$backup_history = UpdraftPlus_Backup_History::get_history();
$backupable_entities = $updraftplus->get_backupable_file_entities();
$sets = 0;
$uploaded = 0;
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
*
* @param bool $echo_instead_of_return Indicate whether the content is to be shown directly (echoed) or just for retrieval
* @return string/void - the clone content
*/
public function get_content($echo_instead_of_return = false) {
if (!$echo_instead_of_return) ob_start();
?>
backups_dir_location());
if (file_exists($updraft_dir.'ready_for_restore')) return self::RESTORING;
return self::UPLOADING;
}
/**
* Get the progress item class
*
* @param int $number The status number
* @return string
*/
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
* @param bool $echo_instead_of_return Indicate whether the icon is to be shown directly (echoed) or just for retrieval
* @return string/void
*/
private function get_progress_item_icon($number = 1000, $echo_instead_of_return = false) {
if (!$echo_instead_of_return) ob_start();
$anchor_text = '#'.(($number === $this->current_status) ? 'update' : (($number < $this->current_status) ? 'yes' : 'clock'));
?>