| 1 |
<?php |
| 2 |
|
| 3 |
spl_autoload_register( function( $class ) { |
| 4 |
$namespace = 'Barn2\\Plugin\\Posts_Table_Search_Sort'; |
| 5 |
$src_path = __DIR__ . '/src'; |
| 6 |
|
| 7 |
// Bail if the class is not in our namespace. |
| 8 |
if ( 0 !== strpos( $class, $namespace ) ) { |
| 9 |
return; |
| 10 |
} |
| 11 |
|
| 12 |
// Remove the namespace. |
| 13 |
$class = str_replace( $namespace, '', $class ); |
| 14 |
|
| 15 |
// Build the filename - realpath returns false if file doesn't exist. |
| 16 |
$file = realpath( $src_path . '/' . str_replace( '\\', '/', $class ) . '.php' ); |
| 17 |
|
| 18 |
// If the file exists for the class name, load it. |
| 19 |
if ( $file ) { |
| 20 |
include_once $file; |
| 21 |
} |
| 22 |
} |
| 23 |
); |
| 24 |
|
| 25 |
spl_autoload_register( function( $class ) { |
| 26 |
$namespace = 'Barn2\\Lib'; |
| 27 |
$lib_path = __DIR__ . '/lib'; |
| 28 |
|
| 29 |
// Bail if the class is not in our namespace. |
| 30 |
if ( 0 !== strpos( $class, $namespace ) ) { |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
// Remove the namespace. |
| 35 |
$class = str_replace( $namespace, '', $class ); |
| 36 |
|
| 37 |
// Build the filename - realpath returns false if file doesn't exist. |
| 38 |
$file = realpath( $lib_path . '/' . str_replace( '\\', '/', $class ) . '.php' ); |
| 39 |
|
| 40 |
// If the file exists for the class name, load it. |
| 41 |
if ( $file ) { |
| 42 |
include_once $file; |
| 43 |
} |
| 44 |
} |
| 45 |
); |
| 46 |
|