-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathStatsUtils.php
More file actions
41 lines (38 loc) · 1.42 KB
/
StatsUtils.php
File metadata and controls
41 lines (38 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/*[pro exclude-file-from="lite"]*/
/*[pro strip-from="lite"]*/
namespace WebSharks\CometCache\Pro\Traits\Plugin;
use WebSharks\CometCache\Pro\Classes;
trait StatsUtils
{
/**
* Pings our stats log w/ anonymous details.
*
* @since 150716 Adding stats logging.
*
* @attaches-to `admin_init` hook.
*
* @see https://cometcache.com/?p=2426
*/
public function statsLogPinger()
{
if (!apply_filters(GLOBAL_NS.'_statsLogPinger_enable', IS_PRO)) {
return; // Stats collection disabled by site.
} elseif ($this->options['last_pro_stats_log'] >= strtotime('-1 week')) {
return; // No reason to keep pinging.
}
$this->updateOptions(['last_pro_stats_log' => time()]);
$stats_api_endpoint = 'https://stats.wpsharks.io/log';
$stats_api_url_args = [ // See: <https://cometcache.com/?p=2426>
'os' => PHP_OS,
'php_version' => PHP_VERSION,
'wp_version' => get_bloginfo('version'),
'mysql_version' => $this->wpdb()->db_version(),
'product_version' => VERSION, // Plugin version.
'product' => SLUG_TD.(IS_PRO ? '-pro' : ''),
];
$stats_api_url = add_query_arg(urlencode_deep($stats_api_url_args), $stats_api_endpoint);
wp_remote_get($stats_api_url, ['blocking' => false, 'sslverify' => false]);
}
}
/*[/pro]*/