wp-seopress
Last commit date
assets
7 months ago
inc
7 months ago
languages
7 months ago
public
7 months ago
src
7 months ago
templates
7 months ago
vendor
7 months ago
contributors.txt
7 months ago
readme.txt
7 months ago
seopress-autoload.php
7 months ago
seopress-functions.php
7 months ago
seopress.php
7 months ago
uninstall.php
7 months ago
wpml-config.xml
7 months ago
seopress-autoload.php
34 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'ABSPATH' ) || exit( 'Please don’t call the plugin directly. Thanks :)' ); |
| 4 | |
| 5 | spl_autoload_register( |
| 6 | function ( $class ) { |
| 7 | // project-specific namespace prefix |
| 8 | $prefix = 'SEOPress\\'; |
| 9 | |
| 10 | // base directory for the namespace prefix |
| 11 | $base_dir = __DIR__ . '/src/'; |
| 12 | |
| 13 | // does the class use the namespace prefix? |
| 14 | $len = strlen( $prefix ); |
| 15 | if ( 0 !== strncmp( $prefix, $class, $len ) ) { |
| 16 | // no, move to the next registered autoloader |
| 17 | return; |
| 18 | } |
| 19 | |
| 20 | // get the relative class name |
| 21 | $relative_class = substr( $class, $len ); |
| 22 | |
| 23 | // replace the namespace prefix with the base directory, replace namespace |
| 24 | // separators with directory separators in the relative class name, append |
| 25 | // with .php |
| 26 | $file = $base_dir . str_replace( '\\', '/', $relative_class ) . '.php'; |
| 27 | |
| 28 | // if the file exists, require it |
| 29 | if ( file_exists( $file ) ) { |
| 30 | require $file; |
| 31 | } |
| 32 | } |
| 33 | ); |
| 34 |