| @@ -1,16 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.0.11 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2022 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -namespace FireBox\Core { | |
| 12 | +namespace FireBox\Core | |
| 13 | +{ | |
| 13 | 14 | if (!defined('ABSPATH')) |
| 14 | 15 | { |
| 15 | 16 | exit; // Exit if accessed directly. |
| 16 | 17 | } |
| @@ -15,20 +16,14 @@ | ||
| 15 | 16 | exit; // Exit if accessed directly. |
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | use FPFramework\Framework; |
| 19 | - use FPFramework\Admin\Includes\MetaboxManager; | |
| 20 | - use FPFramework\Libs\FPGeoIP; | |
| 21 | 20 | use FPFramework\Base\Renderer; |
| 22 | 21 | |
| 23 | 22 | use FireBox\Core\Admin\Admin; |
| 24 | 23 | use FireBox\Core\Admin\Includes\Library; |
| 25 | - use FireBox\Core\Admin\Includes\Metaboxes as PluginMetaboxes; | |
| 26 | 24 | use FireBox\Core\Admin\Includes\Cpts\Cpts; |
| 27 | - | |
| 28 | - use FireBox\Core\Admin\Analytics\Overview\Overview as AnalyticsOverview; | |
| 29 | 25 | use FireBox\Core\Admin\Menu\PluginMenu; |
| 30 | - use FireBox\Core\Admin\Maintenance; | |
| 31 | 26 | use FireBox\Core\FB\Box; |
| 32 | 27 | use FireBox\Core\FB\Boxes; |
| 33 | 28 | use FireBox\Core\FB\Log; |
| 34 | 29 | use FireBox\Core\FB\Track; |
| @@ -77,29 +72,8 @@ | ||
| 77 | 72 | */ |
| 78 | 73 | public $renderer; |
| 79 | 74 | |
| 80 | 75 | /** |
| 81 | - * Plugin Metaboxes | |
| 82 | - * | |
| 83 | - * @var Metaboxes | |
| 84 | - */ | |
| 85 | - public $plugin_metaboxes; | |
| 86 | - | |
| 87 | - /** | |
| 88 | - * Metaboxes Manager | |
| 89 | - * | |
| 90 | - * @var MetaboxManager | |
| 91 | - */ | |
| 92 | - public $metaboxes_manager; | |
| 93 | - | |
| 94 | - /** | |
| 95 | - * Maintenance | |
| 96 | - * | |
| 97 | - * @var Maintenance | |
| 98 | - */ | |
| 99 | - public $maintenance; | |
| 100 | - | |
| 101 | - /** | |
| 102 | 76 | * Box |
| 103 | 77 | * |
| 104 | 78 | * @var Box |
| 105 | 79 | */ |
| @@ -119,22 +93,8 @@ | ||
| 119 | 93 | */ |
| 120 | 94 | public $menu; |
| 121 | 95 | |
| 122 | 96 | /** |
| 123 | - * The geolocation class | |
| 124 | - * | |
| 125 | - * @var GeoIP | |
| 126 | - */ | |
| 127 | - public $fpgeoip; | |
| 128 | - | |
| 129 | - /** | |
| 130 | - * The REST API. | |
| 131 | - * | |
| 132 | - * @var RESTAPI | |
| 133 | - */ | |
| 134 | - public $api; | |
| 135 | - | |
| 136 | - /** | |
| 137 | 97 | * Helper Classes |
| 138 | 98 | * |
| 139 | 99 | * @var HelperMiddleware |
| 140 | 100 | */ |
| @@ -147,15 +107,8 @@ | ||
| 147 | 107 | */ |
| 148 | 108 | public $blocks; |
| 149 | 109 | |
| 150 | 110 | /** |
| 151 | - * Widgets | |
| 152 | - * | |
| 153 | - * @var Widgets | |
| 154 | - */ | |
| 155 | - public $widgets; | |
| 156 | - | |
| 157 | - /** | |
| 158 | 111 | * Shortcodes |
| 159 | 112 | * |
| 160 | 113 | * @var Shortcodes |
| 161 | 114 | */ |
| @@ -177,13 +130,13 @@ | ||
| 177 | 130 | |
| 178 | 131 | |
| 179 | 132 | |
| 180 | 133 | /** |
| 181 | - * Translations | |
| 134 | + * Translations cache | |
| 182 | 135 | * |
| 183 | - * @var Translations | |
| 136 | + * @var Libs\Translations | |
| 184 | 137 | */ |
| 185 | - public $translations; | |
| 138 | + private $translations_cache; | |
| 186 | 139 | |
| 187 | 140 | /** |
| 188 | 141 | * Tables used by Hook |
| 189 | 142 | * |
| @@ -188,10 +141,10 @@ | ||
| 188 | 141 | * Tables used by Hook |
| 189 | 142 | * |
| 190 | 143 | * @var array |
| 191 | 144 | */ |
| 192 | - private $hook_data = [ | |
| 193 | - 'tables' => [ 'firebox_logs' ], | |
| 145 | + public $hook_data = [ | |
| 146 | + 'tables' => [ 'firebox_logs', 'firebox_logs_details', 'firebox_submissions', 'firebox_submission_meta' ], | |
| 194 | 147 | 'activation' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/firebox.sql', |
| 195 | 148 | 'uninstall' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/uninstall.firebox.sql' |
| 196 | 149 | ]; |
| 197 | 150 | |
| @@ -247,19 +200,19 @@ | ||
| 247 | 200 | * @return void |
| 248 | 201 | */ |
| 249 | 202 | public function admin_init() |
| 250 | 203 | { |
| 204 | + new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name); | |
| 205 | + | |
| 251 | 206 | |
| 252 | - new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name); | |
| 207 | + new \FireBox\Core\Admin\Includes\UpgradeToPlanModal(); | |
| 253 | 208 | |
| 254 | 209 | |
| 255 | 210 | // Admin |
| 256 | 211 | $this->admin = new Admin(); |
| 257 | 212 | |
| 258 | - // Metaboxes | |
| 259 | - $this->metaboxes_manager = new MetaboxManager(); | |
| 260 | - $this->plugin_metaboxes = new PluginMetaboxes(); | |
| 261 | - $this->metaboxes_manager->init(); | |
| 213 | + // Library | |
| 214 | + $this->library = new Library(); | |
| 262 | 215 | } |
| 263 | 216 | |
| 264 | 217 | /** |
| 265 | 218 | * Runs at the start of the Plugin |
| @@ -267,50 +220,15 @@ | ||
| 267 | 220 | * @return void |
| 268 | 221 | */ |
| 269 | 222 | public function preFlight() |
| 270 | 223 | { |
| 271 | - // set translations | |
| 272 | - $this->translations = new Libs\Translations(); | |
| 273 | - | |
| 274 | 224 | // loads text domain |
| 275 | 225 | add_action('plugins_loaded', [$this, 'loadTextdomain'], 10); |
| 276 | 226 | |
| 277 | - // show rate reminder after user has activated the plugin | |
| 278 | - add_action('activated_plugin', [$this, 'set_rate_reminder']); | |
| 279 | - | |
| 280 | - // adds plugin translation class to the framework set of translate classes | |
| 281 | - add_filter('fpframework/set_translation_paths', [$this, 'setTranslationsPaths']); | |
| 282 | - | |
| 283 | - // Widgets | |
| 284 | - $this->widgets = new Widgets(); | |
| 285 | - | |
| 286 | - if (is_admin()) | |
| 287 | - { | |
| 288 | - // Run Activation/Deactivation procedures | |
| 289 | - $this->maintenance = new Maintenance($this->hook_data); | |
| 290 | - $this->maintenance->init(); | |
| 291 | - } | |
| 227 | + | |
| 292 | 228 | } |
| 293 | 229 | |
| 294 | 230 | /** |
| 295 | - * Set rate reminder transient on plugin activation. | |
| 296 | - * | |
| 297 | - * @return void | |
| 298 | - */ | |
| 299 | - public function set_rate_reminder() | |
| 300 | - { | |
| 301 | - if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) ) | |
| 302 | - { | |
| 303 | - return; | |
| 304 | - } | |
| 305 | - | |
| 306 | - // make rate reminder appear 2 days after the plugin has been activated. | |
| 307 | - $date = new \DateTime(); | |
| 308 | - $date->add( new \DateInterval( 'P2D' ) ); | |
| 309 | - set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) ); | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | 231 | * Ensures only one instance of the plugin class is loaded or can be loaded |
| 314 | 232 | * |
| 315 | 233 | * @return Plugin An instance of the class. |
| 316 | 234 | */ |
| @@ -342,11 +260,8 @@ | ||
| 342 | 260 | private function initCommons() |
| 343 | 261 | { |
| 344 | 262 | new AdminBarMenu(); |
| 345 | 263 | |
| 346 | - // Library | |
| 347 | - $this->library = new Library(); | |
| 348 | - | |
| 349 | 264 | // Tables |
| 350 | 265 | $this->tables = new Tables(); |
| 351 | 266 | |
| 352 | 267 | // Shortcodes |
| @@ -354,14 +269,18 @@ | ||
| 354 | 269 | |
| 355 | 270 | // Log |
| 356 | 271 | $this->log = new Log(); |
| 357 | 272 | |
| 358 | - // REST API | |
| 359 | - $this->api = new RESTAPI(); | |
| 273 | + new API\API(); | |
| 274 | + | |
| 275 | + | |
| 360 | 276 | |
| 361 | - // Custom Post Types | |
| 362 | - $this->cpts = new Cpts(); | |
| 363 | - $this->cpts->init(); | |
| 277 | + // Register Custom Post Type | |
| 278 | + new \FireBox\Core\Admin\Includes\Cpts\Firebox(); | |
| 279 | + | |
| 280 | + // Keep the campaign-derived caches (box list, "session conditions in use" | |
| 281 | + // flag) in sync with campaign writes | |
| 282 | + \FireBox\Core\Helpers\BoxHelper::registerCacheInvalidation(); | |
| 364 | 283 | |
| 365 | 284 | // Renderer |
| 366 | 285 | $this->renderer = new Renderer(FBOX_LAYOUTS_DIR); |
| 367 | 286 | |
| @@ -370,11 +289,8 @@ | ||
| 370 | 289 | |
| 371 | 290 | // Boxes |
| 372 | 291 | $this->boxes = new Boxes(); |
| 373 | 292 | |
| 374 | - // FPGeo IP | |
| 375 | - $this->fpgeoip = new FPGeoIP(); | |
| 376 | - | |
| 377 | 293 | // Helper |
| 378 | 294 | $this->helper = new HelperMiddleware(); |
| 379 | 295 | |
| 380 | 296 | // Gutenberg Blocks |
| @@ -379,24 +295,24 @@ | ||
| 379 | 295 | |
| 380 | 296 | // Gutenberg Blocks |
| 381 | 297 | $this->blocks = new Blocks(); |
| 382 | 298 | |
| 299 | + // Forms AJAX | |
| 300 | + new \FireBox\Core\Form\Ajax(); | |
| 301 | + | |
| 302 | + // Analytics AJAX | |
| 303 | + new \FireBox\Core\Analytics\Ajax(); | |
| 304 | + | |
| 383 | 305 | // Track |
| 384 | 306 | $this->track = new Track(); |
| 385 | 307 | |
| 386 | - // Initialize Analytics | |
| 387 | - global $wpdb; | |
| 388 | - $analytics_configuration = [ | |
| 389 | - 'boxes_table' => $wpdb->prefix . 'posts', | |
| 390 | - 'logs_table' => firebox()->tables->boxlog->getFullTableName(), | |
| 391 | - 'logs_details_table' => firebox()->tables->boxlogdetails->getFullTableName(), | |
| 392 | - 'nonce_value' => wp_create_nonce('fb-analytics-nonce'), | |
| 393 | - ]; | |
| 394 | 308 | |
| 395 | - | |
| 396 | - | |
| 397 | - // Initialize Analytics Overview | |
| 398 | - $this->analytics_overview = new AnalyticsOverview($analytics_configuration); | |
| 309 | + | |
| 310 | + // Usage Tracking | |
| 311 | + $usageTracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 312 | + $usageTracking->maybeStart(); | |
| 313 | + | |
| 314 | + new FB\Meta(); | |
| 399 | 315 | } |
| 400 | 316 | |
| 401 | 317 | /** |
| 402 | 318 | * Initializes FireBox Plugin with the required components |
| @@ -415,29 +331,8 @@ | ||
| 415 | 331 | new Frontend(); |
| 416 | 332 | } |
| 417 | 333 | |
| 418 | 334 | /** |
| 419 | - * Append our Plugin translation class to the set of translation classes of the Framework | |
| 420 | - * | |
| 421 | - * @param array | |
| 422 | - * | |
| 423 | - * @return array | |
| 424 | - */ | |
| 425 | - public function setTranslationsPaths($paths) | |
| 426 | - { | |
| 427 | - if (isset($paths['firebox'])) | |
| 428 | - { | |
| 429 | - return $paths; | |
| 430 | - } | |
| 431 | - | |
| 432 | - $paths['firebox'] = [ | |
| 433 | - 'prefix' => 'FB_' | |
| 434 | - ]; | |
| 435 | - | |
| 436 | - return $paths; | |
| 437 | - } | |
| 438 | - | |
| 439 | - /** | |
| 440 | 335 | * Retrieves the translation of $text |
| 441 | 336 | * |
| 442 | 337 | * @param string $text |
| 443 | 338 | * @param string $fallback |
| @@ -445,9 +340,16 @@ | ||
| 445 | 340 | * @return string |
| 446 | 341 | */ |
| 447 | 342 | public function _($text, $fallback = null) |
| 448 | 343 | { |
| 449 | - return $this->translations->_($text, $fallback); | |
| 344 | + // check if translations instance exists | |
| 345 | + if (!isset($this->translations_cache)) | |
| 346 | + { | |
| 347 | + // set translations | |
| 348 | + $this->translations_cache = new Libs\Translations(); | |
| 349 | + } | |
| 350 | + | |
| 351 | + return $this->translations_cache->_($text, $fallback); | |
| 450 | 352 | } |
| 451 | 353 | } |
| 452 | 354 | } |
| 453 | 355 | |