Пример #1
0
/**
 * Display the row of actions for a schedule
 *
 * @access public
 * @param Scheduled_Backup $schedule
 * @return void
 */
function schedule_status(Scheduled_Backup $schedule, $echo = true)
{
    $status = new Backup_Status($schedule->get_id());
    ob_start();
    ?>

	<span class="hmbkp-status"<?php 
    if ($status->get_status()) {
        ?>
 title="<?php 
        printf(__('Started %s ago', 'backupwordpress'), human_time_diff($status->get_start_time()));
        ?>
"<?php 
    }
    ?>
>
		<?php 
    echo $status->get_status() ? wp_kses_data($status->get_status()) : __('Starting backup...', 'backupwordpress');
    ?>
		<a href="<?php 
    echo admin_action_url('request_cancel_backup', array('hmbkp_schedule_id' => $schedule->get_id()));
    ?>
"><?php 
    _e('cancel', 'backupwordpress');
    ?>
</a>
	</span>

	<?php 
    $output = ob_get_clean();
    if (!$echo) {
        return $output;
    }
    echo $output;
}
Пример #2
0
/**
 * Receive the heartbeat and return backup status
 */
function heartbeat_received($response, $data)
{
    $response['heartbeat_interval'] = 'fast';
    if (!empty($data['hmbkp_schedule_id'])) {
        $schedule = new Scheduled_Backup(sanitize_text_field(urldecode($data['hmbkp_schedule_id'])));
        $status = new Backup_Status($schedule->get_id());
        if (!empty($data['hmbkp_is_in_progress'])) {
            if (!$status->get_status()) {
                $response['hmbkp_schedule_status'] = 0;
                // Slow the heartbeat back down
                $response['heartbeat_interval'] = 'slow';
            } else {
                $response['hmbkp_schedule_status'] = schedule_status($schedule, false);
            }
        }
        if (!empty($data['hmbkp_client_request'])) {
            $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
            // Pass the site size to be displayed when it's ready.
            if ($site_size->is_site_size_cached()) {
                $response['hmbkp_site_size'] = $site_size->get_formatted_site_size();
                ob_start();
                require HMBKP_PLUGIN_PATH . 'admin/schedule-form-excludes.php';
                $response['hmbkp_dir_sizes'] = ob_get_clean();
                // Slow the heartbeat back down
                $response['heartbeat_interval'] = 'slow';
            }
        }
    }
    return $response;
}
    if (is_wp_error($service)) {
        $email_msg = $service->get_error_message();
    } elseif ('Email' === $service->name) {
        $email_msg = wp_kses_post($service->display());
    } elseif ($service->is_service_active() && $service->display()) {
        $services[] = esc_html($service->display());
    }
}
if (!empty($services) && count($services) > 1) {
    $services[count($services) - 2] .= ' & ' . $services[count($services) - 1];
    array_pop($services);
}
?>

<div class="hmbkp-schedule-sentence<?php 
if ($status->get_status()) {
    ?>
 hmbkp-running<?php 
}
?>
">

	<?php 
$sentence = sprintf(_x('Backup my %1$s %2$s %3$s, %4$s.', '1: Backup Type 2: Total size of backup 3: Schedule 4: Number of backups to store', 'backupwordpress'), '<span>' . esc_html($type) . '</span>', $filesize, $reoccurrence, $backup_to_keep);
if ($email_msg) {
    $sentence .= ' ' . $email_msg;
}
if (!empty($services)) {
    $sentence .= ' ' . sprintf(__('Send a copy of each backup to %s.', 'backupwordpress'), implode(', ', $services));
}
echo $sentence;
Пример #4
0
    $current_schedule = new Scheduled_Backup(sanitize_text_field($_GET['hmbkp_schedule_id']));
} else {
    $current_schedule = reset($schedules);
}
?>

<div class="wp-filter">
	<ul class="filter-links">

		<?php 
foreach ($schedules as $schedule) {
    $status = new Backup_Status($schedule->get_id());
    ?>

			<li<?php 
    if ($status->get_status()) {
        ?>
 title="<?php 
        echo esc_attr(strip_tags($status->get_status()));
        ?>
"<?php 
    }
    ?>
><a href="<?php 
    echo esc_url(add_query_arg('hmbkp_schedule_id', $schedule->get_id(), HMBKP_ADMIN_URL));
    ?>
" class="<?php 
    if ($status->get_status()) {
        ?>
hmbkp-running<?php 
    }
 public function test_multiple_status_dont_clash()
 {
     $status1 = $this->status;
     $status2 = new Backup_Status('status2');
     $status1->start('darth', 'vadar');
     $status2->start('master', 'yoda');
     $this->assertNotEquals($status1->get_status_filepath(), $status2->get_status_filepath());
     $this->assertEquals('darth', $status1->get_backup_filename());
     $this->assertEquals('vadar', $status1->get_status());
     $this->assertEquals('master', $status2->get_backup_filename());
     $this->assertEquals('yoda', $status2->get_status());
 }