Backup
2 years ago
FileList
2 years ago
Restore
3 years ago
Backup.php
2 years ago
BackupSpeedIndex.php
2 years ago
Cancel.php
3 years ago
Delete.php
3 years ago
Edit.php
3 years ago
FileInfo.php
3 years ago
FileList.php
3 years ago
Listing.php
2 years ago
Parts.php
3 years ago
PrepareJob.php
2 years ago
Restore.php
2 years ago
ScheduleList.php
2 years ago
Status.php
3 years ago
Upload.php
2 years ago
Backup.php
39 lines
| 1 | <?php |
| 2 | |
| 3 | // TODO PHP7.x; declare(strict_type=1); |
| 4 | // TODO PHP7.x; type hints & return types |
| 5 | |
| 6 | namespace WPStaging\Backup\Ajax; |
| 7 | |
| 8 | use WPStaging\Backup\Job\JobBackupProvider; |
| 9 | use WPStaging\Core\WPStaging; |
| 10 | use WPStaging\Framework\Component\AbstractTemplateComponent; |
| 11 | use WPStaging\Framework\Traits\MemoryExhaustTrait; |
| 12 | |
| 13 | class Backup extends AbstractTemplateComponent |
| 14 | { |
| 15 | use MemoryExhaustTrait; |
| 16 | |
| 17 | /** |
| 18 | * @var string |
| 19 | */ |
| 20 | const WPSTG_REQUEST = 'wpstg_backup'; |
| 21 | |
| 22 | /** |
| 23 | * @return void |
| 24 | */ |
| 25 | public function render() |
| 26 | { |
| 27 | if (!$this->canRenderAjax()) { |
| 28 | return; |
| 29 | } |
| 30 | |
| 31 | $tmpFileToDelete = $this->getMemoryExhaustErrorTmpFile(self::WPSTG_REQUEST); |
| 32 | |
| 33 | $jobBackup = WPStaging::make(JobBackupProvider::class)->getJob(); |
| 34 | $jobBackup->setMemoryExhaustErrorTmpFile($tmpFileToDelete); |
| 35 | |
| 36 | wp_send_json($jobBackup->prepareAndExecute()); |
| 37 | } |
| 38 | } |
| 39 |