Skip to content

Instantly share code, notes, and snippets.

@aaroneaton
Last active December 12, 2015 07:58
Show Gist options
  • Save aaroneaton/4740442 to your computer and use it in GitHub Desktop.
Save aaroneaton/4740442 to your computer and use it in GitHub Desktop.
WP:Class Autoloading
<?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