dimanche 11 mars 2018

PHP WooCommerce Class Why So Many Includes

I'm interested in learning more about WordPress/WooCommerce to be able to learn from them and extend their functionalities.

In that regard, I'm reading through the WooCommerce source code, and found the main class here. I belive it is a utilization of the singleton pattern called from the plugin's init file.

What I don't understand is after reading a lot about code organization in PHP centered around proper requires, autoloading, dependency injection and use statements, why they have an autoload functionality and then all these includes coming after it like that? Isn't there a better way?

Is it in case the autoload fails for some reason? Is that why it says include_once as oppose to just include...

If someone can explain this code to me that would be great, not in the context of functionality per se, but rather clean code and organization.

A lot of the docs on WooCommerce are about how to use it, which I'm not interested in as much as understanding its source code. Any pointers on that would also be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire