autoload.php in Microthemer Lite – Visual Editor to Customize CSS trunk, at src/autoload.php
| 1 | <?php |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit; |
| 5 | } |
| 6 | |
| 7 | // Simple autoloader |
| 8 | spl_autoload_register(function ($class) { |
| 9 | |
| 10 | $prefix = 'Microthemer\\'; |
| 11 | $base_dir = dirname(__FILE__) . '/'; |
| 12 | $len = strlen($prefix); |
| 13 | |
| 14 | if (strncmp($prefix, $class, $len) !== 0) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | $relative_class = substr($class, $len); |
| 19 | $file = $base_dir . str_replace('\\', '/', $relative_class) . '.php'; |
| 20 | |
| 21 | if (file_exists($file)) { |
| 22 | require $file; |
| 23 | } |
| 24 | |
| 25 | }); |