PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 4.9.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v4.9.2
4.9.2 4.9.1 4.9.0 4.8.1 trunk 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.10.0 3.2.0 3.3.1 3.3.2 3.3.3 3.4.1 3.4.3 3.5.0 3.6.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.8.6 3.8.7 3.9.0 3.9.1 3.9.2 3.9.3 3.9.4 4.0.0 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.8.0
wp-staging / Staging / Ajax / Delete / DeleteConfirm.php
wp-staging / Staging / Ajax / Delete Last commit date
DeleteConfirm.php 9 months ago PrepareDelete.php 2 weeks ago
DeleteConfirm.php
76 lines
1 <?php
2
3 namespace WPStaging\Staging\Ajax\Delete;
4
5 use WPStaging\Framework\Component\AbstractTemplateComponent;
6 use WPStaging\Framework\TemplateEngine\TemplateEngine;
7 use WPStaging\Framework\Utils\Sanitize;
8 use WPStaging\Staging\Sites;
9 use WPStaging\Staging\Traits\WithStagingDatabase;
10
11 class DeleteConfirm extends AbstractTemplateComponent
12 {
13 use WithStagingDatabase;
14
15 /** @var Sites */
16 private $sites;
17
18 /** @var Sanitize */
19 private $sanitize;
20
21 public function __construct(Sites $sites, Sanitize $sanitize, TemplateEngine $templateEngine)
22 {
23 parent::__construct($templateEngine);
24 $this->sites = $sites;
25 $this->sanitize = $sanitize;
26 }
27
28 /**
29 * @return void
30 */
31 public function ajaxConfirm()
32 {
33 if (!$this->canRenderAjax()) {
34 wp_send_json_error('Invalid request.');
35 }
36
37 $cloneId = $this->sanitize->sanitizeString(isset($_POST['cloneId']) ? $_POST['cloneId'] : '');
38 if (empty($cloneId)) {
39 wp_send_json_error('Invalid request. Clone ID missing!');
40 }
41
42 $stagingSiteDto = null;
43 try {
44 $stagingSiteDto = $this->sites->getStagingSiteDtoByCloneId($cloneId);
45 } catch (\Throwable $e) {
46 wp_send_json_error($e->getMessage());
47 }
48
49 $tables = [];
50 $connected = false;
51 try {
52 $this->initStagingDatabase($stagingSiteDto);
53 $tables = $this->getStagingTablesStatus($stagingSiteDto->getUsedPrefix());
54 $connected = true;
55 } catch (\Throwable $e) {
56 $tables = [];
57 $connected = false;
58 }
59
60 $result = $this->templateEngine->render(
61 'staging/confirm-delete.php',
62 [
63 'stagingSite' => $stagingSiteDto,
64 'tables' => $tables === null ? [] : $tables,
65 'isDatabaseConnected' => $connected,
66 'stagingSiteSize' => '', // TODO: not-available but still used in UI, find a way how we can get this efficiently
67 ]
68 );
69
70 wp_send_json_success([
71 'stagingSiteName' => $stagingSiteDto->getSiteName(),
72 'html' => $result,
73 ]);
74 }
75 }
76