-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoloader.php
More file actions
34 lines (26 loc) · 821 Bytes
/
autoloader.php
File metadata and controls
34 lines (26 loc) · 821 Bytes
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
<?php
if (!defined('ABSPATH')) {
exit;
}
spl_autoload_register(function ($filename) {
$file_path = explode('\\', $filename);
if (isset($file_path[count($file_path) - 1 ])) {
$class_file = strtolower(
$file_path[count($file_path) - 1]
);
$class_file = str_ireplace('_', '-', $class_file);
$class_file = "class-$class_file.php";
}
$fully_qualified_path = trailingslashit(
dirname(__FILE__)
);
for ($i = 1; $i < count($file_path) - 1; $i ++) {
$dir = strtolower($file_path[$i]);
$dir = str_ireplace('_', '-', $dir);
$fully_qualified_path .= trailingslashit($dir);
}
$fully_qualified_path .= $class_file;
if (file_exists($fully_qualified_path)) {
include_once($fully_qualified_path);
}
});