| 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 |
|
| 14 |
// load default filters |
| 15 |
require __DIR__ . '/src/default-filters.php'; |
| 16 |
|
| 17 |
add_action( 'init', function() use( $boxzilla ){ |
| 18 |
// Register custom post type |
| 19 |
$args = array( |
| 20 |
'public' => false, |
| 21 |
'labels' => array( |
| 22 |
'name' => __( 'Boxzilla', 'boxzilla' ), |
| 23 |
'singular_name' => __( 'Box', 'boxzilla' ), |
| 24 |
'add_new' => __( 'Add New', 'boxzilla' ), |
| 25 |
'add_new_item' => __( 'Add New Box', 'boxzilla' ), |
| 26 |
'edit_item' => __( 'Edit Box', 'boxzilla' ), |
| 27 |
'new_item' => __( 'New Box', 'boxzilla' ), |
| 28 |
'all_items' => __( 'All Boxes', 'boxzilla' ), |
| 29 |
'view_item' => __( 'View Box', 'boxzilla' ), |
| 30 |
'search_items' => __( 'Search Boxes', 'boxzilla' ), |
| 31 |
'not_found' => __( 'No Boxes found', 'boxzilla' ), |
| 32 |
'not_found_in_trash' => __( 'No Boxes found in Trash', 'boxzilla' ), |
| 33 |
'parent_item_colon' => '', |
| 34 |
'menu_name' => __( 'Boxzilla', 'boxzilla' ) |
| 35 |
), |
| 36 |
'show_ui' => true, |
| 37 |
'menu_position' => '108.1337133', |
| 38 |
'menu_icon' => $boxzilla->plugin->url( '/assets/img/menu-icon.png' ), |
| 39 |
'query_var' => false |
| 40 |
); |
| 41 |
|
| 42 |
register_post_type( 'boxzilla-box', $args ); |
| 43 |
}); |
| 44 |
|
| 45 |
if( ! is_admin() ) { |
| 46 |
|
| 47 |
// PUBLIC |
| 48 |
add_action( 'template_redirect', function() use( $boxzilla ) { |
| 49 |
$boxzilla['box_loader']->init(); |
| 50 |
}); |
| 51 |
|
| 52 |
} else { |
| 53 |
|
| 54 |
// ADMIN (and AJAX) |
| 55 |
$provider = new Licensing\LicenseServiceProvider(); |
| 56 |
$provider->register( $boxzilla ); |
| 57 |
|
| 58 |
if( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) { |
| 59 |
add_action('init', function() use( $boxzilla ) { |
| 60 |
$boxzilla['admin']->init(); |
| 61 |
}); |
| 62 |
} else { |
| 63 |
$boxzilla['filter.autocomplete']->add_hooks(); |
| 64 |
} |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
|