PluginProbe ʕ •ᴥ•ʔ
WP STAGING – WordPress Backups, Restore, Migration & Clone / 3.2.0
WP STAGING – WordPress Backups, Restore, Migration & Clone v3.2.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 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 / Utils / PluginInfo.php
wp-staging / Framework / Utils Last commit date
Cache 2 years ago ThirdParty 2 years ago DBPermissions.php 2 years ago Escape.php 2 years ago Hooks.php 2 years ago Math.php 2 years ago PluginInfo.php 2 years ago Sanitize.php 3 years ago ServerVars.php 2 years ago SlashMode.php 5 years ago Strings.php 2 years ago Times.php 2 years ago Urls.php 3 years ago WpDefaultDirectories.php 3 years ago
PluginInfo.php
106 lines
1 <?php
2
3 namespace WPStaging\Framework\Utils;
4
5 class PluginInfo
6 {
7 /**
8 * Checks if the admin menu can be displayed. The different cases are:
9 * - if the free only version is active;
10 * - if the pro version is active then the free version must be active and compatible with the pro version.
11 *
12 * @return bool
13 */
14 public function canShowAdminMenu(): bool
15 {
16 if (!defined('WPSTGPRO_VERSION')) {
17 return true;
18 }
19
20 if (wpstgIsFreeActiveInNetworkOrCurrentSite()) {
21 return true;
22 }
23
24 if (wpstgIsFreeVersionCompatible()) {
25 return true;
26 }
27
28 return false;
29 }
30
31 /**
32 * @return array
33 */
34 public function getAllActivePluginsInSubsites(): array
35 {
36 if (!is_multisite()) {
37 return [];
38 }
39
40 $activePlugins = [];
41 $sites = get_sites();
42
43 foreach ($sites as $site) {
44 switch_to_blog($site->blog_id);
45
46 $activeForCurrent = (array) get_option('active_plugins', []);
47 $activeWithPath = array_map(
48 function ($plugin) {
49 return trailingslashit(WP_PLUGIN_DIR) . $plugin;
50 },
51 $activeForCurrent
52 );
53
54 $activePlugins = array_merge($activePlugins, $activeWithPath);
55
56 restore_current_blog();
57 }
58
59 return array_unique($activePlugins);
60 }
61
62 /**
63 * @return array
64 */
65 public function getAllActiveThemesInSubsites(): array
66 {
67 if (!is_multisite()) {
68 return [];
69 }
70
71 $activeThemes = [];
72 $sites = get_sites();
73
74 remove_all_filters('stylesheet_directory'); // to get the real value of get_stylesheet_directory().
75 remove_all_filters('template_directory'); // to get the real value of get_template_directory().
76
77 foreach ($sites as $site) {
78 switch_to_blog($site->blog_id);
79
80 $activeThemes[] = get_stylesheet_directory();
81 $activeThemes[] = get_template_directory();
82
83 restore_current_blog();
84 }
85
86 return array_unique($activeThemes);
87 }
88
89 /**
90 * Get active parent and child themes
91 * @return array
92 */
93 public function getActiveThemes(): array
94 {
95 $activeThemes = [];
96
97 remove_all_filters('stylesheet_directory'); // to get the real value of get_stylesheet_directory().
98 remove_all_filters('template_directory'); // to get the real value of get_template_directory().
99
100 $activeThemes[] = get_stylesheet_directory(); // child theme
101 $activeThemes[] = get_template_directory(); // parent theme
102
103 return array_unique($activeThemes);
104 }
105 }
106