forked from allbitsnbytes/wp-log-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
41 lines (32 loc) · 840 Bytes
/
autoload.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
* Autoload Dependencies
*/
if (!defined('WPLOGVIEWER_BASE')) {
header('HTTP/1.0 403 Forbidden');
die;
}
/**
* Register autoloader for this project
*
* @since 0.1.0
*
* @param string $class The fully-qualified class name.
* @return void
*/
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'Allbitsnbytes\\WPLogViewer\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/libs/';
// If the class doesn't use the namespace prefix continue to next autoloader
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists($file)) {
require $file;
}
});