| @@ -1,16 +1,17 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 1.0.5 Free | |
| 4 | + * @version 2.1.39 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2025 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 | } |
| @@ -16,9 +17,8 @@ | ||
| 16 | 17 | } |
| 17 | 18 | |
| 18 | 19 | use FPFramework\Framework; |
| 19 | 20 | use FPFramework\Admin\Includes\MetaboxManager; |
| 20 | - use FPFramework\Libs\FPGeoIP; | |
| 21 | 21 | use FPFramework\Base\Renderer; |
| 22 | 22 | |
| 23 | 23 | use FireBox\Core\Admin\Admin; |
| 24 | 24 | use FireBox\Core\Admin\Includes\Library; |
| @@ -23,12 +23,9 @@ | ||
| 23 | 23 | use FireBox\Core\Admin\Admin; |
| 24 | 24 | use FireBox\Core\Admin\Includes\Library; |
| 25 | 25 | use FireBox\Core\Admin\Includes\Metaboxes as PluginMetaboxes; |
| 26 | 26 | use FireBox\Core\Admin\Includes\Cpts\Cpts; |
| 27 | - | |
| 28 | - use FireBox\Core\Admin\Analytics\Overview\Overview as AnalyticsOverview; | |
| 29 | 27 | use FireBox\Core\Admin\Menu\PluginMenu; |
| 30 | - use FireBox\Core\Admin\Maintenance; | |
| 31 | 28 | use FireBox\Core\FB\Box; |
| 32 | 29 | use FireBox\Core\FB\Boxes; |
| 33 | 30 | use FireBox\Core\FB\Log; |
| 34 | 31 | use FireBox\Core\FB\Track; |
| @@ -91,15 +88,8 @@ | ||
| 91 | 88 | */ |
| 92 | 89 | public $metaboxes_manager; |
| 93 | 90 | |
| 94 | 91 | /** |
| 95 | - * Maintenance | |
| 96 | - * | |
| 97 | - * @var Maintenance | |
| 98 | - */ | |
| 99 | - public $maintenance; | |
| 100 | - | |
| 101 | - /** | |
| 102 | 92 | * Box |
| 103 | 93 | * |
| 104 | 94 | * @var Box |
| 105 | 95 | */ |
| @@ -119,22 +109,8 @@ | ||
| 119 | 109 | */ |
| 120 | 110 | public $menu; |
| 121 | 111 | |
| 122 | 112 | /** |
| 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 | 113 | * Helper Classes |
| 138 | 114 | * |
| 139 | 115 | * @var HelperMiddleware |
| 140 | 116 | */ |
| @@ -147,15 +123,8 @@ | ||
| 147 | 123 | */ |
| 148 | 124 | public $blocks; |
| 149 | 125 | |
| 150 | 126 | /** |
| 151 | - * Widgets | |
| 152 | - * | |
| 153 | - * @var Widgets | |
| 154 | - */ | |
| 155 | - public $widgets; | |
| 156 | - | |
| 157 | - /** | |
| 158 | 127 | * Shortcodes |
| 159 | 128 | * |
| 160 | 129 | * @var Shortcodes |
| 161 | 130 | */ |
| @@ -174,16 +143,22 @@ | ||
| 174 | 143 | * @var Log |
| 175 | 144 | */ |
| 176 | 145 | public $log; |
| 177 | 146 | |
| 178 | - | |
| 147 | + /** | |
| 148 | + * PHP Scripts | |
| 149 | + * | |
| 150 | + * @var PHPScripts | |
| 151 | + */ | |
| 152 | + public $phpscripts; | |
| 153 | + #PRO-END | |
| 179 | 154 | |
| 180 | 155 | /** |
| 181 | - * Translations | |
| 156 | + * Translations cache | |
| 182 | 157 | * |
| 183 | - * @var Translations | |
| 158 | + * @var Libs\Translations | |
| 184 | 159 | */ |
| 185 | - public $translations; | |
| 160 | + private $translations_cache; | |
| 186 | 161 | |
| 187 | 162 | /** |
| 188 | 163 | * Tables used by Hook |
| 189 | 164 | * |
| @@ -188,10 +163,10 @@ | ||
| 188 | 163 | * Tables used by Hook |
| 189 | 164 | * |
| 190 | 165 | * @var array |
| 191 | 166 | */ |
| 192 | - private $hook_data = [ | |
| 193 | - 'tables' => [ 'firebox_logs' ], | |
| 167 | + public $hook_data = [ | |
| 168 | + 'tables' => [ 'firebox_logs', 'firebox_logs_details', 'firebox_submissions', 'firebox_submission_meta' ], | |
| 194 | 169 | 'activation' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/firebox.sql', |
| 195 | 170 | 'uninstall' => FBOX_PLUGIN_DIR . 'Inc/Core/Admin/sql/uninstall.firebox.sql' |
| 196 | 171 | ]; |
| 197 | 172 | |
| @@ -254,8 +229,11 @@ | ||
| 254 | 229 | |
| 255 | 230 | // Admin |
| 256 | 231 | $this->admin = new Admin(); |
| 257 | 232 | |
| 233 | + // Library | |
| 234 | + $this->library = new Library(); | |
| 235 | + | |
| 258 | 236 | // Metaboxes |
| 259 | 237 | $this->metaboxes_manager = new MetaboxManager(); |
| 260 | 238 | $this->plugin_metaboxes = new PluginMetaboxes(); |
| 261 | 239 | $this->metaboxes_manager->init(); |
| @@ -267,50 +245,13 @@ | ||
| 267 | 245 | * @return void |
| 268 | 246 | */ |
| 269 | 247 | public function preFlight() |
| 270 | 248 | { |
| 271 | - // set translations | |
| 272 | - $this->translations = new Libs\Translations(); | |
| 273 | - | |
| 274 | 249 | // loads text domain |
| 275 | 250 | add_action('plugins_loaded', [$this, 'loadTextdomain'], 10); |
| 276 | - | |
| 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 | - } | |
| 292 | 251 | } |
| 293 | 252 | |
| 294 | 253 | /** |
| 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 | 254 | * Ensures only one instance of the plugin class is loaded or can be loaded |
| 314 | 255 | * |
| 315 | 256 | * @return Plugin An instance of the class. |
| 316 | 257 | */ |
| @@ -342,11 +283,8 @@ | ||
| 342 | 283 | private function initCommons() |
| 343 | 284 | { |
| 344 | 285 | new AdminBarMenu(); |
| 345 | 286 | |
| 346 | - // Library | |
| 347 | - $this->library = new Library(); | |
| 348 | - | |
| 349 | 287 | // Tables |
| 350 | 288 | $this->tables = new Tables(); |
| 351 | 289 | |
| 352 | 290 | // Shortcodes |
| @@ -355,9 +293,11 @@ | ||
| 355 | 293 | // Log |
| 356 | 294 | $this->log = new Log(); |
| 357 | 295 | |
| 358 | 296 | // REST API |
| 359 | - $this->api = new RESTAPI(); | |
| 297 | + new RESTAPI(); | |
| 298 | + | |
| 299 | + | |
| 360 | 300 | |
| 361 | 301 | // Custom Post Types |
| 362 | 302 | $this->cpts = new Cpts(); |
| 363 | 303 | $this->cpts->init(); |
| @@ -370,11 +310,8 @@ | ||
| 370 | 310 | |
| 371 | 311 | // Boxes |
| 372 | 312 | $this->boxes = new Boxes(); |
| 373 | 313 | |
| 374 | - // FPGeo IP | |
| 375 | - $this->fpgeoip = new FPGeoIP(); | |
| 376 | - | |
| 377 | 314 | // Helper |
| 378 | 315 | $this->helper = new HelperMiddleware(); |
| 379 | 316 | |
| 380 | 317 | // Gutenberg Blocks |
| @@ -379,24 +316,20 @@ | ||
| 379 | 316 | |
| 380 | 317 | // Gutenberg Blocks |
| 381 | 318 | $this->blocks = new Blocks(); |
| 382 | 319 | |
| 320 | + // Forms AJAX | |
| 321 | + new \FireBox\Core\Form\Ajax(); | |
| 322 | + | |
| 323 | + // Analytics AJAX | |
| 324 | + new \FireBox\Core\Analytics\Ajax(); | |
| 325 | + | |
| 383 | 326 | // Track |
| 384 | 327 | $this->track = new Track(); |
| 385 | 328 | |
| 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 | - | |
| 395 | - | |
| 396 | - | |
| 397 | - // Initialize Analytics Overview | |
| 398 | - $this->analytics_overview = new AnalyticsOverview($analytics_configuration); | |
| 329 | + // Usage Tracking | |
| 330 | + $usageTracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 331 | + $usageTracking->maybeStart(); | |
| 399 | 332 | } |
| 400 | 333 | |
| 401 | 334 | /** |
| 402 | 335 | * Initializes FireBox Plugin with the required components |
| @@ -445,9 +378,16 @@ | ||
| 445 | 378 | * @return string |
| 446 | 379 | */ |
| 447 | 380 | public function _($text, $fallback = null) |
| 448 | 381 | { |
| 449 | - return $this->translations->_($text, $fallback); | |
| 382 | + // check if translations instance exists | |
| 383 | + if (!isset($this->translations_cache)) | |
| 384 | + { | |
| 385 | + // set translations | |
| 386 | + $this->translations_cache = new Libs\Translations(); | |
| 387 | + } | |
| 388 | + | |
| 389 | + return $this->translations_cache->_($text, $fallback); | |
| 450 | 390 | } |
| 451 | 391 | } |
| 452 | 392 | } |
| 453 | 393 | |