| 1 |
<?php |
| 2 |
|
| 3 |
namespace Boxzilla; |
| 4 |
|
| 5 |
defined( 'ABSPATH' ) or exit; |
| 6 |
|
| 7 |
|
| 8 |
require __DIR__ . '/src/services.php'; |
| 9 |
require __DIR__ . '/src/licensing/services.php'; |
| 10 |
|
| 11 |
// Bootstrap plugin at later action hook |
| 12 |
add_action( |
| 13 |
'plugins_loaded', |
| 14 |
function() { |
| 15 |
$boxzilla = boxzilla(); |
| 16 |
|
| 17 |
// load default filters |
| 18 |
require __DIR__ . '/src/default-filters.php'; |
| 19 |
require __DIR__ . '/src/default-actions.php'; |
| 20 |
|
| 21 |
if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
| 22 |
$boxzilla['filter.autocomplete']->init(); |
| 23 |
$boxzilla['admin.menu']->init(); |
| 24 |
} elseif ( defined( 'DOING_CRON' ) && DOING_CRON ) { |
| 25 |
$boxzilla['license_poller']->init(); |
| 26 |
} elseif ( is_admin() ) { |
| 27 |
$boxzilla['admin']->init(); |
| 28 |
$boxzilla['admin.menu']->init(); |
| 29 |
} else { |
| 30 |
add_action( |
| 31 |
'template_redirect', |
| 32 |
function() use ( $boxzilla ) { |
| 33 |
$boxzilla['box_loader']->init(); |
| 34 |
} |
| 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 |
}, |
| 51 |
90 |
| 52 |
); |
| 53 |
|