PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.1
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.1
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 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 / CloneOptions.php
wp-staging / Staging Last commit date
Ajax 1 week ago Dto 1 week ago Interfaces 5 days ago Jobs 1 week ago Renderer 1 week ago Service 1 week ago Tasks 5 days ago Traits 5 days ago CloneOptions.php 1 week ago FirstRun.php 1 week ago Sites.php 5 days ago StagingServiceProvider.php 1 week ago
CloneOptions.php
123 lines
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