Example #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;
}
Example #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;
}
<?php

namespace HM\BackUpWordPress;

$filesize = get_site_size_text($schedule);
// Backup Type
$type = strtolower(human_get_type($schedule->get_type()));
// Backup Time
$day = date_i18n('l', $schedule->get_next_occurrence(false));
// Next Backup
$next_backup = 'title="' . esc_attr(sprintf(__('The next backup will be on %1$s at %2$s %3$s', 'backupwordpress'), date_i18n(get_option('date_format'), $schedule->get_next_occurrence(false)), date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false)), date_i18n('T', $schedule->get_next_occurrence(false)))) . '"';
// Backup status
$status = new Backup_Status($schedule->get_id());
// Backup Re-occurrence
switch ($schedule->get_reoccurrence()) {
    case 'hourly':
        $reoccurrence = date_i18n('i', $schedule->get_next_occurrence(false)) === '00' ? '<span ' . $next_backup . '>' . __('hourly on the hour', 'backupwordpress') . '</span>' : sprintf(__('hourly at %s minutes past the hour', 'backupwordpress'), '<span ' . $next_backup . '>' . intval(date_i18n('i', $schedule->get_next_occurrence(false)))) . '</span>';
        break;
    case 'daily':
        $reoccurrence = sprintf(__('daily at %s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'twicedaily':
        $times[] = date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false));
        $times[] = date_i18n(get_option('time_format'), strtotime('+ 12 hours', $schedule->get_next_occurrence(false)));
        sort($times);
        $reoccurrence = sprintf(__('every 12 hours at %1$s &amp; %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html(reset($times)) . '</span>', '<span>' . esc_html(end($times))) . '</span>';
        break;
    case 'weekly':
        $reoccurrence = sprintf(__('weekly on %1$s at %2$s', 'backupwordpress'), '<span ' . $next_backup . '>' . esc_html($day) . '</span>', '<span>' . esc_html(date_i18n(get_option('time_format'), $schedule->get_next_occurrence(false))) . '</span>');
        break;
    case 'fortnightly':
Example #4
0
// Refresh the schedules from the database to make sure we have the latest changes
Schedules::get_instance()->refresh_schedules();
$schedules = Schedules::get_instance()->get_schedules();
if (!empty($_GET['hmbkp_schedule_id'])) {
    $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 
 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());
 }