| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.13 Free | |
| 4 | + * @version 2.1.0 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,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 | */ |
| @@ -126,17 +149,16 @@ | ||
| 126 | 149 | * |
| 127 | 150 | * @var Log |
| 128 | 151 | */ |
| 129 | 152 | public $log; |
| 153 | + #PRO-END | |
| 130 | 154 | |
| 131 | - | |
| 132 | - | |
| 133 | 155 | /** |
| 134 | - * Translations cache | |
| 156 | + * Translations | |
| 135 | 157 | * |
| 136 | - * @var Libs\Translations | |
| 158 | + * @var Translations | |
| 137 | 159 | */ |
| 138 | - private $translations_cache; | |
| 160 | + public $translations; | |
| 139 | 161 | |
| 140 | 162 | /** |
| 141 | 163 | * Tables used by Hook |
| 142 | 164 | * |
| @@ -200,13 +222,11 @@ | ||
| 200 | 222 | * @return void |
| 201 | 223 | */ |
| 202 | 224 | public function admin_init() |
| 203 | 225 | { |
| 226 | + | |
| 204 | 227 | new \FPFramework\Admin\Includes\UpgradeProModal($this->plugin_slug, $this->plugin_name); |
| 205 | - | |
| 206 | 228 | |
| 207 | - new \FireBox\Core\Admin\Includes\UpgradeToPlanModal(); | |
| 208 | - | |
| 209 | 229 | |
| 210 | 230 | // Admin |
| 211 | 231 | $this->admin = new Admin(); |
| 212 | 232 | |
| @@ -211,8 +231,13 @@ | ||
| 211 | 231 | $this->admin = new Admin(); |
| 212 | 232 | |
| 213 | 233 | // Library |
| 214 | 234 | $this->library = new Library(); |
| 235 | + | |
| 236 | + // Metaboxes | |
| 237 | + $this->metaboxes_manager = new MetaboxManager(); | |
| 238 | + $this->plugin_metaboxes = new PluginMetaboxes(); | |
| 239 | + $this->metaboxes_manager->init(); | |
| 215 | 240 | } |
| 216 | 241 | |
| 217 | 242 | /** |
| 218 | 243 | * Runs at the start of the Plugin |
| @@ -220,15 +245,40 @@ | ||
| 220 | 245 | * @return void |
| 221 | 246 | */ |
| 222 | 247 | public function preFlight() |
| 223 | 248 | { |
| 249 | + // set translations | |
| 250 | + $this->translations = new Libs\Translations(); | |
| 251 | + | |
| 224 | 252 | // loads text domain |
| 225 | 253 | add_action('plugins_loaded', [$this, 'loadTextdomain'], 10); |
| 226 | 254 | |
| 227 | - | |
| 255 | + // show rate reminder after user has activated the plugin | |
| 256 | + add_action('activated_plugin', [$this, 'set_rate_reminder']); | |
| 257 | + | |
| 258 | + // Widgets | |
| 259 | + $this->widgets = new Widgets(); | |
| 228 | 260 | } |
| 229 | 261 | |
| 230 | 262 | /** |
| 263 | + * Set rate reminder transient on plugin activation. | |
| 264 | + * | |
| 265 | + * @return void | |
| 266 | + */ | |
| 267 | + public function set_rate_reminder() | |
| 268 | + { | |
| 269 | + if( get_transient( 'fpf_firebox_rate_reminder_deleted' ) || get_transient( 'fpf_firebox_rate_reminder' ) ) | |
| 270 | + { | |
| 271 | + return; | |
| 272 | + } | |
| 273 | + | |
| 274 | + // make rate reminder appear 2 days after the plugin has been activated. | |
| 275 | + $date = new \DateTime(); | |
| 276 | + $date->add( new \DateInterval( 'P2D' ) ); | |
| 277 | + set_transient( 'fpf_firebox_rate_reminder', $date->format( 'Y-m-d' ) ); | |
| 278 | + } | |
| 279 | + | |
| 280 | + /** | |
| 231 | 281 | * Ensures only one instance of the plugin class is loaded or can be loaded |
| 232 | 282 | * |
| 233 | 283 | * @return Plugin An instance of the class. |
| 234 | 284 | */ |
| @@ -269,18 +319,15 @@ | ||
| 269 | 319 | |
| 270 | 320 | // Log |
| 271 | 321 | $this->log = new Log(); |
| 272 | 322 | |
| 273 | - new API\API(); | |
| 323 | + // REST API | |
| 324 | + new RESTAPI(); | |
| 274 | 325 | |
| 275 | - | |
| 276 | 326 | |
| 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(); | |
| 327 | + // Custom Post Types | |
| 328 | + $this->cpts = new Cpts(); | |
| 329 | + $this->cpts->init(); | |
| 283 | 330 | |
| 284 | 331 | // Renderer |
| 285 | 332 | $this->renderer = new Renderer(FBOX_LAYOUTS_DIR); |
| 286 | 333 | |
| @@ -303,16 +350,8 @@ | ||
| 303 | 350 | new \FireBox\Core\Analytics\Ajax(); |
| 304 | 351 | |
| 305 | 352 | // Track |
| 306 | 353 | $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 | 354 | } |
| 316 | 355 | |
| 317 | 356 | /** |
| 318 | 357 | * Initializes FireBox Plugin with the required components |
| @@ -331,8 +370,29 @@ | ||
| 331 | 370 | new Frontend(); |
| 332 | 371 | } |
| 333 | 372 | |
| 334 | 373 | /** |
| 374 | + * Append our Plugin translation class to the set of translation classes of the Framework | |
| 375 | + * | |
| 376 | + * @param array | |
| 377 | + * | |
| 378 | + * @return array | |
| 379 | + */ | |
| 380 | + public function setTranslationsPaths($paths) | |
| 381 | + { | |
| 382 | + if (isset($paths['firebox'])) | |
| 383 | + { | |
| 384 | + return $paths; | |
| 385 | + } | |
| 386 | + | |
| 387 | + $paths['firebox'] = [ | |
| 388 | + 'prefix' => 'FB_' | |
| 389 | + ]; | |
| 390 | + | |
| 391 | + return $paths; | |
| 392 | + } | |
| 393 | + | |
| 394 | + /** | |
| 335 | 395 | * Retrieves the translation of $text |
| 336 | 396 | * |
| 337 | 397 | * @param string $text |
| 338 | 398 | * @param string $fallback |
| @@ -340,16 +400,9 @@ | ||
| 340 | 400 | * @return string |
| 341 | 401 | */ |
| 342 | 402 | public function _($text, $fallback = null) |
| 343 | 403 | { |
| 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); | |
| 404 | + return $this->translations->_($text, $fallback); | |
| 352 | 405 | } |
| 353 | 406 | } |
| 354 | 407 | } |
| 355 | 408 | |