PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / trunk
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits vtrunk
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / classes / notifications / base / user-data.php

user-data.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits trunk, at inc/classes/notifications/base/user-data.php

225 lines 5.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace MasterAddons\Inc\Classes\Notifications\Base;
4
5 // No, Direct access Sir !!!
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 trait User_Data
11 {
12
13 /**
14 * Get plugins list
15 *
16 * @author Jewel Theme <support@jeweltheme.com>
17 */
18 public function get_plugins_list()
19 {
20 if (!function_exists('get_plugins')) {
21 require_once ABSPATH . 'wp-admin/includes/plugin.php';
22 }
23
24 $plugins = get_plugins();
25 $activated_plugins = '==== Activated Plugins List ====' . PHP_EOL;
26 $deactivated_plugins = PHP_EOL . PHP_EOL . '==== Deactivated Plugins List ====' . PHP_EOL;
27
28 $active_plugins_keys = get_option('active_plugins', array());
29 $inactive_counter = array();
30 $active_counter = array();
31
32 foreach ($plugins as $key => $plugin) {
33 $network_plugins = !empty($plugin['Network']) ? $plugin['Network'] : 'n/a';
34 $PluginURI = !empty($plugin['PluginURI']) ? $plugin['PluginURI'] : 'n/a';
35 $new_plugin = $plugin['Name'] . '- v' . $plugin['Version'] . ', URL: ' . $PluginURI . ', Network: ' . $network_plugins;
36
37 if (is_plugin_inactive($key)) {
38 $deactivated_plugins .= $new_plugin . PHP_EOL;
39 } else {
40 $activated_plugins .= $new_plugin . PHP_EOL;
41 }
42
43 if (in_array($key, $active_plugins_keys)) {
44 // Remove active plugins from list so we can show active and inactive separately .
45 unset($plugins[$key]);
46 $inactive_counter[$key] = $key;
47 } else {
48 $active_counter[$key] = $key;
49 }
50 }
51
52 return array(
53 'active_plugins' => $activated_plugins,
54 'active_plugins_count' => count($active_counter),
55 'deactivated_plugins' => $deactivated_plugins,
56 'deactivated_plugins_count' => count($inactive_counter),
57 );
58 }
59
60 /**
61 * Get Server Info
62 *
63 * @author Jewel Theme <support@jeweltheme.com>
64 */
65 public function get_server_info()
66 {
67 global $wpdb;
68
69 $server_data = array();
70
71 $server_software = (isset($_SERVER['SERVER_SOFTWARE']) && !empty($_SERVER['SERVER_SOFTWARE'])) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_SOFTWARE'])) : '';
72 if ($server_software) {
73 $server_data['software'] = $server_software;
74 }
75
76 if (function_exists('phpversion')) {
77 $server_data['php_version'] = phpversion();
78 }
79
80 $server_data['mysql_version'] = $wpdb->db_version();
81
82 $server_data['php_max_upload_size'] = size_format(wp_max_upload_size());
83 $server_data['php_default_timezone'] = date_default_timezone_get();
84 $server_data['php_soap'] = class_exists('SoapClient') ? 'Yes' : 'No';
85 $server_data['php_fsockopen'] = function_exists('fsockopen') ? 'Yes' : 'No';
86 $server_data['php_curl'] = function_exists('curl_init') ? 'Yes' : 'No';
87
88 return $server_data;
89 }
90
91 /**
92 * Get WP Info
93 *
94 * @author Jewel Theme <support@jeweltheme.com>
95 */
96 public function get_wp_info()
97 {
98 $wp_data = array();
99
100 $wp_data['memory_limit'] = WP_MEMORY_LIMIT;
101 $wp_data['debug_mode'] = (defined('WP_DEBUG') && WP_DEBUG) ? 'Yes' : 'No';
102 $wp_data['locale'] = get_locale();
103 $wp_data['version'] = get_bloginfo('version');
104 $wp_data['multisite'] = is_multisite() ? 'Yes' : 'No';
105 $wp_data['theme_slug'] = get_stylesheet();
106
107 $theme = wp_get_theme($wp_data['theme_slug']);
108
109 $wp_data['theme_name'] = $theme->get('Name');
110 $wp_data['theme_version'] = $theme->get('Version');
111 $wp_data['theme_uri'] = $theme->get('ThemeURI');
112 $wp_data['theme_author'] = $theme->get('Author');
113
114 return $wp_data;
115 }
116
117 /**
118 * Get User Counts
119 *
120 * @author Jewel Theme <support@jeweltheme.com>
121 */
122 public function get_user_counts()
123 {
124 $user_count = array();
125 $user_count_data = count_users();
126 $user_count['total'] = $user_count_data['total_users'];
127
128 // Get user count based on user role .
129 foreach ($user_count_data['avail_roles'] as $role => $count) {
130 if (!$count) {
131 continue;
132 }
133
134 $user_count[$role] = $count;
135 }
136
137 return $user_count;
138 }
139
140 /**
141 * Get Site Name
142 *
143 * @author Jewel Theme <support@jeweltheme.com>
144 */
145 public function get_site_name()
146 {
147 $site_name = get_bloginfo('name');
148
149 if (empty($site_name)) {
150 $site_name = get_bloginfo('description');
151 $site_name = wp_trim_words($site_name, 3, '');
152 }
153
154 if (empty($site_name)) {
155 $site_name = esc_url(home_url());
156 }
157
158 return $site_name;
159 }
160
161 /**
162 * Check if Local Server
163 *
164 * @return boolean
165 * @author Jewel Theme <support@jeweltheme.com>
166 */
167 public function is_local_server()
168 {
169 $host = isset($_SERVER['HTTP_HOST']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_HOST'])) : 'localhost';
170 $ip = isset($_SERVER['SERVER_ADDR']) ? sanitize_text_field(wp_unslash($_SERVER['SERVER_ADDR'])) : '127.0.0.1';
171 $is_local = false;
172
173 if (
174 in_array($ip, array('127.0.0.1', '::1'))
175 || !strpos($host, '.')
176 || in_array(strrchr($host, '.'), array('.test', '.testing', '.local', '.localhost', '.localdomain'))
177 ) {
178 $is_local = true;
179 }
180
181 return apply_filters('jltma_is_local', $is_local);
182 }
183
184 /**
185 * Get Collection Data
186 *
187 * @return void
188 * @author Jewel Theme <support@jeweltheme.com>
189 */
190 public function get_collect_data($user_id, $arr = [])
191 {
192 // Only the data the administrator actively submits through the form,
193 // plus the site URL and plugin slug needed to route the request.
194 // No site telemetry, plugin list, IP address or customer billing data is sent.
195 $data = array(
196 'site_url' => \get_site_url(),
197 'installed_product_slug' => JLTMA_SLUG,
198 );
199
200 $payload_data = array_merge($arr, $data);
201 $endpoint_url = \MasterAddons\Inc\Classes\Helper::crm_endpoint();
202 if ('local' === wp_get_environment_type()) {
203 $response = wp_remote_post(
204 $endpoint_url,
205 array(
206 'body' => json_encode( $payload_data ),
207 'timeout' => 100,
208 'sslverify' => false,
209 )
210 );
211 } else {
212 // 'production' === wp_get_environment_type() .
213 $response = wp_safe_remote_post(
214 $endpoint_url,
215 array(
216 'body' => json_encode( $payload_data ),
217 'timeout' => 100,
218 )
219 );
220 }
221
222 return $response;
223 }
224 }
225