PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.0.1
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.0.1
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 3.0.1, at Inc/Core/Plugin.php

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