PluginProbe
Metricool – Social media and site statistics / trunk
Metricool – Social media and site statistics vtrunk
2.1.0 2.0.2 2.0.1 2.0.0 1.27 trunk
← All changes | app/Services/TrackingScriptService.php +44 -0 2.0.1trunk View file →
@@ -1,0 +1,44 @@
1 +<?php
2 +
3 +declare(strict_types=1);
4 +
5 +namespace Metricool\Services;
6 +
7 +class TrackingScriptService
8 +{
9 + public const OPTION_TRACKING_HASH = 'metricool_tracking_script_hash';
10 + public const OPTION_TRACKING_ACTIVE = 'metricool_tracking_script_active';
11 +
12 + /**
13 + * Stores the tracking hash in the database
14 + */
15 + public function storeTrackingHash(string $hash): self
16 + {
17 + update_option(self::OPTION_TRACKING_HASH, $hash, true);
18 +
19 + return $this;
20 + }
21 +
22 + public function activateTrackingWidget(): self
23 + {
24 + update_option(self::OPTION_TRACKING_ACTIVE, true, true);
25 +
26 + return $this;
27 + }
28 +
29 + /**
30 + * Returns if the user has enabled the widget in the settings
31 + */
32 + public function isTrackingWidgetActive(): bool
33 + {
34 + return (bool) get_option(self::OPTION_TRACKING_ACTIVE, false);
35 + }
36 +
37 + /**
38 + * Returns the hash from settings
39 + */
40 + public function getTrackingHash(): string
41 + {
42 + return (string) get_option(self::OPTION_TRACKING_HASH, '');
43 + }
44 +}