-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathautoload.php
More file actions
40 lines (36 loc) · 662 Bytes
/
autoload.php
File metadata and controls
40 lines (36 loc) · 662 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
35
36
37
38
39
40
<?php
/**
* PSR-4 Autoloader.
*/
spl_autoload_register( function ( $class ) {
// validate namespace
if (
strncmp(
$namespace = 'SergeLiatko\WPSettings',
$class,
$namespace_length = strlen( $namespace )
) !== 0
) {
return;
}
// try to load the file
if ( file_exists(
$file = join(
DIRECTORY_SEPARATOR,
array(
__DIR__,
'src',
str_replace(
'\\',
DIRECTORY_SEPARATOR,
trim(
substr( $class, $namespace_length ),
'\\'
)
),
)
) . '.php'
) ) {
include $file;
}
} );