PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.0.1
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.0.1
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 3.0.1, at Inc/Core/Admin/Admin.php

845 lines 23.7 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.0.1 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('admin_head', [$this, 'set_gutenberg_editor_logo']);
45
46 add_action('wp_trash_post', [$this, 'on_campaign_trash'], 10, 2);
47 add_action('untrash_post', [$this, 'on_campaign_untrash'], 10, 2);
48
49
50 add_action('admin_enqueue_scripts', [$this, 'global_backend_assets'], 20);
51
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 add_action('save_post', [$this, 'onSave'], 20);
70 }
71
72 /**
73 * On Save, clear the campaign cookie if closing behavior > when closed is set to "never".
74 *
75 * @param string $post_id
76 *
77 * @return void
78 */
79 public function onSave($post_id)
80 {
81 if (!isset($_POST['post_type']) || $_POST['post_type'] !== 'firebox')
82 {
83 return;
84 }
85
86 if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
87 {
88 return;
89 }
90
91 if ($parent_id = wp_is_post_revision($post_id))
92 {
93 $post_id = $parent_id;
94 }
95
96 $meta = get_post_meta($post_id, 'firebox_meta');
97
98 $assign_cookietype = isset($meta[0]['assign_cookietype']) ? $meta[0]['assign_cookietype'] : '';
99
100 if ($assign_cookietype === 'never')
101 {
102 setcookie('firebox_' . $post_id, '', time() - 3600, '/');
103 }
104 }
105
106 /**
107 * Set the FireBox logo in the Gutenberg editor.
108 *
109 * @return void
110 */
111 public function set_gutenberg_editor_logo()
112 {
113 if (get_post_type() !== 'firebox')
114 {
115 return;
116 }
117
118 ?>
119 <style>
120 @media screen and (min-width: 782px) {
121 .editor-header:has(>.editor-header__center) {
122 grid-template: auto / auto minmax(min-content, 1fr) 2fr minmax(min-content, 1fr) 60px;
123 }
124
125 }
126 .editor-header__back-button a {
127 background: transparent !important;
128 background-image: url("<?php echo FBOX_MEDIA_ADMIN_URL; ?>images/logo_full.svg") !important;
129 background-size: 105px !important;
130 margin-right: 5px !important;
131 margin-left: 17px !important;
132 background-repeat: no-repeat !important;
133 background-position: center center !important;
134 width: 120px !important;
135 }
136 .editor-header__back-button a:before,
137 .editor-header__back-button img,
138 .editor-header__back-button svg {
139 display: none !important;
140 }
141 </style>
142 <?php
143 }
144
145 private function maybeExportSubmsissions()
146 {
147 if (!isset($_GET['task']) || $_GET['task'] !== 'export') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
148 {
149 return;
150 }
151
152 if (!isset($_GET['form_id'])) //phpcs:ignore WordPress.Security.NonceVerification.Recommended
153 {
154 return;
155 }
156
157 if (!isset($_GET['page']) || $_GET['page'] !== 'firebox-submissions') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
158 {
159 return;
160 }
161
162 $form_id = sanitize_text_field(wp_unslash($_GET['form_id'])); //phpcs:ignore WordPress.Security.NonceVerification.Recommended
163
164 $payload = [
165 'where' => [
166 'form_id' => " = '" . esc_sql($form_id) . "'",
167 'state' => ' = 1'
168 ],
169 'offset' => 0,
170 'limit' => 99999,
171 'orderby' => 'created_at ASC'
172 ];
173
174 if (!$submissions = firebox()->tables->submission->getResults($payload))
175 {
176 return;
177 }
178
179 if (!$form = \FireBox\Core\Helpers\Form\Form::getFormByID($form_id, true))
180 {
181 return;
182 }
183
184 $prepared = [];
185
186 // Set submission fields values
187 foreach ($submissions as $item)
188 {
189 $prepared_payload = [
190 'id' => $item->id,
191 'created' => get_date_from_gmt($item->created_at),
192 'state' => $item->state === '1' ? 'Published' : 'Unpublished'
193 ];
194
195 // Find field values
196 $meta = firebox()->tables->submissionmeta->getResults([
197 'where' => [
198 'submission_id' => " = " . esc_sql($item->id)
199 ]
200 ]);
201
202 if ($meta && $form['fields'])
203 {
204 foreach ($form['fields'] as $field)
205 {
206 foreach ($meta as $meta_item)
207 {
208 if ($field->getOptionValue('id') === $meta_item->meta_key)
209 {
210 $prepared_payload[$field->getOptionValue('name')] = $field->prepareValue($meta_item->meta_value);
211 }
212 }
213 }
214 }
215
216 $prepared[] = $prepared_payload;
217 }
218
219
220 $filename = get_temp_dir() . 'submissions_' . $form['name'] . '_' . date('Y-m-d_H-i-s') . '.csv';
221 self::toCSV($prepared, $filename);
222
223 // Prompt to download the file
224 error_reporting(0);
225
226 // Send the appropriate headers to force the download in the browser
227 header('Content-Description: File Transfer');
228 header('Content-Type: application/octet-stream');
229 header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
230 header('Expires: 0');
231 header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
232 header('Cache-Control: public', false);
233 header('Pragma: public');
234 header('Content-Length: ' . @filesize($filename));
235
236 // Clear the output buffer and disable output buffering
237 ob_clean();
238 flush();
239
240 readfile($filename);
241
242 unlink($filename);
243
244 exit;
245 }
246
247 /**
248 * Create a CSV file with given data
249 *
250 * @param array $data The data to populate the file
251 * @param string $destination The path where the store the CSV file
252 * @param bool $append If true, given data will be appended to the end of the file.
253 * @param boolean $excel_security If enabled, certain row values will be prefixed by a tab to avoid any CSV injection.
254 *
255 * @return void
256 */
257 private static function toCSV($data, $destination, $append = false, $excel_security = true, $check_for_duplicates = true)
258 {
259 $resource = fopen($destination, $append ? 'a+' : 'w');
260
261 if (!$append)
262 {
263 // Support UTF-8 on Microsoft Excel
264 fputs($resource, "\xEF\xBB\xBF");
265
266 // Add column names in the first line
267 fputcsv($resource, array_keys($data[0]));
268 }
269
270 // Get CSV content
271 $existingRows = [];
272 if ($append && $check_for_duplicates)
273 {
274 while (($existingData = fgetcsv($resource)) !== false)
275 {
276 $existingRows[(int) $existingData[0]] = $existingData;
277 }
278 }
279
280 foreach ($data as $row)
281 {
282 if (!empty($existingRows) && isset($row['id']) && array_key_exists($row['id'], $existingRows))
283 {
284 continue;
285 }
286
287 // Prevent CSV Injection: https://vel.joomla.org/articles/2140-introducing-csv-injection
288 if ($excel_security)
289 {
290 foreach ($row as &$value)
291 {
292 $value = is_array($value) ? implode(', ', $value) : $value;
293
294 $firstChar = substr($value, 0, 1);
295
296 // Prefixe values starting with a =, +, - or @ by a tab character
297 if (in_array($firstChar, array('=', '+', '-', '@')))
298 {
299 $value = ' ' . $value;
300 }
301 }
302 }
303
304 fputcsv($resource, $row);
305 }
306
307 fclose($resource);
308 }
309
310 /**
311 * Fires when a campaign is trashed.
312 *
313 * @param int $post_id
314 * @param string $previous_status
315 *
316 * @return void
317 */
318 public function on_campaign_trash($post_id, $previous_status)
319 {
320 $post_type = get_post_type($post_id);
321 $post_status = get_post_status($post_id);
322
323 if ($post_type === 'firebox' && $post_status === 'draft')
324 {
325 \FPFramework\Libs\AdminNotice::displaySuccess(firebox()->_('FB_CAMPAIGN_HAS_BEEN_TRASHED'));
326 }
327 }
328
329 /**
330 * Fires when a campaign is untrashed.
331 *
332 * @param int $post_id
333 * @param string $previous_status
334 *
335 * @return void
336 */
337 public function on_campaign_untrash($post_id, $previous_status)
338 {
339 $post_type = get_post_type($post_id);
340 $post_status = get_post_status($post_id);
341
342 if ($post_type === 'firebox' && $post_status === 'trash')
343 {
344 \FPFramework\Libs\AdminNotice::displaySuccess(firebox()->_('FB_CAMPAIGN_HAS_BEEN_RESTORED'));
345 }
346 }
347
348 public function showNotices()
349 {
350 \FireBox\Core\Notices\Notices::getInstance()->show();
351 }
352
353
354 public function global_backend_assets()
355 {
356 wp_register_style(
357 'firebox-admin-lite',
358 FBOX_MEDIA_ADMIN_URL . 'css/lite.css',
359 [],
360 FBOX_VERSION,
361 false
362 );
363 wp_enqueue_style('firebox-admin-lite');
364 }
365
366
367 public function current_screen($screen)
368 {
369 add_action('admin_enqueue_scripts', [$this, 'registerEditorMedia'], 11);
370 add_action('enqueue_block_assets', [$this, 'registerCampaignEditorAssets'], 12);
371
372 // Check for classic editor with firebox post type
373 if (isset($screen->id) && $screen->id === 'firebox' && !$screen->is_block_editor) {
374 add_action('admin_notices', [$this, 'showClassicEditorNotice']);
375 }
376
377 $allowed_pages = [
378 'toplevel_page_firebox',
379 'firebox_page_firebox-campaigns',
380 'firebox_page_firebox-analytics',
381 'firebox_page_firebox-submissions',
382 'firebox_page_firebox-settings',
383 'firebox_page_firebox-import'
384 ];
385
386 if (isset($screen->id) && in_array($screen->id, $allowed_pages))
387 {
388 add_action('admin_enqueue_scripts', [$this, 'registerMediaAdminPages'], 20);
389
390 add_filter('admin_footer_text', [$this, 'admin_footer_text']);
391 }
392 }
393
394 /**
395 * Shows a notice when using classic editor with firebox post type
396 *
397 * @return void
398 */
399 public function showClassicEditorNotice()
400 {
401 ?>
402 <div class="notice notice-warning">
403 <p><?php echo esc_html(firebox()->_('FB_CLASSIC_EDITOR_NOT_SUPPORTED')); ?></p>
404 </div>
405 <?php
406 }
407
408 public function registerEditorMedia()
409 {
410 wp_register_script('firebox-admin-editor', false);
411 wp_enqueue_script('firebox-admin-editor');
412
413 $data = [
414 'media_url' => FBOX_MEDIA_URL,
415 'timezone' => $this->getTimezone(),
416 'license_type' => FBOX_LICENSE_TYPE
417 ];
418
419 wp_localize_script('firebox-admin-editor', 'fbox_admin_editor_js_object', $data);
420 }
421
422 public function registerCampaignEditorAssets()
423 {
424 if (!is_admin())
425 {
426 return;
427 }
428
429 // Enqueue block editor style only in Gutenberg editor
430 if (!function_exists('get_current_screen'))
431 {
432 return;
433 }
434
435 $screen = get_current_screen();
436 if (!$screen->is_block_editor)
437 {
438 return;
439 }
440
441 wp_enqueue_script(
442 'firebox-helper-store',
443 FBOX_MEDIA_ADMIN_URL . 'js/blocks/helper_store.js',
444 ['wp-data'],
445 FBOX_VERSION,
446 false
447 );
448
449 wp_enqueue_style(
450 'firebox-blocks',
451 FBOX_MEDIA_PUBLIC_URL . 'css/blocks.css',
452 [],
453 FBOX_VERSION
454 );
455
456 $css = '
457 :root {
458 --firebox-editor-background-image: url(' . FBOX_MEDIA_ADMIN_URL . 'images/browser-bg.png);
459 }
460 ';
461 wp_add_inline_style('firebox-blocks', $css);
462
463 if (get_post_type() !== 'firebox')
464 {
465 return;
466 }
467
468 wp_register_script('firebox-campaign-editor', false);
469 wp_enqueue_script('firebox-campaign-editor');
470
471 $data = [
472 'plugins' => [
473 'wpml_active' => \is_plugin_active('sitepress-multilingual-cms/sitepress.php'),
474 'edd_active' => \is_plugin_active('easy-digital-downloads/easy-digital-downloads.php') || \is_plugin_active('easy-digital-downloads-pro/easy-digital-downloads.php'),
475 'woo_active' => \is_plugin_active('woocommerce/woocommerce.php')
476 ],
477 'geolocation_updated' => !\FPFramework\Helpers\Geolocation::geoNeedsUpdate(),
478 'geolocation_update_url' => admin_url('admin.php?page=firebox-settings#geolocation'),
479 'geolocation_city_notice' => (new \FPFramework\Base\Conditions\Conditions\Geo\City())->getValueHint(),
480 'geolocation_country_notice' => (new \FPFramework\Base\Conditions\Conditions\Geo\Country())->getValueHint(),
481 'geolocation_region_notice' => (new \FPFramework\Base\Conditions\Conditions\Geo\Region())->getValueHint(),
482 'geolocation_continent_notice' => (new \FPFramework\Base\Conditions\Conditions\Geo\Continent())->getValueHint(),
483 'countries_list' => \FPFramework\Helpers\CountriesHelper::getCountriesList(),
484 'user_ip' => \FPFramework\Base\User::getIP()
485 ];
486
487 wp_localize_script('firebox-campaign-editor', 'firebox_campaign_editor', $data);
488 }
489
490 public function admin_footer_text()
491 {
492 return;
493 }
494
495 /**
496 * Load admin dependencies.
497 *
498 * @return void
499 */
500 private function initDependencies()
501 {
502 new Media();
503
504 $this->library = firebox()->library;
505 }
506
507 /**
508 * Runs all Admin Actions
509 *
510 * @return void
511 */
512 private function handleActions()
513 {
514 add_action('admin_enqueue_scripts', [$this, 'registerGlobalMedia'], 20);
515
516
517 add_action('plugin_action_links_' . plugin_basename(FBOX_PLUGIN_BASE_FILE), [$this, 'plugin_action_links']);
518
519 }
520
521 public function registerGlobalMedia()
522 {
523 wp_register_style('firebox-global-admin', false);
524 wp_enqueue_style('firebox-global-admin');
525 $css = '
526 #adminmenu li.toplevel_page_firebox .wp-menu-image {
527 padding: 4px 0 0 0;
528 height: auto;
529 }
530 #adminmenu li.toplevel_page_firebox img {
531 width: 20px !important;
532 padding: 0;
533 padding-top: 3px !important;
534 }
535 ';
536 wp_add_inline_style('firebox-global-admin', $css);
537 }
538
539
540 /**
541 * Adds extra links to the Plugins page in the free version.
542 * - Upgrade to Pro button
543 *
544 * @param array $links
545 *
546 * @return array
547 */
548 public function plugin_action_links($links)
549 {
550 $links = array_merge( $links, array(
551 '<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>'
552 ) );
553
554 return $links;
555 }
556
557
558 /**
559 * Runs all Admin Filters
560 *
561 * @return void
562 */
563 private function handleFilters()
564 {
565 add_filter('admin_body_class', [$this, 'setPluginPageBodyClass']);
566 add_filter('plugin_row_meta' , [$this, 'addPluginMetaLinks'], 10, 4);
567 }
568
569 /**
570 * Adds extra links to the plugins page.
571 *
572 * @param array $links
573 * @param string $file
574 * @param array $plugin_data
575 * @param string $status
576 *
577 * @return array
578 */
579 public function addPluginMetaLinks($links, $file, $plugin_data, $status)
580 {
581 if ($file === FBOX_PLUGIN_BASENAME)
582 {
583 $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>';
584 $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>';
585 }
586
587 return $links;
588 }
589
590 /**
591 * Sets a class to the body of the FireBox Admin Pages
592 *
593 * @return string
594 */
595 public function setPluginPageBodyClass($classes)
596 {
597 if (!$this->isPluginPage())
598 {
599 return $classes;
600 }
601
602 $classes .= ' fpf-admin-page fpf-firebox-page';
603
604 if ($this->isControllerPage())
605 {
606 $classes .= ' fpf-controller-page';
607 }
608
609 // Set admin template theme class
610 $fireplugins_theme = isset($_COOKIE['fireplugins_theme']) ? sanitize_key($_COOKIE['fireplugins_theme']) : 'light';
611 $classes .= ' ' . $fireplugins_theme;
612
613 // Set admin template sidebar toggle class
614 $sidebar_state = isset($_COOKIE['fireplugins_sidebar_state']) ? sanitize_key($_COOKIE['fireplugins_sidebar_state']) : 'expand';
615 $classes .= ' ' . ($sidebar_state === 'expand' ? 'fpf-admin-sidebar-expand' : 'fpf-admin-sidebar-shrink');
616
617 return $classes;
618 }
619
620 /**
621 * Checks if we are in a plugin page
622 *
623 * @return boolean
624 */
625 private function isPluginPage()
626 {
627 if (in_array($this->getPageNow(), ['edit.php', 'post-new.php']) && isset($_GET['post_type']) && $_GET['post_type'] == 'firebox') //phpcs:ignore WordPress.Security.NonceVerification.Recommended
628 {
629 return true;
630 }
631
632 if ($this->getPageNow() == 'post.php')
633 {
634 return true;
635 }
636
637 if ($this->isControllerPage())
638 {
639 return true;
640 }
641
642 return false;
643 }
644
645 /**
646 * Whether we are browsing a plugin page from the plugin's menu
647 *
648 * @return boolean
649 */
650 private function isControllerPage()
651 {
652 if (!firebox()->menu)
653 {
654 return false;
655 }
656
657 $current_plugin_page = fpframework()->getPluginPage();
658 $plugin_menu_items = firebox()->menu->getPluginMenuItems();
659
660 // Only set the class to the plugin pages
661 return $this->getPageNow() == 'admin.php' && in_array($current_plugin_page, $plugin_menu_items);
662 }
663
664 /**
665 * Returns page now
666 *
667 * @return string
668 */
669 protected function getPageNow()
670 {
671 global $pagenow;
672 return $pagenow;
673 }
674
675 /**
676 * Registers CSS and JS files
677 *
678 * @return void
679 */
680 public function registerMediaAdminPages()
681 {
682 $this->registerStyles();
683 $this->registerScripts();
684 }
685
686 /**
687 * Register admin styles.
688 *
689 * @return void
690 */
691 public function registerStyles()
692 {
693 // load dashicons
694 wp_enqueue_style('dashicons');
695
696 // firebox main admin css
697 wp_register_style(
698 'firebox-admin',
699 FBOX_MEDIA_ADMIN_URL . 'css/firebox.css',
700 [],
701 FBOX_VERSION,
702 false
703 );
704 wp_enqueue_style('firebox-admin');
705
706 // firebox admin design
707 wp_register_style(
708 'firebox-design-admin',
709 FBOX_MEDIA_ADMIN_URL . 'css/firebox_design.css',
710 [],
711 FBOX_VERSION,
712 false
713 );
714 wp_enqueue_style('firebox-design-admin');
715
716 $css = '
717 :root {
718 --fpf-templates-library-header-logo: url(' . FBOX_MEDIA_ADMIN_URL . 'images/logo.svg);
719 }
720 ';
721 wp_add_inline_style('firebox-admin', $css);
722 }
723
724 /**
725 * Registers admin scripts.
726 *
727 * @return void
728 */
729 public function registerScripts()
730 {
731 wp_register_script('firebox-admin', false);
732 wp_enqueue_script('firebox-admin');
733
734 $data = array(
735 'campaigns_item_new_url' => admin_url('post-new.php?post_type=firebox'),
736 'campaigns_list_url' => admin_url('admin.php?page=firebox-campaigns'),
737 'campaigns_item_edit_url' => admin_url('post.php?post={{ID}}&action=edit'),
738 'campaigns_item_analytics_url' => admin_url('admin.php?page=firebox-analytics&campaign={{ID}}'),
739 'campaigns_analytics_url' => admin_url('admin.php?page=firebox-analytics'),
740 'submissions_page' => admin_url('admin.php?page=firebox-submissions'),
741 'flags_url' => FBOX_PLUGIN_URL . 'Inc/Framework/media/admin/images/flags/{{FLAG}}.png',
742 'license_type' => FBOX_LICENSE_TYPE,
743 'langs' => [
744 'CAMPAIGN_INFO' => firebox()->_('FB_CAMPAIGN_INFO'),
745 'EDIT_CAMPAIGN' => firebox()->_('FB_EDIT_CAMPAIGN'),
746 'STATUS' => fpframework()->_('FPF_STATUS'),
747 'CREATED' => fpframework()->_('FPF_CREATED'),
748 'LAST_VIEWED' => firebox()->_('FB_LAST_VIEWED'),
749 'ACTIVE' => firebox()->_('FB_ACTIVE'),
750 'DISABLED' => fpframework()->_('FPF_DISABLED'),
751 'ID' => fpframework()->_('FPF_ID'),
752 'CAMPAIGN' => firebox()->_('FB_CAMPAIGN'),
753 'VIEWS' => firebox()->_('FB_VIEWS'),
754 'ACTIONS' => firebox()->_('FB_ACTIONS'),
755 'CONVERSIONS' => firebox()->_('FB_CONVERSIONS'),
756 'CONVERSION_RATE' => firebox()->_('FB_CONVERSION_RATE'),
757 'NO_DATA_AVAILABLE' => firebox()->_('FB_NO_DATA_AVAILABLE'),
758 'COUNTRIES' => fpframework()->_('FPF_COUNTRIES'),
759 'FLAG' => fpframework()->_('FPF_FLAG'),
760 'DEVICES' => fpframework()->_('FPF_DEVICES'),
761 'EVENTS' => fpframework()->_('FPF_EVENTS'),
762 'PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD' => firebox()->_('FB_PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD'),
763 'NO_CAMPAIGN_DATA_FOUND' => firebox()->_('FB_NO_CAMPAIGN_DATA_FOUND'),
764 'MOST_POPULAR_CAMPAIGNS' => firebox()->_('FB_MOST_POPULAR_CAMPAIGNS'),
765 'TOP_CAMPAIGNS' => firebox()->_('FB_TOP_CAMPAIGNS'),
766 'N/A' => fpframework()->_('FPF_N/A'),
767 'ALL_DAYS' => firebox()->_('FB_ALL_DAYS'),
768 'MONDAY' => firebox()->_('FB_MONDAY'),
769 'TUESDAY' => firebox()->_('FB_TUESDAY'),
770 'WEDNESDAY' => firebox()->_('FB_WEDNESDAY'),
771 'THURSDAY' => firebox()->_('FB_THURSDAY'),
772 'FRIDAY' => firebox()->_('FB_FRIDAY'),
773 'SATURDAY' => firebox()->_('FB_SATURDAY'),
774 'SUNDAY' => firebox()->_('FB_SUNDAY'),
775 'VIEW_HOURS' => firebox()->_('FB_VIEW_HOURS'),
776 'PATHS' => fpframework()->_('FPF_PATHS'),
777 'REFERRERS' => fpframework()->_('FPF_REFERRERS'),
778 'S' => fpframework()->_('FPF_S'),
779 'VIEW_CAMPAIGN_ANALYTICS' => firebox()->_('FB_VIEW_CAMPAIGN_ANALYTICS'),
780 'ACTIVATE' => fpframework()->_('FPF_ACTIVATE'),
781 'DEACTIVATE' => fpframework()->_('FPF_DEACTIVATE'),
782 'EDIT' => fpframework()->_('FPF_EDIT'),
783 'DELETE' => fpframework()->_('FPF_DELETE'),
784 'DUPLICATE' => fpframework()->_('FPF_DUPLICATE'),
785 'ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN' => firebox()->_('FB_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN'),
786 'RECENT_CAMPAIGNS' => firebox()->_('FB_RECENT_CAMPAIGNS'),
787 'VIEW_ALL' => firebox()->_('FB_VIEW_ALL'),
788 'YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET' => firebox()->_('FB_YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET'),
789 'NEW_CAMPAIGN' => firebox()->_('FB_NEW_CAMPAIGN'),
790 'NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS' => firebox()->_('FB_NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS'),
791 'NUMBER_OF_CONVERSIONS_IN_THE_LAST_30_DAYS' => firebox()->_('FB_NUMBER_OF_CONVERSIONS_IN_THE_LAST_30_DAYS'),
792 'CONVERSION_RATE_IN_THE_LAST_30_DAYS' => firebox()->_('FB_CONVERSION_RATE_IN_THE_LAST_30_DAYS'),
793 'LOADING_CAMPAIGNS' => firebox()->_('FB_LOADING_CAMPAIGNS'),
794 'NO_CAMPAIGNS_FOUND' => firebox()->_('FB_NO_CAMPAIGNS_FOUND'),
795 'SEARCH_DOTS' => firebox()->_('FB_SEARCH_DOTS'),
796 'TODAY' => firebox()->_('FB_TODAY'),
797 'YESTERDAY' => firebox()->_('FB_YESTERDAY'),
798 'LAST_7_DAYS' => firebox()->_('FB_LAST_7_DAYS'),
799 'LAST_30_DAYS' => firebox()->_('FB_LAST_30_DAYS'),
800 'LAST_WEEK' => firebox()->_('FB_LAST_WEEK'),
801 'LAST_MONTH' => firebox()->_('FB_LAST_MONTH'),
802 'CUSTOM' => firebox()->_('FB_CUSTOM'),
803 'READ_MORE' => firebox()->_('FB_READ_MORE'),
804 'AVG_TIME_OPEN' => firebox()->_('FB_AVG_TIME_OPEN'),
805 'CONVERSION_RATE_TOOLTIP_DESC' => firebox()->_('FB_CONVERSION_RATE_TOOLTIP_DESC'),
806 'CONVERSIONS_TOOLTIP_DESC' => firebox()->_('FB_CONVERSIONS_TOOLTIP_DESC'),
807 'VS_PREVIOUS_PERIOD' => firebox()->_('FB_VS_PREVIOUS_PERIOD'),
808 'VIEWS_TOOLTIP_DESC' => firebox()->_('FB_VIEWS_TOOLTIP_DESC'),
809 'NO' => firebox()->_('FB_NO'),
810 'DATA_AVAILABLE' => firebox()->_('FB_DATA_AVAILABLE'),
811 'PERFORMANCE' => firebox()->_('FB_PERFORMANCE'),
812 'TRENDING_TEMPLATES' => firebox()->_('FB_TRENDING_TEMPLATES'),
813 'THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW' => firebox()->_('FB_THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW'),
814 'INSERT_TEMPLATE' => firebox()->_('FB_INSERT_TEMPLATE'),
815 'INSERT' => firebox()->_('FB_INSERT'),
816 'VIEW_ALL_ANALYTICS' => firebox()->_('FB_VIEW_ALL_ANALYTICS'),
817 'DAILY' => firebox()->_('FB_DAILY'),
818 'WEEKLY' => firebox()->_('FB_WEEKLY'),
819 'MONTHLY' => firebox()->_('FB_MONTHLY'),
820 'UPGRADE_TO_PRO' => fpframework()->_('FPF_UPGRADE_TO_PRO'),
821 'ALL_CAMPAIGNS' => firebox()->_('FB_ALL_CAMPAIGNS'),
822 'OVERVIEW' => fpframework()->_('FPF_OVERVIEW'),
823 'TO' => fpframework()->_('FPF_TO'),
824 'SHOWING_TOP_30_RESULTS' => firebox()->_('FB_SHOWING_TOP_30_RESULTS'),
825 'DAY_OF_THE_WEEK' => firebox()->_('FB_DAY_OF_THE_WEEK'),
826 'ANALYTICS' => fpframework()->_('FPF_ANALYTICS')
827 ]
828 );
829
830 wp_localize_script('firebox-admin', 'fbox_admin_js_object', $data);
831 }
832
833 /**
834 * Returns the timezone in format: +-XX:XX
835 *
836 * @return string
837 */
838 private function getTimezone()
839 {
840 $offset = get_option('gmt_offset');
841 $hours = (int) $offset;
842 $minutes = abs(($offset - (int) $offset) * 60);
843 return sprintf('%+03d:%02d', $hours, $minutes);
844 }
845 }