46 lines
812 B
PHP
46 lines
812 B
PHP
<?php
|
|
/**
|
|
* Simple PSR-4 style autoloader for the plugin.
|
|
*
|
|
* @package KGV\VereinManager
|
|
*/
|
|
|
|
namespace KGV\VereinManager;
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
class Autoloader {
|
|
|
|
/**
|
|
* Register the autoloader.
|
|
*
|
|
* @return void
|
|
*/
|
|
public static function register() {
|
|
spl_autoload_register( array( __CLASS__, 'autoload' ) );
|
|
}
|
|
|
|
/**
|
|
* Load matching class files.
|
|
*
|
|
* @param string $class Fully qualified class name.
|
|
* @return void
|
|
*/
|
|
public static function autoload( $class ) {
|
|
$prefix = __NAMESPACE__ . '\\';
|
|
|
|
if ( 0 !== strpos( $class, $prefix ) ) {
|
|
return;
|
|
}
|
|
|
|
$relative = substr( $class, strlen( $prefix ) );
|
|
$file = KGVVM_PLUGIN_DIR . 'includes/' . str_replace( '\\', '/', $relative ) . '.php';
|
|
|
|
if ( file_exists( $file ) ) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
}
|