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

218 lines 4.1 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 1.0.0 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2021 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 class AdminBarMenu
20 {
21 public function __construct()
22 {
23 // add media to both front and back end
24 add_action( 'wp_enqueue_scripts', [ $this, 'addMedia' ] );
25 add_action( 'admin_enqueue_scripts', [ $this, 'addMedia' ] );
26
27 // add FireBox menu item on top admin bar
28 add_action( 'admin_bar_menu', [ $this, 'register' ], 999 );
29 }
30
31 /**
32 * Enqueue styles.
33 *
34 * @return void
35 */
36 public function addMedia()
37 {
38 if (!$this->canRun())
39 {
40 return;
41 }
42
43 wp_enqueue_style(
44 'firebox-admin-bar',
45 FBOX_MEDIA_ADMIN_URL . 'css/admin-bar.css',
46 [],
47 FBOX_VERSION
48 );
49 }
50
51 /**
52 * Check if current user has access to see admin bar menu.
53 *
54 * @return boolean
55 */
56 public function canRun()
57 {
58 if (is_user_logged_in() &&
59 current_user_can('manage_options') &&
60 !get_option('hide-admin-bar', false))
61 {
62 return true;
63 }
64
65 return false;
66 }
67
68 /**
69 * Register and render admin menu bar items.
70 *
71 * @param $wp_admin_bar WordPress Admin Bar object.
72 *
73 * @return void
74 */
75 public function register($wp_admin_bar)
76 {
77 if (!$this->canRun())
78 {
79 return;
80 }
81
82 $items = [
83 'main_menu',
84 'add_new_menu',
85 'all_popups_menu',
86 'analytics_menu',
87 'support_menu',
88
89 'upgrade_menu',
90
91 ];
92
93 foreach ($items as $item)
94 {
95 $this->{$item}($wp_admin_bar);
96 }
97 }
98
99 /**
100 * Render FireBox plugin main page
101 *
102 * @param object $wp_admin_bar WordPress Admin Bar object.
103 *
104 * @return void
105 */
106 public function main_menu($wp_admin_bar)
107 {
108 $logo = '<img src="' . FBOX_MEDIA_ADMIN_URL . 'images/logo_white.svg' . '" alt="firebox logo" />';
109
110 $wp_admin_bar->add_menu(
111 [
112 'id' => 'firebox-menu',
113 'title' => $logo . firebox()->_('FB_PLUGIN_NAME'),
114 'href' => admin_url( 'admin.php?page=firebox' ),
115 ]
116 );
117 }
118
119 /**
120 * Render FireBox Popups page
121 *
122 * @param object $wp_admin_bar WordPress Admin Bar object.
123 *
124 * @return void
125 */
126 public function all_popups_menu($wp_admin_bar)
127 {
128 $wp_admin_bar->add_menu(
129 [
130 'parent' => 'firebox-menu',
131 'id' => 'firebox-menu-all-boxes',
132 'title' => firebox()->_('FB_POPUPS'),
133 'href' => admin_url( 'edit.php?post_type=firebox' ),
134 ]
135 );
136 }
137
138 /**
139 * Render FireBox New Item page
140 *
141 * @param object $wp_admin_bar WordPress Admin Bar object.
142 *
143 * @return void
144 */
145 public function add_new_menu($wp_admin_bar)
146 {
147 $wp_admin_bar->add_menu(
148 [
149 'parent' => 'firebox-menu',
150 'id' => 'firebox-menu-new-box',
151 'title' => firebox()->_('FB_NEW_POPUP'),
152 'href' => admin_url( 'post-new.php?post_type=firebox' ),
153 ]
154 );
155 }
156
157 /**
158 * Render FireBox Support Page
159 *
160 * @param object $wp_admin_bar WordPress Admin Bar object.
161 *
162 * @return void
163 */
164 public function support_menu($wp_admin_bar)
165 {
166 $wp_admin_bar->add_menu(
167 [
168 'parent' => 'firebox-menu',
169 'id' => 'firebox-menu-support',
170 'title' => fpframework()->_('FPF_SUPPORT'),
171 'href' => FPF_SUPPORT_URL
172 ]
173 );
174 }
175
176 /**
177 * Render FireBox Analytics Page
178 *
179 * @param object $wp_admin_bar WordPress Admin Bar object.
180 *
181 * @return void
182 */
183 public function analytics_menu($wp_admin_bar)
184 {
185 $wp_admin_bar->add_menu(
186 [
187 'parent' => 'firebox-menu',
188 'id' => 'firebox-menu-analytics',
189 'title' => fpframework()->_('FPF_ANALYTICS'),
190 'href' => admin_url('admin.php?page=firebox-analytics')
191 ]
192 );
193 }
194
195
196 /**
197 * Render FireBox Upgrade Page
198 *
199 * @param object $wp_admin_bar WordPress Admin Bar object.
200 *
201 * @return void
202 */
203 public function upgrade_menu($wp_admin_bar)
204 {
205 $wp_admin_bar->add_menu(
206 [
207 'parent' => 'firebox-menu',
208 'id' => 'firebox-menu-upgrade',
209 'title' => fpframework()->_('FPF_UPGRADE'),
210 'href' => FBOX_GO_PRO_URL,
211 'meta' => [
212 'class' => 'fb-yellow-link'
213 ]
214 ]
215 );
216 }
217
218 }