PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backup, Restore, Migration & Clone / 3.8.2
WP STAGING – WordPress Backup, Restore, Migration & Clone v3.8.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 / Backend / Modules / Jobs / Cancel.php
wp-staging / Backend / Modules / Jobs Last commit date
Cleaners 5 years ago Exceptions 5 years ago Cancel.php 2 years ago CancelUpdate.php 2 years ago Cloning.php 2 years ago CloningProcess.php 2 years ago Data.php 2 years ago Database.php 2 years ago Delete.php 2 years ago Directories.php 2 years ago Files.php 2 years ago Finish.php 1 year ago Job.php 2 years ago JobExecutable.php 2 years ago Logs.php 3 years ago PreserveDataFirstStep.php 3 years ago PreserveDataSecondStep.php 2 years ago ProcessLock.php 2 years ago Scan.php 2 years ago SearchReplace.php 2 years ago TotalStepsAreNumberOfTables.php 5 years ago Updating.php 2 years ago
Cancel.php
93 lines
1 <?php
2
3 namespace WPStaging\Backend\Modules\Jobs;
4
5 use WPStaging\Core\WPStaging;
6 use WPStaging\Framework\Analytics\AnalyticsEventDto;
7
8 /**
9 * Class Cancel Processing
10 * @package WPStaging\Backend\Modules\Jobs
11 */
12 class Cancel extends Job
13 {
14
15 /**
16 * Start Module
17 * @return bool
18 */
19 public function start()
20 {
21 $cloneData = $this->createCloneData();
22
23 if (!empty($this->options->jobIdentifier)) {
24 AnalyticsEventDto::enqueueCancelEvent($this->options->jobIdentifier);
25 }
26
27 if (empty($cloneData)) {
28 return true;
29 }
30
31 $deleteJob = WPStaging::make(Delete::class);
32 $deleteJob->setIsExternalDb(!$this->isStagingDatabaseSameAsProductionDatabase());
33
34 return $deleteJob->start($cloneData);
35 }
36
37 /**
38 * @return array
39 */
40 protected function createCloneData()
41 {
42 $clone = [];
43
44 if (!$this->check()) {
45 return $clone;
46 }
47
48 $clone["name"] = $this->options->clone;
49 $clone["number"] = $this->options->cloneNumber;
50 $clone["path"] = ABSPATH . $this->options->cloneDirectoryName;
51 $clone["prefix"] = $this->options->prefix;
52 $clone["databaseServer"] = $this->options->databaseServer;
53 $clone["databaseUser"] = $this->options->databaseUser;
54 $clone["databasePassword"] = $this->options->databasePassword;
55 $clone["databasePrefix"] = $this->options->databasePrefix;
56 $clone["databaseDatabase"] = $this->options->databaseDatabase;
57 $clone["databaseSsl"] = $this->options->databaseSsl;
58
59 return $clone;
60 }
61
62 /**
63 * @return bool
64 */
65 public function check()
66 {
67 return (
68 isset($this->options) &&
69 isset($this->options->clone) &&
70 isset($this->options->cloneNumber) &&
71 isset($this->options->cloneDirectoryName) &&
72 isset($_POST["clone"]) &&
73 $_POST["clone"] === $this->options->clone
74 );
75 }
76
77 /**
78 * Get json response
79 * return json
80 */
81 private function returnFinish($message = '')
82 {
83
84 wp_die(json_encode([
85 'job' => 'delete',
86 'status' => true,
87 'message' => $message,
88 'error' => false,
89 'delete' => 'finished'
90 ]));
91 }
92 }
93