PHP-only block registration: skip React for simple blocks

For years I watched developers pull in the whole React toolchain just to ship a text-and-image block. PHP-only block registration, landing in Core for WordPress 7.0, finally makes that optional. If you spend your days in PHP and would rather not babysit a build pipeline, this one is worth a look.

Setting up Webpack or wp-scripts just to print a piece of server-side data always felt like a bad trade. For server-rendered blocks that step is now gone. The autoRegister flag lets you define the block logic and its inspector controls in functions.php or a plugin file, and nowhere else.

How PHP-only block registration works

Dynamic blocks still needed a small JavaScript file, if only to register the block name and its attributes with the editor. That file is no longer necessary. register_block_type now takes a supports array carrying autoRegister => true, and it does the registration itself.

The editor also reads your PHP attribute definitions and builds the Inspector sidebar controls from them. A string gets a text field, an integer gets a number input, a boolean gets a toggle, and none of it costs you a line of React. I wrote about the same direction of travel in Gutenberg’s smarter block logic.

function bbioon_register_php_only_blocks() {
    register_block_type(
        'bbioon/server-side-stat',
        array(
            'title'           => 'Server-Side Stat',
            'icon'            => 'chart-bar',
            'attributes'      => array(
                'label'   => array(
                    'type'    => 'string',
                    'default' => 'Total Sales',
                ),
                'value'   => array(
                    'type'    => 'integer',
                    'default' => 100,
                ),
                'is_active' => array(
                    'type'    => 'boolean',
                    'default' => true,
                ),
            ),
            'render_callback' => function ( $attributes ) {
                if ( ! $attributes['is_active'] ) {
                    return '';
                }
                return sprintf(
                    '<div class="bbioon-stat"><h3>%s</h3><p>%d</p></div>',
                    esc_html( $attributes['label'] ),
                    intval( $attributes['value'] )
                );
            },
            'supports'        => array(
                'autoRegister' => true,
            ),
        )
    );
}
add_action( 'init', 'bbioon_register_php_only_blocks' );

Where PHP-only blocks run out of road

PHP-only block registration does not replace the JavaScript path. I have watched people try to force a drag-and-drop gallery into this format, and it ends in a refactor every time. The target is blocks that render on the server and hold no real client-side state.

Two things will catch you out. Attributes with a local role get no generated control at all. And if your attribute type is one the editor does not support, a nested object for instance, it gets ignored silently, which leaves whoever edits the page with no way to change the data. Keep the official register_block_type documentation and Trac ticket #64639 open while you work.

If PHP-only block registration is eating your dev hours, hand it to me. I have been building on WordPress since the 4.x days, and I know when PHP is enough and when React actually earns the build step.

What this changes about block architecture

Not every block needs to be a mini application, and PHP-only block registration finally admits it. With render_callback and autoRegister you ship less code and skip the build step that has made modern WordPress work so tedious. Of everything arriving in WordPress 7.0 development, this is the change I expect to lean on most.

author avatar
Ahmad Wael
I'm a WordPress and WooCommerce developer with 15+ years of experience building custom e-commerce solutions and plugins. I specialize in PHP development, following WordPress coding standards to deliver clean, maintainable code. Currently, I'm exploring AI and e-commerce by building multi-agent systems and SaaS products that integrate technologies like Google Gemini API with WordPress platforms, approaching every project with a commitment to performance, security, and exceptional user experience.