-
Notifications
You must be signed in to change notification settings - Fork 5
/
StatsUtils.php
43 lines (40 loc) · 1.35 KB
/
StatsUtils.php
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
42
43
<?php
/*[pro strip-from="lite"]*/
namespace WebSharks\ZenCache\Pro;
/*
* Pings our stats log w/ anonymous details.
*
* @since 150716 Adding stats logging.
*
* @attaches-to `admin_init` hook.
*
* @see https://zencache.com/?p=1458
*/
$self->statsLogPinger = function () use ($self) {
if (!$self->applyWpFilters(GLOBAL_NS.'_statsLogPinger_enable', IS_PRO)) {
return; // Stats collection disabled by site.
}
if ($self->options['last_pro_stats_log'] >= strtotime('-1 week')) {
return; // No reason to keep pinging.
}
$self->updateOptions(array('last_pro_stats_log' => time()));
$wpdb = $self->wpdb(); // WordPress DB.
$stats_api_url = 'https://www.websharks-inc.com/products/stats-log.php';
$stats_api_url_args = array( // See: <https://zencache.com/?p=1458>
'os' => PHP_OS,
'php_version' => PHP_VERSION,
'mysql_version' => $wpdb->db_version(),
'wp_version' => get_bloginfo('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_url);
wp_remote_get(
$stats_api_url,
array(
'blocking' => false,
'sslverify' => false,
)
);
};
/*[/pro]*/