WordPress runs on PHP, and so does every plugin. The question is not whether to know PHP but which PHP: the version you write for decides which language features you can use.
Two PHP worlds in one project
| Where | PHP |
|---|---|
| Our site | 8.3 or newer |
| Public plugins | Mostly 7.4 and up, for WordPress.org users on older hosting |
| Newer plugins | 8.0 and up, for example SEO Helper and LMS4WP |
A plugin written for the widest audience cannot use newer language features, even if your own server runs the latest PHP. Decide the minimum version first, and declare it in both the plugin header (Requires PHP) and composer.json.
How we organize PHP code
- Namespaces: our plugins use
ForWP\…, so class names never collide with other plugins. - Autoloading: some plugins, such as Drive and LMS4WP, load classes through Composer PSR-4 autoload instead of manual
requirecalls. - Strict types: used in MCP Connector, where data passes between agents and the site.
Tooling
| Tool | What it does | Where we use it |
|---|---|---|
| PHPCS with WPCS | WordPress Coding Standards | Plugins |
| PHPCompatibility | Checks code against the declared PHP versions | Plugins |
| PHPUnit | Unit tests | Plugins |
| Pint | Code style | Site |
php -l | Syntax check before every commit and deploy | Site |