Skip to content

Instantly share code, notes, and snippets.

@SimonS
Created March 8, 2012 11:47
Show Gist options
  • Save SimonS/2000649 to your computer and use it in GitHub Desktop.
Save SimonS/2000649 to your computer and use it in GitHub Desktop.
Simple autoloader, customised the Zend autoloader to work with wordpress parent & child themes. Tries Parent and then fallsback to child. Could easily be reversed.
function __autoload($class_name) {
$parent_path = realpath(dirname(__FILE__).'/'.str_replace("_", "/", $class_name).'.php');
if(file_exists($parent_path)) {
require_once $parent_path;
}
$child_path = realpath( get_stylesheet_directory() . '/class/'. str_replace("_", "/", $class_name).'.php' );
if(file_exists($child_path)) {
require_once $child_path;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment