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

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

404 lines 6.7 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.39 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2025 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\Framework;
20 use FPFramework\Admin\Includes\MetaboxManager;
21 use FPFramework\Base\Renderer;
22
23 use FireBox\Core\Admin\Admin;
24 use FireBox\Core\Admin\Includes\Library;
25 use FireBox\Core\Admin\Includes\Metaboxes as PluginMetaboxes;
26 use FireBox\Core\Admin\Includes\Cpts\Cpts;
27 use FireBox\Core\Admin\Menu\PluginMenu;
28 use FireBox\Core\FB\Box;
29 use FireBox\Core\FB\Boxes;
30 use FireBox\Core\FB\Log;
31 use FireBox\Core\FB\Track;
32 use FireBox\Core\Shortcodes\Shortcodes;
33 use FireBox\Core\Libs\Translations;
34
35 /**
36 * This class is responsible for initializing FireBox.
37 *
38 * It registers all required components needed for the plugin to run.
39 */
40 final class Plugin
41 {
42 /**
43 * Holds the admin plugin.
44 *
45 * @var Admin
46 */
47 public $admin;
48
49 /**
50 * Library
51 *
52 * @var Library
53 */
54 public $library;
55
56 /**
57 * Tables
58 *
59 * @var Tables
60 */
61 public $tables;
62
63 /**
64 * Custom Post Types
65 *
66 * @var CPTS
67 */
68 public $cpts;
69
70 /**
71 * Renderer
72 *
73 * @var Renderer
74 */
75 public $renderer;
76
77 /**
78 * Plugin Metaboxes
79 *
80 * @var Metaboxes
81 */
82 public $plugin_metaboxes;
83
84 /**
85 * Metaboxes Manager
86 *
87 * @var MetaboxManager
88 */
89 public $metaboxes_manager;
90
91 /**
92 * Box
93 *
94 * @var Box
95 */
96 public $box;
97
98 /**
99 * Boxes
100 *
101 * @var Boxes
102 */
103 public $boxes;
104
105 /**
106 * The WP Admin Menu of the Plugin
107 *
108 * @var Menu
109 */
110 public $menu;
111
112 /**
113 * Helper Classes
114 *
115 * @var HelperMiddleware
116 */
117 public $helper;
118
119 /**
120 * Gutenberg blocks
121 *
122 * @var Blocks
123 */
124 public $blocks;
125
126 /**
127 * Shortcodes
128 *
129 * @var Shortcodes
130 */
131 public $shortcodes;
132
133 /**
134 * Track
135 *
136 * @var Track
137 */
138 public $track;
139
140 /**
141 * log
142 *
143 * @var Log
144 */
145 public $log;
146
147 /**
148 * PHP Scripts
149 *
150 * @var PHPScripts
151 */
152 public $phpscripts;
153 #PRO-END
154
155 /**
156 * Translations cache
157 *
158 * @var Libs\Translations
159 */
160 private $translations_cache;
161
162 /**
163 * Tables used by Hook
164 *
165 * @var array
166 */
167 public $hook_data = [
168 'tables' => [ 'firebox_logs', 'firebox_logs_details', 'firebox_submissions', 'firebox_submission_meta' ],
169 'activation' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/firebox.sql',
170 'uninstall' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/uninstall.firebox.sql'
171 ];
172
173 /**
174 * The plugin name
175 *
176 * @var String
177 */
178 public $plugin_name = 'FireBox';
179
180 /**
181 * The plugin slug
182 *
183 * @var String
184 */
185 public $plugin_slug = 'firebox';
186
187 /**
188 * Holds the plugin instance
189 *
190 * @var Plugin $instance
191 */
192 public static $instance = null;
193
194 private function __construct()
195 {
196 $this->preFlight();
197
198 // run init
199 add_action('fpf_init', [$this, 'init']);
200
201 // admin init
202 add_action('fpf_admin_init', [$this, 'admin_init']);
203
204 // admin menu
205 add_action('admin_menu', [$this, 'admin_menu']);
206 }
207
208 /**
209 * Admin Menu
210 *
211 * @return void
212 */
213 public function admin_menu()
214 {
215 $this->menu = new PluginMenu();
216 $this->menu->init();
217 }
218
219 /**
220 * Admin Init
221 *
222 * @return void
223 */
224 public function admin_init()
225 {
226
227 new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name);
228
229
230 // Admin
231 $this->admin = new Admin();
232
233 // Library
234 $this->library = new Library();
235
236 // Metaboxes
237 $this->metaboxes_manager = new MetaboxManager();
238 $this->plugin_metaboxes = new PluginMetaboxes();
239 $this->metaboxes_manager->init();
240 }
241
242 /**
243 * Runs at the start of the Plugin
244 *
245 * @return void
246 */
247 public function preFlight()
248 {
249 // loads text domain
250 add_action('plugins_loaded', [$this, 'loadTextdomain'], 10);
251 }
252
253 /**
254 * Ensures only one instance of the plugin class is loaded or can be loaded
255 *
256 * @return Plugin An instance of the class.
257 */
258 public static function instance()
259 {
260 if (is_null(self::$instance))
261 {
262 self::$instance = new self();
263 }
264
265 return self::$instance;
266 }
267
268 /**
269 * Loads the textdomain
270 *
271 * @return void
272 */
273 public function loadTextdomain()
274 {
275 load_plugin_textdomain('firebox', false, FBOX_PLUGIN_DIR . 'languages/');
276 }
277
278 /**
279 * Initializes all Common components used by front-end and back-end.
280 *
281 * @return void
282 */
283 private function initCommons()
284 {
285 new AdminBarMenu();
286
287 // Tables
288 $this->tables = new Tables();
289
290 // Shortcodes
291 $this->shortcodes = new Shortcodes();
292
293 // Log
294 $this->log = new Log();
295
296 // REST API
297 new RESTAPI();
298
299
300
301 // Custom Post Types
302 $this->cpts = new Cpts();
303 $this->cpts->init();
304
305 // Renderer
306 $this->renderer = new Renderer(FBOX_LAYOUTS_DIR);
307
308 // Box
309 $this->box = new Box();
310
311 // Boxes
312 $this->boxes = new Boxes();
313
314 // Helper
315 $this->helper = new HelperMiddleware();
316
317 // Gutenberg Blocks
318 $this->blocks = new Blocks();
319
320 // Forms AJAX
321 new \FireBox\Core\Form\Ajax();
322
323 // Analytics AJAX
324 new \FireBox\Core\Analytics\Ajax();
325
326 // Track
327 $this->track = new Track();
328
329 // Usage Tracking
330 $usageTracking = new \FireBox\Core\UsageTracking\SendUsage();
331 $usageTracking->maybeStart();
332 }
333
334 /**
335 * Initializes FireBox Plugin with the required components
336 *
337 * @return void
338 */
339 public function init()
340 {
341 // init framework
342 \FPFramework\Framework::getInstance($this->plugin_slug);
343
344 // common classes (both front/back end)
345 $this->initCommons();
346
347 // Load front-end
348 new Frontend();
349 }
350
351 /**
352 * Append our Plugin translation class to the set of translation classes of the Framework
353 *
354 * @param array
355 *
356 * @return array
357 */
358 public function setTranslationsPaths($paths)
359 {
360 if (isset($paths['firebox']))
361 {
362 return $paths;
363 }
364
365 $paths['firebox'] = [
366 'prefix' => 'FB_'
367 ];
368
369 return $paths;
370 }
371
372 /**
373 * Retrieves the translation of $text
374 *
375 * @param string $text
376 * @param string $fallback
377 *
378 * @return string
379 */
380 public function _($text, $fallback = null)
381 {
382 // check if translations instance exists
383 if (!isset($this->translations_cache))
384 {
385 // set translations
386 $this->translations_cache = new Libs\Translations();
387 }
388
389 return $this->translations_cache->_($text, $fallback);
390 }
391 }
392 }
393
394 namespace {
395 /**
396 * The function which returns the one and only FireBox instance.
397 *
398 * @return Plugin
399 */
400 function firebox()
401 {
402 return FireBox\Core\Plugin::instance();
403 }
404 }