| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -52,8 +52,17 @@ | ||
| 52 | 52 | { |
| 53 | 53 | return; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | + /** | |
| 57 | + * A network is one install, so it reports once. Without this every site | |
| 58 | + * that opts in sends its own weekly payload for the same install. | |
| 59 | + */ | |
| 60 | + if (is_multisite() && !$this->isTrackingSite()) | |
| 61 | + { | |
| 62 | + return; | |
| 63 | + } | |
| 64 | + | |
| 56 | 65 | if (wp_next_scheduled($this->tracking_hook)) |
| 57 | 66 | { |
| 58 | 67 | return; |
| 59 | 68 | } |
| @@ -60,8 +69,30 @@ | ||
| 60 | 69 | |
| 61 | 70 | // Schedule event to run weekly from now |
| 62 | 71 | wp_schedule_event(time(), 'weekly', $this->tracking_hook); |
| 63 | 72 | } |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Whether this site is the one that reports for the network. | |
| 76 | + * | |
| 77 | + * The first site to opt in claims it, so a network whose main site never | |
| 78 | + * enables tracking still reports. The claim is released by stop(). | |
| 79 | + * | |
| 80 | + * @return bool | |
| 81 | + */ | |
| 82 | + private function isTrackingSite() | |
| 83 | + { | |
| 84 | + $claimed = (int) get_site_option('firebox_usage_tracking_site', 0); | |
| 85 | + | |
| 86 | + if ($claimed && get_site($claimed)) | |
| 87 | + { | |
| 88 | + return $claimed === get_current_blog_id(); | |
| 89 | + } | |
| 90 | + | |
| 91 | + update_site_option('firebox_usage_tracking_site', get_current_blog_id()); | |
| 92 | + | |
| 93 | + return true; | |
| 94 | + } | |
| 64 | 95 | |
| 65 | 96 | public function track() |
| 66 | 97 | { |
| 67 | 98 | // Abort if site URL contains "fireplugins.test", "fireplugins.com", or "fireboxwp.com" |
| @@ -92,7 +123,13 @@ | ||
| 92 | 123 | |
| 93 | 124 | if ($timestamp) |
| 94 | 125 | { |
| 95 | 126 | wp_unschedule_event($timestamp, $this->tracking_hook); |
| 127 | + } | |
| 128 | + | |
| 129 | + // Release the network claim so another site can report. | |
| 130 | + if (is_multisite() && (int) get_site_option('firebox_usage_tracking_site', 0) === get_current_blog_id()) | |
| 131 | + { | |
| 132 | + delete_site_option('firebox_usage_tracking_site'); | |
| 96 | 133 | } |
| 97 | 134 | } |
| 98 | 135 | } |