forked from simpleanalytics/wordpress-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnalyticsScript.php
More file actions
36 lines (31 loc) · 1.28 KB
/
Copy pathAnalyticsScript.php
File metadata and controls
36 lines (31 loc) · 1.28 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
<?php
namespace SimpleAnalytics\Scripts;
use SimpleAnalytics\Scripts\Contracts\HasAttributes;
use SimpleAnalytics\Scripts\Contracts\HideScriptId;
use SimpleAnalytics\Scripts\Contracts\Script;
use SimpleAnalytics\Setting;
use SimpleAnalytics\SettingName;
class AnalyticsScript implements Script, HasAttributes, HideScriptId
{
public function path(): string
{
return sprintf("https://%s/latest.js", Setting::get(SettingName::CUSTOM_DOMAIN, 'scripts.simpleanalyticscdn.com'));
}
public function handle(): string
{
return 'simpleanalytics';
}
public function attributes(): array
{
return array_filter([
'data-platform' => 'wordpress',
'data-mode' => Setting::boolean(SettingName::HASH_MODE) ? 'hash' : null,
'data-collect-dnt' => Setting::boolean(SettingName::COLLECT_DNT) ? 'true' : null,
'data-ignore-pages' => Setting::get(SettingName::IGNORE_PAGES),
'data-auto-collect' => Setting::get(SettingName::MANUAL_COLLECT) ? 'true' : null,
'data-onload' => Setting::get(SettingName::ONLOAD_CALLBACK),
'data-sa-global' => Setting::get(SettingName::SA_GLOBAL),
'data-hostname' => Setting::get(SettingName::HOSTNAME),
]);
}
}