PluginProbe ʕ •ᴥ•ʔ
Starter Templates – AI-Powered Templates for Elementor & Gutenberg / 2.6.11
Starter Templates – AI-Powered Templates for Elementor & Gutenberg v2.6.11
4.6.1 4.6.0 4.5.4 4.5.3 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.5.0 2.5.1 2.6.0 2.6.1 2.6.10 2.6.11 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.18 2.6.19 2.6.2 2.6.20 2.6.21 2.6.22 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.24 3.0.25 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.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.21 3.1.22 3.1.23 3.1.24 3.1.25 3.1.26 3.1.27 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.10 4.4.11 4.4.12 4.4.13 4.4.14 4.4.16 4.4.17 4.4.18 4.4.19 4.4.2 4.4.20 4.4.21 4.4.22 4.4.23 4.4.24 trunk 4.4.25 0.4.4.0 4.4.26 0.4.4.15 4.4.27 1.0.0 4.4.28 1.0.1 4.4.29 1.0.10 4.4.3 1.0.11 4.4.30 1.0.12 4.4.31 1.0.13 4.4.32 1.0.14 4.4.33 1.0.2 4.4.34 1.0.3 4.4.35 1.0.4 4.4.36 1.0.5 4.4.37 1.0.6 4.4.38 1.0.7 4.4.39 1.0.8 4.4.4 1.0.9 4.4.40 1.1.0 4.4.41 1.1.1 4.4.42 1.1.2 4.4.43 1.1.3 4.4.44 1.1.4 4.4.45 1.1.5 4.4.46 1.1.6 4.4.47 1.1.7 4.4.48 1.1.8 4.4.49 1.1.9 4.4.5 1.2.0 4.4.50 1.2.1 4.4.51 1.2.10 4.4.52 1.2.11 4.4.6 1.2.12 4.4.7 1.2.13 4.4.8 1.2.14 4.4.9 1.2.15 4.5.0 1.2.2 4.5.1 1.2.3 4.5.2 1.2.4 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.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.19 1.3.2 1.3.20 1.3.21 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 2.0.0 2.0.1 2.0.2 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5
astra-sites / admin / bsf-analytics / class-bsf-analytics-stats.php
astra-sites / admin / bsf-analytics Last commit date
assets 5 years ago class-bsf-analytics-loader.php 5 years ago class-bsf-analytics-stats.php 5 years ago class-bsf-analytics.php 5 years ago version.json 5 years ago
class-bsf-analytics-stats.php
257 lines
1 <?php
2 /**
3 * BSF analytics stat class file.
4 *
5 * @package bsf-analytics
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit; // Exit if accessed directly.
10 }
11
12 if ( ! class_exists( 'BSF_Analytics_Stats' ) ) {
13 /**
14 * BSF analytics stat class.
15 */
16 class BSF_Analytics_Stats {
17
18 /**
19 * Active plugins.
20 *
21 * Holds the sites active plugins list.
22 *
23 * @var array
24 */
25 private $plugins;
26
27 /**
28 * Instance of BSF_Analytics_Stats.
29 *
30 * Holds only the first object of class.
31 *
32 * @var object
33 */
34 private static $instance = null;
35
36 /**
37 * Create only once instance of a class.
38 *
39 * @return object
40 * @since 1.0.0
41 */
42 public static function instance() {
43 if ( null === self::$instance ) {
44 self::$instance = new self();
45 }
46
47 return self::$instance;
48 }
49
50 /**
51 * Get stats.
52 *
53 * @return array stats data.
54 * @since 1.0.0
55 */
56 public function get_stats() {
57 return apply_filters( 'bsf_core_stats', $this->get_default_stats() );
58 }
59
60 /**
61 * Retrieve stats for site.
62 *
63 * @return array stats data.
64 * @since 1.0.0
65 */
66 private function get_default_stats() {
67 return array(
68 'graupi_version' => defined( 'BSF_UPDATER_VERSION' ) ? BSF_UPDATER_VERSION : false,
69 'domain_name' => get_site_url(),
70 'php_os' => PHP_OS,
71 'server_software' => isset( $_SERVER['SERVER_SOFTWARE'] ) ? filter_var( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), FILTER_SANITIZE_STRING ) : '',
72 'mysql_version' => $this->get_mysql_version(),
73 'php_version' => $this->get_php_version(),
74 'php_max_input_vars' => ini_get( 'max_input_vars' ), // phpcs:ignore:PHPCompatibility.IniDirectives.NewIniDirectives.max_input_varsFound
75 'php_post_max_size' => ini_get( 'post_max_size' ),
76 'php_max_execution_time' => ini_get( 'max_execution_time' ),
77 'php_memory_limit' => ini_get( 'memory_limit' ),
78 'zip_installed' => extension_loaded( 'zip' ),
79 'imagick_availabile' => extension_loaded( 'imagick' ),
80 'xmlreader_exists' => class_exists( 'XMLReader' ),
81 'gd_available' => extension_loaded( 'gd' ),
82 'curl_version' => $this->get_curl_version(),
83 'curl_ssl_version' => $this->get_curl_ssl_version(),
84 'is_writable' => $this->is_content_writable(),
85
86 'wp_version' => get_bloginfo( 'version' ),
87 'user_count' => $this->get_user_count(),
88 'site_language' => get_locale(),
89 'timezone' => wp_timezone_string(),
90 'is_ssl' => is_ssl(),
91 'is_multisite' => is_multisite(),
92 'network_url' => network_site_url(),
93 'external_object_cache' => (bool) wp_using_ext_object_cache(),
94 'wp_debug' => WP_DEBUG,
95 'wp_debug_display' => WP_DEBUG_DISPLAY,
96 'script_debug' => SCRIPT_DEBUG,
97
98 'active_plugins' => $this->get_active_plugins(),
99
100 'active_theme' => get_template(),
101 'active_stylesheet' => get_stylesheet(),
102 );
103 }
104
105 /**
106 * Get installed PHP version.
107 *
108 * @return float PHP version.
109 * @since 1.0.0
110 */
111 private function get_php_version() {
112 if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
113 return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
114 }
115
116 return phpversion();
117 }
118
119 /**
120 * User count on site.
121 *
122 * @return int User count.
123 * @since 1.0.0
124 */
125 private function get_user_count() {
126 if ( is_multisite() ) {
127 $user_count = get_user_count();
128 } else {
129 $count = count_users();
130 $user_count = $count['total_users'];
131 }
132
133 return $user_count;
134 }
135
136 /**
137 * Get active plugin's data.
138 *
139 * @return array active plugin's list.
140 * @since 1.0.0
141 */
142 private function get_active_plugins() {
143 if ( ! $this->plugins ) {
144 // Ensure get_plugin_data function is loaded.
145 if ( ! function_exists( 'get_plugin_data' ) ) {
146 require_once ABSPATH . 'wp-admin/includes/plugin.php';
147 }
148
149 $plugins = wp_get_active_and_valid_plugins();
150 $plugins = array_map( 'get_plugin_data', $plugins );
151 $this->plugins = array_map( array( $this, 'format_plugin' ), $plugins );
152 }
153
154 return $this->plugins;
155 }
156
157 /**
158 * Format plugin data.
159 *
160 * @param string $plugin plugin.
161 * @return array formatted plugin data.
162 * @since 1.0.0
163 */
164 public function format_plugin( $plugin ) {
165 return array(
166 'name' => html_entity_decode( $plugin['Name'], ENT_COMPAT, 'UTF-8' ),
167 'url' => $plugin['PluginURI'],
168 'version' => $plugin['Version'],
169 'slug' => $plugin['TextDomain'],
170 'author_name' => html_entity_decode( wp_strip_all_tags( $plugin['Author'] ), ENT_COMPAT, 'UTF-8' ),
171 'author_url' => $plugin['AuthorURI'],
172 );
173 }
174
175 /**
176 * Curl SSL version.
177 *
178 * @return float SSL version.
179 * @since 1.0.0
180 */
181 private function get_curl_ssl_version() {
182 $curl = array();
183 if ( function_exists( 'curl_version' ) ) {
184 $curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
185 }
186
187 return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
188 }
189
190 /**
191 * Get cURL version.
192 *
193 * @return float cURL version.
194 * @since 1.0.0
195 */
196 private function get_curl_version() {
197 if ( function_exists( 'curl_version' ) ) {
198 $curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
199 }
200
201 return isset( $curl['version'] ) ? $curl['version'] : false;
202 }
203
204 /**
205 * Get MySQL version.
206 *
207 * @return float MySQL version.
208 * @since 1.0.0
209 */
210 private function get_mysql_version() {
211 global $wpdb;
212 return $wpdb->db_version();
213 }
214
215 /**
216 * Check if content directory is writable.
217 *
218 * @return bool
219 * @since 1.0.0
220 */
221 private function is_content_writable() {
222 $upload_dir = wp_upload_dir();
223 return wp_is_writable( $upload_dir['basedir'] );
224 }
225 }
226 }
227
228 /**
229 * Polyfill for sites using WP version less than 5.3
230 */
231 if ( ! function_exists( 'wp_timezone_string' ) ) {
232 /**
233 * Get timezone string.
234 *
235 * @return string timezone string.
236 * @since 1.0.0
237 */
238 function wp_timezone_string() {
239 $timezone_string = get_option( 'timezone_string' );
240
241 if ( $timezone_string ) {
242 return $timezone_string;
243 }
244
245 $offset = (float) get_option( 'gmt_offset' );
246 $hours = (int) $offset;
247 $minutes = ( $offset - $hours );
248
249 $sign = ( $offset < 0 ) ? '-' : '+';
250 $abs_hour = abs( $hours );
251 $abs_mins = abs( $minutes * 60 );
252 $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
253
254 return $tz_offset;
255 }
256 }
257