<?php
/**
* PSR-4-like autoloader for plugin classes.
*
* @package TonItaliaRegistration
*/
defined( 'ABSPATH' ) || exit;
/**
* Class TON_Reg_Autoloader
*/
class TON_Reg_Autoloader {
/**
* Register autoloader.
*/
public static function register() {
spl_autoload_register( array( __CLASS__, 'autoload' ) );
}
/**
* @param string $class Class name.
*/
public static function autoload( $class ) {
if ( 0 !== strpos( $class, 'TON_Reg_' ) ) {
return;
}
$map = array(
'TON_Reg_Plugin' => 'includes/class-plugin.php',
'TON_Reg_Activator' => 'includes/class-activator.php',
'TON_Reg_Deactivator' => 'includes/class-deactivator.php',
'TON_Reg_Uninstaller' => 'includes/class-uninstaller.php',
'TON_Reg_Database' => 'includes/class-database.php',
'TON_Reg_Defaults' => 'includes/class-defaults.php',
'TON_Reg_Captcha' => 'includes/class-captcha.php',
'TON_Reg_User_Manager' => 'includes/class-user-manager.php',
'TON_Reg_Mailer' => 'includes/class-mailer.php',
'TON_Reg_Mailchimp' => 'includes/class-mailchimp.php',
'TON_Reg_Gdpr' => 'includes/class-gdpr.php',
'TON_Reg_Documents' => 'includes/class-documents.php',
'TON_Reg_Members_Export' => 'includes/class-members-export.php',
'TON_Reg_Membership_Renewals' => 'includes/class-membership-renewals.php',
'TON_Reg_Renewal_Reminders' => 'includes/class-renewal-reminders.php',
'TON_Reg_Membership_Card' => 'includes/class-membership-card.php',
'TON_Reg_Membership_Cards' => 'includes/class-membership-cards.php',
'TON_Reg_Profile' => 'includes/class-profile.php',
'TON_Reg_Registration_Form' => 'includes/class-registration-form.php',
'TON_Reg_Registration_Handler' => 'includes/class-registration-handler.php',
'TON_Reg_Admin' => 'admin/class-admin.php',
'TON_Reg_Registration_List_Table' => 'admin/class-registration-list-table.php',
);
if ( ! isset( $map[ $class ] ) ) {
return;
}
$file = TON_REG_PLUGIN_DIR . $map[ $class ];
if ( is_readable( $file ) ) {
require_once $file;
}
}
}