function hmbkp_request_cancel_backup()
 {
     $schedule_id = $this->check_schedule();
     $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field(urldecode($schedule_id)));
     // Delete the running backup
     if ($schedule->get_running_backup_filename() && file_exists(trailingslashit(hmbkp_path()) . $schedule->get_running_backup_filename())) {
         unlink(trailingslashit(hmbkp_path()) . $schedule->get_running_backup_filename());
     }
     if ($schedule->get_schedule_running_path() && file_exists($schedule->get_schedule_running_path())) {
         unlink($schedule->get_schedule_running_path());
     }
     HM\BackUpWordPress\Path::get_instance()->cleanup();
     $information['scheduleStatus'] = $schedule->get_status();
     $information['result'] = 'SUCCESS';
     return $information;
 }
Beispiel #2
0
/**
 * Cancels a running backup then redirect back to the backups page
 */
function hmbkp_request_cancel_backup()
{
    check_admin_referer('hmbkp_request_cancel_backup', 'hmbkp-request_cancel_backup_nonce');
    $schedule = new HM\BackUpWordPress\Scheduled_Backup(sanitize_text_field(urldecode($_GET['hmbkp_schedule_id'])));
    // Delete the running backup
    if ($schedule->get_running_backup_filename() && file_exists(trailingslashit(hmbkp_path()) . $schedule->get_running_backup_filename())) {
        unlink(trailingslashit(hmbkp_path()) . $schedule->get_running_backup_filename());
    }
    if ($schedule->get_schedule_running_path() && file_exists($schedule->get_schedule_running_path())) {
        unlink($schedule->get_schedule_running_path());
    }
    HM\BackUpWordPress\Path::get_instance()->cleanup();
    wp_safe_redirect(hmbkp_get_settings_url(), 303);
    die;
}