PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 4.11.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v4.11.0
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 / Framework / Adapter / WpAdapter.php
wp-staging / Framework / Adapter Last commit date
Database 1 day ago Database.php 1 day ago DatabaseInterface.php 1 year ago DateTimeAdapter.php 1 day ago Directory.php 1 day ago DirectoryInterface.php 1 year ago Maintenance.php 1 day ago PhpAdapter.php 1 day ago SourceDatabase.php 1 day ago WpAdapter.php 1 day ago
WpAdapter.php
122 lines
1 <?php
2
3 namespace WPStaging\Framework\Adapter;
4
5
6
7
8
9
10
11 class WpAdapter
12 {
13
14 const FILTER_OPTION_ACTIVE_PLUGINS = 'option_active_plugins';
15
16
17 const FILTER_SITE_OPTION_ACTIVE_SITEWIDE_PLUGINS = 'site_option_active_sitewide_plugins';
18
19
20
21
22
23
24
25
26 public function doingAjax()
27 {
28 return defined('DOING_AJAX') && DOING_AJAX;
29 }
30
31
32
33
34 public function isWpCliRequest()
35 {
36 return defined('WP_CLI') && WP_CLI;
37 }
38
39
40
41
42
43
44
45
46
47 public function isPluginActive($plugin)
48 {
49
50 remove_all_filters(self::FILTER_OPTION_ACTIVE_PLUGINS);
51 return in_array($plugin, (array) get_option('active_plugins', [])) || $this->isPluginNetworkActive($plugin);
52 }
53
54
55
56
57
58
59
60
61
62 public function isPluginNetworkActive($plugin)
63 {
64 if (!is_multisite()) {
65 return false;
66 }
67
68
69 remove_all_filters(self::FILTER_SITE_OPTION_ACTIVE_SITEWIDE_PLUGINS);
70 $plugins = get_site_option('active_sitewide_plugins');
71 if (isset($plugins[$plugin])) {
72 return true;
73 }
74
75 return false;
76 }
77
78
79
80
81
82
83
84
85
86 public function getCurrentNetworkId()
87 {
88
89 if (!is_multisite()) {
90 return 1;
91 }
92
93
94 if (is_callable('get_current_network_id')) {
95 return get_current_network_id();
96 }
97
98
99 if (!is_callable('get_current_site')) {
100 return 1;
101 }
102
103 $currentSite = get_current_site();
104
105 if (!is_object($currentSite)) {
106 return 1;
107 }
108
109
110 if (property_exists($currentSite, 'id')) {
111 $currentSite->id;
112 }
113
114
115 if (property_exists($currentSite, 'ID')) {
116 $currentSite->ID;
117 }
118
119 return 1;
120 }
121 }
122