| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Metricool\Services; |
| 6 |
|
| 7 |
class TrackingScriptService |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Stores the tracking hash in the database |
| 11 |
*/ |
| 12 |
public function storeTrackingHash(string $hash): self |
| 13 |
{ |
| 14 |
update_option('metricool_tracking_script_hash', $hash); |
| 15 |
|
| 16 |
return $this; |
| 17 |
} |
| 18 |
|
| 19 |
public function activateTrackingWidget(): self |
| 20 |
{ |
| 21 |
update_option('metricool_tracking_script_active', true); |
| 22 |
|
| 23 |
return $this; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Returns if the user has enabled the widget in the settings |
| 28 |
*/ |
| 29 |
public function isTrackingWidgetActive(): bool |
| 30 |
{ |
| 31 |
return (bool) get_option('metricool_tracking_script_active', false); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Returns the hash from settings |
| 36 |
*/ |
| 37 |
public function getTrackingHash(): string |
| 38 |
{ |
| 39 |
return (string) get_option('metricool_tracking_script_hash', ''); |
| 40 |
} |
| 41 |
} |
| 42 |
|