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 / Framework / Settings / EventLogger.php
wp-staging / Framework / Settings Last commit date
DarkMode.php 2 years ago EventLogger.php 1 year ago Settings.php 2 years ago
EventLogger.php
73 lines
1 <?php
2
3 namespace WPStaging\Framework\Settings;
4
5 use WPStaging\Framework\Traits\EventLoggerTrait;
6 use WPStaging\Framework\Utils\Sanitize;
7
8 class EventLogger
9 {
10 use EventLoggerTrait;
11
12 /**
13 * @var Sanitize
14 */
15 private $sanitize;
16
17 /**
18 * @var string
19 */
20 private $process;
21
22 /**
23 * @var array
24 */
25 private $processPrefixes;
26
27 /**
28 * @param Sanitize $sanitize
29 */
30 public function __construct(Sanitize $sanitize)
31 {
32 $this->sanitize = $sanitize;
33 $this->processPrefixes = [
34 'backup' => $this->backupProcessPrefix,
35 'restore' => $this->restoreProcessPrefix,
36 'clone' => $this->cloneProcessPrefix,
37 'push' => $this->pushProcessPrefix,
38 ];
39 }
40
41 /**
42 * @return void
43 */
44 public function ajaxLogEventFailure()
45 {
46 $process = isset($_POST['process']) ? $this->sanitize->sanitizeString($_POST['process']) : '';
47 if (empty($process)) {
48 wp_send_json_error();
49 }
50
51 $this->process = $this->getProcessPrefix($process);
52 if (empty($this->process)) {
53 wp_send_json_error();
54 }
55
56 $response = $this->updateFailedProcess($this->process);
57 if ($response) {
58 wp_send_json_success();
59 }
60
61 wp_send_json_error();
62 }
63
64 /**
65 * @param string $processName
66 * @return string
67 */
68 protected function getProcessPrefix(string $processName): string
69 {
70 return empty($this->processPrefixes[$processName]) ? '' : $this->processPrefixes[$processName];
71 }
72 }
73