Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin

tommcfarlin/00-autoloader.php Secret

Last active Sep 29, 2016
Embed
What would you like to do?
[WordPress] Using a PHP Autoloader in WordPress
<?php
spl_autoload_register( 'acme_namespace_demo_autoload' );
/**
* @param string $class_name The fully-qualified name of the class to load.
*/
function acme_namespace_demo_autoload( $class_name ) {
// If the specified $class_name does not include our namespace, duck out.
if ( false === strpos( $class_name, 'Acme_Namespace_Demo' ) ) {
return;
}
// Autoloading work goes here...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment