Click.php
8 months ago
Click_Processing_Job.php
4 days ago
Config_File_Manager.php
4 days ago
Link_Rule.php
1 year ago
Link_Rule_Finder.php
2 months ago
Site.php
4 days ago
Site.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP\Click_Tracking; |
| 4 | |
| 5 | use IAWPSCOPED\Illuminate\Support\Str; |
| 6 | /** @internal */ |
| 7 | class Site |
| 8 | { |
| 9 | /** |
| 10 | * A site will have a click id only if it's part of a multisite network. |
| 11 | */ |
| 12 | public static function id() : ?string |
| 13 | { |
| 14 | if (!\is_multisite()) { |
| 15 | return null; |
| 16 | } |
| 17 | $option_value = \get_option('iawp_click_tracking_id'); |
| 18 | if (!\is_string($option_value)) { |
| 19 | \update_option('iawp_click_tracking_id', Str::random(8), \false); |
| 20 | $option_value = \get_option('iawp_click_tracking_id'); |
| 21 | } |
| 22 | return $option_value; |
| 23 | } |
| 24 | /** |
| 25 | * A site will have a non-empty click file suffix only if it's part of a multisite network. |
| 26 | */ |
| 27 | public static function file_suffix() : string |
| 28 | { |
| 29 | if (self::id() === null) { |
| 30 | return ''; |
| 31 | } |
| 32 | return '-' . self::id(); |
| 33 | } |
| 34 | } |
| 35 |