| 1 |
<?php |
| 2 |
|
| 3 |
use Bookit\Plugin; |
| 4 |
|
| 5 |
/* Load Textdomain */ |
| 6 |
if ( ! is_textdomain_loaded( 'bookit' ) ) { |
| 7 |
load_plugin_textdomain( 'bookit', false, 'bookit/lang' ); |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Init Ajax Actions |
| 12 |
*/ |
| 13 |
add_action( |
| 14 |
'init', |
| 15 |
function () { |
| 16 |
\Bookit\Classes\AjaxActions::init(); |
| 17 |
if ( ! empty( $_GET['stm_bookit_check_ipn'] ) ) { |
| 18 |
|
| 19 |
$paypal = new \Bookit\Classes\Payments\PayPal(); |
| 20 |
$paypal->check_payment( $_REQUEST ); |
| 21 |
} |
| 22 |
} |
| 23 |
); |
| 24 |
|
| 25 |
/** |
| 26 |
* Init Ajax Actions |
| 27 |
*/ |
| 28 |
add_action('init', function () { |
| 29 |
\Bookit\Classes\AjaxActions::init(); |
| 30 |
}); |
| 31 |
|
| 32 |
/** |
| 33 |
* Init Admin Classes |
| 34 |
*/ |
| 35 |
if ( is_admin() ) { |
| 36 |
\Bookit\Classes\Vendor\BookitUpdates::init(); |
| 37 |
\Bookit\Classes\Admin\AdminMenu::init(); |
| 38 |
\Bookit\Classes\Customization::init(); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Init Classes |
| 43 |
*/ |
| 44 |
\Bookit\Classes\BookitController::init(); |
| 45 |
\Bookit\Classes\Notifications::init(); |
| 46 |
|
| 47 |
/** |
| 48 |
* Init Widgets |
| 49 |
*/ |
| 50 |
add_action( 'vc_after_set_mode', [new \Bookit\Widgets\VisualComposerWidget(), 'load'] ); |
| 51 |
add_action( 'plugins_loaded', function() { |
| 52 |
if ( defined('ELEMENTOR_VERSION') && version_compare( ELEMENTOR_VERSION, '2.6.7', '>=' ) ) { |
| 53 |
require_once( BOOKIT_INCLUDES_PATH . '/widgets/ElementorWidget.php' ); |
| 54 |
} |
| 55 |
}); |
| 56 |
|
| 57 |
/** if this is staff, hide dashboard menu link */ |
| 58 |
add_action( 'admin_init', function(){ |
| 59 |
if ( \Bookit\Classes\Base\User::getUserData()['is_staff'] ) { |
| 60 |
remove_menu_page( 'index.php' ); |
| 61 |
} |
| 62 |
} ); |
| 63 |
|
| 64 |
/** |
| 65 |
* Register and load the service provider for loading the plugin. |
| 66 |
* |
| 67 |
* @since 2.5.0 |
| 68 |
*/ |
| 69 |
function bookit_load() { |
| 70 |
// Last file that needs to be loaded manually. |
| 71 |
require_once dirname( BOOKIT_FILE ) . '/src/Bookit/Plugin.php'; |
| 72 |
|
| 73 |
// Load the plugin, autoloading happens here. |
| 74 |
$plugin = new Plugin(); |
| 75 |
$plugin->boot(); |
| 76 |
} |
| 77 |
|