forked from DevinVinson/WordPress-Plugin-Boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 8
/
autoload.php
44 lines (36 loc) · 1.04 KB
/
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
42
43
44
<?php
/**
* Loads all required classes
*
* Uses classmap autoloader and WPCS autoloader.
*
* @link http://example.com
* @since 1.0.0
* @package PHP_Package_Name
*/
namespace Plugin_Package_Name;
use Plugin_Package_Name\Alley_Interactive\Autoloader\Autoloader;
$class_map_files = array(
__DIR__ . '/autoload-classmap.php',
);
foreach ( $class_map_files as $class_map_file ) {
if ( file_exists( $class_map_file ) ) {
$class_map = include $class_map_file;
if ( is_array( $class_map ) ) {
spl_autoload_register(
function ( $classname ) use ( $class_map ) {
if ( array_key_exists( $classname, $class_map ) && file_exists( $class_map[ $classname ] ) ) {
require_once $class_map[ $classname ];
}
}
);
}
}
}
unset( $class_map_files, $class_map_file, $class_map );
// Load strauss classes after autoload-classmap.php so classes can be substituted.
require_once __DIR__ . '/vendor-prefixed/autoload.php';
Autoloader::generate(
'Plugin_Package_Name',
__DIR__ . '/src',
)->register();