Autoloading classes
-
Hi there, I’ve included classes.php in my core plugin file.
In classes.php I try to autoload all my classes. When I activate the plugin it should autoload them, but instead I’m getting an error that it tries to autoload a theme .class.php, which isn’t even in my classes folder.spl_autoload_register( function($classname) { $class = str_replace( '\\', DIRECTORY_SEPARATOR, strtolower($classname) ); $classpath = plugin_dir_path(__FILE__) . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . $class . '.php'; if ( file_exists( $classpath) ) { include_once $classpath; } });
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Autoloading classes’ is closed to new replies.