Skip to content

Commit 9480067

Browse files
allow pro plugin to filter pageview data and contents of optimized endpoint file
1 parent d921d26 commit 9480067

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/class-endpoint-installer.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function get_file_contents(): string
3535
$functions_filename = ltrim(substr($functions_filename, strlen(ABSPATH)), '/');
3636
}
3737

38-
return <<<EOT
38+
$content = <<<EOT
3939
<?php
4040
/**
4141
* @package koko-analytics
@@ -61,6 +61,7 @@ public static function get_file_contents(): string
6161
KokoAnalytics\collect_request();
6262
6363
EOT;
64+
return apply_filters('koko_analytics_endpoint_file_contents', $content);
6465
}
6566

6667
/**

src/collect-functions.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,20 @@ function extract_pageview_data(array $raw): array
4242
// limit referrer URL to 255 chars
4343
$referrer_url = \substr($referrer_url, 0, 255);
4444

45-
return [
45+
$data = [
4646
'p', // type indicator
4747
\time(), // unix timestamp
4848
$post_id,
4949
$new_visitor ? 1 : 0,
5050
$unique_pageview ? 1 : 0,
5151
$referrer_url,
5252
];
53+
54+
if (function_exists('KokoAnalytics\Pro\filter_pageview_data')) {
55+
$data = \KokoAnalytics\Pro\filter_pageview_data($data);
56+
}
57+
58+
return $data;
5359
}
5460

5561
function extract_event_data(array $raw): array

0 commit comments

Comments
 (0)