Client-side filters in the WordPress Block Editor

The WordPress Developer Blog has rapidly become a regular read for me, as it contains practical code examples for many topics which may be too complicated for pure documentation. I learn more quickly using practical examples, so blog posts like the most recent one by Nick Diego are ideal.

This latest post shows how developers can use the same principles as add_filter or add_action (from PHP) in the Javascript environment of the Block Editor. For example, the theme.json file contains a number of configuration options, but you might want to stop non-admins from changing the colour of a heading block. That can be achieved by using the new blockEditor.useSetting.before filter, which is incredibly powerful and which offers the developer a very wide range of options for overriding the settings from theme.json on a per-post, per-user or other specific basis.


Discover more from Permanent Tourist

Subscribe to get the latest posts to your email.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.