PluginProbe
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.12.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.12.0
4.12.0 4.11.2 4.11.1 4.11.0 4.10.0 4.9.5 4.9.4 4.9.3 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 All 67 releases
wp-staging / Staging / CloneOptions.php
CloneOptions.php
123 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace WPStaging\Staging;
4
5 use stdClass;
6 use WPStaging\Core\WPStaging;
7 use WPStaging\Framework\SiteInfo;
8
9
10
11
12
13
14
15
16 class CloneOptions
17 {
18
19
20
21
22 const WPSTG_CLONE_SETTINGS_KEY = 'wpstg_clone_settings';
23
24
25 const FILTER_CLONING_TARGET_HOSTNAME = 'wpstg_cloning_target_hostname';
26
27
28 const FILTER_CLONING_TARGET_DIR = 'wpstg_cloning_target_dir';
29
30
31
32
33
34
35
36
37
38 public function get($option = null, $default = null)
39 {
40
41 if (!WPStaging::make(SiteInfo::class)->isStagingSite()) {
42 return $default;
43 }
44
45 $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null);
46
47
48 if ($option === null) {
49 return $settings;
50 }
51
52
53 if ($settings === null || !is_object($settings)) {
54 return $default;
55 }
56
57
58 if (!property_exists($settings, $option)) {
59 return $default;
60 }
61
62 return $settings->{$option};
63 }
64
65
66
67
68
69
70
71
72
73 public function set(string $option, $value): bool
74 {
75
76 if (!WPStaging::make(SiteInfo::class)->isStagingSite()) {
77 return false;
78 }
79
80 $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null);
81
82
83 if ($settings === null || !is_object($settings)) {
84 $settings = new stdClass();
85 }
86
87 $settings->{$option} = $value;
88
89 return update_option(self::WPSTG_CLONE_SETTINGS_KEY, $settings);
90 }
91
92
93
94
95
96
97
98
99 public function delete(string $option): bool
100 {
101
102 if (!WPStaging::make(SiteInfo::class)->isStagingSite()) {
103 return false;
104 }
105
106 $settings = get_option(self::WPSTG_CLONE_SETTINGS_KEY, null);
107
108
109 if ($settings === null || !is_object($settings)) {
110 return false;
111 }
112
113
114 if (!property_exists($settings, $option)) {
115 return true;
116 }
117
118 unset($settings->{$option});
119
120 return update_option(self::WPSTG_CLONE_SETTINGS_KEY, $settings);
121 }
122 }
123