Object-Oriented Programming
The DWS WP Framework is fully OOP. Support for OOP hasn’t been historically great in PHP, but it’s remarkably good in PHP7 in general and PHP7.4 in particular. And it only gets better in PHP8!
That means that most logic is encapsulated in (namespaced) classes. There is a long debate to be had about OOP vs non-OOP, but we believe that WordPress plugins are great candidates for an OOP design.
To make things predictable (and standardized), the namespace-structure follows the PSR-4 standard. You can read more about that here but it’s basically a convention that enforces the following things:
One class -- one PHP file.
The namespace structure follows the folder structure of the filesystem.
Each namespace is of the form:
For example, let’s assume that:
your project namespace is SomeCompany\Plugins\SomePlugin
all your PHP files are in the includes folder
Then the class SomeCompany\Plugins\SomePlugin\Admin\Settings will be in the file includes/Admin/Settings.php.
Last updated