PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.7
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.7
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Classes / Notifications / Base / User_Data.php

User_Data.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.7, at Inc/Classes/Notifications/Base/User_Data.php

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