profile

Fränk Klein from WP Development Courses

Maximizing control, minimizing chaos: Controlling block customization options

Published 3 months ago • 3 min read

Hi Reader,

I still read messages like this in WordPress developer Facebook Groups and Twitter:

Clients breaking sites is a common issue for developers. And that’s because block theme development is entirely different to classic theme development.

In “old” WordPress, clients couldn’t change their website significantly unless you allowed them to.

In modern WordPress, it’s the other way around. Clients can change anything unless you prevent them.

And that’s because WordPress users have access to all blocks by default, in every editor. And with these blocks come the default customization options–of which there are many.

Therefore, removing any unwanted customization tools should be the first task on any website you build for clients.

What features should how you remove?

My checklist goes like this:

  1. Remove WordPress.org repositories: Patterns, Block, Media.
  2. Remove unwanted blocks.
  3. Remove unwanted customization options.
  4. Remove unwanted block styles.

That is the basis for every block theme project I do. For Hybrid Themes, you should also look into disabling block widgets and the page template editor.

How should you go about removing blocks?

By default, WordPress shows all available blocks in all editors. Meaning that the content editor also gives access to theme building blocks.

The removal strategy, therefore, depends on whether the client should have access to theme and layout blocks.

A typical scenario is that you want to remove any theme and most layout blocks from Posts. This post type is all about content.

If you use the content editor as a page builder, a common approach in hybrid themes, you can give access to the relevant blocks there.

Even if you use a block theme, I would still remove blocks like widgets.

Remember that removing blocks does not prevent them from being used in patterns. Because you should only prevent blocks from showing up in the inserter. Do not unregister Core blocks; it’s a surefire way to create bugs.

A possible refinement here would be to add an additional layer that targets user roles. For example administrator users can get access to more blocks, and this way, create patterns from blocks that authors might not get access to.

Make sure to lock these patterns though. Else authors might remove blocks that they can’t re-add themselves because you filtered them out.

How should you go about removing customization options?

There will always be customization options that you do not want at all. For those, just remove them using theme.json. This not only works for Core blocks, but also for all well-coded blocks in plugins.

Then there might be customization options that you want for some blocks, but not others. For those you can use theme.json as well to remove them for specific block types.

Typically I wouldn’t want text blocks (heading, paragraphs, lists,…) to have background color selectors. Because I prefer to use Group blocks for that. This is possible to achieve with just a few lines of JSON.

Then we get to the more advanced use cases. What about a client that uses Posts for plain content, and Pages for building layouts?

In that case, use the PHP filters for theme.json. The way I approach this is that I temporarily change the theme.json to remove all the settings I want.

Then I copy and paste this JSON into my PHP filter callback, and use json_decode() to transform it into an array. It’s a workflow that sounds awkward, but that works really well.

In opposition to theme.json, the PHP callbacks have access to the wider application context. So you can filter per post type, and per user role.

Technical implementation

When I launched the first version of my block theme development course, it wasn’t possible to control the editor experience.

This only changed with the introduction of theme.json in WordPress 5.8, and then the PHP filters in 6.1. Now there is a lot to cover.

So much that the Block Theme Academy course bundle contains a course that only focusses on this aspect: the Controlling the Block Editor course.

It contains all the lessons and code snippets necessary to lock websites down. And as a bonus you get the Bare-bones Starter Theme, which gives you a clean slate to start from.

But before you jump onto the implementation, I want you to pause. Because with the right starting points and information, this isn’t too hard.

But what is harder is coming up with the approach for how you want to handle things. This depends a lot on the types of clients you have, the projects you build, and how you build these projects.

Planning your customization strategy

So what I’d encourage you to do next week is analyze your specific needs, and come up with your own starter checklist and theme.

It’s fine if it’s not the end all be all. But just get started.

Because don’t make the two mistakes I have seen on the last two block theme development projects I worked on:

  1. Not locking things down: If there is a customization option, sooner or later your client will use it.
  2. Locking down after the fact: This results in a lot of unnecessary “where did X go?” conversations with your clients.

What’s the better approach?

Come up with a customization strategy before the client ever opens the WordPress admin.

And if what you gave access to is not enough, you can always add more customization options.

But do so deliberately, and sparingly. And you’ll enjoy the same peace of mind as you did in “old” WordPress.

Until next week, when we'll dive into a very exciting feature shipping with the upcoming WordPress 6.5 release!

Cheers,
Fränk

Fränk Klein from WP Development Courses

Level Up Your WordPress Business With One Email Per Week

Every Sunday, I send out tips, strategies, and case studies designed to help agencies and freelancers succeed with modern WordPress. My goal is to go off the beaten path, and focus on sharing lessons learned from what I know best: building websites for clients. 100% free and 100% useful.

Read more from Fränk Klein from WP Development Courses

Hi, last week I shared a video about how to choose the best starter theme for a client project. One option is to start with an existing block theme (like Rockbase), and then create a child theme to implement your own customizations. And I got a couple of emails from readers that were running into challenges when using block child themes. So this week I want to do a deep dive into the topic of block child themes. Why would you want to use a child theme? With a block theme, you could just use...

about 14 hours ago • 3 min read

Hi Reader, "What is the best starter theme?" is a common question that my readers and students ask. The answer is "it depends". Because there are three options: You choose an opinionated design. You choose a neutral design. You start from scratch. 👉 This video dives into the details Cheers,Fränk P.S. This video is part of a new section I'm adding to my Block Theme Academy course. The focus is on best practices for building client projects. So, if you'd like anything addressed in that section,...

8 days ago • 1 min read

Hi Reader, One essential tool in your toolbox as a professional website builder is source control, also called version control. Source control is the practice of tracking and managing changes to code. This means using Git, often used along with Github to host the code. Why use source control Using Git or other source control tool to manage your code gives you lots of benefits: Versioning: By tracking every change done to a code base, you can understand how it evolved. You’ll also be able to...

15 days ago • 3 min read
Share this post