Skip to content

cd ../tech-notes

NOTE

WordPress 7.0: registering Gutenberg blocks with PHP only

by 2 min read

cat wordpress-7-php-only-blocks.md en

I’ve spent a big part of my career working with WordPress and PHP. One of the WordPress 7.0 changes that caught my attention goes almost in the opposite direction of what we’ve seen over the last few years: you can now register certain Gutenberg blocks using only PHP.

For developers who came from traditional WordPress development, this is interesting. For a long time, moving from a classic PHP plugin into block development usually meant dealing with a very different stack: React, JavaScript, JSX, build tools, block.json…

All of that still makes sense for more complex and interactive blocks. But not every block needs that. Imagine a simple block that only reads something from the backend and renders the result.

Now you can do something along these lines:

register_block_type(
	'my-plugin/status',
	[
		'supports' => [
			'autoRegister' => true,
		],
		'render_callback' => function () {
			return '<p>System status: online</p>';
		},
	]
);

What I like here is not simply “writing less JavaScript.” It is having the option to choose an architecture that better fits the problem. If a block mainly depends on server-side logic, a database, or an external API, building an entire frontend layer just to register and render that block may be unnecessary.

At the same time, I don’t see this as WordPress “going back to PHP.” I see it as something more practical: PHP remains an important part of the platform, while Gutenberg becomes more flexible about where each responsibility should live. For developers who have worked with WordPress for a long time, this also reduces some of the distance between traditional plugin development and the modern Block ecosystem.

I like that direction. Less complexity when it isn’t needed. And JavaScript when it actually adds value.

For those working with WordPress today: do you prefer building blocks with React, or do you see a place for this more server-side PHP approach?

MORE NOTES

HIRING? GET THE FULL CV

filipe --send-cv --to=<email>

Leave your email and I will send you the full CV as a PDF, with direct contact details.

Used only to send the CV and reply to you. No newsletter.