tec_tickets_wallet_plus_preload()
Register and load the service provider for loading the plugin.
The function will detect the presence of Common and TEC and decline to load if not found.
Return
(bool) Whether the plugin did load successfully or not.
Source
File: src/functions/load.php
function tec_tickets_wallet_plus_preload() {
/**
* This function is attached to two hooks:
* - `tribe_common_loaded` with a priority of 15
* - `plugins_loaded` with a priority of 25
*
* So this check here will ensure the plugin doesn't load twice.
*
*/
if ( did_action( 'tribe_common_loaded' ) && ! doing_action( 'tribe_common_loaded' ) ) {
return false;
}
// We need these two to be true to even test for the rest.
if ( ! (
function_exists( 'tribe_register_provider' )
&& class_exists( 'Tribe__Abstract_Plugin_Register', false )
) ) {
// Loaded in single site or not network-activated in a multisite installation.
add_action( 'admin_notices', 'tec_tickets_wallet_plus_show_fail_message', 10, 0 );
// Network-activated in a multisite installation.
add_action( 'network_admin_notices', 'tec_tickets_wallet_plus_show_fail_message', 10, 0 );
// Prevent loading of the plugin if common is loaded (better safe than sorry).
remove_action( 'tribe_common_loaded', 'tec_tickets_wallet_plus_load', 50 );
return false;
}
// Load the Plugin register which contains the dependency manifest.
if ( ! class_exists( '\TEC\Tickets_Wallet_Plus\Plugin_Register', false ) ) {
require_once dirname( EVENT_TICKETS_WALLET_FILE ) . '/src/Tickets_Wallet_Plus/Plugin_Register.php';
}
$plugin_register = new \TEC\Tickets_Wallet_Plus\Plugin_Register();
$plugin_register->set_base_dir( EVENT_TICKETS_WALLET_FILE );
$plugin_register->register_plugin();
if ( ! tribe_check_plugin( $plugin_register->get_plugin_class() ) ) {
// Prevent loading of the plugin if common is loaded (better safe than sorry).
remove_action( 'tribe_common_loaded', 'tec_tickets_wallet_plus_load', 50 );
return false;
}
// After this point, it's safe to assume Common has been loaded.
tribe_singleton( \TEC\Tickets_Wallet_Plus\Plugin_Register::class, $plugin_register );
return true;
}
Changelog
| Version | Description |
|---|---|
| 1.0.0 | Introduced. |