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

406 lines 6.6 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.23 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 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 * Widgets
128 *
129 * @var Widgets
130 */
131 public $widgets;
132
133 /**
134 * Shortcodes
135 *
136 * @var Shortcodes
137 */
138 public $shortcodes;
139
140 /**
141 * Track
142 *
143 * @var Track
144 */
145 public $track;
146
147 /**
148 * log
149 *
150 * @var Log
151 */
152 public $log;
153
154 /**
155 * PHP Scripts
156 *
157 * @var PHPScripts
158 */
159 public $phpscripts;
160 #PRO-END
161
162 /**
163 * Translations
164 *
165 * @var Translations
166 */
167 public $translations;
168
169 /**
170 * Tables used by Hook
171 *
172 * @var array
173 */
174 public $hook_data = [
175 'tables' => [ 'firebox_logs', 'firebox_logs_details', 'firebox_submissions', 'firebox_submission_meta' ],
176 'activation' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/firebox.sql',
177 'uninstall' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/uninstall.firebox.sql'
178 ];
179
180 /**
181 * The plugin name
182 *
183 * @var String
184 */
185 public $plugin_name = 'FireBox';
186
187 /**
188 * The plugin slug
189 *
190 * @var String
191 */
192 public $plugin_slug = 'firebox';
193
194 /**
195 * Holds the plugin instance
196 *
197 * @var Plugin $instance
198 */
199 public static $instance = null;
200
201 private function __construct()
202 {
203 $this->preFlight();
204
205 // run init
206 add_action('fpf_init', [$this, 'init']);
207
208 // admin init
209 add_action('fpf_admin_init', [$this, 'admin_init']);
210
211 // admin menu
212 add_action('admin_menu', [$this, 'admin_menu']);
213 }
214
215 /**
216 * Admin Menu
217 *
218 * @return void
219 */
220 public function admin_menu()
221 {
222 $this->menu = new PluginMenu();
223 $this->menu->init();
224 }
225
226 /**
227 * Admin Init
228 *
229 * @return void
230 */
231 public function admin_init()
232 {
233
234 new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name);
235
236
237 // Admin
238 $this->admin = new Admin();
239
240 // Library
241 $this->library = new Library();
242
243 // Metaboxes
244 $this->metaboxes_manager = new MetaboxManager();
245 $this->plugin_metaboxes = new PluginMetaboxes();
246 $this->metaboxes_manager->init();
247 }
248
249 /**
250 * Runs at the start of the Plugin
251 *
252 * @return void
253 */
254 public function preFlight()
255 {
256 // set translations
257 $this->translations = new Libs\Translations();
258
259 // loads text domain
260 add_action('plugins_loaded', [$this, 'loadTextdomain'], 10);
261
262 // Widgets
263 $this->widgets = new Widgets();
264 }
265
266 /**
267 * Ensures only one instance of the plugin class is loaded or can be loaded
268 *
269 * @return Plugin An instance of the class.
270 */
271 public static function instance()
272 {
273 if (is_null(self::$instance))
274 {
275 self::$instance = new self();
276 }
277
278 return self::$instance;
279 }
280
281 /**
282 * Loads the textdomain
283 *
284 * @return void
285 */
286 public function loadTextdomain()
287 {
288 load_plugin_textdomain('firebox', false, FBOX_PLUGIN_DIR . 'languages/');
289 }
290
291 /**
292 * Initializes all Common components used by front-end and back-end.
293 *
294 * @return void
295 */
296 private function initCommons()
297 {
298 new AdminBarMenu();
299
300 // Tables
301 $this->tables = new Tables();
302
303 // Shortcodes
304 $this->shortcodes = new Shortcodes();
305
306 // Log
307 $this->log = new Log();
308
309 // REST API
310 new RESTAPI();
311
312
313
314 // Custom Post Types
315 $this->cpts = new Cpts();
316 $this->cpts->init();
317
318 // Renderer
319 $this->renderer = new Renderer(FBOX_LAYOUTS_DIR);
320
321 // Box
322 $this->box = new Box();
323
324 // Boxes
325 $this->boxes = new Boxes();
326
327 // Helper
328 $this->helper = new HelperMiddleware();
329
330 // Gutenberg Blocks
331 $this->blocks = new Blocks();
332
333 // Forms AJAX
334 new \FireBox\Core\Form\Ajax();
335
336 // Analytics AJAX
337 new \FireBox\Core\Analytics\Ajax();
338
339 // Track
340 $this->track = new Track();
341 }
342
343 /**
344 * Initializes FireBox Plugin with the required components
345 *
346 * @return void
347 */
348 public function init()
349 {
350 // init framework
351 \FPFramework\Framework::getInstance($this->plugin_slug);
352
353 // common classes (both front/back end)
354 $this->initCommons();
355
356 // Load front-end
357 new Frontend();
358 }
359
360 /**
361 * Append our Plugin translation class to the set of translation classes of the Framework
362 *
363 * @param array
364 *
365 * @return array
366 */
367 public function setTranslationsPaths($paths)
368 {
369 if (isset($paths['firebox']))
370 {
371 return $paths;
372 }
373
374 $paths['firebox'] = [
375 'prefix' => 'FB_'
376 ];
377
378 return $paths;
379 }
380
381 /**
382 * Retrieves the translation of $text
383 *
384 * @param string $text
385 * @param string $fallback
386 *
387 * @return string
388 */
389 public function _($text, $fallback = null)
390 {
391 return $this->translations->_($text, $fallback);
392 }
393 }
394 }
395
396 namespace {
397 /**
398 * The function which returns the one and only FireBox instance.
399 *
400 * @return Plugin
401 */
402 function firebox()
403 {
404 return FireBox\Core\Plugin::instance();
405 }
406 }