PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.6
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.6
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 / AdminBarMenu.php

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

248 lines 5.0 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.6 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;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FPFramework\Libs\Registry;
20 use FireBox\Core\Helpers\BoxHelper;
21
22 class AdminBarMenu
23 {
24 public function __construct()
25 {
26 $cParam = BoxHelper::getParams();
27 $cParam = new Registry($cParam);
28
29 // Ensure we have enabled the showing of the admin bar menu item
30 if ($cParam->get('show_admin_bar_menu_item', '1') !== '1')
31 {
32 return;
33 }
34
35 // add media to both front and back end
36 add_action('wp_enqueue_scripts', [ $this, 'addMedia' ]);
37 add_action('admin_enqueue_scripts', [ $this, 'addMedia' ]);
38
39 // add FireBox menu item on top admin bar
40 add_action('admin_bar_menu', [ $this, 'register' ], 999);
41 }
42
43 /**
44 * Enqueue styles.
45 *
46 * @return void
47 */
48 public function addMedia()
49 {
50 if (!$this->canRun())
51 {
52 return;
53 }
54
55 wp_enqueue_style(
56 'firebox-admin-bar',
57 FBOX_MEDIA_ADMIN_URL . 'css/admin-bar.css',
58 [],
59 FBOX_VERSION
60 );
61 }
62
63 /**
64 * Check if current user has access to see admin bar menu.
65 *
66 * @return boolean
67 */
68 public function canRun()
69 {
70 if (is_user_logged_in() && current_user_can('read_fireboxes') && !get_option('hide-admin-bar', false))
71 {
72 return true;
73 }
74
75 return false;
76 }
77
78 /**
79 * Register and render admin menu bar items.
80 *
81 * @param $wp_admin_bar WordPress Admin Bar object.
82 *
83 * @return void
84 */
85 public function register($wp_admin_bar)
86 {
87 if (!$this->canRun())
88 {
89 return;
90 }
91
92 $items = [
93 'main_menu',
94 'add_new_menu',
95 'all_popups_menu',
96 'analytics_menu',
97 'submissions_menu',
98 'support_menu',
99
100 'upgrade_menu',
101
102 ];
103
104 foreach ($items as $item)
105 {
106 $this->{$item}($wp_admin_bar);
107 }
108 }
109
110 /**
111 * Render FireBox plugin main page
112 *
113 * @param object $wp_admin_bar WordPress Admin Bar object.
114 *
115 * @return void
116 */
117 public function main_menu($wp_admin_bar)
118 {
119 $logo = '<img src="' . FBOX_MEDIA_ADMIN_URL . 'images/logo_white.svg' . '" width="22" height="22" alt="firebox logo" />';
120
121 $wp_admin_bar->add_menu(
122 [
123 'id' => 'firebox-menu',
124 'title' => $logo . firebox()->_('FB_PLUGIN_NAME'),
125 'href' => admin_url('admin.php?page=firebox')
126 ]
127 );
128 }
129
130 /**
131 * Render FireBox Popups page
132 *
133 * @param object $wp_admin_bar WordPress Admin Bar object.
134 *
135 * @return void
136 */
137 public function all_popups_menu($wp_admin_bar)
138 {
139 $wp_admin_bar->add_menu(
140 [
141 'parent' => 'firebox-menu',
142 'id' => 'firebox-menu-all-boxes',
143 'title' => firebox()->_('FB_CAMPAIGNS'),
144 'href' => admin_url('admin.php?page=firebox-campaigns')
145 ]
146 );
147 }
148
149 /**
150 * Render FireBox New Item page
151 *
152 * @param object $wp_admin_bar WordPress Admin Bar object.
153 *
154 * @return void
155 */
156 public function add_new_menu($wp_admin_bar)
157 {
158 $wp_admin_bar->add_menu(
159 [
160 'parent' => 'firebox-menu',
161 'id' => 'firebox-menu-new-box',
162 'title' => firebox()->_('FB_NEW_CAMPAIGN'),
163 'href' => admin_url('post-new.php?post_type=firebox')
164 ]
165 );
166 }
167
168 /**
169 * Render FireBox Support Page
170 *
171 * @param object $wp_admin_bar WordPress Admin Bar object.
172 *
173 * @return void
174 */
175 public function support_menu($wp_admin_bar)
176 {
177 $wp_admin_bar->add_menu(
178 [
179 'parent' => 'firebox-menu',
180 'id' => 'firebox-menu-support',
181 'title' => fpframework()->_('FPF_SUPPORT'),
182 'href' => \FPFramework\Base\Functions::getUTMURL(FPF_SUPPORT_URL . '?topic=Pre-sale Question', null, 'misc', 'contact')
183 ]
184 );
185 }
186
187 /**
188 * Render FireBox Analytics Page
189 *
190 * @param object $wp_admin_bar WordPress Admin Bar object.
191 *
192 * @return void
193 */
194 public function analytics_menu($wp_admin_bar)
195 {
196 $wp_admin_bar->add_menu(
197 [
198 'parent' => 'firebox-menu',
199 'id' => 'firebox-menu-analytics',
200 'title' => fpframework()->_('FPF_ANALYTICS'),
201 'href' => admin_url('admin.php?page=firebox-analytics')
202 ]
203 );
204 }
205
206 /**
207 * Render FireBox Submissions Page
208 *
209 * @param object $wp_admin_bar WordPress Admin Bar object.
210 *
211 * @return void
212 */
213 public function submissions_menu($wp_admin_bar)
214 {
215 $wp_admin_bar->add_menu(
216 [
217 'parent' => 'firebox-menu',
218 'id' => 'firebox-menu-submissions',
219 'title' => fpframework()->_('FPF_SUBMISSIONS'),
220 'href' => admin_url('admin.php?page=firebox-submissions')
221 ]
222 );
223 }
224
225
226 /**
227 * Render FireBox Upgrade Page
228 *
229 * @param object $wp_admin_bar WordPress Admin Bar object.
230 *
231 * @return void
232 */
233 public function upgrade_menu($wp_admin_bar)
234 {
235 $wp_admin_bar->add_menu(
236 [
237 'parent' => 'firebox-menu',
238 'id' => 'firebox-menu-upgrade',
239 'title' => fpframework()->_('FPF_UPGRADE_TO_PRO'),
240 'href' => sprintf(FBOX_GO_PRO_URL, 'pro'),
241 'meta' => [
242 'class' => 'firebox-go-pro-yellow-link'
243 ]
244 ]
245 );
246 }
247
248 }