Skip to content

Instantly share code, notes, and snippets.

@tommcfarlin
Last active September 29, 2016 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tommcfarlin/2b43bcb72aace6f51ca1b236bfc2fc0f to your computer and use it in GitHub Desktop.
Save tommcfarlin/2b43bcb72aace6f51ca1b236bfc2fc0f to your computer and use it in GitHub Desktop.
[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