Architecture
Everything in functions.php? Split It with MVC
AI writes WordPress code fast — _POST, SQL and HTML all in one file. Who splits it? MVC for WordPress in 41 seconds: Controller (hooks, REST), Model (CPTs
// language · backend
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.
8.3
// 01 — Two PHP worlds
One project can hold two PHP worlds. A plugin written for the widest audience cannot use newer language features, even if your own server runs the latest PHP. Pick a target and see what you get.
7.4typed properties · arrow functions fn() =>8.0match · named arguments · union types · nullsafe ?->8.1enum · readonly properties · first-class callables8.2readonly classes8.3typed class constants · #[\Override]8.6partial application ? · clamp() · readonly with defaults · what is useful for WordPress →Decide the minimum version first, and declare it in both the plugin header (Requires PHP) and composer.json.
// 02 — 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 require calls.
Strict types
Used in MCP Connector, where data passes between agents and the site.
// before: every file by hand
require_once __DIR__ . '/inc/class-api.php';
require_once __DIR__ . '/inc/class-cart.php';
require_once __DIR__ . '/inc/class-log.php';
// after: composer.json
"autoload": {
"psr-4": { "ForWP\\Shop\\": "src/" }
}
// 03 — Tooling
PHPCS + WPCSWordPress Coding Standards
PluginsPHPCompatibilityChecks code against the declared PHP versions
PluginsPHPUnitUnit tests
PluginsPintCode style
Sitephp -lSyntax check before every commit and deploy
Site$ php -l inc/class-assets.php
No syntax errors detected in inc/class-assets.php
// 04 — LMS4WP course · 9 modules
WordPress runs on PHP 8. Most WordPress code is still written for PHP 5.6. Modern PHP in the WordPress context, from the runtime to plugin architecture and interview prep.
Stage 1 · Language
Stage 2 · Architecture
Stage 3 · Production code
From functions.php habits to modern, typed, testable PHP in WordPress.
// 05 — Videos
Architecture
AI writes WordPress code fast — _POST, SQL and HTML all in one file. Who splits it? MVC for WordPress in 41 seconds: Controller (hooks, REST), Model (CPTs
WooCommerce
A template copy freezes at the version it was copied from. Settings, hook, block or pattern first; a template override only as the last resort.
// 06 — FAQ
Decide the minimum version first. For WordPress.org users on older hosting our public plugins mostly require 7.4 and up; newer plugins such as SEO Helper and LMS4WP require 8.0 and up.
In both the plugin header (Requires PHP) and composer.json.
So class names never collide with other plugins. Ours use ForWP\….
PHPCompatibility checks code against the declared PHP versions; php -l catches syntax errors before every commit and deploy.