Development · Backend (PHP)

Backend (PHP)

WordPress was built on PHP from the start — and PHP remains the foundation of every request, even as the stack adds blocks, JavaScript, REST, and headless frontends.

PHP as the foundation of WordPress development

WordPress began in 2003 as open-source blogging software written in PHP. Twenty years later the ecosystem looks different — block themes, the Site Editor, React in the admin, REST and GraphQL APIs, decoupled Next.js frontends — but the server still boots through PHP on every page load, cron job, WP-CLI command, and authenticated REST request.

That does not mean WordPress is “PHP only.” Modern projects combine PHP with JavaScript, CSS, SQL, and external services. It means business logic, security boundaries, and data access still live primarily in PHP — in core, in your plugins, and in theme functions.php files. If you understand PHP in a WordPress context, you understand how the platform actually executes your code.

What still runs in PHP today

  • Core bootstrap — wp-load.php, wp-settings.php, loading must-use plugins, active plugins, and the theme.
  • Plugins and themes — registration hooks, admin screens, custom post types, taxonomies, and service classes.
  • Blocks on the server — block.json, dynamic render callbacks, block patterns registered from PHP, and server-side block supports.
  • REST API — route registration, permission_callback, argument schemas, and response shaping.
  • Admin & AJAX — list tables, settings pages, meta boxes, and admin-ajax.php handlers.
  • Data layer — $wpdb, Options API, meta APIs, transients, and custom tables via dbDelta().
  • Background work — WP-Cron events, Action Scheduler jobs, and WP-CLI scripts.

JavaScript owns interactivity in the editor and on the front end; PHP owns what WordPress stores, who may access it, and how it is rendered on the server. Production 4WP plugins follow that split: React blocks and inspector UI on the client; PHP services, repositories, and REST controllers on the server.

Why PHP skills still matter for WordPress developers

  • Extension model — WordPress extends through hooks (add_action, add_filter), and those are PHP functions.
  • Security — capability checks, nonces, sanitization, escaping, and prepared SQL statements are implemented in PHP.
  • Integrations — payment gateways, CRMs, OAuth, webhooks, and email delivery are typically wired in PHP classes or procedural bootstrap files.
  • Performance — query design, autoloaded options, object cache usage, and lazy loading are backend concerns.
  • Maintainability — WordPress Coding Standards (WPCS), namespaces, and OOP patterns keep large plugins readable across teams.

Headless and API-first setups do not remove PHP — they move the HTML theme elsewhere while WordPress continues to authenticate users, enforce capabilities, run queries, and expose content through PHP-registered endpoints.

Modern PHP in WordPress projects

WordPress supports a wide range of PHP versions depending on hosting; production sites should run a supported, actively maintained PHP release for security and performance. In plugin code you will encounter:

  • Procedural bootstrap files and hook callbacks — still common and valid.
  • Namespaced classes with autoloading (Composer PSR-4) — standard in larger plugins and Bedrock-style stacks.
  • Type hints and return types — increasingly used in modern WordPress and 4WP codebases.
  • WordPress APIs over raw PHP — prefer WP_Query, Options API, and transients instead of reinventing storage.

Backend on 4WP.dev

Five topics make up the backend in our structure. Each goes deeper into one part of server-side WordPress work.

PHP

Which PHP to write for: our site runs 8.3+, public plugins support 7.4 for older hosting. Namespaces, autoloading and the tools that keep PHP clean.

PHP →

Plugins

How a plugin is put together and shipped: main file, namespaced classes, hooks, REST routes, abilities for AI, and a release by Git tag through Composer and GitHub Actions.

Plugin development →

WordPress Coding Standards

PHPCS and WPCS for code that passes review and reads the same across a team.

WordPress Coding Standards →

Security

Nonces, capabilities, escaping and guard clauses: the 12 mistakes that fail plugin review, and how we protect our own site from commit to recovery.

Security →

The Laravel approach

Container, queues, migrations and layers in WordPress projects. In preparation.

Core topics (Hooks, Functions, Database) are in Core, and the REST API is in API.

For system structure and OOP patterns see Architectures; for process (SDD, DDD, TDD) see Methodologies.

← Back to Development