| 1 |
<?php |
| 2 |
|
| 3 |
namespace Boxzilla; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) or exit; |
| 6 |
|
| 7 |
/** @var Boxzilla $boxzilla */ |
| 8 |
$boxzilla = boxzilla(); |
| 9 |
|
| 10 |
// register services |
| 11 |
$provider = new BoxzillaServiceProvider(); |
| 12 |
$provider->register( $boxzilla ); |
| 13 |
$provider = new Licensing\LicenseServiceProvider(); |
| 14 |
$provider->register( $boxzilla ); |
| 15 |
|
| 16 |
|
| 17 |
// Rest of bootstrapping runs at plugins_loaded:90 |
| 18 |
add_action( 'plugins_loaded', function() use( $boxzilla ) { |
| 19 |
|
| 20 |
// load default filters |
| 21 |
require __DIR__ . '/src/default-filters.php'; |
| 22 |
require __DIR__ . '/src/default-actions.php'; |
| 23 |
|
| 24 |
if (defined('DOING_AJAX') && DOING_AJAX) { |
| 25 |
$boxzilla['filter.autocomplete']->init(); |
| 26 |
$boxzilla['admin.menu']->init(); |
| 27 |
} else if(defined('DOING_CRON') && DOING_CRON) { |
| 28 |
$boxzilla['license_poller']->init(); |
| 29 |
} elseif (is_admin()) { |
| 30 |
$boxzilla['admin']->init(); |
| 31 |
$boxzilla['admin.menu']->init(); |
| 32 |
} else { |
| 33 |
add_action( 'template_redirect', function() use( $boxzilla ) { |
| 34 |
$boxzilla['box_loader']->init(); |
| 35 |
}); |
| 36 |
} |
| 37 |
|
| 38 |
// license manager |
| 39 |
if( is_admin() || ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
| 40 |
$boxzilla['license_manager']->init(); |
| 41 |
|
| 42 |
if( count( $boxzilla->plugins ) > 0 ) { |
| 43 |
$boxzilla['update_manager']->init(); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
// for legacy reasons: Boxzilla Theme Pack & Boxzilla WooCommerce used this |
| 48 |
// we will be removing this in future versions |
| 49 |
$boxzilla['bootstrapper']->run(); |
| 50 |
}, 90 ); |
| 51 |
|