Skip to content

Instantly share code, notes, and snippets.

@cfoellmann
Last active August 29, 2015 13:56
Show Gist options
  • Save cfoellmann/8832520 to your computer and use it in GitHub Desktop.
Save cfoellmann/8832520 to your computer and use it in GitHub Desktop.
<?php
class PluginNameGrunt {
/**
* PSR-0 compliant autoloader to load classes as needed.
*
* @static
* @access public
* @since 1.0.0
*
* @param string $classname The name of the class
* @return null Return early if the class name does not start with the correct prefix
*/
public static function autoload( $classname ) {
if ( 'WPCollab_{%= title_camel_uppercase %}' !== mb_substr( $classname, 0, 19 ) ) { // change length
return;
}
$class = substr( $classname, 9 );
$filename = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $class ) . '.php';
if ( file_exists( $filename ) ) {
require $filename;
}
} // END autoload()
} // END class PluginClassGrunt
<?php
class PluginName {
/**
* PSR-0 compliant autoloader to load classes as needed.
*
* @static
* @access public
* @since 1.0.0
*
* @param string $classname The name of the class
* @return null Return early if the class name does not start with the correct prefix
*/
public static function autoload( $classname ) {
if ( 'WPCollab_PluginName' !== mb_substr( $classname, 0, 19 ) ) {
return;
}
$class = substr( $classname, 9 );
$filename = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . str_replace( '_', DIRECTORY_SEPARATOR, $class ) . '.php';
if ( file_exists( $filename ) ) {
require $filename;
}
} // END autoload()
} // END class PluginClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment