For a while now PHP-FIG has been making the PHP world better by defining standards for things like coding standards, coding styles, loggers and, importantly, autoloading. Autoloading is important because it allows us to write our code using Namespaces which makes for a much nicer folder structure and more modular classes (and packages), without having to worry about require(ing) files all the time. If you're still not with me have a look at the PSR-4 spec. Anyway, I would recommend that any PHP developer worth their salt should be using PSR-0 and PSR-4 as much as possbile. So how do you go about doing this in WordPress plugins? Well it's actually relatively simple. Let's say we have a WordPress plugin called "Turnover", with a basic folder structure that looks like: /turnover - turnover.php So the content of our main turnover.php plugin file should look like this:
Share This

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.