WP.Autoload (formerly PHP Autoload Manager) was created to allow me to easily extend the power of WordPress by using PHP’s autoload function to quic
Autoloading V2.0 In V2.0 the autoloading process is a lot more ubiquitous allowing developers to create and use any class that follows the Zend Framework naming conventions.
From now on classes meant to use WP.Autoload will start with the vendor, theme, library or plugin name as the root directory with an underscore following / separating each subsequent directory followed by the class name. Filenames will be given the class-name with ‘.php’ extension.
Now theme or plugin developers only need to ensure that classes follow these simple naming conventions :
Vendor_Folder_Class.php and filename would be Classname.php
The directory structure should look like this \Vendor\Folder\Classname.php
For example if you had a class named Hello stored in a classes folder in your plugin your class would be named — MyPlugin_Classes_Hello, the file would be Hello.php and your directory structure would look like this – \MyPlugin\Classes\Hello.php. The same would apply for themes.
Remember the naming conventions are whats important here, follow them an you will be safe.
Once you get that all you need to do is call instantiate your class :
$hello = new Hello(); $hello->say_hello(); I will add a more detailed tutorial soon, for now you can leave your thoughts and suggestions in the comments below.