PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.6.0
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.6.0
4.9.1 4.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.1 3.0.0 3.1.0 3.1.1 4.0.0 4.0.1 4.1.0 4.1.1 4.2.0 4.2.1 4.3.0 4.3.1 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.6.6 4.6.7 4.6.8 4.6.9 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.7.8 4.7.9 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 trunk 0.1.2-beta 0.1.3-beta 0.1.4-beta 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.2.1 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.5.0 1.5.1 1.6.0 1.6.1 1.7.0 1.8.0 1.8.1 1.9.0
shopengine / core / settings / plugin-status.php
shopengine / core / settings Last commit date
screens 4 years ago action.php 3 years ago api.php 3 years ago base.php 2 years ago plugin-status.php 3 years ago
plugin-status.php
179 lines
1 <?php
2
3 namespace ShopEngine\Core\Settings;
4
5 defined('ABSPATH') || exit;
6
7 class Plugin_Status
8 {
9 /**
10 * @var mixed
11 */
12 private static $instance;
13 /**
14 * @var array
15 */
16 private $installedPlugins = [];
17 /**
18 * @var array
19 */
20 private $activatedPlugins = [];
21
22 public function __construct()
23 {
24 $this->collect_installed_plugins();
25 $this->collect_activated_plugins();
26 }
27
28 private function collect_installed_plugins()
29 {
30 foreach (get_plugins() as $key => $plugin) {
31 array_push($this->installedPlugins, $key);
32 }
33 }
34
35 private function collect_activated_plugins()
36 {
37 foreach (apply_filters('active_plugins', get_option('active_plugins')) as $plugin) {
38 array_push($this->activatedPlugins, $plugin);
39 }
40 }
41
42 public static function instance()
43 {
44 if (!static::$instance) {
45 static::$instance = new static();
46 }
47
48 return static::$instance;
49 }
50
51 /**
52 * @return mixed
53 */
54 public function get_installed_plugins()
55 {
56 return $this->installedPlugins;
57 }
58
59 /**
60 * @return mixed
61 */
62 public function get_activated_plugins()
63 {
64 return $this->activatedPlugins;
65 }
66
67 /**
68 * @param $name
69 * @return mixed
70 */
71 public function get_status($name)
72 {
73 $data = [
74 "url" => "",
75 "activation_url" => "",
76 "installation_url" => "",
77 "title" => "",
78 "status" => ""
79 ];
80
81 if ($this->check_installed_plugin($name)) {
82 if ($this->check_activated_plugin($name)) {
83 $data['title'] = __('Activated', 'shopengine');
84 $data['status'] = "activated";
85 } else {
86 $data['title'] = __('Activate Now', 'shopengine');
87 $data['status'] = 'installed';
88 $data['activation_url'] = $this->activation_url($name);
89 }
90 } else {
91 $data['title'] = __('Install Now', 'shopengine');
92 $data['status'] = 'not_installed';
93 $data['installation_url'] = $this->installation_url($name);
94 $data['activation_url'] = $this->activation_url($name);
95 }
96
97 return $data;
98 }
99
100 /**
101 * @param $name
102 */
103 public function check_installed_plugin($name)
104 {
105 return in_array($name, $this->installedPlugins);
106 }
107
108 /**
109 * @param $name
110 */
111 public function check_activated_plugin($name)
112 {
113 return in_array($name, $this->activatedPlugins);
114 }
115
116 /**
117 * @param $pluginName
118 */
119 public function activation_url($pluginName)
120 {
121
122 $url = wp_nonce_url(add_query_arg(
123 [
124 'action' => 'activate',
125 'plugin' => $pluginName,
126 'plugin_status' => 'all',
127 'paged' => '1&s'
128 ],
129 admin_url('plugins.php')
130 ), 'activate-plugin_' . $pluginName);
131
132 return str_replace('&amp;', '&', $url);
133 }
134
135 /**
136 * @param $pluginName
137 */
138 public function installation_url($pluginName)
139 {
140 $action = 'install-plugin';
141 $pluginSlug = $this->get_plugin_slug($pluginName);
142
143 $url = wp_nonce_url(
144 add_query_arg(
145 [
146 'action' => $action,
147 'plugin' => $pluginSlug
148 ],
149 admin_url('update.php')
150 ),
151 $action . '_' . $pluginSlug
152 );
153
154 return str_replace('&amp;', '&', $url);
155 }
156
157 /**
158 * @param $name
159 */
160 public function get_plugin_slug($name)
161 {
162 $split = explode('/', $name);
163
164 return isset($split[0]) ? $split[0] : null;
165 }
166
167 /**
168 * @param $pluginName
169 */
170 public function activated_url($pluginName)
171 {
172 return add_query_arg(
173 [
174 'page' => $this->get_plugin_slug($pluginName)
175 ],
176 admin_url('admin.php'));
177 }
178 }
179