PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.0.16
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.0.16
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
firebox / Inc / Core / Admin / Analytics / Overview / Overview.php

Overview.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.0.16, at Inc/Core/Admin/Analytics/Overview/Overview.php

332 lines 10.2 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 2.0.16 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2023 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Admin\Analytics\Overview;
13
14 use FireBox\Core\Admin\Analytics\Helpers\AnalyticsHelper;
15
16 if (!defined('ABSPATH'))
17 {
18 exit; // Exit if accessed directly.
19 }
20
21 class Overview
22 {
23 /**
24 * The default Overview filters
25 *
26 * @var array
27 */
28 private $default_filters = [
29 'date' => 'this_month'
30 ];
31
32 /**
33 * Analytics Toolbar
34 *
35 * @var Toolbar
36 */
37 private $toolbar;
38
39 public function __construct()
40 {
41 // Ensure we can show analytics overview on current page
42 if (!\FireBox\Core\Admin\Analytics\Helpers\AnalyticsHelper::canRun('firebox'))
43 {
44 return;
45 }
46
47 $this->init();
48
49 // render overview filters
50 add_action('firebox/analytics/overview/filters', [$this, 'renderFilters']);
51
52 // render overview
53 add_action('firebox/dashboard/content', [$this, 'render']);
54 }
55
56 public function init()
57 {
58 $this->toolbar = new \FireBox\Core\Admin\Analytics\Toolbar();
59 }
60
61 /**
62 * Display the Analytics Overview
63 *
64 * @return void
65 */
66 public function render()
67 {
68 // Load CSS & JS files
69 $this->loadMedia();
70
71 firebox()->renderer->admin->render('analytics/overview/tmpl', [
72 'overview_items_names' => $this->getOverviewItemsNames(),
73 'default_filters' => $this->default_filters
74 ]);
75 }
76
77 public function renderFilters()
78 {
79 firebox()->renderer->admin->render('analytics/overview/filters', [
80 'configuration' => firebox()->analytics_configuration,
81 'filters' => $this->getFilters()
82 ]);
83 }
84
85 public function getOverviewItemsNames()
86 {
87 $names = array_keys($this->getOverviewItemsPayload());
88
89
90 if (FBOX_LICENSE_TYPE === 'lite')
91 {
92 unset($names['submissions']);
93 unset($names['conversionrate']);
94 unset($names['countries']);
95 unset($names['referrers']);
96 unset($names['pie']); // Devices
97 }
98
99
100
101
102 return $names;
103 }
104
105 public function getOverviewItemsPayload()
106 {
107 $configuration = firebox()->analytics_configuration;
108
109 return [
110 'impressions' => [
111 'overview_type' => 'chart',
112 'metrics' => ['impressions'],
113 'allowed_filters' => [
114 'box',
115 'date'
116 ],
117 'toolbar_items' => [
118 'date' => [
119 'method' => 'filter',
120 'options_key' => 'this_month',
121 ]
122 ],
123 ],
124 'avg_time_open' => [
125 'overview_type' => 'chart',
126 'metrics' => ['averagetimeopen'],
127 'allowed_filters' => [
128 'box',
129 'date'
130 ],
131 'toolbar_items' => [
132 'date' => [
133 'method' => 'filter',
134 'options_key' => 'this_month',
135 ]
136 ],
137 ],
138
139 'boxes' => [
140 'overview_title' => firebox()->_('FB_TOP_CAMPAIGNS'),
141 'overview_type' => 'boxestable',
142 'layout' => 'table',
143 'reference_toolbar_item' => 'box',
144 'metrics' => ['impressions'],
145 'show_total' => false,
146 'show_percentage' => false,
147 'allowed_filters' => [
148 'box',
149 'date'
150 ],
151 'other_data' => [
152 'modify_query_data' => [
153 'select' => [
154 'boxes.ID as box_id',
155 'boxes.post_title as label',
156 'count(bl.id) as total'
157 ],
158 'join' => [
159 'left join ' . $configuration['boxes_table'] . ' as boxes' => ' ON boxes.ID = bl.box'
160 ],
161 'groupby' => 'bl.box',
162 'orderby' => 'total desc'
163 ],
164 'options' => [
165 'skip_filling_dates' => true,
166 'skip_compare_check_to_retrieve_previous_data' => true
167 ]
168 ],
169 'table_columns' => [
170 'box' => [
171 'label' => firebox()->_('FB_CAMPAIGN'),
172 ],
173 'impressions' => [
174 'label' => fpframework()->_('FPF_IMPRESSIONS'),
175 ],
176 'percentage' => [
177 'label' => '%',
178 'title' => fpframework()->_('FPF_PERCENTAGE_CHANGE_OVER_PREVIOUS_PERIOD')
179 ]
180 ],
181 'toolbar_items' => [
182 'date' => [
183 'method' => 'filter',
184 'options_key' => 'this_month',
185 ]
186 ],
187 ],
188
189
190 'submissions_pro' => [
191 'overview_title' => fpframework()->_('FPF_SUBMISSIONS'),
192 'overview_type' => 'pro',
193 'layout' => 'pro',
194 'redirect_base' => true,
195 'feature' => fpframework()->_('FPF_SUBMISSIONS_CHART'),
196 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_submissions.png',
197 'show_overlay_message' => true,
198 'class' => 'overlay-bg corner',
199 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1'
200 ],
201 'conversionrate_pro' => [
202 'overview_title' => fpframework()->_('FPF_CONVERSION_RATE'),
203 'overview_type' => 'pro',
204 'layout' => 'pro',
205 'redirect_base' => true,
206 'feature' => fpframework()->_('FPF_CONVERSION_RATE_CHART'),
207 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_conversionrate.png',
208 'show_overlay_message' => true,
209 'class' => 'overlay-bg corner',
210 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1'
211 ],
212 'devices_pro' => [
213 'overview_title' => fpframework()->_('FPF_TOP_DEVICES'),
214 'overview_type' => 'pro',
215 'layout' => 'pro',
216 'redirect_base' => true,
217 'feature' => fpframework()->_('FPF_TOP_DEVICES'),
218 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_devices.png',
219 'show_overlay_message' => true,
220 'class' => 'overlay-bg corner',
221 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1'
222 ],
223 'countries_pro' => [
224 'overview_title' => fpframework()->_('FPF_TOP_COUNTRIES'),
225 'overview_type' => 'pro',
226 'layout' => 'pro',
227 'redirect_base' => true,
228 'feature' => fpframework()->_('FPF_TOP_COUNTRIES'),
229 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_countries.png',
230 'show_overlay_message' => true,
231 'class' => 'overlay-bg corner',
232 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1'
233 ],
234 'referrers_pro' => [
235 'overview_title' => fpframework()->_('FPF_TOP_REFERRERS'),
236 'overview_type' => 'pro',
237 'layout' => 'pro',
238 'redirect_base' => true,
239 'feature' => fpframework()->_('FPF_TOP_REFERRERS'),
240 'image' => FBOX_MEDIA_ADMIN_URL . 'images/analytics_overview_referrers.png',
241 'show_overlay_message' => true,
242 'class' => 'overlay-bg corner',
243 'message' => 'FPF_ANALYTICS_OVERVIEW_OVERLAY_PRO_MSG1'
244 ],
245
246 ];
247 }
248
249 public function getFilters($plain = false)
250 {
251
252
253 return [
254
255
256 'box_pro' => [
257 'default_label' => firebox()->_('FB_ALL_CAMPAIGNS'),
258 'item' => firebox()->_('FB_CAMPAIGN_SELECTION')
259 ],
260 'date_pro' => [
261 'default_label' => firebox()->_('FB_THIS_MONTH'),
262 'item' => fpframework()->_('FPF_DATE_PERIOD')
263 ]
264
265 ];
266 }
267
268 /**
269 * Load media for the Analytics Overview page
270 *
271 * @return void
272 */
273 private function loadMedia()
274 {
275 // Countries Icons CSS Library
276 wp_register_style(
277 'firebox-analytics-overview-countries-icons',
278 FBOX_MEDIA_ADMIN_URL . 'css/flag-icon.min.css',
279 [],
280 FBOX_VERSION,
281 false
282 );
283 wp_enqueue_style('firebox-analytics-overview-countries-icons');
284
285 // Chart JS CSS Library
286 wp_register_style(
287 'firebox-analytics-chart',
288 FBOX_MEDIA_ADMIN_URL . 'css/chart.min.css',
289 [],
290 FBOX_VERSION,
291 false
292 );
293 wp_enqueue_style('firebox-analytics-chart');
294
295 // Moments JS
296 wp_register_script(
297 'firebox-analytics-moment-js-library',
298 includes_url('js/dist/vendor/moment.min.js'),
299 [],
300 FBOX_VERSION,
301 false
302 );
303 wp_enqueue_script('firebox-analytics-moment-js-library');
304
305 // Chart JS
306 wp_register_script(
307 'firebox-analytics-chart',
308 FBOX_MEDIA_ADMIN_URL . 'js/chart.min.js',
309 ['firebox-analytics-moment-js-library'],
310 FBOX_VERSION,
311 false
312 );
313 wp_enqueue_script('firebox-analytics-chart');
314
315
316
317 // FireBox Analytics Overview JS
318 wp_register_script(
319 'firebox-analytics-overview',
320 FBOX_MEDIA_ADMIN_URL . 'js/fb_analytics_overview.js',
321 [],
322 FBOX_VERSION,
323 false
324 );
325 wp_enqueue_script('firebox-analytics-overview');
326 }
327
328 public function getToolbar()
329 {
330 return $this->toolbar;
331 }
332 }