| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.0.19 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <info@fireplugins.com> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2023 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FireBox\Core |
| @@ -16,13 +16,18 @@ | ||
| 16 | 16 | exit; // Exit if accessed directly. |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | use FPFramework\Framework; |
| 20 | + use FPFramework\Admin\Includes\MetaboxManager; | |
| 20 | 21 | use FPFramework\Base\Renderer; |
| 21 | 22 | |
| 22 | 23 | use FireBox\Core\Admin\Admin; |
| 23 | 24 | use FireBox\Core\Admin\Includes\Library; |
| 25 | + use FireBox\Core\Admin\Includes\Metaboxes as PluginMetaboxes; | |
| 24 | 26 | use FireBox\Core\Admin\Includes\Cpts\Cpts; |
| 27 | + | |
| 28 | + use FireBox\Core\Admin\Analytics\Overview\Overview as AnalyticsOverview; | |
| 29 | + use FireBox\Core\Admin\Analytics\Overview\Ajax as AnalyticsOverviewAjax; | |
| 25 | 30 | use FireBox\Core\Admin\Menu\PluginMenu; |
| 26 | 31 | use FireBox\Core\FB\Box; |
| 27 | 32 | use FireBox\Core\FB\Boxes; |
| 28 | 33 | use FireBox\Core\FB\Log; |
| @@ -72,8 +77,22 @@ | ||
| 72 | 77 | */ |
| 73 | 78 | public $renderer; |
| 74 | 79 | |
| 75 | 80 | /** |
| 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 | + /** | |
| 76 | 95 | * Box |
| 77 | 96 | * |
| 78 | 97 | * @var Box |
| 79 | 98 | */ |
| @@ -107,8 +126,15 @@ | ||
| 107 | 126 | */ |
| 108 | 127 | public $blocks; |
| 109 | 128 | |
| 110 | 129 | /** |
| 130 | + * Widgets | |
| 131 | + * | |
| 132 | + * @var Widgets | |
| 133 | + */ | |
| 134 | + public $widgets; | |
| 135 | + | |
| 136 | + /** | |
| 111 | 137 | * Shortcodes |
| 112 | 138 | * |
| 113 | 139 | * @var Shortcodes |
| 114 | 140 | */ |
| @@ -127,16 +153,23 @@ | ||
| 127 | 153 | * @var Log |
| 128 | 154 | */ |
| 129 | 155 | public $log; |
| 130 | 156 | |
| 157 | + /** | |
| 158 | + * Analytics configuration. | |
| 159 | + * | |
| 160 | + * @var array | |
| 161 | + */ | |
| 162 | + public $analytics_configuration; | |
| 163 | + | |
| 131 | 164 | |
| 132 | 165 | |
| 133 | 166 | /** |
| 134 | - * Translations cache | |
| 167 | + * Translations | |
| 135 | 168 | * |
| 136 | - * @var Libs\Translations | |
| 169 | + * @var Translations | |
| 137 | 170 | */ |
| 138 | - private $translations_cache; | |
| 171 | + public $translations; | |
| 139 | 172 | |
| 140 | 173 | /** |
| 141 | 174 | * Tables used by Hook |
| 142 | 175 | * |
| @@ -200,13 +233,11 @@ | ||
| 200 | 233 | * @return void |
| 201 | 234 | */ |
| 202 | 235 | public function admin_init() |
| 203 | 236 | { |
| 237 | + | |
| 204 | 238 | new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name); |
| 205 | - | |
| 206 | 239 | |
| 207 | - new \FireBox\Core\Admin\Includes\UpgradeToPlanModal(); | |
| 208 | - | |
| 209 | 240 | |
| 210 | 241 | // Admin |
| 211 | 242 | $this->admin = new Admin(); |
| 212 | 243 | |
| @@ -211,8 +242,13 @@ | ||
| 211 | 242 | $this->admin = new Admin(); |
| 212 | 243 | |
| 213 | 244 | // Library |
| 214 | 245 | $this->library = new Library(); |
| 246 | + | |
| 247 | + // Metaboxes | |
| 248 | + $this->metaboxes_manager = new MetaboxManager(); | |
| 249 | + $this->plugin_metaboxes = new PluginMetaboxes(); | |
| 250 | + $this->metaboxes_manager->init(); | |
| 215 | 251 | } |
| 216 | 252 | |
| 217 | 253 | /** |
| 218 | 254 | * Runs at the start of the Plugin |
| @@ -220,15 +256,40 @@ | ||
| 220 | 256 | * @return void |
| 221 | 257 | */ |
| 222 | 258 | public function preFlight() |
| 223 | 259 | { |
| 260 | + // set translations | |
| 261 | + $this->translations = new Libs\Translations(); | |
| 262 | + | |
| 224 | 263 | // loads text domain |
| 225 | 264 | add_action('plugins_loaded', [$this, 'loadTextdomain'], 10); |
| 226 | 265 | |
| 227 | - | |
| 266 | + // show rate reminder after user has activated the plugin | |
| 267 | + add_action('activated_plugin', [$this, 'set_rate_reminder']); | |
| 268 | + | |
| 269 | + // Widgets | |
| 270 | + $this->widgets = new Widgets(); | |
| 228 | 271 | } |
| 229 | 272 | |
| 230 | 273 | /** |
| 274 | + * Set rate reminder transient on plugin activation. | |
| 275 | + * | |
| 276 | + * @return void | |
| 277 | + */ | |
| 278 | + public function set_rate_reminder() | |
| 279 | + { | |
| 280 | + if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) ) | |
| 281 | + { | |
| 282 | + return; | |
| 283 | + } | |
| 284 | + | |
| 285 | + // make rate reminder appear 2 days after the plugin has been activated. | |
| 286 | + $date = new \DateTime(); | |
| 287 | + $date->add( new \DateInterval( 'P2D' ) ); | |
| 288 | + set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) ); | |
| 289 | + } | |
| 290 | + | |
| 291 | + /** | |
| 231 | 292 | * Ensures only one instance of the plugin class is loaded or can be loaded |
| 232 | 293 | * |
| 233 | 294 | * @return Plugin An instance of the class. |
| 234 | 295 | */ |
| @@ -269,18 +330,15 @@ | ||
| 269 | 330 | |
| 270 | 331 | // Log |
| 271 | 332 | $this->log = new Log(); |
| 272 | 333 | |
| 273 | - new API\API(); | |
| 334 | + // REST API | |
| 335 | + new RESTAPI(); | |
| 274 | 336 | |
| 275 | - | |
| 276 | 337 | |
| 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(); | |
| 338 | + // Custom Post Types | |
| 339 | + $this->cpts = new Cpts(); | |
| 340 | + $this->cpts->init(); | |
| 283 | 341 | |
| 284 | 342 | // Renderer |
| 285 | 343 | $this->renderer = new Renderer(FBOX_LAYOUTS_DIR); |
| 286 | 344 | |
| @@ -295,24 +353,30 @@ | ||
| 295 | 353 | |
| 296 | 354 | // Gutenberg Blocks |
| 297 | 355 | $this->blocks = new Blocks(); |
| 298 | 356 | |
| 299 | - // Forms AJAX | |
| 300 | 357 | new \FireBox\Core\Form\Ajax(); |
| 301 | 358 | |
| 302 | - // Analytics AJAX | |
| 303 | - new \FireBox\Core\Analytics\Ajax(); | |
| 304 | - | |
| 305 | 359 | // Track |
| 306 | 360 | $this->track = new Track(); |
| 307 | 361 | |
| 362 | + // Initialize Analytics | |
| 363 | + global $wpdb; | |
| 364 | + $this->analytics_configuration = [ | |
| 365 | + 'boxes_table' => $wpdb->prefix . 'posts', | |
| 366 | + 'logs_table' => firebox()->tables->boxlog->getFullTableName(), | |
| 367 | + 'logs_details_table' => firebox()->tables->boxlogdetails->getFullTableName(), | |
| 368 | + 'submissions_table' => firebox()->tables->submission->getFullTableName(), | |
| 369 | + 'submissions_meta_table' => firebox()->tables->submissionmeta->getFullTableName(), | |
| 370 | + 'nonce_name' => 'fb-analytics-nonce', | |
| 371 | + 'nonce_value' => wp_create_nonce('fb-analytics-nonce'), | |
| 372 | + ]; | |
| 373 | + | |
| 308 | 374 | |
| 309 | - | |
| 310 | - // Usage Tracking | |
| 311 | - $usageTracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 312 | - $usageTracking->maybeStart(); | |
| 313 | - | |
| 314 | - new FB\Meta(); | |
| 375 | + | |
| 376 | + // Initialize Analytics Overview | |
| 377 | + $this->analytics_overview = new AnalyticsOverview(); | |
| 378 | + $this->analytics_overview_ajax = new AnalyticsOverviewAjax(); | |
| 315 | 379 | } |
| 316 | 380 | |
| 317 | 381 | /** |
| 318 | 382 | * Initializes FireBox Plugin with the required components |
| @@ -331,8 +395,29 @@ | ||
| 331 | 395 | new Frontend(); |
| 332 | 396 | } |
| 333 | 397 | |
| 334 | 398 | /** |
| 399 | + * Append our Plugin translation class to the set of translation classes of the Framework | |
| 400 | + * | |
| 401 | + * @param array | |
| 402 | + * | |
| 403 | + * @return array | |
| 404 | + */ | |
| 405 | + public function setTranslationsPaths($paths) | |
| 406 | + { | |
| 407 | + if (isset($paths['firebox'])) | |
| 408 | + { | |
| 409 | + return $paths; | |
| 410 | + } | |
| 411 | + | |
| 412 | + $paths['firebox'] = [ | |
| 413 | + 'prefix' => 'FB_' | |
| 414 | + ]; | |
| 415 | + | |
| 416 | + return $paths; | |
| 417 | + } | |
| 418 | + | |
| 419 | + /** | |
| 335 | 420 | * Retrieves the translation of $text |
| 336 | 421 | * |
| 337 | 422 | * @param string $text |
| 338 | 423 | * @param string $fallback |
| @@ -340,16 +425,9 @@ | ||
| 340 | 425 | * @return string |
| 341 | 426 | */ |
| 342 | 427 | public function _($text, $fallback = null) |
| 343 | 428 | { |
| 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); | |
| 429 | + return $this->translations->_($text, $fallback); | |
| 352 | 430 | } |
| 353 | 431 | } |
| 354 | 432 | } |
| 355 | 433 | |