PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / trunk
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment vtrunk
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 / Controllers / BaseController.php

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

118 lines 2.8 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.13 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
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\Controllers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class BaseController
20 {
21 /**
22 * Render page
23 *
24 * @return void
25 */
26 public function renderPage()
27 {
28 add_action('admin_enqueue_scripts', [$this, 'admin_enqueue_scripts']);
29
30 // render base view of controller
31 add_action('fpframework_' . fpframework()->getPluginPage() . '/admin_page', [$this, 'renderBaseView']);
32
33 // render each controller view from the child controllers
34 add_action('firebox/admin/content', [$this, 'render']);
35 }
36
37 public function admin_enqueue_scripts()
38 {
39 // load media for current page
40 if (method_exists($this, 'addMedia'))
41 {
42 $this->addMedia();
43 }
44 }
45
46 /**
47 * Renders the Basic View of a Controller
48 *
49 * @return void
50 */
51 public function renderBaseView()
52 {
53 firebox()->renderer->admin->render('static/template', [
54 'settings' => get_option('firebox_settings'),
55 'current_page' => $this->getCurrentPage(),
56 'navigation' => $this->getNavigation(),
57 'call_to_action_label' => firebox()->_('FB_NEW_CAMPAIGN'),
58 'plugin_version' => FBOX_VERSION,
59 'plugin_slug' => 'firebox',
60 'plugin_name' => 'FireBox',
61 ]);
62 }
63
64 private function getCurrentPage()
65 {
66 return isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : ''; //phpcs:ignore WordPress.Security.NonceVerification.Recommended
67 }
68
69 /**
70 * Returns the sidebar navigation.
71 *
72 * @return array
73 */
74 private function getNavigation()
75 {
76 $campaigns = false;
77
78 if (current_user_can('read_fireboxes'))
79 {
80 $campaigns = [
81 'label' => firebox()->_('FB_CAMPAIGNS'),
82 'url' => admin_url('admin.php?page=firebox-campaigns'),
83 'slug' => 'firebox-campaigns'
84 ];
85 }
86
87 $items = [
88 [
89 'label' => fpframework()->_('FPF_OVERVIEW'),
90 'url' => admin_url('admin.php?page=firebox'),
91 'slug' => 'firebox'
92 ],
93 $campaigns,
94 [
95 'label' => fpframework()->_('FPF_ANALYTICS'),
96 'url' => admin_url('admin.php?page=firebox-analytics'),
97 'slug' => 'firebox-analytics'
98 ],
99 [
100 'label' => fpframework()->_('FPF_SUBMISSIONS'),
101 'url' => admin_url('admin.php?page=firebox-submissions'),
102 'slug' => 'firebox-submissions'
103 ],
104 [
105 'label' => fpframework()->_('FPF_SETTINGS'),
106 'url' => admin_url('admin.php?page=firebox-settings'),
107 'slug' => 'firebox-settings'
108 ]
109 ];
110
111 $items = array_filter($items, function($item) {
112 return $item !== false;
113 });
114 $items = array_values($items);
115
116 return $items;
117 }
118 }