Seven and a half years after the modern block architecture first arrived in WordPress Core, developers finally have a native way to build custom blocks using only PHP. Released in WordPress 7.0, the new feature lets developers bypass React, avoid setting up complex build pipelines, and steer clear of managing external NPM packages. While the long-awaited addition has sparked significant discussion across the developer community, its true value lies less in creating brand-new, highly interactive features and more in bridging the gap for legacy PHP-based codebases.

For years, building a custom WordPress block required a dual-registration process. Developers had to register their blocks once in PHP and once in JavaScript, setting up specialized toolchains just to output custom elements in the block editor. WordPress 7.0 streamlines this process dramatically. By introducing a new autoRegister flag within the block support configurations, the platform can automatically generate the required client-side registration and editor preview directly from a PHP block definition.
To implement this, developers can write a standard block registration function using register_block_type, incorporating a render callback and the autoRegister parameter. This integration allows the block to function seamlessly within the block editor alongside native elements, requiring no separate JavaScript compilation steps.

Similarly, adding basic user customization options—traditionally requiring custom React-based sidebar controls—can now be achieved entirely through PHP. By defining an attributes array during registration, WordPress automatically generates corresponding input controls within the block’s settings sidebar. Simple data types such as strings, numbers, and booleans map to native editor inputs like text fields, numeric inputs, and checkboxes, removing the need for manual UI interface programming.
Despite the initial appeal of returning to a purely PHP-driven workflow, the feature comes with distinct architectural limitations that developers must navigate. Because these blocks are rendered via asynchronous requests to a REST API endpoint rather than operating within the single-page JavaScript application powering the rest of the editor, they cannot interact dynamically with block content. This constraint means developers cannot implement in-place editing directly within the block preview, limiting customizations entirely to the auto-generated sidebar controls. Furthermore, attaching dynamic JavaScript libraries—such as sliders or interactive carousels—to the block preview proves unreliable because the underlying HTML markup is continuously fetched and replaced during re-renders.

Another notable limitation involves data freshness and global state management. PHP-only registered blocks bypass the client-side data store used by the editor, querying the database directly instead. Consequently, blocks cannot react in real time to modifications made elsewhere in the editor, such as updates to a post title or excerpt, until the post is explicitly saved and the page is reloaded. Additionally, because the REST API endpoints are stateless, the render callbacks lack access to the global WordPress post context, preventing standard template tags and functions from correctly identifying the currently edited post without custom workarounds.
Attribute types and editing interfaces are similarly restricted in WordPress 7.0. The system supports only basic data types and simple dropdown menus without keyed array capabilities, making it impossible to separate a stored database value—such as a category ID—from its human-readable label in the interface. Essential interactive elements like image uploaders, rich text editors, and date pickers remain absent from the PHP-only registration API.

Given these constraints, industry consensus suggests that PHP-only blocks are poorly suited for building modern, feature-rich blocks from scratch. Instead, their killer use case centers on migrating legacy PHP code into modern block themes. For years, the high cost of learning JavaScript block development and restructuring existing theme code has served as a major barrier preventing classic theme authors from adopting block-based workflows.
By leveraging PHP-only registration, developers can wrap older custom headers, template parts, shortcodes, and specialized widgets into server-side rendered blocks. While these migrated blocks may lack advanced editor interactivity, they render accurately on the front end, enabling teams to transition legacy websites to block themes in a fraction of the time previously required.

Practical implementation of the feature requires careful navigation of its current boundaries. For instance, developers wishing to display different content in the admin view compared to the front end cannot rely on the traditional is_admin() function because REST API endpoint requests evaluate differently. Instead, checking for the block renderer endpoint via wp_is_rest_endpoint() allows conditional rendering logic. Similarly, developers can pass the current post ID into a local block attribute during the initialization hook to bypass state limitations when working with existing posts.
Styling PHP-only blocks aligns closely with standard WordPress practices. Developers can enqueue stylesheets using block-specific registration arguments, while get_block_wrapper_attributes() automatically applies the necessary wrapper classes and inline styles required for core features like color customization, layout alignments, and block supports. Opting into Block API Version 3 and ensuring the editor runs within an iframe further helps harmonize styles between the front end and the backend preview environment.

Ultimately, WordPress 7.0 does not replace JavaScript-driven block development, nor was it designed to do so. Complex, interactive user experiences will continue to rely on JavaScript frameworks. However, by removing the massive technical hurdle of rewriting legacy code just to adopt block themes, the new PHP-only registration system signals a broader shift within WordPress Core toward prioritizing practical developer experience and easing long-term platform modernization.
Leave a Reply