Last active
December 12, 2015 07:58
-
-
Save aaroneaton/4740442 to your computer and use it in GitHub Desktop.
WP:Class Autoloading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Autoloads the requested class. PSR-0 compliant | |
* | |
* @since 1.0 | |
* @param string $classname The name of the class | |
*/ | |
public static function autoload( $classname ) { | |
$filename = dirname( __FILE__ ) . | |
DIRECTORY_SEPARATOR . | |
str_replace( '_', DIRECTORY_SEPARATOR, $classname ) . | |
'.php'; | |
if ( file_exists( $filename ) ) | |
require $filename; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment