PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.0.19
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.0.19
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 2.0.19, at Inc/Core/AdminBarMenu.php

250 lines 4.9 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.19 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;
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() &&
71 current_user_can('manage_options') &&
72 !get_option('hide-admin-bar', false))
73 {
74 return true;
75 }
76
77 return false;
78 }
79
80 /**
81 * Register and render admin menu bar items.
82 *
83 * @param $wp_admin_bar WordPress Admin Bar object.
84 *
85 * @return void
86 */
87 public function register($wp_admin_bar)
88 {
89 if (!$this->canRun())
90 {
91 return;
92 }
93
94 $items = [
95 'main_menu',
96 'add_new_menu',
97 'all_popups_menu',
98 'analytics_menu',
99 'submissions_menu',
100 'support_menu',
101
102 'upgrade_menu',
103
104 ];
105
106 foreach ($items as $item)
107 {
108 $this->{$item}($wp_admin_bar);
109 }
110 }
111
112 /**
113 * Render FireBox plugin main page
114 *
115 * @param object $wp_admin_bar WordPress Admin Bar object.
116 *
117 * @return void
118 */
119 public function main_menu($wp_admin_bar)
120 {
121 $logo = '<img src="' . FBOX_MEDIA_ADMIN_URL . 'images/logo_white.svg' . '" alt="firebox logo" />';
122
123 $wp_admin_bar->add_menu(
124 [
125 'id' => 'firebox-menu',
126 'title' => $logo . firebox()->_('FB_PLUGIN_NAME'),
127 'href' => admin_url('admin.php?page=firebox')
128 ]
129 );
130 }
131
132 /**
133 * Render FireBox Popups page
134 *
135 * @param object $wp_admin_bar WordPress Admin Bar object.
136 *
137 * @return void
138 */
139 public function all_popups_menu($wp_admin_bar)
140 {
141 $wp_admin_bar->add_menu(
142 [
143 'parent' => 'firebox-menu',
144 'id' => 'firebox-menu-all-boxes',
145 'title' => firebox()->_('FB_CAMPAIGNS'),
146 'href' => admin_url('edit.php?post_type=firebox')
147 ]
148 );
149 }
150
151 /**
152 * Render FireBox New Item page
153 *
154 * @param object $wp_admin_bar WordPress Admin Bar object.
155 *
156 * @return void
157 */
158 public function add_new_menu($wp_admin_bar)
159 {
160 $wp_admin_bar->add_menu(
161 [
162 'parent' => 'firebox-menu',
163 'id' => 'firebox-menu-new-box',
164 'title' => firebox()->_('FB_NEW_CAMPAIGN'),
165 'href' => admin_url('post-new.php?post_type=firebox')
166 ]
167 );
168 }
169
170 /**
171 * Render FireBox Support Page
172 *
173 * @param object $wp_admin_bar WordPress Admin Bar object.
174 *
175 * @return void
176 */
177 public function support_menu($wp_admin_bar)
178 {
179 $wp_admin_bar->add_menu(
180 [
181 'parent' => 'firebox-menu',
182 'id' => 'firebox-menu-support',
183 'title' => fpframework()->_('FPF_SUPPORT'),
184 'href' => FPF_SUPPORT_URL
185 ]
186 );
187 }
188
189 /**
190 * Render FireBox Analytics Page
191 *
192 * @param object $wp_admin_bar WordPress Admin Bar object.
193 *
194 * @return void
195 */
196 public function analytics_menu($wp_admin_bar)
197 {
198 $wp_admin_bar->add_menu(
199 [
200 'parent' => 'firebox-menu',
201 'id' => 'firebox-menu-analytics',
202 'title' => fpframework()->_('FPF_ANALYTICS'),
203 'href' => admin_url('admin.php?page=firebox-analytics')
204 ]
205 );
206 }
207
208 /**
209 * Render FireBox Submissions Page
210 *
211 * @param object $wp_admin_bar WordPress Admin Bar object.
212 *
213 * @return void
214 */
215 public function submissions_menu($wp_admin_bar)
216 {
217 $wp_admin_bar->add_menu(
218 [
219 'parent' => 'firebox-menu',
220 'id' => 'firebox-menu-submissions',
221 'title' => fpframework()->_('FPF_SUBMISSIONS'),
222 'href' => admin_url('admin.php?page=firebox-submissions')
223 ]
224 );
225 }
226
227
228 /**
229 * Render FireBox Upgrade Page
230 *
231 * @param object $wp_admin_bar WordPress Admin Bar object.
232 *
233 * @return void
234 */
235 public function upgrade_menu($wp_admin_bar)
236 {
237 $wp_admin_bar->add_menu(
238 [
239 'parent' => 'firebox-menu',
240 'id' => 'firebox-menu-upgrade',
241 'title' => fpframework()->_('FPF_UPGRADE'),
242 'href' => FBOX_GO_PRO_URL,
243 'meta' => [
244 'class' => 'fb-yellow-link'
245 ]
246 ]
247 );
248 }
249
250 }