PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.14
3.1.14 3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 All 123 releases
firebox / Inc / Core / Analytics / Ajax / Shared.php

Shared.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.14, at Inc/Core/Analytics/Ajax/Shared.php

63 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 3.1.14 Free
5 *
6 * @author FirePlugins <[email protected]>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Analytics\Ajax;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 Trait Shared
20 {
21 protected function getPreviousPeriodDates($startDate, $period)
22 {
23 if (!\DateTime::createFromFormat('Y/m/d 00:00:00', $startDate))
24 {
25 return false;
26 }
27
28 $newStartDate = new \DateTime($startDate);
29 $newStartDate->sub(new \DateInterval("P{$period}D"));
30 $newStartDateStr = $newStartDate->format('Y/m/d 00:00:00');
31
32 $period--;
33 $newEndDate = clone $newStartDate;
34 $newEndDate->add(new \DateInterval("P{$period}D"));
35 $newEndDateStr = $newEndDate->format('Y/m/d 23:59:59');
36
37 return [$newStartDateStr, $newEndDateStr];
38 }
39
40 /**
41 * Determine the transient TTL to use for cached analytics data.
42 * Only fully-past date ranges are cached. Ranges that include today are
43 * still being collected, and caching them makes freshly tracked views and
44 * conversions appear to be missing from the dashboard.
45 *
46 * @param string $end_date The end date of the range (e.g. 'Y/m/d H:i:s').
47 *
48 * @return int TTL in seconds, or 0 when the range must not be cached.
49 */
50 protected function getAnalyticsCacheTtl($end_date)
51 {
52 $end_date_ts = strtotime($end_date);
53
54 if ($end_date_ts && $end_date_ts < strtotime('today midnight', current_time('timestamp')))
55 {
56 // Fully-past range: data is no longer being collected for it.
57 return HOUR_IN_SECONDS;
58 }
59
60 // Range includes today: always serve live data.
61 return 0;
62 }
63 }