| 1 |
<?php |
| 2 |
|
| 3 |
spl_autoload_register(function ($class) { |
| 4 |
|
| 5 |
$prefix = 'Updraftplus\Wp_Optimize\\'; |
| 6 |
|
| 7 |
// Only handle classes with namespace starting with prefix. |
| 8 |
if (strpos($class, $prefix) !== 0) { |
| 9 |
return; |
| 10 |
} |
| 11 |
|
| 12 |
// Remove the namespace prefix |
| 13 |
$relative_class = substr($class, strlen($prefix)); |
| 14 |
$relative_path = str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php'; |
| 15 |
$file = __DIR__ . DIRECTORY_SEPARATOR . $relative_path; |
| 16 |
|
| 17 |
// Require the file if it exists. |
| 18 |
if (file_exists($file)) { |
| 19 |
require_once $file; |
| 20 |
} |
| 21 |
}); |
| 22 |
|