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
firebox / Inc / Core / Admin / Admin.php

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

701 lines 19.6 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.1.37 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2025 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core\Admin;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Admin
20 {
21 /**
22 * Admin Page Settings
23 *
24 * @var AdminPageSettings
25 */
26 private $pageSettings;
27
28 /**
29 * Library
30 *
31 * @var Library
32 */
33 public $library;
34
35 /**
36 * Admin constructor
37 */
38 public function __construct()
39 {
40 new \FireBox\Core\Notices\Ajax();
41
42 $this->maybeExportSubmsissions();
43
44 add_action('wp_trash_post', [$this, 'on_campaign_trash'], 10, 2);
45 add_action('untrash_post', [$this, 'on_campaign_untrash'], 10, 2);
46
47
48 add_action('admin_enqueue_scripts', [$this, 'global_backend_assets'], 20);
49
50
51 add_action('enqueue_block_editor_assets', [$this, 'block_editor_assets'], -100);
52
53 add_action('current_screen', [$this, 'current_screen']);
54
55 add_action('firebox/admin/content', [$this, 'showNotices'], -5);
56
57 // init dependencies
58 $this->initDependencies();
59
60 // Admin Page Settings
61 $this->pageSettings = new AdminPageSettings();
62
63 // run actions
64 $this->handleActions();
65
66 // run filters
67 $this->handleFilters();
68 }
69
70 private function maybeExportSubmsissions()
71 {
72 if (!isset($_GET['task']) || $_GET['task'] !== 'export') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
73 {
74 return;
75 }
76
77 if (!isset($_GET['form_id'])) //phpcs:ignore WordPress.Security.NonceVerification.Recommended
78 {
79 return;
80 }
81
82 if (!isset($_GET['page']) || $_GET['page'] !== 'firebox-submissions') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
83 {
84 return;
85 }
86
87 $form_id = sanitize_text_field(wp_unslash($_GET['form_id'])); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
88
89 $payload = [
90 'where' => [
91 'form_id' => " = '" . esc_sql($form_id) . "'",
92 'state' => ' = 1'
93 ],
94 'offset' => 0,
95 'limit' => 99999,
96 'orderby' => 'created_at ASC'
97 ];
98
99 if (!$submissions = firebox()->tables->submission->getResults($payload))
100 {
101 return;
102 }
103
104 if (!$form = \FireBox\Core\Helpers\Form\Form::getFormByID($form_id, true))
105 {
106 return;
107 }
108
109 $prepared = [];
110
111 // Set submission fields values
112 foreach ($submissions as $item)
113 {
114 $prepared_payload = [
115 'id' => $item->id,
116 'created' => get_date_from_gmt($item->created_at),
117 'state' => $item->state === '1' ? 'Published' : 'Unpublished'
118 ];
119
120 // Find field values
121 $meta = firebox()->tables->submissionmeta->getResults([
122 'where' => [
123 'submission_id' => " = " . esc_sql($item->id)
124 ]
125 ]);
126
127 if ($meta && $form['fields'])
128 {
129 foreach ($form['fields'] as $field)
130 {
131 foreach ($meta as $meta_item)
132 {
133 if ($field->getOptionValue('id') === $meta_item->meta_key)
134 {
135 $prepared_payload[$field->getOptionValue('name')] = $field->prepareValue($meta_item->meta_value);
136 }
137 }
138 }
139 }
140
141 $prepared[] = $prepared_payload;
142 }
143
144
145 $filename = get_temp_dir() . 'submissions_' . $form['name'] . '_' . date('Y-m-d_H-i-s') . '.csv';
146 self::toCSV($prepared, $filename);
147
148 // Prompt to download the file
149 error_reporting(0);
150
151 // Send the appropriate headers to force the download in the browser
152 header('Content-Description: File Transfer');
153 header('Content-Type: application/octet-stream');
154 header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
155 header('Expires: 0');
156 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
157 header('Cache-Control: public', false);
158 header('Pragma: public');
159 header('Content-Length: ' . @filesize($filename));
160
161 // Clear the output buffer and disable output buffering
162 ob_clean();
163 flush();
164
165 readfile($filename);
166
167 unlink($filename);
168
169 exit;
170 }
171
172 /**
173 * Create a CSV file with given data
174 *
175 * @param array $data The data to populate the file
176 * @param string $destination The path where the store the CSV file
177 * @param bool $append If true, given data will be appended to the end of the file.
178 * @param boolean $excel_security If enabled, certain row values will be prefixed by a tab to avoid any CSV injection.
179 *
180 * @return void
181 */
182 private static function toCSV($data, $destination, $append = false, $excel_security = true, $check_for_duplicates = true)
183 {
184 $resource = fopen($destination, $append ? 'a+' : 'w');
185
186 if (!$append)
187 {
188 // Support UTF-8 on Microsoft Excel
189 fputs($resource, "\xEF\xBB\xBF");
190
191 // Add column names in the first line
192 fputcsv($resource, array_keys($data[0]));
193 }
194
195 // Get CSV content
196 $existingRows = [];
197 if ($append && $check_for_duplicates)
198 {
199 while (($existingData = fgetcsv($resource)) !== false)
200 {
201 $existingRows[(int) $existingData[0]] = $existingData;
202 }
203 }
204
205 foreach ($data as $row)
206 {
207 if (!empty($existingRows) && isset($row['id']) && array_key_exists($row['id'], $existingRows))
208 {
209 continue;
210 }
211
212 // Prevent CSV Injection: https://vel.joomla.org/articles/2140-introducing-csv-injection
213 if ($excel_security)
214 {
215 foreach ($row as &$value)
216 {
217 $value = is_array($value) ? implode(', ', $value) : $value;
218
219 $firstChar = substr($value, 0, 1);
220
221 // Prefixe values starting with a =, +, - or @ by a tab character
222 if (in_array($firstChar, array('=', '+', '-', '@')))
223 {
224 $value = ' ' . $value;
225 }
226 }
227 }
228
229 fputcsv($resource, $row);
230 }
231
232 fclose($resource);
233 }
234
235 /**
236 * Fires when a campaign is trashed.
237 *
238 * @param int $post_id
239 * @param string $previous_status
240 *
241 * @return void
242 */
243 public function on_campaign_trash($post_id, $previous_status)
244 {
245 $post_type = get_post_type($post_id);
246 $post_status = get_post_status($post_id);
247
248 if ($post_type === 'firebox' && $post_status === 'draft')
249 {
250 \FPFramework\Libs\AdminNotice::displaySuccess(firebox()->_('FB_CAMPAIGN_HAS_BEEN_TRASHED'));
251 }
252 }
253
254 /**
255 * Fires when a campaign is untrashed.
256 *
257 * @param int $post_id
258 * @param string $previous_status
259 *
260 * @return void
261 */
262 public function on_campaign_untrash($post_id, $previous_status)
263 {
264 $post_type = get_post_type($post_id);
265 $post_status = get_post_status($post_id);
266
267 if ($post_type === 'firebox' && $post_status === 'trash')
268 {
269 \FPFramework\Libs\AdminNotice::displaySuccess(firebox()->_('FB_CAMPAIGN_HAS_BEEN_RESTORED'));
270 }
271 }
272
273 public function showNotices()
274 {
275 \FireBox\Core\Notices\Notices::getInstance()->show();
276 }
277
278 public function block_editor_assets()
279 {
280 wp_enqueue_style(
281 'firebox-blocks',
282 FBOX_MEDIA_PUBLIC_URL . 'css/blocks.css',
283 [],
284 FBOX_VERSION
285 );
286
287 wp_enqueue_script(
288 'firebox-store',
289 FBOX_MEDIA_ADMIN_URL . 'js/blocks/store.js',
290 ['wp-data'],
291 FBOX_VERSION,
292 false
293 );
294 }
295
296
297 public function global_backend_assets()
298 {
299 wp_register_style(
300 'firebox-admin-lite',
301 FBOX_MEDIA_ADMIN_URL . 'css/lite.css',
302 [],
303 FBOX_VERSION,
304 false
305 );
306 wp_enqueue_style('firebox-admin-lite');
307 }
308
309
310 public function current_screen($screen)
311 {
312 add_action('admin_enqueue_scripts', [$this, 'registerEditorMedia'], 11);
313
314 $allowed_pages = [
315 'toplevel_page_firebox',
316 'firebox_page_firebox-campaigns',
317 'firebox_page_firebox-analytics',
318 'firebox_page_firebox-submissions',
319 'firebox_page_firebox-settings',
320 'firebox_page_firebox-import'
321 ];
322
323 if (isset($screen->id) && in_array($screen->id, $allowed_pages))
324 {
325 add_action('admin_enqueue_scripts', [$this, 'registerMediaAdminPages'], 20);
326
327 add_filter('admin_footer_text', [$this, 'admin_footer_text']);
328 }
329 }
330
331 public function registerEditorMedia()
332 {
333 wp_register_script('firebox-admin-editor', false);
334 wp_enqueue_script('firebox-admin-editor');
335
336 $data = [
337 'media_url' => FBOX_MEDIA_URL,
338 'timezone' => $this->getTimezone(),
339 'license_type' => FBOX_LICENSE_TYPE
340 ];
341
342 wp_localize_script('firebox-admin-editor', 'fbox_admin_editor_js_object', $data);
343
344 }
345
346 public function admin_footer_text()
347 {
348 return;
349 }
350
351 /**
352 * Load admin dependencies.
353 *
354 * @return void
355 */
356 private function initDependencies()
357 {
358 new Media();
359
360 $this->library = firebox()->library;
361 }
362
363 /**
364 * Runs all Admin Actions
365 *
366 * @return void
367 */
368 private function handleActions()
369 {
370 add_action('admin_enqueue_scripts', [$this, 'registerGlobalMedia'], 20);
371
372
373 add_action('plugin_action_links_' . plugin_basename(FBOX_PLUGIN_BASE_FILE), [$this, 'plugin_action_links']);
374
375 }
376
377 public function registerGlobalMedia()
378 {
379 wp_register_style('firebox-global-admin', false);
380 wp_enqueue_style('firebox-global-admin');
381 $css = '
382 #adminmenu li.toplevel_page_firebox .wp-menu-image {
383 padding: 6px 0 0 3px;
384 height: auto;
385 }
386 #adminmenu li.toplevel_page_firebox img {
387 width: 22px;
388 padding: 0;
389 }
390 ';
391 wp_add_inline_style('firebox-global-admin', $css);
392 }
393
394
395 /**
396 * Adds extra links to the Plugins page in the free version.
397 * - Upgrade to Pro button
398 *
399 * @param array $links
400 *
401 * @return array
402 */
403 public function plugin_action_links($links)
404 {
405 $links = array_merge( $links, array(
406 '<a href="' . FBOX_GO_PRO_URL . '" class="firebox-go-pro-link" title="' . fpframework()->_('FPF_UNLOCK_MORE_FEATURES_WITH_PRO_READ_MORE') . '">' . firebox()->_('FB_UPGRADE_20_OFF') . '</a>'
407 ) );
408
409 return $links;
410 }
411
412
413 /**
414 * Runs all Admin Filters
415 *
416 * @return void
417 */
418 private function handleFilters()
419 {
420 add_filter('admin_body_class', [$this, 'setPluginPageBodyClass']);
421 add_filter('plugin_row_meta' , [$this, 'addPluginMetaLinks'], 10, 4);
422 }
423
424 /**
425 * Adds extra links to the plugins page.
426 *
427 * @param array $links
428 * @param string $file
429 * @param array $plugin_data
430 * @param string $status
431 *
432 * @return array
433 */
434 public function addPluginMetaLinks($links, $file, $plugin_data, $status)
435 {
436 if ($file === FBOX_PLUGIN_BASENAME)
437 {
438 $links['rate'] = '<a href="https://wordpress.org/support/plugin/firebox/reviews/?filter=5#new-post" aria-label="' . esc_attr(firebox()->_('FB_RATE_FIREBOX')) . '" target="_blank">' . esc_html(firebox()->_('FB_RATE_FIREBOX')) . '</a>';
439 $links['support'] = '<a href="' . \FPFramework\Base\Functions::getUTMURL('https://www.fireplugins.com/contact/', '', 'misc', 'support') . '" aria-label="' . esc_attr(fpframework()->_('FPF_SUPPORT')) . '" target="_blank">' . esc_html(fpframework()->_('FPF_SUPPORT')) . '</a>';
440 }
441
442 return $links;
443 }
444
445 /**
446 * Sets a class to the body of the FireBox Admin Pages
447 *
448 * @return string
449 */
450 public function setPluginPageBodyClass($classes)
451 {
452 if (!$this->isPluginPage())
453 {
454 return $classes;
455 }
456
457 $classes .= ' fpf-admin-page fpf-firebox-page';
458
459 if ($this->isControllerPage())
460 {
461 $classes .= ' fpf-controller-page';
462 }
463
464 // Set admin template theme class
465 $fireplugins_theme = isset($_COOKIE['fireplugins_theme']) ? sanitize_key($_COOKIE['fireplugins_theme']) : 'light';
466 $classes .= ' ' . $fireplugins_theme;
467
468 // Set admin template sidebar toggle class
469 $sidebar_state = isset($_COOKIE['fireplugins_sidebar_state']) ? sanitize_key($_COOKIE['fireplugins_sidebar_state']) : 'expand';
470 $classes .= ' ' . ($sidebar_state === 'expand' ? 'fpf-admin-sidebar-expand' : 'fpf-admin-sidebar-shrink');
471
472 return $classes;
473 }
474
475 /**
476 * Checks if we are in a plugin page
477 *
478 * @return boolean
479 */
480 private function isPluginPage()
481 {
482 if (in_array($this->getPageNow(), ['edit.php', 'post-new.php']) && isset($_GET['post_type']) && $_GET['post_type'] == 'firebox') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
483 {
484 return true;
485 }
486
487 if ($this->getPageNow() == 'post.php')
488 {
489 return true;
490 }
491
492 if ($this->isControllerPage())
493 {
494 return true;
495 }
496
497 return false;
498 }
499
500 /**
501 * Whether we are browsing a plugin page from the plugin's menu
502 *
503 * @return boolean
504 */
505 private function isControllerPage()
506 {
507 if (!firebox()->menu)
508 {
509 return false;
510 }
511
512 $current_plugin_page = fpframework()->getPluginPage();
513 $plugin_menu_items = firebox()->menu->getPluginMenuItems();
514
515 // Only set the class to the plugin pages
516 return $this->getPageNow() == 'admin.php' && in_array($current_plugin_page, $plugin_menu_items);
517 }
518
519 /**
520 * Returns page now
521 *
522 * @return string
523 */
524 protected function getPageNow()
525 {
526 global $pagenow;
527 return $pagenow;
528 }
529
530 /**
531 * Registers CSS and JS files
532 *
533 * @return void
534 */
535 public function registerMediaAdminPages()
536 {
537 $this->registerStyles();
538 $this->registerScripts();
539 }
540
541 /**
542 * Register admin styles.
543 *
544 * @return void
545 */
546 public function registerStyles()
547 {
548 // load dashicons
549 wp_enqueue_style('dashicons');
550
551 // firebox main admin css
552 wp_register_style(
553 'firebox-admin',
554 FBOX_MEDIA_ADMIN_URL . 'css/firebox.css',
555 [],
556 FBOX_VERSION,
557 false
558 );
559 wp_enqueue_style('firebox-admin');
560
561 // firebox admin design
562 wp_register_style(
563 'firebox-design-admin',
564 FBOX_MEDIA_ADMIN_URL . 'css/firebox_design.css',
565 [],
566 FBOX_VERSION,
567 false
568 );
569 wp_enqueue_style('firebox-design-admin');
570
571 $css = '
572 :root {
573 --fpf-templates-library-header-logo: url(' . FBOX_MEDIA_ADMIN_URL . 'images/logo.svg);
574 }
575 ';
576 wp_add_inline_style('firebox-admin', $css);
577 }
578
579 /**
580 * Registers admin scripts.
581 *
582 * @return void
583 */
584 public function registerScripts()
585 {
586 wp_register_script('firebox-admin', false);
587 wp_enqueue_script('firebox-admin');
588
589 $data = array(
590 'campaigns_item_new_url' => admin_url('post-new.php?post_type=firebox'),
591 'campaigns_list_url' => admin_url('admin.php?page=firebox-campaigns'),
592 'campaigns_item_edit_url' => admin_url('post.php?post={{ID}}&action=edit'),
593 'campaigns_item_analytics_url' => admin_url('admin.php?page=firebox-analytics&campaign={{ID}}'),
594 'campaigns_analytics_url' => admin_url('admin.php?page=firebox-analytics'),
595 'submissions_page' => admin_url('admin.php?page=firebox-submissions'),
596 'flags_url' => FBOX_PLUGIN_URL . 'Inc/Framework/media/admin/images/flags/{{FLAG}}.png',
597 'license_type' => FBOX_LICENSE_TYPE,
598 'langs' => [
599 'CAMPAIGN_INFO' => firebox()->_('FB_CAMPAIGN_INFO'),
600 'EDIT_CAMPAIGN' => firebox()->_('FB_EDIT_CAMPAIGN'),
601 'STATUS' => fpframework()->_('FPF_STATUS'),
602 'CREATED' => fpframework()->_('FPF_CREATED'),
603 'LAST_VIEWED' => firebox()->_('FB_LAST_VIEWED'),
604 'ACTIVE' => firebox()->_('FB_ACTIVE'),
605 'DISABLED' => fpframework()->_('FPF_DISABLED'),
606 'ID' => fpframework()->_('FPF_ID'),
607 'CAMPAIGN' => firebox()->_('FB_CAMPAIGN'),
608 'VIEWS' => firebox()->_('FB_VIEWS'),
609 'ACTIONS' => firebox()->_('FB_ACTIONS'),
610 'CONVERSIONS' => firebox()->_('FB_CONVERSIONS'),
611 'CONVERSION_RATE' => firebox()->_('FB_CONVERSION_RATE'),
612 'NO_DATA_AVAILABLE' => firebox()->_('FB_NO_DATA_AVAILABLE'),
613 'COUNTRIES' => fpframework()->_('FPF_COUNTRIES'),
614 'FLAG' => fpframework()->_('FPF_FLAG'),
615 'DEVICES' => fpframework()->_('FPF_DEVICES'),
616 'EVENTS' => fpframework()->_('FPF_EVENTS'),
617 'PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD' => firebox()->_('FB_PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD'),
618 'NO_CAMPAIGN_DATA_FOUND' => firebox()->_('FB_NO_CAMPAIGN_DATA_FOUND'),
619 'MOST_POPULAR_CAMPAIGNS' => firebox()->_('FB_MOST_POPULAR_CAMPAIGNS'),
620 'TOP_CAMPAIGNS' => firebox()->_('FB_TOP_CAMPAIGNS'),
621 'N/A' => fpframework()->_('FPF_N/A'),
622 'ALL_DAYS' => firebox()->_('FB_ALL_DAYS'),
623 'MONDAY' => firebox()->_('FB_MONDAY'),
624 'TUESDAY' => firebox()->_('FB_TUESDAY'),
625 'WEDNESDAY' => firebox()->_('FB_WEDNESDAY'),
626 'THURSDAY' => firebox()->_('FB_THURSDAY'),
627 'FRIDAY' => firebox()->_('FB_FRIDAY'),
628 'SATURDAY' => firebox()->_('FB_SATURDAY'),
629 'SUNDAY' => firebox()->_('FB_SUNDAY'),
630 'VIEW_HOURS' => firebox()->_('FB_VIEW_HOURS'),
631 'PATHS' => fpframework()->_('FPF_PATHS'),
632 'REFERRERS' => fpframework()->_('FPF_REFERRERS'),
633 'S' => fpframework()->_('FPF_S'),
634 'VIEW_CAMPAIGN_ANALYTICS' => firebox()->_('FB_VIEW_CAMPAIGN_ANALYTICS'),
635 'ACTIVATE' => fpframework()->_('FPF_ACTIVATE'),
636 'DEACTIVATE' => fpframework()->_('FPF_DEACTIVATE'),
637 'EDIT' => fpframework()->_('FPF_EDIT'),
638 'DELETE' => fpframework()->_('FPF_DELETE'),
639 'DUPLICATE' => fpframework()->_('FPF_DUPLICATE'),
640 'ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN' => firebox()->_('FB_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN'),
641 'RECENT_CAMPAIGNS' => firebox()->_('FB_RECENT_CAMPAIGNS'),
642 'VIEW_ALL' => firebox()->_('FB_VIEW_ALL'),
643 'YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET' => firebox()->_('FB_YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET'),
644 'NEW_CAMPAIGN' => firebox()->_('FB_NEW_CAMPAIGN'),
645 'NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS' => firebox()->_('FB_NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS'),
646 'NUMBER_OF_CONVERSIONS_IN_THE_LAST_30_DAYS' => firebox()->_('FB_NUMBER_OF_CONVERSIONS_IN_THE_LAST_30_DAYS'),
647 'CONVERSION_RATE_IN_THE_LAST_30_DAYS' => firebox()->_('FB_CONVERSION_RATE_IN_THE_LAST_30_DAYS'),
648 'LOADING_CAMPAIGNS' => firebox()->_('FB_LOADING_CAMPAIGNS'),
649 'NO_CAMPAIGNS_FOUND' => firebox()->_('FB_NO_CAMPAIGNS_FOUND'),
650 'SEARCH_DOTS' => firebox()->_('FB_SEARCH_DOTS'),
651 'TODAY' => firebox()->_('FB_TODAY'),
652 'YESTERDAY' => firebox()->_('FB_YESTERDAY'),
653 'LAST_7_DAYS' => firebox()->_('FB_LAST_7_DAYS'),
654 'LAST_30_DAYS' => firebox()->_('FB_LAST_30_DAYS'),
655 'LAST_WEEK' => firebox()->_('FB_LAST_WEEK'),
656 'LAST_MONTH' => firebox()->_('FB_LAST_MONTH'),
657 'CUSTOM' => firebox()->_('FB_CUSTOM'),
658 'AVG_TIME_OPEN_TOOLTIP_DESC' => firebox()->_('FB_AVG_TIME_OPEN_TOOLTIP_DESC'),
659 'READ_MORE' => firebox()->_('FB_READ_MORE'),
660 'AVG_TIME_OPEN' => firebox()->_('FB_AVG_TIME_OPEN'),
661 'CONVERSION_RATE_TOOLTIP_DESC' => firebox()->_('FB_CONVERSION_RATE_TOOLTIP_DESC'),
662 'CONVERSIONS_TOOLTIP_DESC' => firebox()->_('FB_CONVERSIONS_TOOLTIP_DESC'),
663 'VS_PREVIOUS_PERIOD' => firebox()->_('FB_VS_PREVIOUS_PERIOD'),
664 'VIEWS_TOOLTIP_DESC' => firebox()->_('FB_VIEWS_TOOLTIP_DESC'),
665 'NO' => firebox()->_('FB_NO'),
666 'DATA_AVAILABLE' => firebox()->_('FB_DATA_AVAILABLE'),
667 'PERFORMANCE' => firebox()->_('FB_PERFORMANCE'),
668 'TRENDING_TEMPLATES' => firebox()->_('FB_TRENDING_TEMPLATES'),
669 'THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW' => firebox()->_('FB_THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW'),
670 'INSERT_TEMPLATE' => firebox()->_('FB_INSERT_TEMPLATE'),
671 'INSERT' => firebox()->_('FB_INSERT'),
672 'VIEW_ALL_ANALYTICS' => firebox()->_('FB_VIEW_ALL_ANALYTICS'),
673 'DAILY' => firebox()->_('FB_DAILY'),
674 'WEEKLY' => firebox()->_('FB_WEEKLY'),
675 'MONTHLY' => firebox()->_('FB_MONTHLY'),
676 'UPGRADE_TO_PRO' => fpframework()->_('FPF_UPGRADE_TO_PRO'),
677 'ALL_CAMPAIGNS' => firebox()->_('FB_ALL_CAMPAIGNS'),
678 'OVERVIEW' => fpframework()->_('FPF_OVERVIEW'),
679 'TO' => fpframework()->_('FPF_TO'),
680 'SHOWING_TOP_30_RESULTS' => firebox()->_('FB_SHOWING_TOP_30_RESULTS'),
681 'DAY_OF_THE_WEEK' => firebox()->_('FB_DAY_OF_THE_WEEK'),
682 'ANALYTICS' => fpframework()->_('FPF_ANALYTICS')
683 ]
684 );
685
686 wp_localize_script('firebox-admin', 'fbox_admin_js_object', $data);
687 }
688
689 /**
690 * Returns the timezone in format: +-XX:XX
691 *
692 * @return string
693 */
694 private function getTimezone()
695 {
696 $offset = get_option('gmt_offset');
697 $hours = (int) $offset;
698 $minutes = abs(($offset - (int) $offset) * 60);
699 return sprintf('%+03d:%02d', $hours, $minutes);
700 }
701 }