PluginProbe ʕ •ᴥ•ʔ
Wp Social Login and Register Social Counter / trunk
Wp Social Login and Register Social Counter vtrunk
trunk 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.10 1.3.11 1.3.2 1.3.3 1.3.4 1.3.6 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.4 1.4.5 1.4.6 1.4.8 1.4.9 1.5.0 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.5 1.8.6 1.9.0 2.0.0 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.8 2.2.9 3.0.0 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0
wp-social / lib / onboard / classes / plugin-data-sender.php
wp-social / lib / onboard / classes Last commit date
ajax.php 7 months ago plugin-data-sender.php 9 months ago plugin-installer.php 7 months ago plugin-skin.php 7 months ago plugin-status.php 4 years ago utils.php 3 years ago
plugin-data-sender.php
125 lines
1 <?php
2
3 namespace WP_Social\Lib\Onboard\Classes;
4
5 use WP_Social\Lib\Onboard\Onboard;
6 use WP_Social\Plugin;
7 use WP_Social\Traits\Singleton;
8
9 defined( 'ABSPATH' ) || exit;
10
11 class Plugin_Data_Sender {
12
13 use Singleton;
14
15 private $installedPlugins = [];
16 private $themes = [];
17 private $activatedPlugins = [];
18
19 public function __construct() {
20 $this->set_activated_plugins();
21 $this->set_installed_plugins();
22 $this->setThemes();
23 }
24
25 private function set_activated_plugins() {
26 foreach ( apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) as $plugin ) {
27 array_push( $this->activatedPlugins, $plugin );
28 }
29 }
30
31 private function set_installed_plugins() {
32 foreach ( get_plugins() as $key => $plugin ) {
33 $status = false;
34 if ( in_array( $key, $this->activatedPlugins ) ) {
35 $status = true;
36 }
37 array_push( $this->installedPlugins, [
38 'name' => $plugin['Name'],
39 'version' => $plugin['Version'],
40 'is_active' => $status,
41 ] );
42 }
43 }
44
45 private function setThemes() {
46 $activeTheme = wp_get_theme()->get('Name') ;
47 foreach (wp_get_themes() as $key => $theme) {
48 array_push($this->themes, [
49 "name" => $theme->Name,
50 "version" => $theme->Version,
51 'is_active' => $activeTheme == $theme->Name,
52 ]);
53 }
54 }
55
56
57 private function getUrl( $route ) {
58 return Plugin::instance()->account_url(). '/sync/api/' . $route;
59 }
60
61 public function send( $route ) {
62 return wp_remote_post(
63 $this->getUrl($route) ,
64 [
65 'method' => 'POST',
66 'data_format' => 'body',
67 'headers' => [
68 'Content-Type' => 'application/json'
69 ],
70 'body' => json_encode( $this->get_data() )
71 ]
72 );
73 }
74
75 public function sendAutomizyData( $route, $data ) {
76 return wp_remote_post(
77 $this->getUrl($route) ,
78 [
79 'method' => 'POST',
80 'data_format' => 'body',
81 'headers' => [
82 'Content-Type' => 'application/json'
83 ],
84 'body' => json_encode( $data )
85 ]
86 );
87 }
88
89 /**
90 * @param $route
91 * @param $data
92 */
93 public function sendEmailSubscribeData( $route, $data )
94 {
95 return wp_remote_post(
96 'https://api.wpmet.com/public/' . $route,
97 [
98 'method' => 'POST',
99 'data_format' => 'body',
100 'headers' => [
101 'Accept' => '*/*',
102 'Content-Type' => 'application/json'
103 ],
104 'body' => json_encode($data)
105 ]
106 );
107 }
108
109 public function get_data() {
110 return [
111 'environment_id' => Onboard::ENVIRONMENT_ID,
112 "domain" => get_home_url(),
113 "total_user" => count_users()['total_users'],
114 "themes" => $this->themes,
115 "plugins" => $this->installedPlugins,
116 "php_version" => phpversion(),
117 "db_version" => mysqli_get_client_version(),
118 "server_name" => explode( ' ', sanitize_text_field( $_SERVER['SERVER_SOFTWARE'] ))[0],
119 "max_execution_time" => ini_get( 'max_execution_time' ),
120 "php_memory_size" => ini_get( 'memory_limit' ),
121 "language" => get_locale()
122 ];
123
124 }
125 }