| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.1.14 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 © 2024 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,12 +16,14 @@ | ||
| 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; |
| 25 | 27 | use FireBox\Core\Admin\Menu\PluginMenu; |
| 26 | 28 | use FireBox\Core\FB\Box; |
| 27 | 29 | use FireBox\Core\FB\Boxes; |
| @@ -72,8 +74,22 @@ | ||
| 72 | 74 | */ |
| 73 | 75 | public $renderer; |
| 74 | 76 | |
| 75 | 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 | + /** | |
| 76 | 92 | * Box |
| 77 | 93 | * |
| 78 | 94 | * @var Box |
| 79 | 95 | */ |
| @@ -107,8 +123,15 @@ | ||
| 107 | 123 | */ |
| 108 | 124 | public $blocks; |
| 109 | 125 | |
| 110 | 126 | /** |
| 127 | + * Widgets | |
| 128 | + * | |
| 129 | + * @var Widgets | |
| 130 | + */ | |
| 131 | + public $widgets; | |
| 132 | + | |
| 133 | + /** | |
| 111 | 134 | * Shortcodes |
| 112 | 135 | * |
| 113 | 136 | * @var Shortcodes |
| 114 | 137 | */ |
| @@ -127,16 +150,22 @@ | ||
| 127 | 150 | * @var Log |
| 128 | 151 | */ |
| 129 | 152 | public $log; |
| 130 | 153 | |
| 131 | - | |
| 154 | + /** | |
| 155 | + * PHP Scripts | |
| 156 | + * | |
| 157 | + * @var PHPScripts | |
| 158 | + */ | |
| 159 | + public $phpscripts; | |
| 160 | + #PRO-END | |
| 132 | 161 | |
| 133 | 162 | /** |
| 134 | - * Translations cache | |
| 163 | + * Translations | |
| 135 | 164 | * |
| 136 | - * @var Libs\Translations | |
| 165 | + * @var Translations | |
| 137 | 166 | */ |
| 138 | - private $translations_cache; | |
| 167 | + public $translations; | |
| 139 | 168 | |
| 140 | 169 | /** |
| 141 | 170 | * Tables used by Hook |
| 142 | 171 | * |
| @@ -200,13 +229,11 @@ | ||
| 200 | 229 | * @return void |
| 201 | 230 | */ |
| 202 | 231 | public function admin_init() |
| 203 | 232 | { |
| 233 | + | |
| 204 | 234 | new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name); |
| 205 | - | |
| 206 | 235 | |
| 207 | - new \FireBox\Core\Admin\Includes\UpgradeToPlanModal(); | |
| 208 | - | |
| 209 | 236 | |
| 210 | 237 | // Admin |
| 211 | 238 | $this->admin = new Admin(); |
| 212 | 239 | |
| @@ -211,8 +238,13 @@ | ||
| 211 | 238 | $this->admin = new Admin(); |
| 212 | 239 | |
| 213 | 240 | // Library |
| 214 | 241 | $this->library = new Library(); |
| 242 | + | |
| 243 | + // Metaboxes | |
| 244 | + $this->metaboxes_manager = new MetaboxManager(); | |
| 245 | + $this->plugin_metaboxes = new PluginMetaboxes(); | |
| 246 | + $this->metaboxes_manager->init(); | |
| 215 | 247 | } |
| 216 | 248 | |
| 217 | 249 | /** |
| 218 | 250 | * Runs at the start of the Plugin |
| @@ -220,15 +252,40 @@ | ||
| 220 | 252 | * @return void |
| 221 | 253 | */ |
| 222 | 254 | public function preFlight() |
| 223 | 255 | { |
| 256 | + // set translations | |
| 257 | + $this->translations = new Libs\Translations(); | |
| 258 | + | |
| 224 | 259 | // loads text domain |
| 225 | 260 | add_action('plugins_loaded', [$this, 'loadTextdomain'], 10); |
| 226 | 261 | |
| 227 | - | |
| 262 | + // show rate reminder after user has activated the plugin | |
| 263 | + add_action('activated_plugin', [$this, 'set_rate_reminder']); | |
| 264 | + | |
| 265 | + // Widgets | |
| 266 | + $this->widgets = new Widgets(); | |
| 228 | 267 | } |
| 229 | 268 | |
| 230 | 269 | /** |
| 270 | + * Set rate reminder transient on plugin activation. | |
| 271 | + * | |
| 272 | + * @return void | |
| 273 | + */ | |
| 274 | + public function set_rate_reminder() | |
| 275 | + { | |
| 276 | + if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) ) | |
| 277 | + { | |
| 278 | + return; | |
| 279 | + } | |
| 280 | + | |
| 281 | + // make rate reminder appear 2 days after the plugin has been activated. | |
| 282 | + $date = new \DateTime(); | |
| 283 | + $date->add( new \DateInterval( 'P2D' ) ); | |
| 284 | + set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) ); | |
| 285 | + } | |
| 286 | + | |
| 287 | + /** | |
| 231 | 288 | * Ensures only one instance of the plugin class is loaded or can be loaded |
| 232 | 289 | * |
| 233 | 290 | * @return Plugin An instance of the class. |
| 234 | 291 | */ |
| @@ -269,18 +326,16 @@ | ||
| 269 | 326 | |
| 270 | 327 | // Log |
| 271 | 328 | $this->log = new Log(); |
| 272 | 329 | |
| 273 | - new API\API(); | |
| 330 | + // REST API | |
| 331 | + new RESTAPI(); | |
| 274 | 332 | |
| 275 | 333 | |
| 276 | 334 | |
| 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(); | |
| 335 | + // Custom Post Types | |
| 336 | + $this->cpts = new Cpts(); | |
| 337 | + $this->cpts->init(); | |
| 283 | 338 | |
| 284 | 339 | // Renderer |
| 285 | 340 | $this->renderer = new Renderer(FBOX_LAYOUTS_DIR); |
| 286 | 341 | |
| @@ -303,16 +358,8 @@ | ||
| 303 | 358 | new \FireBox\Core\Analytics\Ajax(); |
| 304 | 359 | |
| 305 | 360 | // Track |
| 306 | 361 | $this->track = new Track(); |
| 307 | - | |
| 308 | - | |
| 309 | - | |
| 310 | - // Usage Tracking | |
| 311 | - $usageTracking = new \FireBox\Core\UsageTracking\SendUsage(); | |
| 312 | - $usageTracking->maybeStart(); | |
| 313 | - | |
| 314 | - new FB\Meta(); | |
| 315 | 362 | } |
| 316 | 363 | |
| 317 | 364 | /** |
| 318 | 365 | * Initializes FireBox Plugin with the required components |
| @@ -331,8 +378,29 @@ | ||
| 331 | 378 | new Frontend(); |
| 332 | 379 | } |
| 333 | 380 | |
| 334 | 381 | /** |
| 382 | + * Append our Plugin translation class to the set of translation classes of the Framework | |
| 383 | + * | |
| 384 | + * @param array | |
| 385 | + * | |
| 386 | + * @return array | |
| 387 | + */ | |
| 388 | + public function setTranslationsPaths($paths) | |
| 389 | + { | |
| 390 | + if (isset($paths['firebox'])) | |
| 391 | + { | |
| 392 | + return $paths; | |
| 393 | + } | |
| 394 | + | |
| 395 | + $paths['firebox'] = [ | |
| 396 | + 'prefix' => 'FB_' | |
| 397 | + ]; | |
| 398 | + | |
| 399 | + return $paths; | |
| 400 | + } | |
| 401 | + | |
| 402 | + /** | |
| 335 | 403 | * Retrieves the translation of $text |
| 336 | 404 | * |
| 337 | 405 | * @param string $text |
| 338 | 406 | * @param string $fallback |
| @@ -340,16 +408,9 @@ | ||
| 340 | 408 | * @return string |
| 341 | 409 | */ |
| 342 | 410 | public function _($text, $fallback = null) |
| 343 | 411 | { |
| 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); | |
| 412 | + return $this->translations->_($text, $fallback); | |
| 352 | 413 | } |
| 353 | 414 | } |
| 354 | 415 | } |
| 355 | 416 | |