PluginProbe ʕ •ᴥ•ʔ
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution / 4.8.7
ShopEngine Elementor WooCommerce Builder Addon – All in One WooCommerce Solution v4.8.7
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 / onboard / plugin-data-sender.php
shopengine / core / onboard Last commit date
onboard.php 11 months ago plugin-data-sender.php 11 months ago
plugin-data-sender.php
150 lines
1 <?php
2
3 namespace ShopEngine\Core\Onboard;
4
5 use ShopEngine\Core\Onboard\Onboard;
6 use ShopEngine\Traits\Singleton;
7
8 defined('ABSPATH') || exit;
9
10 class Plugin_Data_Sender
11 {
12 use Singleton;
13
14 /**
15 * @var array
16 */
17 private $installedPlugins = [];
18 /**
19 * @var array
20 */
21 private $themes = [];
22 /**
23 * @var array
24 */
25 private $activatedPlugins = [];
26
27 public function __construct()
28 {
29 $this->set_activated_plugins();
30 $this->set_installed_plugins();
31 $this->setThemes();
32 }
33
34 private function set_activated_plugins()
35 {
36 foreach (apply_filters('active_plugins', get_option('active_plugins')) as $plugin) {
37 array_push($this->activatedPlugins, $plugin);
38 }
39 }
40
41 private function set_installed_plugins()
42 {
43 foreach (get_plugins() as $key => $plugin) {
44 $status = false;
45 if (in_array($key, $this->activatedPlugins)) {
46 $status = true;
47 }
48 array_push($this->installedPlugins, [
49 'name' => $plugin['Name'],
50 'version' => $plugin['Version'],
51 'is_active' => $status
52 ]);
53 }
54 }
55
56 private function setThemes()
57 {
58 $activeTheme = wp_get_theme()->get('Name');
59 foreach (wp_get_themes() as $key => $theme) {
60 array_push($this->themes, [
61 "name" => $theme->Name,
62 "version" => $theme->Version,
63 'is_active' => $activeTheme == $theme->Name
64 ]);
65 }
66 }
67
68 /**
69 * @param $route
70 */
71 private function getUrl($route)
72 {
73 return Onboard::ACCOUNT_URL . '/sync/api/' . $route;
74 }
75
76 /**
77 * @param $route
78 */
79 public function send($route)
80 {
81 return wp_remote_post(
82 $this->getUrl($route),
83 [
84 'method' => 'POST',
85 'data_format' => 'body',
86 'headers' => [
87 'Content-Type' => 'application/json'
88 ],
89 'body' => json_encode($this->get_data())
90 ]
91 );
92 }
93
94 /**
95 * @param $route
96 * @param $data
97 */
98 public function sendAutomizyData($route, $data)
99 {
100 return wp_remote_post(
101 $this->getUrl($route),
102 [
103 'method' => 'POST',
104 'data_format' => 'body',
105 'headers' => [
106 'Content-Type' => 'application/json'
107 ],
108 'body' => json_encode($data)
109 ]
110 );
111 }
112
113 /**
114 * @param $route
115 * @param $data
116 */
117 public function sendEmailSubscribeData( $route, $data )
118 {
119 return wp_remote_post(
120 'https://api.wpmet.com/public/' . $route,
121 [
122 'method' => 'POST',
123 'data_format' => 'body',
124 'headers' => [
125 'Accept' => '*/*',
126 'Content-Type' => 'application/json'
127 ],
128 'body' => json_encode($data)
129 ]
130 );
131 }
132
133 public function get_data()
134 {
135 return [
136 'environment_id' => Onboard::ENVIRONMENT_ID,
137 "domain" => get_site_url(),
138 "total_user" => count_users()['total_users'],
139 "themes" => $this->themes,
140 "plugins" => $this->installedPlugins,
141 "php_version" => phpversion(),
142 "db_version" => mysqli_get_client_version(), //phpcs:ignore WordPress.DB.RestrictedFunctions.mysql_mysqli_get_client_version
143 "server_name" => !empty($_SERVER['SERVER_SOFTWARE']) ? explode(' ', sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE'])))[0] : '',
144 "max_execution_time" => ini_get('max_execution_time'),
145 "php_memory_size" => ini_get('memory_limit'),
146 "language" => get_locale()
147 ];
148 }
149 }
150