PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.37
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.37
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 1.1.1 All 122 releases
← All changes | Inc/Core/UsageTracking/PluginData.php +11 -189 trunk2.1.37 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 3.1.13 Free
4 + * @version 2.1.37 Free
5 5 *
6 6 * @author FirePlugins <info@fireplugins.com>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2026 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2025 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core\UsageTracking;
@@ -33,15 +33,14 @@
33 33 return;
34 34 }
35 35
36 36 global $wpdb;
37 - $query = $wpdb->prepare(
38 - "SELECT COUNT(id) as total
39 - FROM {$wpdb->posts}
40 - WHERE post_type = 'firebox'
41 - AND post_status IN (%s)",
42 - $status
43 - );
37 + $query = "
38 + SELECT COUNT(id) as total
39 + FROM {$wpdb->posts}
40 + WHERE post_type = 'firebox'
41 + AND post_status IN ('" . $status . "')
42 + ";
44 43 $results = $wpdb->get_var($query);
45 44 return $results;
46 45 }
47 46
@@ -52,177 +51,8 @@
52 51 $total_submissions = $wpdb->get_var("SELECT COUNT(id) FROM $table_name");
53 52 return $total_submissions;
54 53 }
55 54
56 - /**
57 - * Returns one-time duration (in seconds) from tracking start to first campaign draft.
58 - *
59 - * @return int|null
60 - */
61 - public function getTimeToFirstCampaignDraft()
62 - {
63 - $duration = get_option('firebox_time_to_first_campaign_draft_seconds', null);
64 -
65 - if ($duration === null || $duration === '')
66 - {
67 - return null;
68 - }
69 -
70 - return (int) $duration;
71 - }
72 -
73 - /**
74 - * Returns one-time duration (in seconds) from tracking start to first campaign publish.
75 - *
76 - * @return int|null
77 - */
78 - public function getTimeToFirstCampaignPublish()
79 - {
80 - $duration = get_option('firebox_time_to_first_campaign_publish_seconds', null);
81 -
82 - if ($duration === null || $duration === '')
83 - {
84 - return null;
85 - }
86 -
87 - return (int) $duration;
88 - }
89 -
90 - /**
91 - * Get total view-through revenue across all campaigns
92 - * View-through revenue is when someone views a campaign and purchases later without converting
93 - *
94 - * @return float
95 - */
96 - public function getViewThroughRevenue()
97 - {
98 - return $this->getRevenueBySource('impression');
99 - }
100 -
101 - /**
102 - * Get total click-through (conversion-through) revenue across all campaigns
103 - * Click-through revenue is when someone views a campaign, converts through it, and then purchases
104 - *
105 - * @return float
106 - */
107 - public function getClickThroughRevenue()
108 - {
109 - return $this->getRevenueBySource('conversion');
110 - }
111 -
112 - /**
113 - * Get cached revenue totals by attribution source
114 - * Uses a single optimized query and caches results
115 - *
116 - * @param string $source Attribution source ('impression' or 'conversion')
117 - * @return float
118 - */
119 - private function getRevenueBySource($source)
120 - {
121 - // Check cache first
122 - $cache_key = "firebox_revenue_totals_{$source}";
123 - $cached_result = wp_cache_get($cache_key, 'firebox_revenue');
124 -
125 - if ($cached_result !== false)
126 - {
127 - return (float) $cached_result;
128 - }
129 -
130 - // Get revenue data with single query
131 - $revenue_data = $this->getCachedRevenueData();
132 -
133 - $total_revenue = 0.0;
134 -
135 - foreach ($revenue_data as $row)
136 - {
137 - if ($row->event_source !== $source || !$row->order_id || !$row->order_type)
138 - {
139 - continue;
140 - }
141 -
142 - $total_revenue += $this->getOrderTotalCached($row->order_id, $row->order_type);
143 - }
144 -
145 - // Cache result for 1 hour
146 - wp_cache_set($cache_key, $total_revenue, 'firebox_revenue', HOUR_IN_SECONDS);
147 -
148 - return $total_revenue;
149 - }
150 -
151 - /**
152 - * Get all revenue data with a single optimized query and cache it
153 - *
154 - * @return array
155 - */
156 - private function getCachedRevenueData()
157 - {
158 - $cache_key = 'firebox_all_revenue_data';
159 - $cached_results = wp_cache_get($cache_key, 'firebox_revenue');
160 -
161 - if ($cached_results === false)
162 - {
163 - global $wpdb;
164 - $table_name = $wpdb->prefix . 'firebox_logs_details';
165 -
166 - $query = "
167 - SELECT
168 - event_source,
169 - JSON_UNQUOTE(JSON_EXTRACT(event_label, '$.order_id')) AS order_id,
170 - JSON_UNQUOTE(JSON_EXTRACT(event_label, '$.order_type')) AS order_type
171 - FROM {$table_name}
172 - WHERE event = 'revenue'
173 - AND event_source IN ('impression', 'conversion')
174 - AND JSON_VALID(event_label)
175 - AND JSON_EXTRACT(event_label, '$.order_id') IS NOT NULL
176 - ";
177 -
178 - $cached_results = $wpdb->get_results($query);
179 - if (!is_array($cached_results))
180 - {
181 - $cached_results = [];
182 - }
183 -
184 - // Cache for 1 hour
185 - wp_cache_set($cache_key, $cached_results, 'firebox_revenue', HOUR_IN_SECONDS);
186 - }
187 -
188 - return $cached_results;
189 - }
190 -
191 - /**
192 - * Get order total with caching to avoid duplicate queries
193 - *
194 - * @param string $order_id
195 - * @param string $order_type
196 - * @return float
197 - */
198 - private function getOrderTotalCached($order_id, $order_type)
199 - {
200 - if (!$order_id || !$order_type)
201 - {
202 - return 0.0;
203 - }
204 -
205 - $cache_key = "firebox_order_total_{$order_type}_{$order_id}";
206 - $cached_total = wp_cache_get($cache_key, 'firebox_orders');
207 -
208 - if ($cached_total !== false)
209 - {
210 - return (float) $cached_total;
211 - }
212 -
213 - $total = 0.0;
214 - if (class_exists('\FireBox\Core\RevenueAttribution\OrderHelper'))
215 - {
216 - $total = \FireBox\Core\RevenueAttribution\OrderHelper::getOrderTotal($order_id, $order_type);
217 - }
218 -
219 - // Cache for 6 hours (orders don't change frequently)
220 - wp_cache_set($cache_key, $total, 'firebox_orders', 6 * HOUR_IN_SECONDS);
221 -
222 - return (float) $total;
223 - }
224 -
225 55 public function getTotalsBySetting($setting_name = '', $setting_value = '')
226 56 {
227 57 if (!$setting_name || !$setting_value)
228 58 {
@@ -272,9 +102,9 @@
272 102 $count++;
273 103 }
274 104 break;
275 105 case 'not:emptyArray':
276 - if (is_array($meta[$tmp_setting_name]) && count($meta[$tmp_setting_name]))
106 + if (count($meta[$tmp_setting_name]))
277 107 {
278 108 $count++;
279 109 }
280 110 break;
@@ -279,16 +109,8 @@
279 109 }
280 110 break;
281 111 }
282 112 }
283 - else if ($tmp_setting_value === 'boolean')
284 - {
285 - // Check if the value is a boolean
286 - if ((is_bool($meta[$tmp_setting_name]) && $meta[$tmp_setting_name]) || $meta[$tmp_setting_name] === '1')
287 - {
288 - $count++;
289 - }
290 - }
291 113
292 114 // Equal comparison
293 115 if ($meta[$tmp_setting_name] === $tmp_setting_value)
294 116 {
@@ -410,9 +232,9 @@
410 232 FROM {$wpdb->posts} p
411 233 LEFT JOIN {$wpdb->postmeta} pm ON p.ID = pm.post_id
412 234 WHERE p.post_type = 'firebox'
413 235 AND p.post_status IN ('draft', 'trash', 'publish')
414 - AND (pm.meta_key = 'fpframework_meta_settings' OR pm.meta_key = 'firebox_meta')
236 + AND pm.meta_key = 'fpframework_meta_settings'
415 237 ";
416 238 $cached_results = $wpdb->get_results($query);
417 239 wp_cache_set($cache_key, $cached_results, 'firebox', 6 * DAY_IN_SECONDS + 12 * HOUR_IN_SECONDS);
418 240 }
@@ -418,5 +240,5 @@
418 240 }
419 241
420 242 return $cached_results;
421 243 }
422 -}
244 +}