Skip to content

Instantly share code, notes, and snippets.

@emgk
emgk / autoload-main.php
Last active April 22, 2018 00:30
How to use spl_autoload_register() function to load all classes from plugin.
<?php
/**
* Plugin Name: Class Autoloader
* Author: Govind
* Author URI: http://emgk.github.io
* Email: [email protected]
*
* Suppose, In our WP plugin we have three classes inside 'classes' folder.
* to load them without long lines of require_once statements, then in that
* case we have to use spl_autoload_register() function.