| 1 |
<?php |
| 2 |
/** |
| 3 |
* Autoload for Sessions. |
| 4 |
* |
| 5 |
* @package Bootstrap |
| 6 |
* @author Pierre Lannoy <https://pierre.lannoy.fr/>. |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
spl_autoload_register( |
| 11 |
function ( $class ) { |
| 12 |
$classname = $class; |
| 13 |
$filepath = __DIR__ . '/'; |
| 14 |
if ( strpos( $classname, 'POSessions\\' ) === 0 ) { |
| 15 |
while ( strpos( $classname, '\\' ) !== false ) { |
| 16 |
$classname = substr( $classname, strpos( $classname, '\\' ) + 1, 1000 ); |
| 17 |
} |
| 18 |
$filename = 'class-' . str_replace( '_', '-', strtolower( $classname ) ) . '.php'; |
| 19 |
if ( strpos( $class, 'POSessions\System\\' ) === 0 ) { |
| 20 |
$filepath = POSE_INCLUDES_DIR . 'system/'; |
| 21 |
} |
| 22 |
if ( strpos( $class, 'POSessions\Plugin\Feature\\' ) === 0 ) { |
| 23 |
$filepath = POSE_INCLUDES_DIR . 'features/'; |
| 24 |
} elseif ( strpos( $class, 'POSessions\Plugin\Integration\\' ) === 0 ) { |
| 25 |
$filepath = POSE_INCLUDES_DIR . 'integrations/'; |
| 26 |
} elseif ( strpos( $class, 'POSessions\Plugin\\' ) === 0 ) { |
| 27 |
$filepath = POSE_INCLUDES_DIR . 'plugin/'; |
| 28 |
} elseif ( strpos( $class, 'POSessions\API\\' ) === 0 ) { |
| 29 |
$filepath = POSE_INCLUDES_DIR . 'api/'; |
| 30 |
} |
| 31 |
if ( strpos( $class, 'POSessions\Library\\' ) === 0 ) { |
| 32 |
$filepath = POSE_VENDOR_DIR; |
| 33 |
} |
| 34 |
if ( strpos( $filename, '-public' ) !== false ) { |
| 35 |
$filepath = POSE_PUBLIC_DIR; |
| 36 |
} |
| 37 |
if ( strpos( $filename, '-admin' ) !== false ) { |
| 38 |
$filepath = POSE_ADMIN_DIR; |
| 39 |
} |
| 40 |
$file = $filepath . $filename; |
| 41 |
if ( file_exists( $file ) ) { |
| 42 |
include_once $file; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
); |
| 47 |
|