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 / Plugin.php

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

419 lines 7.1 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
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 #PRO-END
154
155 /**
156 * Translations
157 *
158 * @var Translations
159 */
160 public $translations;
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 // set translations
250 $this->translations = new Libs\Translations();
251
252 // loads text domain
253 add_action('plugins_loaded', [$this, 'loadTextdomain'], 10);
254
255 // show rate reminder after user has activated the plugin
256 add_action('activated_plugin', [$this, 'set_rate_reminder']);
257
258 // Widgets
259 $this->widgets = new Widgets();
260 }
261
262 /**
263 * Set rate reminder transient on plugin activation.
264 *
265 * @return void
266 */
267 public function set_rate_reminder()
268 {
269 if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) )
270 {
271 return;
272 }
273
274 // make rate reminder appear 2 days after the plugin has been activated.
275 $date = new \DateTime();
276 $date->add( new \DateInterval( 'P2D' ) );
277 set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) );
278 }
279
280 /**
281 * Ensures only one instance of the plugin class is loaded or can be loaded
282 *
283 * @return Plugin An instance of the class.
284 */
285 public static function instance()
286 {
287 if (is_null(self::$instance))
288 {
289 self::$instance = new self();
290 }
291
292 return self::$instance;
293 }
294
295 /**
296 * Loads the textdomain
297 *
298 * @return void
299 */
300 public function loadTextdomain()
301 {
302 load_plugin_textdomain('firebox', false, FBOX_PLUGIN_DIR . 'languages/');
303 }
304
305 /**
306 * Initializes all Common components used by front-end and back-end.
307 *
308 * @return void
309 */
310 private function initCommons()
311 {
312 new AdminBarMenu();
313
314 // Tables
315 $this->tables = new Tables();
316
317 // Shortcodes
318 $this->shortcodes = new Shortcodes();
319
320 // Log
321 $this->log = new Log();
322
323 // REST API
324 new RESTAPI();
325
326
327 // Custom Post Types
328 $this->cpts = new Cpts();
329 $this->cpts->init();
330
331 // Renderer
332 $this->renderer = new Renderer(FBOX_LAYOUTS_DIR);
333
334 // Box
335 $this->box = new Box();
336
337 // Boxes
338 $this->boxes = new Boxes();
339
340 // Helper
341 $this->helper = new HelperMiddleware();
342
343 // Gutenberg Blocks
344 $this->blocks = new Blocks();
345
346 // Forms AJAX
347 new \FireBox\Core\Form\Ajax();
348
349 // Analytics AJAX
350 new \FireBox\Core\Analytics\Ajax();
351
352 // Track
353 $this->track = new Track();
354 }
355
356 /**
357 * Initializes FireBox Plugin with the required components
358 *
359 * @return void
360 */
361 public function init()
362 {
363 // init framework
364 \FPFramework\Framework::getInstance($this->plugin_slug);
365
366 // common classes (both front/back end)
367 $this->initCommons();
368
369 // Load front-end
370 new Frontend();
371 }
372
373 /**
374 * Append our Plugin translation class to the set of translation classes of the Framework
375 *
376 * @param array
377 *
378 * @return array
379 */
380 public function setTranslationsPaths($paths)
381 {
382 if (isset($paths['firebox']))
383 {
384 return $paths;
385 }
386
387 $paths['firebox'] = [
388 'prefix' => 'FB_'
389 ];
390
391 return $paths;
392 }
393
394 /**
395 * Retrieves the translation of $text
396 *
397 * @param string $text
398 * @param string $fallback
399 *
400 * @return string
401 */
402 public function _($text, $fallback = null)
403 {
404 return $this->translations->_($text, $fallback);
405 }
406 }
407 }
408
409 namespace {
410 /**
411 * The function which returns the one and only FireBox instance.
412 *
413 * @return Plugin
414 */
415 function firebox()
416 {
417 return FireBox\Core\Plugin::instance();
418 }
419 }