PluginProbe ʕ •ᴥ•ʔ
Starter Templates – AI-Powered Templates for Elementor & Gutenberg / 4.4.45
Starter Templates – AI-Powered Templates for Elementor & Gutenberg v4.4.45
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 4 years ago classes 1 year ago modules 10 months ago changelog.txt 10 months ago class-bsf-analytics-loader.php 5 years ago class-bsf-analytics-stats.php 1 year ago class-bsf-analytics.php 1 year ago version.json 10 months ago
class-bsf-analytics-stats.php
259 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'] ) ? wp_kses( wp_unslash( $_SERVER['SERVER_SOFTWARE'] ), [] ) : '',
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 'posts_count' => wp_count_posts()->publish,
89 'page_count' => wp_count_posts( 'page' )->publish,
90 'site_language' => get_locale(),
91 'timezone' => wp_timezone_string(),
92 'is_ssl' => is_ssl(),
93 'is_multisite' => is_multisite(),
94 'network_url' => network_site_url(),
95 'external_object_cache' => (bool) wp_using_ext_object_cache(),
96 'wp_debug' => WP_DEBUG,
97 'wp_debug_display' => WP_DEBUG_DISPLAY,
98 'script_debug' => SCRIPT_DEBUG,
99
100 'active_plugins' => $this->get_active_plugins(),
101
102 'active_theme' => get_template(),
103 'active_stylesheet' => get_stylesheet(),
104 );
105 }
106
107 /**
108 * Get installed PHP version.
109 *
110 * @return float PHP version.
111 * @since 1.0.0
112 */
113 private function get_php_version() {
114 if ( defined( 'PHP_MAJOR_VERSION' ) && defined( 'PHP_MINOR_VERSION' ) && defined( 'PHP_RELEASE_VERSION' ) ) { // phpcs:ignore
115 return PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION . '.' . PHP_RELEASE_VERSION;
116 }
117
118 return phpversion();
119 }
120
121 /**
122 * User count on site.
123 *
124 * @return int User count.
125 * @since 1.0.0
126 */
127 private function get_user_count() {
128 if ( is_multisite() ) {
129 $user_count = get_user_count();
130 } else {
131 $count = count_users();
132 $user_count = $count['total_users'];
133 }
134
135 return $user_count;
136 }
137
138 /**
139 * Get active plugin's data.
140 *
141 * @return array active plugin's list.
142 * @since 1.0.0
143 */
144 private function get_active_plugins() {
145 if ( ! $this->plugins ) {
146 // Ensure get_plugin_data function is loaded.
147 if ( ! function_exists( 'get_plugin_data' ) ) {
148 require_once ABSPATH . 'wp-admin/includes/plugin.php';
149 }
150
151 $plugins = wp_get_active_and_valid_plugins();
152 $plugins = array_map( 'get_plugin_data', $plugins );
153 $this->plugins = array_map( array( $this, 'format_plugin' ), $plugins );
154 }
155
156 return $this->plugins;
157 }
158
159 /**
160 * Format plugin data.
161 *
162 * @param string $plugin plugin.
163 * @return array formatted plugin data.
164 * @since 1.0.0
165 */
166 public function format_plugin( $plugin ) {
167 return array(
168 'name' => html_entity_decode( $plugin['Name'], ENT_COMPAT, 'UTF-8' ),
169 'url' => $plugin['PluginURI'],
170 'version' => $plugin['Version'],
171 'slug' => $plugin['TextDomain'],
172 'author_name' => html_entity_decode( wp_strip_all_tags( $plugin['Author'] ), ENT_COMPAT, 'UTF-8' ),
173 'author_url' => $plugin['AuthorURI'],
174 );
175 }
176
177 /**
178 * Curl SSL version.
179 *
180 * @return float SSL version.
181 * @since 1.0.0
182 */
183 private function get_curl_ssl_version() {
184 $curl = array();
185 if ( function_exists( 'curl_version' ) ) {
186 $curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
187 }
188
189 return isset( $curl['ssl_version'] ) ? $curl['ssl_version'] : false;
190 }
191
192 /**
193 * Get cURL version.
194 *
195 * @return float cURL version.
196 * @since 1.0.0
197 */
198 private function get_curl_version() {
199 if ( function_exists( 'curl_version' ) ) {
200 $curl = curl_version(); // phpcs:ignore WordPress.WP.AlternativeFunctions.curl_curl_version
201 }
202
203 return isset( $curl['version'] ) ? $curl['version'] : false;
204 }
205
206 /**
207 * Get MySQL version.
208 *
209 * @return float MySQL version.
210 * @since 1.0.0
211 */
212 private function get_mysql_version() {
213 global $wpdb;
214 return $wpdb->db_version();
215 }
216
217 /**
218 * Check if content directory is writable.
219 *
220 * @return bool
221 * @since 1.0.0
222 */
223 private function is_content_writable() {
224 $upload_dir = wp_upload_dir();
225 return wp_is_writable( $upload_dir['basedir'] );
226 }
227 }
228 }
229
230 /**
231 * Polyfill for sites using WP version less than 5.3
232 */
233 if ( ! function_exists( 'wp_timezone_string' ) ) {
234 /**
235 * Get timezone string.
236 *
237 * @return string timezone string.
238 * @since 1.0.0
239 */
240 function wp_timezone_string() {
241 $timezone_string = get_option( 'timezone_string' );
242
243 if ( $timezone_string ) {
244 return $timezone_string;
245 }
246
247 $offset = (float) get_option( 'gmt_offset' );
248 $hours = (int) $offset;
249 $minutes = ( $offset - $hours );
250
251 $sign = ( $offset < 0 ) ? '-' : '+';
252 $abs_hour = abs( $hours );
253 $abs_mins = abs( $minutes * 60 );
254 $tz_offset = sprintf( '%s%02d:%02d', $sign, $abs_hour, $abs_mins );
255
256 return $tz_offset;
257 }
258 }
259