There’s a new WordPress release cycle being started right now for WordPress 4.6, and the core developers have built a wishlist to collect the feature/change requests to consider for this release. One of the more interesting items on this list is the plan to include a central autoloader within WordPress Core (#36335 – Next generation: core autoloader proposal), which could then be reused by plugins & themes. I recommended not building a custom autoloader for WordPress, but rather reuse the one provided with Composer. I’d do this by first implementing a very quick version to just enable the autoloader at all, and then incrementally make changes to the existing Core code to make it autoloadable. Once the Composer’s composer.json schema is in place, it is very easy to add classes that are ready to be autoloaded. I have now made a quick test to see whether that approach is viable. And my conclusion, so far, is that this is probably much easier than people think. Basic Approach Most of the discussions I read about adding an autoloader to WordPress make it seem like it would be necessary to do this as one big change that tries to autoload each and every file. However, this is not necessary
Share This