PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.0
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.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 / Admin / Admin.php

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

477 lines 14.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 2.1.0 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
41 add_action('admin_enqueue_scripts', [$this, 'global_backend_assets'], 20);
42
43
44 add_action('current_screen', [$this, 'current_screen']);
45
46 // init dependencies
47 $this->initDependencies();
48
49 // Admin Page Settings
50 $this->pageSettings = new AdminPageSettings();
51
52 // run actions
53 $this->handleActions();
54
55 // run filters
56 $this->handleFilters();
57 }
58
59
60 public function global_backend_assets()
61 {
62 wp_register_style(
63 'firebox-admin-lite',
64 FBOX_MEDIA_ADMIN_URL . 'css/lite.css',
65 [],
66 FBOX_VERSION,
67 false
68 );
69 wp_enqueue_style('firebox-admin-lite');
70 }
71
72
73 public function current_screen($screen)
74 {
75 $allowed_pages = [
76 'toplevel_page_firebox',
77 'firebox_page_firebox-campaigns',
78 'firebox_page_firebox-analytics',
79 'firebox_page_firebox-submissions',
80 'firebox_page_firebox-settings',
81 'firebox_page_firebox-import'
82 ];
83
84 if (isset($screen->id) && in_array($screen->id, $allowed_pages))
85 {
86 add_action('admin_enqueue_scripts', [$this, 'registerMedia'], 20);
87
88 add_filter('admin_footer_text', [$this, 'admin_footer_text']);
89 }
90 }
91
92 public function admin_footer_text()
93 {
94 return;
95 }
96
97 /**
98 * Load admin dependencies.
99 *
100 * @return void
101 */
102 private function initDependencies()
103 {
104 new Media();
105
106 $this->library = firebox()->library;
107
108 // Update Notice
109 $valid_pages = [
110 'firebox',
111 'firebox-campaigns',
112 'firebox-analytics',
113 'firebox-import',
114 'firebox-submissions',
115 'firebox-settings'
116 ];
117 $updateNotice = new \FPFramework\Admin\Includes\UpdateNotice(
118 firebox()->plugin_slug,
119 firebox()->plugin_name,
120 FBOX_VERSION,
121 $valid_pages
122 );
123 $updateNotice->init();
124
125 // Review Reminder
126 new \FPFramework\Admin\Includes\ReviewReminder(
127 firebox()->plugin_slug,
128 firebox()->plugin_name,
129 FBOX_MEDIA_ADMIN_URL
130 );
131 }
132
133 /**
134 * Runs all Admin Actions
135 *
136 * @return void
137 */
138 private function handleActions()
139 {
140 add_action('admin_enqueue_scripts', [$this, 'registerGlobalMedia'], 20);
141
142
143 add_action('plugin_action_links_' . plugin_basename(FBOX_PLUGIN_BASE_FILE), [$this, 'plugin_action_links']);
144
145 }
146
147 public function registerGlobalMedia()
148 {
149 wp_register_style('firebox-global-admin', false);
150 wp_enqueue_style('firebox-global-admin');
151 $css = '
152 #adminmenu li.toplevel_page_firebox img {
153 max-height: 22px;
154 padding-top: 6px;
155 }
156 ';
157 wp_add_inline_style('firebox-global-admin', $css);
158 }
159
160
161 /**
162 * Adds extra links to the Plugins page in the free version.
163 * - Upgrade to Pro button
164 *
165 * @param array $links
166 *
167 * @return array
168 */
169 public function plugin_action_links($links)
170 {
171 $links = array_merge( $links, array(
172 '<a href="' . FBOX_GO_PRO_URL . '" class="firebox-go-pro-link" title="' . fpframework()->_('FPF_UNLOCK_MORE_FEATURES_WITH_PRO_READ_MORE') . '">' . firebox()->_('FB_UPGRADE_20_OFF') . '</a>'
173 ) );
174
175 return $links;
176 }
177
178
179 /**
180 * Runs all Admin Filters
181 *
182 * @return void
183 */
184 private function handleFilters()
185 {
186 add_filter('admin_body_class', [$this, 'setPluginPageBodyClass']);
187 add_filter('plugin_row_meta' , [$this, 'addPluginMetaLinks'], 10, 4);
188 }
189
190 /**
191 * Adds extra links to the plugins page.
192 *
193 * @param array $links
194 * @param string $file
195 * @param array $plugin_data
196 * @param string $status
197 *
198 * @return array
199 */
200 public function addPluginMetaLinks($links, $file, $plugin_data, $status)
201 {
202 if ($file === FBOX_PLUGIN_BASENAME)
203 {
204 $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>';
205 $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>';
206 }
207
208 return $links;
209 }
210
211 /**
212 * Sets a class to the body of the FireBox Admin Pages
213 *
214 * @return string
215 */
216 public function setPluginPageBodyClass($classes)
217 {
218 if (!$this->isPluginPage())
219 {
220 return $classes;
221 }
222
223 $classes .= ' fpf-admin-page fpf-firebox-page';
224
225 if ($this->isControllerPage())
226 {
227 $classes .= ' fpf-controller-page';
228 }
229
230 // Set admin template theme class
231 $fireplugins_theme = isset($_COOKIE['fireplugins_theme']) ? sanitize_key($_COOKIE['fireplugins_theme']) : 'light';
232 $classes .= ' ' . $fireplugins_theme;
233
234 // Set admin template sidebar toggle class
235 $sidebar_state = isset($_COOKIE['fireplugins_sidebar_state']) ? $_COOKIE['fireplugins_sidebar_state'] : 'expand';
236 $classes .= ' ' . ($sidebar_state === 'expand' ? 'fpf-admin-sidebar-expand' : 'fpf-admin-sidebar-shrink');
237
238 return $classes;
239 }
240
241 /**
242 * Checks if we are in a plugin page
243 *
244 * @return boolean
245 */
246 private function isPluginPage()
247 {
248 if (in_array($this->getPageNow(), ['edit.php', 'post-new.php']) && isset($_GET['post_type']) && $_GET['post_type'] == 'firebox')
249 {
250 return true;
251 }
252
253 if ($this->getPageNow() == 'post.php')
254 {
255 return true;
256 }
257
258 if ($this->isControllerPage())
259 {
260 return true;
261 }
262
263 return false;
264 }
265
266 /**
267 * Whether we are browsing a plugin page from the plugin's menu
268 *
269 * @return boolean
270 */
271 private function isControllerPage()
272 {
273 if (!firebox()->menu)
274 {
275 return false;
276 }
277
278 $current_plugin_page = fpframework()->getPluginPage();
279 $plugin_menu_items = firebox()->menu->getPluginMenuItems();
280
281 // Only set the class to the plugin pages
282 return $this->getPageNow() == 'admin.php' && in_array($current_plugin_page, $plugin_menu_items);
283 }
284
285 /**
286 * Returns page now
287 *
288 * @return string
289 */
290 protected function getPageNow()
291 {
292 global $pagenow;
293 return $pagenow;
294 }
295
296 /**
297 * Registers CSS and JS files
298 *
299 * @return void
300 */
301 public function registerMedia()
302 {
303 $this->registerStyles();
304 $this->registerScripts();
305 }
306
307 /**
308 * Register admin styles.
309 *
310 * @return void
311 */
312 public function registerStyles()
313 {
314 // load dashicons
315 wp_enqueue_style('dashicons');
316
317 // firebox main admin css
318 wp_register_style(
319 'firebox-admin',
320 FBOX_MEDIA_ADMIN_URL . 'css/firebox.css',
321 [],
322 FBOX_VERSION,
323 false
324 );
325 wp_enqueue_style('firebox-admin');
326
327 // firebox admin design
328 wp_register_style(
329 'firebox-design-admin',
330 FBOX_MEDIA_ADMIN_URL . 'css/firebox_design.css',
331 [],
332 FBOX_VERSION,
333 false
334 );
335 wp_enqueue_style('firebox-design-admin');
336
337 $css = '
338 :root {
339 --fpf-templates-library-header-logo: url(' . FBOX_MEDIA_ADMIN_URL . 'images/logo.svg);
340 }
341 ';
342 wp_add_inline_style('firebox-admin', $css);
343 }
344
345 /**
346 * Registers admin scripts.
347 *
348 * @return void
349 */
350 public function registerScripts()
351 {
352 wp_register_script('firebox-admin', false);
353 wp_enqueue_script('firebox-admin');
354
355 $data = array(
356 'media_url' => FBOX_MEDIA_URL,
357 'campaigns_item_new_url' => admin_url('post-new.php?post_type=firebox'),
358 'campaigns_list_url' => admin_url('admin.php?page=firebox-campaigns'),
359 'campaigns_item_edit_url' => admin_url('post.php?post={{ID}}&action=edit'),
360 'campaigns_item_analytics_url' => admin_url('admin.php?page=firebox-analytics&campaign={{ID}}'),
361 'campaigns_analytics_url' => admin_url('admin.php?page=firebox-analytics'),
362 'admin_url' => get_admin_url(),
363 'submissions_page' => admin_url('admin.php?page=firebox-submissions'),
364 'flags_url' => FBOX_PLUGIN_URL . 'Inc/Framework/media/admin/images/flags/{{FLAG}}.png',
365 'langs' => [
366 'CAMPAIGN_INFO' => firebox()->_('FB_CAMPAIGN_INFO'),
367 'EDIT_CAMPAIGN' => firebox()->_('FB_EDIT_CAMPAIGN'),
368 'STATUS' => fpframework()->_('FPF_STATUS'),
369 'CREATED' => fpframework()->_('FPF_CREATED'),
370 'LAST_VIEWED' => firebox()->_('FB_LAST_VIEWED'),
371 'ACTIVE' => firebox()->_('FB_ACTIVE'),
372 'DISABLED' => fpframework()->_('FPF_DISABLED'),
373 'POPUP_TRIGGER' => firebox()->_('FB_POPUP_TRIGGER'),
374 'POPUP_POSITION' => firebox()->_('FB_POPUP_POSITION'),
375 'ID' => fpframework()->_('FPF_ID'),
376 'CAMPAIGN' => firebox()->_('FB_CAMPAIGN'),
377 'VIEWS' => firebox()->_('FB_VIEWS'),
378 'ACTIONS' => firebox()->_('FB_ACTIONS'),
379 'AVERAGE_TIME_OPEN' => firebox()->_('FB_AVERAGE_TIME_OPEN'),
380 'CONVERSIONS' => firebox()->_('FB_CONVERSIONS'),
381 'CONVERSION_RATE' => firebox()->_('FB_CONVERSION_RATE'),
382 'NO_DATA_AVAILABLE' => firebox()->_('FB_NO_DATA_AVAILABLE'),
383 'COUNTRIES' => fpframework()->_('FPF_COUNTRIES'),
384 'FLAG' => fpframework()->_('FPF_FLAG'),
385 'DEVICES' => fpframework()->_('FPF_DEVICES'),
386 'EVENTS' => fpframework()->_('FPF_EVENTS'),
387 'PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD' => firebox()->_('FB_PERCENTAGE_DIFFERENCE_AGAINST_PREVIOUS_PERIOD'),
388 'NO_CAMPAIGN_DATA_FOUND' => firebox()->_('FB_NO_CAMPAIGN_DATA_FOUND'),
389 'MOST_POPULAR_CAMPAIGNS' => firebox()->_('FB_MOST_POPULAR_CAMPAIGNS'),
390 'TOP_CAMPAIGNS' => firebox()->_('FB_TOP_CAMPAIGNS'),
391 'N/A' => fpframework()->_('FPF_N/A'),
392 'ALL_DAYS' => firebox()->_('FB_ALL_DAYS'),
393 'MONDAY' => firebox()->_('FB_MONDAY'),
394 'TUESDAY' => firebox()->_('FB_TUESDAY'),
395 'WEDNESDAY' => firebox()->_('FB_WEDNESDAY'),
396 'THURSDAY' => firebox()->_('FB_THURSDAY'),
397 'FRIDAY' => firebox()->_('FB_FRIDAY'),
398 'SATURDAY' => firebox()->_('FB_SATURDAY'),
399 'SUNDAY' => firebox()->_('FB_SUNDAY'),
400 'POPULAR_VIEW_TIMES' => firebox()->_('FB_POPULAR_VIEW_TIMES'),
401 'PAGES' => fpframework()->_('FPF_PAGES'),
402 'REFERRERS' => fpframework()->_('FPF_REFERRERS'),
403 'S' => fpframework()->_('FPF_S'),
404 'ANALYTICS' => fpframework()->_('FPF_ANALYTICS'),
405 'ACTIVATE' => fpframework()->_('FPF_ACTIVATE'),
406 'DEACTIVATE' => fpframework()->_('FPF_DEACTIVATE'),
407 'EDIT' => fpframework()->_('FPF_EDIT'),
408 'DELETE' => fpframework()->_('FPF_DELETE'),
409 'DUPLICATE' => fpframework()->_('FPF_DUPLICATE'),
410 'ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN' => firebox()->_('FB_ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_CAMPAIGN'),
411 'RECENT_CAMPAIGNS' => firebox()->_('FB_RECENT_CAMPAIGNS'),
412 'VIEW_ALL' => firebox()->_('FB_VIEW_ALL'),
413 'YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET' => firebox()->_('FB_YOU_HAVENT_CREATED_ANY_CAMPAIGNS_YET'),
414 'NEW_CAMPAIGN' => firebox()->_('FB_NEW_CAMPAIGN'),
415 'ON_PAGE_LOAD' => firebox()->_('FB_ON_PAGE_LOAD'),
416 'ON_PAGE_READY' => firebox()->_('FB_ON_PAGE_READY'),
417 'ON_SCROLL_DEPTH' => firebox()->_('FB_ON_SCROLL_DEPTH'),
418 'ON_ELEMENT_VISIBILITY' => firebox()->_('FB_ON_ELEMENT_VISIBILITY'),
419 'ON_EXIT_INTENT' => firebox()->_('FB_ON_EXIT_INTENT'),
420 'ON_CLICK' => firebox()->_('FB_ON_CLICK'),
421 'ON_EXTERNAL_LINK_CLICK' => firebox()->_('FB_ON_EXTERNAL_LINK_CLICK'),
422 'ON_HOVER' => firebox()->_('FB_ON_HOVER'),
423 'ON_ADBLOCK_DETECT' => firebox()->_('FB_ON_ADBLOCK_DETECT'),
424 'ON_IDLDE' => firebox()->_('FB_ON_IDLDE'),
425 'VIA_FLOATING_BUTTON' => firebox()->_('FB_VIA_FLOATING_BUTTON'),
426 'MANUALLY' => firebox()->_('FB_METABOX_TRIGGER_METHOD_OD'),
427 'TOP_LEFT' => fpframework()->_('FPF_TOP_LEFT'),
428 'TOP_CENTER' => fpframework()->_('FPF_TOP_CENTER'),
429 'TOP_RIGHT' => fpframework()->_('FPF_TOP_RIGHT'),
430 'MIDDLE_LEFT' => fpframework()->_('FPF_MIDDLE_LEFT'),
431 'CENTER' => fpframework()->_('FPF_CENTER'),
432 'MIDDLE_RIGHT' => fpframework()->_('FPF_MIDDLE_RIGHT'),
433 'BOTTOM_LEFT' => fpframework()->_('FPF_BOTTOM_LEFT'),
434 'BOTTOM_CENTER' => fpframework()->_('FPF_BOTTOM_CENTER'),
435 'BOTTOM_RIGHT' => fpframework()->_('FPF_BOTTOM_RIGHT'),
436 'TRIGGER' => firebox()->_('FB_TRIGGER'),
437 'POSITION' => firebox()->_('FB_METABOX_POSITION'),
438 'NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS' => firebox()->_('FB_NUMBER_OF_VIEWS_IN_THE_LAST_30_DAYS'),
439 'LOADING_CAMPAIGNS' => firebox()->_('FB_LOADING_CAMPAIGNS'),
440 'NO_CAMPAIGNS_FOUND' => firebox()->_('FB_NO_CAMPAIGNS_FOUND'),
441 'SEARCH_DOTS' => firebox()->_('FB_SEARCH_DOTS'),
442 'TODAY' => firebox()->_('FB_TODAY'),
443 'YESTERDAY' => firebox()->_('FB_YESTERDAY'),
444 'LAST_7_DAYS' => firebox()->_('FB_LAST_7_DAYS'),
445 'LAST_30_DAYS' => firebox()->_('FB_LAST_30_DAYS'),
446 'LAST_WEEK' => firebox()->_('FB_LAST_WEEK'),
447 'LAST_MONTH' => firebox()->_('FB_LAST_MONTH'),
448 'CUSTOM' => firebox()->_('FB_CUSTOM'),
449 'AVG_TIME_OPEN_TOOLTIP_DESC' => firebox()->_('FB_AVG_TIME_OPEN_TOOLTIP_DESC'),
450 'READ_MORE' => firebox()->_('FB_READ_MORE'),
451 'AVG_TIME_OPEN' => firebox()->_('FB_AVG_TIME_OPEN'),
452 'CONVERSION_RATE_TOOLTIP_DESC' => firebox()->_('FB_CONVERSION_RATE_TOOLTIP_DESC'),
453 'CONVERSIONS_TOOLTIP_DESC' => firebox()->_('FB_CONVERSIONS_TOOLTIP_DESC'),
454 'VS_PREVIOUS_PERIOD' => firebox()->_('FB_VS_PREVIOUS_PERIOD'),
455 'VIEWS_TOOLTIP_DESC' => firebox()->_('FB_VIEWS_TOOLTIP_DESC'),
456 'NO' => firebox()->_('FB_NO'),
457 'DATA_AVAILABLE' => firebox()->_('FB_DATA_AVAILABLE'),
458 'PERFORMANCE' => firebox()->_('FB_PERFORMANCE'),
459 'TRENDING_TEMPLATES' => firebox()->_('FB_TRENDING_TEMPLATES'),
460 'THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW' => firebox()->_('FB_THERE_ARE_NO_TRENDING_TEMPLATES_TO_SHOW'),
461 'INSERT_TEMPLATE' => firebox()->_('FB_INSERT_TEMPLATE'),
462 'INSERT' => firebox()->_('FB_INSERT'),
463 'VIEW_ALL_ANALYTICS' => firebox()->_('FB_VIEW_ALL_ANALYTICS'),
464 'DAILY' => firebox()->_('FB_DAILY'),
465 'WEEKLY' => firebox()->_('FB_WEEKLY'),
466 'MONTHLY' => firebox()->_('FB_MONTHLY'),
467 'UPGRADE_TO_PRO' => fpframework()->_('FPF_UPGRADE_TO_PRO'),
468 'ALL_CAMPAIGNS' => firebox()->_('FB_ALL_CAMPAIGNS'),
469 'OVERVIEW' => fpframework()->_('FPF_OVERVIEW'),
470 'TO' => fpframework()->_('FPF_TO'),
471 'SHOWING_FIRST_30_RESULTS' => firebox()->_('FB_SHOWING_FIRST_30_RESULTS')
472 ]
473 );
474
475 wp_localize_script('firebox-admin', 'fbox_admin_js_object', $data);
476 }
477 }