コード例 #1
0
ファイル: actions.php プロジェクト: crazyyy/bessarabia
/**
 * 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;
}
コード例 #2
0
 /**
  * @return array
  */
 public static function test()
 {
     $backup_sizes = array();
     $schedules = Schedules::get_instance();
     foreach ($schedules->get_schedules() as $schedule) {
         $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
         if ($site_size->is_site_size_cached()) {
             $backup_sizes[$schedule->get_type()] = $site_size->get_formatted_site_size();
         }
     }
     return $backup_sizes;
 }
コード例 #3
0
/**
 * Returns a formatted string containing the calculated total site size or a message
 * to indicate it is being calculated.
 *
 * @param HM\BackUpWordPress\Scheduled_Backup $schedule
 *
 * @return string
 */
function get_site_size_text(Scheduled_Backup $schedule)
{
    if (isset($_GET['hmbkp_add_schedule'])) {
        return '';
    }
    $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
    if ('database' === $schedule->get_type() || $site_size->is_site_size_cached()) {
        return sprintf('(<code title="' . __('Backups will be compressed and should be smaller than this.', 'backupwordpress') . '">%s</code>)', esc_html($site_size->get_formatted_site_size()));
    }
    return '';
}
/**
 * Returns a formatted string containing the calculated total site size or a message
 * to indicate it is being calculated.
 *
 * @param HM\BackUpWordPress\Scheduled_Backup $schedule
 *
 * @return string
 */
function get_site_size_text(Scheduled_Backup $schedule)
{
    if (isset($_GET['hmbkp_add_schedule'])) {
        return '';
    }
    $site_size = new Site_Size($schedule->get_type(), $schedule->get_excludes());
    if ('database' === $schedule->get_type() || $site_size->is_site_size_cached()) {
        return sprintf('(<code title="' . __('Backups will be compressed and should be smaller than this.', 'backupwordpress') . '">%s</code>)', esc_attr($site_size->get_formatted_site_size()));
    } else {
        return sprintf('(<code class="calculating" title="' . __('this shouldn\'t take long&hellip;', 'backupwordpress') . '">' . __('calculating the size of your site&hellip;', 'backupwordpress') . '</code>)');
    }
}