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

453 lines 8.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 1.0.2 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2021 FirePlugins All Rights Reserved
9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 */
11
12 namespace FireBox\Core {
13 if (!defined('ABSPATH'))
14 {
15 exit; // Exit if accessed directly.
16 }
17
18 use FPFramework\Framework;
19 use FPFramework\Admin\Includes\MetaboxManager;
20 use FPFramework\Libs\FPGeoIP;
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
28 use FireBox\Core\Admin\Analytics\Overview\Overview as AnalyticsOverview;
29 use FireBox\Core\Admin\Menu\PluginMenu;
30 use FireBox\Core\Admin\Maintenance;
31 use FireBox\Core\FB\Boxes;
32 use FireBox\Core\FB\Log;
33 use FireBox\Core\FB\Track;
34 use FireBox\Core\Shortcodes\Shortcodes;
35 use FireBox\Core\Libs\Translations;
36
37 /**
38 * This class is responsible for initializing FireBox.
39 *
40 * It registers all required components needed for the plugin to run.
41 */
42 final class Plugin
43 {
44 /**
45 * Holds the admin plugin.
46 *
47 * @var Admin
48 */
49 public $admin;
50
51 /**
52 * Library
53 *
54 * @var Library
55 */
56 public $library;
57
58 /**
59 * Models
60 *
61 * @var Models
62 */
63 public $models;
64
65 /**
66 * Custom Post Types
67 *
68 * @var CPTS
69 */
70 public $cpts;
71
72 /**
73 * Renderer
74 *
75 * @var Renderer
76 */
77 public $renderer;
78
79 /**
80 * Plugin Metaboxes
81 *
82 * @var Metaboxes
83 */
84 public $plugin_metaboxes;
85
86 /**
87 * Metaboxes Manager
88 *
89 * @var MetaboxManager
90 */
91 public $metaboxes_manager;
92
93 /**
94 * Maintenance
95 *
96 * @var Maintenance
97 */
98 public $maintenance;
99
100 /**
101 * Boxes
102 *
103 * @var Boxes
104 */
105 public $boxes;
106
107 /**
108 * The WP Admin Menu of the Plugin
109 *
110 * @var Menu
111 */
112 public $menu;
113
114 /**
115 * The geolocation class
116 *
117 * @var GeoIP
118 */
119 public $fpgeoip;
120
121 /**
122 * The REST API.
123 *
124 * @var RESTAPI
125 */
126 public $api;
127
128 /**
129 * Helper Classes
130 *
131 * @var HelperMiddleware
132 */
133 public $helper;
134
135 /**
136 * Gutenberg blocks
137 *
138 * @var Blocks
139 */
140 public $blocks;
141
142 /**
143 * Widgets
144 *
145 * @var Widgets
146 */
147 public $widgets;
148
149 /**
150 * Shortcodes
151 *
152 * @var Shortcodes
153 */
154 public $shortcodes;
155
156 /**
157 * Track
158 *
159 * @var Track
160 */
161 public $track;
162
163 /**
164 * log
165 *
166 * @var Log
167 */
168 public $log;
169
170
171
172 /**
173 * Translations
174 *
175 * @var Translations
176 */
177 public $translations;
178
179 /**
180 * Tables used by Hook
181 *
182 * @var array
183 */
184 private $hook_data = [
185 'tables' => [ 'firebox_logs' ],
186 'activation' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/firebox.sql',
187 'uninstall' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/uninstall.firebox.sql'
188 ];
189
190 /**
191 * The plugin name
192 *
193 * @var String
194 */
195 public $plugin_name = 'FireBox';
196
197 /**
198 * The plugin slug
199 *
200 * @var String
201 */
202 public $plugin_slug = 'firebox';
203
204 /**
205 * Holds the plugin instance
206 *
207 * @var Plugin $instance
208 */
209 public static $instance = null;
210
211 private function __construct()
212 {
213 $this->preFlight();
214
215 // run init
216 add_action('fpf_init', [$this, 'init']);
217
218 // admin init
219 add_action('fpf_admin_init', [$this, 'admin_init']);
220
221 // admin menu
222 add_action('admin_menu', [$this, 'admin_menu']);
223 }
224
225 /**
226 * Admin Menu
227 *
228 * @return void
229 */
230 public function admin_menu()
231 {
232 $this->menu = new PluginMenu();
233 $this->menu->init();
234 }
235
236 /**
237 * Admin Init
238 *
239 * @return void
240 */
241 public function admin_init()
242 {
243
244 new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name);
245
246
247 // Admin
248 $this->admin = new Admin();
249
250 // Metaboxes
251 $this->metaboxes_manager = new MetaboxManager();
252 $this->plugin_metaboxes = new PluginMetaboxes();
253 $this->metaboxes_manager->init();
254 }
255
256 /**
257 * Runs at the start of the Plugin
258 *
259 * @return void
260 */
261 public function preFlight()
262 {
263 // set translations
264 $this->translations = new Libs\Translations();
265
266 // loads text domain
267 add_action('plugins_loaded', [$this, 'loadTextdomain'], 10);
268
269 // show rate reminder after user has activated the plugin
270 add_action('activated_plugin', [$this, 'set_rate_reminder']);
271
272 // adds plugin translation class to the framework set of translate classes
273 add_filter('fpframework/set_translation_paths', [$this, 'setTranslationsPaths']);
274
275 // Widgets
276 $this->widgets = new Widgets();
277
278 if (is_admin())
279 {
280 // Run Activation/Deactivation procedures
281 $this->maintenance = new Maintenance($this->hook_data);
282 $this->maintenance->init();
283 }
284 }
285
286 /**
287 * Set rate reminder transient on plugin activation.
288 *
289 * @return void
290 */
291 public function set_rate_reminder()
292 {
293 if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) )
294 {
295 return;
296 }
297
298 // make rate reminder appear 2 days after the plugin has been activated.
299 $date = new \DateTime();
300 $date->add( new \DateInterval( 'P2D' ) );
301 set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) );
302 }
303
304 /**
305 * Ensures only one instance of the plugin class is loaded or can be loaded
306 *
307 * @return Plugin An instance of the class.
308 */
309 public static function instance()
310 {
311 if (is_null(self::$instance))
312 {
313 self::$instance = new self();
314 }
315
316 return self::$instance;
317 }
318
319 /**
320 * Loads the textdomain
321 *
322 * @return void
323 */
324 public function loadTextdomain()
325 {
326 load_plugin_textdomain('firebox', false, FBOX_PLUGIN_DIR . 'languages/');
327 }
328
329 /**
330 * Initializes all Common components used by front-end and back-end.
331 *
332 * @return void
333 */
334 private function initCommons()
335 {
336 new AdminBarMenu();
337
338 // Library
339 $this->library = new Library();
340
341 // Models
342 $this->models = new Models();
343
344 // Shortcodes
345 $this->shortcodes = new Shortcodes();
346
347 // Log
348 $this->log = new Log();
349
350 // REST API
351 $this->api = new RESTAPI();
352
353 // Custom Post Types
354 $this->cpts = new Cpts();
355 $this->cpts->init();
356
357 // Renderer
358 $this->renderer = new Renderer(FBOX_LAYOUTS_DIR);
359
360 // Boxes
361 $this->boxes = new Boxes();
362
363 // FPGeo IP
364 $this->fpgeoip = new FPGeoIP();
365
366 // Helper
367 $this->helper = new HelperMiddleware();
368
369 // Gutenberg Blocks
370 $this->blocks = new Blocks();
371
372 // Track
373 $this->track = new Track();
374
375 // Initialize Analytics
376 global $wpdb;
377 $analytics_configuration = [
378 'boxes_table' => $wpdb->prefix . 'posts',
379 'logs_table' => firebox()->models->boxlog->getFullTableName(),
380 'logs_details_table' => firebox()->models->boxlogdetails->getFullTableName(),
381 'nonce_value' => wp_create_nonce('fb-analytics-nonce'),
382 ];
383
384
385
386 // Initialize Analytics Overview
387 $this->analytics_overview = new AnalyticsOverview($analytics_configuration);
388 }
389
390 /**
391 * Initializes FireBox Plugin with the required components
392 *
393 * @return void
394 */
395 public function init()
396 {
397 // init framework
398 \FPFramework\Framework::getInstance($this->plugin_slug);
399
400 // common classes (both front/back end)
401 $this->initCommons();
402
403 // Load front-end
404 new Frontend();
405 }
406
407 /**
408 * Append our Plugin translation class to the set of translation classes of the Framework
409 *
410 * @param array
411 *
412 * @return array
413 */
414 public function setTranslationsPaths($paths)
415 {
416 if (isset($paths['firebox']))
417 {
418 return $paths;
419 }
420
421 $paths['firebox'] = [
422 'prefix' => 'FB_'
423 ];
424
425 return $paths;
426 }
427
428 /**
429 * Retrieves the translation of $text
430 *
431 * @param string $text
432 * @param string $fallback
433 *
434 * @return string
435 */
436 public function _($text, $fallback = null)
437 {
438 return $this->translations->_($text, $fallback);
439 }
440 }
441 }
442
443 namespace {
444 /**
445 * The function which returns the one and only FireBox instance.
446 *
447 * @return Plugin
448 */
449 function firebox()
450 {
451 return FireBox\Core\Plugin::instance();
452 }
453 }