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

309 lines 6.2 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.10 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\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 // init dependencies
41 $this->initDependencies();
42
43 // Admin Page Settings
44 $this->pageSettings = new AdminPageSettings();
45
46 // run actions
47 $this->handleActions();
48
49 // run filters
50 $this->handleFilters();
51 }
52
53 /**
54 * Load admin dependencies.
55 *
56 * @return void
57 */
58 private function initDependencies()
59 {
60 new Media();
61
62 $this->library = firebox()->library;
63
64 // Update Notice
65 $valid_pages = [
66 'firebox',
67 'firebox-analytics',
68 'firebox-import',
69 'firebox-submissions',
70 'firebox-settings'
71 ];
72 $updateNotice = new \FPFramework\Admin\Includes\UpdateNotice(
73 firebox()->plugin_slug,
74 firebox()->plugin_name,
75 FBOX_VERSION,
76 $valid_pages
77 );
78 $updateNotice->init();
79
80 // Top Bar Navigation
81 new Includes\TopBarNavigation();
82
83 // Review Reminder
84 new \FPFramework\Admin\Includes\ReviewReminder(
85 firebox()->plugin_slug,
86 firebox()->plugin_name,
87 FBOX_MEDIA_ADMIN_URL
88 );
89 }
90
91 /**
92 * Runs all Admin Actions
93 *
94 * @return void
95 */
96 private function handleActions()
97 {
98 add_action('admin_enqueue_scripts', [$this, 'registerMedia'], 20);
99
100
101 add_action('plugin_action_links_' . plugin_basename(FBOX_PLUGIN_BASE_FILE), [$this, 'plugin_action_links']);
102
103 add_action('fpframework/admin/template/footer/firebox/nav_links', [$this, 'add_admin_page_template_footer_nav_links']);
104
105 }
106
107
108 /**
109 * Adds extra links to the Plugins page in the free version.
110 * - Upgrade to Pro button
111 *
112 * @param array $links
113 *
114 * @return array
115 */
116 public function plugin_action_links($links)
117 {
118 $links = array_merge( $links, array(
119 '<a href="' . FBOX_GO_PRO_URL . '" class="firebox-go-pro-link" title="' . fpframework()->_('FPF_UNLOCK_MORE_FEATURES_WITH_PRO_READ_MORE') . '">' . fpframework()->_('FPF_GO_PRO') . '</a>'
120 ) );
121
122 return $links;
123 }
124
125 /**
126 * Adds links to the admin template footer nav links
127 *
128 * @return void
129 */
130 public function add_admin_page_template_footer_nav_links()
131 {
132 ?>
133 <li><a href="https://www.fireplugins.com/<?php echo esc_attr(firebox()->plugin_slug); ?>" target="_blank"><?php echo esc_html(fpframework()->_('FPF_GET_PRO_FEATURES')); ?></a></li>
134 <?php
135 }
136
137
138 /**
139 * Runs all Admin Filters
140 *
141 * @return void
142 */
143 private function handleFilters()
144 {
145 add_filter('admin_body_class', [$this, 'setPluginPageBodyClass']);
146 add_filter('plugin_row_meta' , [$this, 'addPluginMetaLinks'], 10, 4);
147 }
148
149 /**
150 * Adds extra links to the plugins page.
151 *
152 * @param array $links
153 * @param string $file
154 * @param array $plugin_data
155 * @param string $status
156 *
157 * @return array
158 */
159 public function addPluginMetaLinks($links, $file, $plugin_data, $status)
160 {
161 if ($file === FBOX_PLUGIN_BASENAME)
162 {
163 $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>';
164 $links['support'] = '<a href="https://www.fireplugins.com/contact?plugin=FireBox" aria-label="' . esc_attr__(fpframework()->_('FPF_SUPPORT')) . '" target="_blank">' . esc_html__(fpframework()->_('FPF_SUPPORT')) . '</a>';
165 }
166
167 return $links;
168 }
169
170 /**
171 * Sets a class to the body of the FireBox Admin Pages
172 *
173 * @return string
174 */
175 public function setPluginPageBodyClass($classes)
176 {
177 if (!$this->isPluginPage())
178 {
179 return $classes;
180 }
181
182 $classes .= ' fpf-admin-page fpf-firebox-page';
183
184 if ($this->isControllerPage())
185 {
186 $classes .= ' fpf-controller-page';
187 }
188
189 return $classes;
190 }
191
192 /**
193 * Checks if we are in a plugin page
194 *
195 * @return boolean
196 */
197 private function isPluginPage()
198 {
199 if ($this->getPageNow() == 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] == 'firebox')
200 {
201 return true;
202 }
203
204 if ($this->getPageNow() == 'post.php')
205 {
206 return true;
207 }
208
209 if ($this->isControllerPage())
210 {
211 return true;
212 }
213
214 if (current_user_can('manage_options'))
215 {
216 return true;
217 }
218
219 return false;
220 }
221
222 /**
223 * Whether we are browsing a plugin page from the plugin's menu
224 *
225 * @return boolean
226 */
227 private function isControllerPage()
228 {
229 if (!firebox()->menu)
230 {
231 return false;
232 }
233
234 $current_plugin_page = fpframework()->getPluginPage();
235 $plugin_menu_items = firebox()->menu->getPluginMenuItems();
236
237 // Only set the class to the plugin pages
238 return $this->getPageNow() == 'admin.php' && in_array($current_plugin_page, $plugin_menu_items);
239 }
240
241 /**
242 * Returns page now
243 *
244 * @return string
245 */
246 protected function getPageNow()
247 {
248 global $pagenow;
249 return $pagenow;
250 }
251
252 /**
253 * Registers CSS and JS files
254 *
255 * @return void
256 */
257 public function registerMedia()
258 {
259 $this->registerStyles();
260 $this->registerScripts();
261 }
262
263 /**
264 * Register admin styles.
265 *
266 * @return void
267 */
268 public function registerStyles()
269 {
270 // load dashicons
271 wp_enqueue_style('dashicons');
272
273 // firebox main admin css
274 wp_register_style(
275 'firebox-admin',
276 FBOX_MEDIA_ADMIN_URL . 'css/firebox.css',
277 [],
278 FBOX_VERSION,
279 false
280 );
281 wp_enqueue_style('firebox-admin');
282
283 $css = '
284 :root {
285 --fpf-templates-library-header-logo: url(' . FBOX_MEDIA_ADMIN_URL . 'images/logo.svg);
286 }
287 ';
288 wp_add_inline_style('firebox-admin', $css);
289 }
290
291 /**
292 * Registers admin scripts.
293 *
294 * @return void
295 */
296 public function registerScripts()
297 {
298 wp_register_script('firebox-admin', false);
299 wp_enqueue_script('firebox-admin');
300
301 $data = array(
302 'media_url' => FBOX_MEDIA_URL,
303 'admin_url' => get_admin_url(),
304 'submissions_page' => admin_url('admin.php?page=firebox-submissions')
305 );
306
307 wp_localize_script('firebox-admin', 'fbox_admin_js_object', $data);
308 }
309 }